Studio (report editor)

@prismbi/prismbi/studio is a drag-and-drop report editor that works like Power BI Desktop, in the browser. End users build and change reports, and the result is a JSON document you store wherever you like.

PrismBI Studio: field list, canvas, visualizations and build pane

import { Studio } from '@prismbi/prismbi/studio';

const studio = new Studio(document.getElementById('editor')!, {
  model,                          // your DataModel
  storageKey: 'sales-report',     // optional: autosave to localStorage and restore on load
  // document: savedDoc,          // or open a saved document
  // starter: 'blank',            // new documents start from a generated page by default
});

studio.on('change', (doc) => api.saveDraft(doc));   // every undoable change
studio.on('save', (doc) => api.publish(doc));        // Ctrl+S / studio.save()

React:

import { PrismStudio } from '@prismbi/prismbi/react';
<PrismStudio model={model} storageKey="sales-report" onChange={saveDraft} style={{ height: '100vh' }} />

To show the finished report to viewers, pass doc.report to <PrismReport definition={…}> or new Report(el, { model, ...doc.report }).

What users can do #

AreaFeatures
CanvasSelect visuals, drag to move, resize from 8 handles. Magnetic smart alignment snap lines guide placement against neighboring visual edges and midpoints. Multi-visual lasso marquee drag selection. Top toolbar quick alignment (left, center, right, top, middle, bottom), spacing distribution (horizontally, vertically), and visual size matching (width, height, both). Visual locking (Ctrl+L) and grouping (Ctrl+G). Drag-and-drop external CSV and JSON data files directly onto the canvas. Everything snaps to the configurable page grid (Ctrl+'). Click empty space to deselect
KeyboardArrows nudge (Shift+arrows resize) · Delete removes · Ctrl+D duplicates · Ctrl+C / Ctrl+V copy and paste · Ctrl+] / Ctrl+[ front and back · Ctrl+Z / Ctrl+Y undo and redo · Ctrl+S saves · Esc deselects
Selection & LayersSide pane listing visuals front-to-back with visibility toggles (hide/show), lock protection, and z-order reordering
Quick measuresWizard dialog generating parameterized DAX measures for Year-over-Year Growth, Running Total, Rolling 3-Month Average, and Share of Category
Fields paneTables with measures (grouped by display folder), columns and hierarchies, plus search and "show hidden". Drag a field onto the canvas, a visual or a well. Click it to add it to the selected visual, or to create a fitting visual. The ⋯ menu edits or deletes measures and studio-created columns, and offers "New measure: Sum" for numeric columns
Build paneVisual type picker: changing type keeps your fields. Field wells per data role: drop, reorder by drag, remove, and change aggregation for columns used as values
Format paneGenerated from a format schema: general (title, Top N, interaction), size and position, title, legend, data labels, axes (including continuous and log), colors (fixed, per series, gradient, rules), bars, lines, analytics (trend and reference lines), small multiples, tooltip (including report-page tooltips), plus visual-specific sections (card, table, matrix, slicer, map, waterfall …), background, border and header icons. With nothing selected, it shows page settings (grid, background, hidden, drill-through fields, tooltip page), the report name and the theme designer (mode, accent, backgrounds, text, font, radius, 8 data colors)
Filters paneVisual, page and report filters (Basic, Advanced, Top N)
PagesAdd, rename (double-click), duplicate, hide, reorder and delete, from the tab bar and its right-click menu. Tooltip and drill-through pages are labelled
Measures and columnsEditors with DAX completion, live diagnostics, signature help, a value preview, format presets and display folders. Renaming a measure updates the visuals that use it
Data viewBrowse every table (types, formats, calculated columns) with high-performance virtualized scrolling
Model viewA relationship diagram with organic hierarchical DAG layout placing fact tables centrally and dimensions by relationship cardinality. Drag tables to arrange them. Drag a column onto another table's column to create a relationship: the side with unique values becomes the one side, otherwise it's many-to-many, and it's inactive when another active path exists. Click a line to switch it active or inactive, change its direction, or delete it
Auto pageGenerates a starter page from the model: slicers, KPI cards, trend, breakdowns and a detail table (autoReport(model))
PreviewHides the editing chrome so you can try the report as a viewer would (cross-filtering, drill, tooltips)
Export / ImportDownload or open the document as JSON

The document #

The Studio model view: tables, columns and relationships

interface StudioDocument {
  version: 1;
  report: ReportDefinition;      // pages, visuals, filters, bookmarks (schema-versioned)
  model: StudioModelState;       // measures / columns / relationships added or changed in the studio
  theme?: Record<string, unknown>; // theme overrides
  diagram?: Record<string, { x: number; y: number }>; // model view layout
}

Model changes are stored as a diff against the model the studio was opened with. Your code stays the source of truth for tables and base measures, and opening a document replays the user's additions and edits on top. Undo and redo cover report and model edits alike. Moving tables in the diagram is saved but isn't an undo step.

Versioning. report.version follows REPORT_SCHEMA_VERSION. migrateReport(json) upgrades older documents, and newer ones are rejected with a clear message. Report.parse() and report.load() migrate automatically.

API #

Member
document / load(doc) / exportJSON() / save()Read or open documents. save() writes to storageKey and emits save
undo() · redo() · canUndo · canRedo · isDirtyHistory
addVisual(type, fields?) · addField(ref) · assign(visualId, ref, role?, index?) · setVisualType(type) · select(id)Build reports from code (each call is one undo step)
setView('report' | 'data' | 'model') · setPreview(on)Views
editMeasure(name?) · editColumn(table?, name?)Open the editors
report · modelThe underlying Report (edit-mode APIs below) and DataModel
on('change' | 'save' | 'selection', fn)Events

Report edit-mode APIs (usable without the studio) #

setEditMode(on) · selectedVisual · visualFormat(id) · findFreeSpot(w, h) · duplicateVisual(id) · arrange(id, 'front' | 'back') · updatePage(id, patch) · movePage(id, index) · duplicatePage(id) · pageDefinition(id?) · load(definition), plus the events definitionChanged and visualSelected.

Building blocks #

assignField, retargetFields, autoVisualFor, defaultSize, fieldKind, autoReport, History, sectionsFor / COMMON_SECTIONS / TYPE_SECTIONS (the format schema) and ExpressionEditor are all exported. You can build a custom editor shell or add your own sections to the format schema.

DAX copilot #

new Studio(el, { model, copilot: daxCopilot(model) }) (from @prismbi/prismbi/ai) adds a plain-English box to the measure editor: ✦ Write DAX fills in the expression, name and format, and Explain describes the current expression. Any object with write(request) and an optional explain(expression) works, so you can plug in your own service. See AI.

The measure editor writing and explaining DAX from plain English

Phone layouts #

Press 📱 Phone in the top bar to arrange the current page for phones:

Editing the phone layout of a page in the Studio

Phone layouts are saved on the page as mobile and used automatically below 640 px:

The rendered phone layout displaying responsive mobile dashboard visuals

{ id: 'overview', name: 'Overview', visuals: [/* … */],
  mobile: { columns: 4, visuals: [{ id: 'k-sales', layout: { x: 0, y: 0, w: 2, h: 3 } }, /* … */] } }
APIDoes
report.setLayoutMode('auto' | 'desktop' | 'mobile')choose the layout; 'auto' switches at mobileBreakpoint (default 640)
report.autoMobileLayout(page?)(re)generate a page's phone layout
report.setMobileVisibility(id, visible)hide a visual on phones, or bring it back at the bottom
report.setMobileLayout(id, layout)move or resize a visual in the phone layout
report.isMobileLayoutwhether the phone layout is showing

Visuals not listed in mobile.visuals are hidden on phones. Pages without a phone layout keep the automatic behaviour: below 640 px every visual takes the full width, in order.

Selecting and arranging several visuals #

The Layers pane in Studio showing visual z-order, lock and visibility

In code: report.selectedVisuals, selectVisuals(ids), toggleVisualSelection(id), alignVisuals(how, ids?), distributeVisuals(axis, ids?), groupVisuals(ids?), ungroupVisuals(ids?), arrange(id, 'front' | 'forward' | 'backward' | 'back') and commitLayouts(updates). All of them work on whichever layout is showing, desktop or phone.

Quick measures #

The Quick measure button in the Studio top bar opens a modal wizard generating parameterized DAX measures:

  1. Year-over-Year Growth: DIVIDE([M] - CALCULATE([M], SAMEPERIODLASTYEAR(Date[Date])), CALCULATE([M], SAMEPERIODLASTYEAR(Date[Date])))
  2. Running Total: CALCULATE([M], DATESBETWEEN(Date[Date], BLANK(), MAX(Date[Date])))
  3. Rolling 3-Month Average: AVERAGEX(DATESINPERIOD(Date[Date], LASTDATE(Date[Date]), -3, MONTH), [M])
  4. Share of Category Total: DIVIDE([M], CALCULATE([M], ALLSELECTED(Table[Category])))

Quick measures wizard dialog with pre-built DAX templates