Dashboard rendering and export
Dashboard rendering turns a validated dashboard definition and its data into an interactive view or a portable artifact. DAC supports a live server path, a self-contained static build, browser downloads for dashboard and widget content, and a Google Slides presentation path. Dashboard definitions can come from YAML or TSX and can use query results or inline data. The dashboard domain model and pipeline owns the wider lifecycle, while dashboard queries and semantic modeling explains how widget data is produced. Dashboard definition lifecycle describes how definitions enter the system, and dashboard theming and templating explains the presentation rules shared by rendered views.
Rendering paths
The rendering paths share the same dashboard definition and widget result shape. They differ in where data is prepared and whether the final artifact keeps a link to a running DAC server.
| Path | Data preparation | Result |
|---|---|---|
| Live dashboard | The server resolves widget work and serves results to the web app. | An interactive dashboard with live queries and reload support |
| Static build | The build process runs the widget work before packaging the web app. | A directory that can run as a static site without a DAC server |
| Browser export | The loaded web view supplies the current data and visual state. | CSV, PNG, or PDF downloaded by the user |
| Slides export | The export process runs widget work and maps the results to slide elements. | A Google Slides presentation |
Dashboard definition loading
Dashboard definition loading turns YAML or a .dashboard.tsx source into the same dashboard model before validation and rendering. The TSX path can compose widgets from reusable components and can use load-time data to shape the dashboard, so downstream render and export paths do not need a separate TSX contract. References: pkg/…/jsloader.go• L23-57, pkg/…/jsloader.go• L98-232, pkg/…/jsloader.go• L242-296, pkg/…/jsloader.go• L382-456, pkg/…/model.go• L27-49
Live dashboard rendering
The live path treats the web app as the final renderer. The server loads and validates the dashboard, normalizes filter values, resolves query-backed widget work, and returns widget results through batch or streaming requests. Text and divider widgets do not need a data request; image widgets are data-driven like tables unless they use inline data. References: pkg/…/server.go• L95-170, pkg/…/api.go• L270-345, pkg/…/filter_values.go• L12-29, pkg/…/model.go• L98-120, pkg/…/model.go• L175-182, frontend/…/DashboardView.tsx• L44-92
Streaming makes the view useful before every widget finishes. Each completed result can reach the web app on its own, so a slow widget does not prevent other widgets from appearing. The same result contract also lets the static and export paths reuse the data prepared for a dashboard. References: pkg/…/api.go• L353-379, frontend/…/client.ts• L83-140
Filter value preparation
Filter value preparation converts client and default values into one safe form before query work starts. Date expressions and date-range presets become concrete dates, date values become canonical date strings, and scalar select or text values keep their string meaning when they echo a YAML default. Validation then rejects unknown filters, invalid shapes, invalid dates, and values outside fixed select options. References: pkg/…/filter_values.go• L12-29, pkg/…/filter_values.go• L32-64, pkg/…/filter_values.go• L67-115, pkg/…/filter_values.go• L132-200, pkg/…/model.go• L410-437
The server-side filter contract follows this sequence:
flowchart LR
A[Dashboard defaults and user values] --> B[Canonical filter values]
B --> C[Filter validation]
C --> D[Query and render or export]
C --> E[Request error]
Static dashboard rendering
The static build creates a portable copy of one dashboard with its query results already attached. It starts from dashboard defaults, applies supplied filter overrides, runs the widget work where needed, and packages the dashboard, summaries, theme settings, filters, and widget data with the web app. Widgets with valid inline data can provide their own result snapshot without a connection or SQL source. References: pkg/…/render.go• L21-36, pkg/…/render.go• L39-141, cmd/build.go• L12-64, pkg/…/model.go• L113-117, pkg/…/model.go• L551-554, pkg/…/validator.go• L338-379
The browser still performs the final layout and visual render when a user opens the static site. It reads the attached payload instead of calling the server, uses hash-based navigation, and does not start live reload. This makes the output suitable for static hosting, but its data remains the snapshot created during the build. References: frontend/…/client.ts• L7-19, frontend/…/client.ts• L38-80, frontend/…/App.tsx• L12-46, frontend/…/useLiveReload.ts• L7-13
Browser export paths
Browser export uses the dashboard view that the user has loaded. The current filters and rendered state therefore shape the exported data or image rather than causing a separate dashboard definition to be built.
Data exports
CSV export converts widget result sets into portable text. A widget export contains its column names and rows. A dashboard export joins data-bearing widgets into named sections and leaves out non-data widgets. Cells use standard CSV quoting, and names become safe file names. References: frontend/…/csv.ts• L1-74, frontend/…/WidgetExportButton.tsx• L20-29, frontend/…/DashboardView.tsx• L214-233
Dashboard CSV export requests the current dashboard data before it builds the file. It includes only widgets with usable rows, so an empty result does not produce a misleading data file. References: frontend/…/DashboardView.tsx• L214-233
Visual exports
PNG and PDF export capture the rendered dashboard or widget frame. The capture waits for fonts, uses the element’s full size, fills transparent backgrounds from the active theme, and omits controls marked as export-only controls. PDF output places the image on A4 pages and adds pages when the rendered view is taller than one page. References: frontend/…/renderExport.ts• L1-49, frontend/…/renderExport.ts• L61-102, frontend/…/WidgetExportButton.tsx• L31-49
The dashboard view exposes all three formats from its header. A widget exposes the same formats from its own frame when usable data exists. This keeps data export tied to the result set while visual export preserves the view that the user can see. References: frontend/…/DashboardView.tsx• L288-303, frontend/…/WidgetFrame.tsx• L44-61
Slide-oriented export
Google Slides export turns a dashboard into a presentation rather than a copy of the web page. It creates a title slide, creates one content slide for each dashboard row, and places each row’s widgets into a slide layout. It applies filter overrides before it runs queries and returns the presentation URL after the slide deck is created. References: pkg/…/export.go• L36-146, cmd/export.go• L12-71
Slide content mapping
Each widget type maps to a presentation-friendly form. Metrics become centered value cards, charts become images, tables become limited previews, and text becomes a text box. If a widget cannot produce its expected content, the exporter places a readable placeholder instead of stopping the whole deck. References: pkg/…/export.go• L181-228, pkg/…/export.go• L231-268, pkg/…/export.go• L316-389, pkg/…/export.go• L391-407
The slide path is a presentation snapshot. It runs widget work in parallel with a bounded level of concurrency, then uses the completed results to build the deck. Temporary chart images are placed in Google Drive so Slides can read them, and the exporter removes those temporary files after slide creation. References: pkg/…/export.go• L61-76, pkg/…/export.go• L122-146, pkg/…/export.go• L149-169, pkg/…/export.go• L270-313
Chart image support
Chart support exists because a Slides deck needs image content rather than the web app’s live chart view. The exporter turns supported chart data into PNG bytes and inserts each image into the matching slide area. References: pkg/…/charts.go• L14-29, pkg/…/export.go• L270-313
The dashboard model supports chart encodings such as axes, values, colors, series, and reference annotations. Validation keeps those fields within the contract of each chart type before a render or export path uses them. The slide chart renderer has a smaller set of direct mappings: pie and funnel charts use a pie view, bar charts use bars, and line, area, and sparkline charts use a line view. Other chart names use the bar view as a fallback, while missing data or missing field mappings produce a placeholder in the deck. References: pkg/…/model.go• L132-164, pkg/…/validator.go• L425-432, pkg/…/validator.go• L563-807, pkg/…/charts.go• L20-29, pkg/…/charts.go• L32-127, pkg/…/export.go• L202-216, pkg/…/export.go• L391-407
Artifact boundaries
Each output path has a different relationship to source data and runtime services. These boundaries matter when an engineer chooses an export for sharing, hosting, or later editing.
| Artifact | Keeps runtime data access? | Main limitation |
|---|---|---|
| Live view | Yes | It depends on the DAC server and its connections |
| Static site | No | It shows the data snapshot from build time |
| CSV | No | It carries result data, not dashboard layout or behavior |
| PNG or PDF | No | It carries the rendered appearance, not query structure |
| Google Slides | No after creation | It is a presentation snapshot, with chart images rather than live charts |
The static, browser, and Slides paths all depend on the same basic rule: a failed or empty result must not be presented as valid data. The visual paths can show a placeholder where a chart cannot render, while data paths omit unusable sections or offer no export action. Invalid filter values fail before query work, and inline data removes the need for runtime data access only for the widgets that carry that data. References: pkg/…/api.go• L306-345, pkg/…/filter_values.go• L113-129, pkg/…/model.go• L551-554, frontend/…/WidgetExportButton.tsx• L20-24, frontend/…/DashboardView.tsx• L220-231, pkg/…/export.go• L206-216
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the static payload contract aligned between pkg/…/render.go and frontend/…/client.ts; a field change can make a static build appear empty without affecting live mode.
- Keep widget identifiers aligned between server result maps and dashboard rendering; the row-and-widget ID is the link between query results and visual widgets.
- Keep filter normalization before filter validation in every server-side render and export path; date presets, date expressions, and YAML scalar defaults must reach the same query contract.
- Keep the YAML and TSX loaders aligned with the
DashboardandWidgetmodel so both source forms reach the same validation and export behavior. - Keep inline data mutually exclusive with query or semantic sources; otherwise a portable snapshot can silently differ from the data source an author intended.
- Keep chart field rules aligned with chart encoding rules when adding chart types; Slides may fall back to a bar image even when the live view supports a richer chart.
- Keep export-control markers around new dashboard actions so PNG and PDF output does not include buttons or other controls.
- Keep temporary Drive image access and cleanup together when changing the Slides image path; Slides must be able to fetch the image before the temporary file is removed.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A static build cannot resolve or execute widget work | The build stops before it writes a usable static site | Dashboard validation and query-job errors are returned from the build path |
| A static site is opened with changed filter values | The view cannot fetch new results | The payload is a build-time snapshot and static mode reads baked data |
| A request contains an unknown filter or an invalid value shape | Query work and its dependent render or export do not start | Filter values are normalized and validated before rendering |
| A widget has no rows or has a query error | Its CSV action is hidden or its visual output is not useful | Browser export checks for usable data; Slides uses a placeholder |
| A widget mixes inline data with a query or semantic source | The dashboard definition is rejected instead of choosing one source silently | Validation permits inline data only for data-bearing widgets and rejects source conflicts |
| A chart uses a field that is absent from its result | The chart image cannot be made | Field lookup fails and the Slides path uses a placeholder |
| A temporary chart image is not readable by Slides | The chart is missing from the presentation | The exporter grants temporary read access before inserting the image |
Key files
| File | Why to read it |
|---|---|
| pkg/…/render.go | Defines the static build boundary and the data payload given to the web app |
| pkg/…/api.go | Shows how widget work becomes the shared result used by live and export paths |
| pkg/…/filter_values.go | Defines the server-side filter value contract used before query and render work |
| pkg/…/model.go | Defines the shared dashboard, widget, chart, and inline-data model used by all paths |
| pkg/…/jsloader.go | Shows how TSX dashboard sources become the shared dashboard model |
| pkg/…/validator.go | Shows the checks that protect render and export paths from invalid dashboard content |
| frontend/…/client.ts | Explains the switch between server-backed data and baked static data |
| frontend/…/DashboardView.tsx | Shows dashboard layout state and dashboard-level export behavior |
| frontend/…/renderExport.ts | Shows the visual capture boundary for PNG and PDF |
| frontend/…/csv.ts | Shows the portable data shape for widget and dashboard CSV files |
| pkg/…/export.go | Shows the dashboard-to-presentation flow and widget mapping |
| pkg/…/charts.go | Shows the chart subset supported by slide image output |
| cmd/build.go | Shows the user-facing static build entry point |
| cmd/export.go | Shows the user-facing Google Slides entry point |