Introducing a new way to review your PRs.

Read the announcement

frappe / insights

Open Source Business Intelligence Tool

View on GitHub

25 documents · Updated Nov 23, 2026

docs / chart-authoring

Chart authoring and sharing

Charts turn a workbook query into a saved visual view. An engineer can select a chart model, map query fields to its visual roles, adjust how the result reads, and share the view with other users or guests. Charts also provide reusable dashboard cards; see Dashboards and visualization and Dashboard composition.

Chart model

An Insights Chart v3 is a saved chart that belongs to a workbook and points to a source query. Its configuration records the chart type, field roles, filters, sort choices, and display settings. The chart derives its result shape from that configuration whenever it runs, so the source query remains a reusable definition for other workbook assets. The server also brings older configuration shapes into the current form before it stores or reads them, so each chart surface uses the same meaning. References: insights/…/insights_chart_v3.json• L20-97, insights/…/insights_chart_v3.py• L70-86, insights/…/chart_query.py• L896-909, insights/…/chart_query.py• L1132-1161

Chart types

Each chart type gives the same query result a different reading. The type sets the fields that an author must provide and the shape that the chart presents.

Chart typeMain view of the data
NumberOne or more measure values, with optional period, comparison, target, or sparkline
Bar, Line, RowMeasures across a dimension; Row presents the axes in the opposite direction
DonutA measure split across labeled categories
FunnelOrdered stages from several measures or from label and value rows
TableDimensions and measures arranged as rows, columns, and values
MapA measure grouped by geographic regions
BubbleTwo measures as X and Y, with optional size and grouping
SankeyWeighted links between source and target groups
HeatmapA measure at each pair of X and Y categories

The selected type controls the valid field roles and the query shape. A change between incompatible chart families must therefore reset or repair old settings before the chart can run. References: insights/…/chart_query.py• L33-44, insights/…/chart_query.py• L159-254, insights/…/chart_query.py• L290-309

Query shape

The chart combines its source query with chart-owned filters, grouping, measures, pivot choices, and sort rules. The result is built as a short-lived query for execution rather than as a second saved query. This makes the saved configuration the source of truth even when no author has opened the builder. Dashboard filters and card filters arrive at run time and narrow that chart result without changing the saved chart model. References: insights/…/chart_query.py• L4-23, insights/…/chart_query.py• L55-70, insights/…/chart_query.py• L810-827, insights/…/insights_chart_v3.py• L284-338

Number charts have an extra period model. A period can group data by a fixed grain or filter it to a time span. Each reading can compare its value with a previous period or with the same period last year, and the server finds the matching result row for each comparison. A sparkline asks a separate question about movement inside the selected span, so it uses a separate result rather than rebuilding a non-additive measure from the card value. References: insights/…/chart_query.py• L73-135, insights/…/chart_query.py• L258-288, insights/…/chart_query.py• L349-476, insights/…/chart_query.py• L507-547, insights/…/insights_chart_v3.py• L219-282

Builder interactions

The chart builder is the authoring surface for selecting the model, assigning fields, and checking the result. It treats an incomplete or malformed configuration as an authoring error instead of presenting raw source rows as if they were a finished chart. This rule applies to charts loaded from a workbook, dashboard, or shared view because each surface derives the result from the saved configuration. References: insights/…/chart_query.py• L160-255, insights/…/chart_query.py• L1421-1498, insights/…/insights_chart_v3.py• L318-338

Field roles

Field roles describe how the chart should read the query. Axis charts use an X-axis dimension and one or more Y-axis measures. Other charts use roles suited to their view, such as label and value, location and value, source and target, or the two dimensions of a heatmap.

The chart checks the roles that its model needs before it derives data. This keeps a missing axis, duplicate grouping field, malformed slot, or incomplete measure assignment visible as a configuration problem. Older field shapes are normalized before these checks, while unsupported shapes remain errors. References: insights/…/chart_query.py• L176-255, insights/…/chart_query.py• L896-909, insights/…/chart_query.py• L1132-1161, insights/…/chart_query.py• L1421-1498

Sorting and periods

Authors can set result limits and sort rules for the chart's reading. Date and time axes receive a forward order when the author has not supplied another order. Number charts apply their own period order after the author's sorts: span periods read in forward order, while grain periods fetch the newest periods first and are then returned in the reader's expected order. References: insights/…/chart_query.py• L383-436, insights/…/chart_query.py• L830-893, insights/…/insights_chart_v3.py• L219-227

Chart reading

The chart exposes more than a static picture. A reader can drill into a segment to see the rows behind it or request a breakdown by another dimension. Each drill level narrows the earlier result, and the server checks every requested column against the columns that the chart exposed before it runs the drill. References: insights/…/chart_drill.py• L4-23, insights/…/chart_drill.py• L155-257, insights/…/chart_drill.py• L795-805

Date and time segments represent buckets rather than single raw values. A breakdown uses the reader's selected grain when present, or derives a grain that fits the segment into a readable set of groups. Row drills can also expose links to desk documents when the result column can be traced safely to a site table or link field. References: insights/…/chart_drill.py• L359-457, insights/…/chart_drill.py• L508-629, insights/…/record_link.py• L53-103

Presentation helpers and colors

Presentation helpers turn the saved chart choices and returned columns into the options used by the visual renderer. They keep shared rules for axes, legends, tooltips, series, reference lines, gradients, and map ranges in one presentation layer, so the same chart meaning can appear in an authoring view, a dashboard, or a shared page.

Color choices have two different meanings. A series color identifies a measure or category. A table or map scale communicates the size of a value. Treating these as separate choices keeps a color identity from being confused with a value range. References: frontend/…/helpers.ts• L74-181, frontend/…/helpers.ts• L209-336, frontend/…/helpers.ts• L504-615, frontend/…/helpers.ts• L990-1065, frontend/…/colors.ts• L1-62

The shared palette supplies default colors for series and categories. Authors can override series or measure colors, while special views use colors suited to their reading: sparklines use a light gradient, maps use a value range, tables can use color scales and conditional formatting, and reference lines use a neutral default unless changed. References: frontend/…/colors.ts• L1-62, frontend/…/Sparkline.vue• L7-15, frontend/…/helpers.ts• L1026-1032

Shared chart viewing

Sharing changes a chart from a workbook-only view into a guest-readable view. An author enables public access and copies a stable chart URL or iframe snippet. The server records the publisher whose permissions support the public read, then reloads the saved chart for each request so the caller cannot replace its query shape. The shared view returns chart data without exposing the editor or generated SQL. References: insights/…/insights_chart_v3.py• L70-114, insights/…/insights_chart_v3.py• L148-217

The shared-chart path resolves the saved chart and then renders its current result. This diagram shows the relationship between the authoring record, the guest request, and the chart data response.

flowchart LR
    A[Author enables public access] --> B[Stable chart link]
    B --> C[Guest shared-chart page]
    C --> D[Reload saved chart]
    D --> E[Derive chart query]
    E --> F[Apply routed dashboard or card filters]
    F --> G[Return rows and chart metadata]
    G --> H[Render shared chart]

The shared request uses stored chart configuration as its source of truth. Dashboard filters are routed from the dashboard's stored items when the link names a dashboard, while a filter on one card is applied to that chart's derived result. The response includes the metadata needed to format periods, links, comparisons, and optional sparklines. When a chart appears through a public dashboard, dashboard publication can also make that chart reachable. Old chart names remain resolvable so a rename does not break saved links. References: insights/…/insights_chart_v3.py• L148-217, insights/…/insights_chart_v3.py• L219-282, insights/…/shared.py• L6-30, insights/…/shared.py• L74-112, frontend/…/SharedChart.vue• L1-19, frontend/…/router.ts• L91-99, frontend/…/router.ts• L123-143

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep chart type names, required roles, derived query shapes, and renderer support aligned when adding or changing a model.
  • Keep saved chart configuration as the source of truth for builder, dashboard, drill, and shared-chart execution paths.
  • Keep Number chart period, comparison, sparkline, row-order, and displayed-measure rules consistent across the query derivation and returned metadata.
  • Keep drill filters limited to the chart's exposed pre-aggregation columns, including date bucket and conditional-measure behavior.
  • Keep record-link tracing conservative when query operations rename, join, aggregate, or create columns.
  • Keep public access, dashboard reachability, stored publisher permissions, and old-name resolution aligned with shared links.

Important failure modes

TriggerConsequenceGuard
A chart lacks its source query or a required model roleThe chart cannot derive a valid result and does not present raw source rows as a chartConfiguration validation runs before operation derivation
A Number chart reuses one result name for different measuresA target or comparison can read the wrong value from the shared result columnMeasure-name validation rejects conflicting computations
A Number chart period changes but comparison logic keeps an old date shiftThe card compares the current value with the wrong periodComparison spans derive from the current period and are resolved at execution time
A drill asks for a column outside the chart's exposed surfaceThe request could widen the chart's data boundaryDrill validation checks requested dimensions against the pre-aggregation surface
A drill traces a value through an expression or ambiguous joinThe reader may open the wrong desk documentRecord-link tracing omits origins it cannot prove
A shared request trusts caller-supplied query or routing stateA guest could read data outside the published chart shapeThe server reloads the saved chart and uses stored dashboard items when needed
A chart is renamed without old-name resolutionExisting shared URLs stop finding the chartShared loading resolves the previous chart name

Key files

FileWhy to read it
insights/…/insights_chart_v3.jsonDefines the saved chart record, its source query, configuration, workbook, and public state
insights/…/insights_chart_v3.pyConnects chart persistence, execution, filters, comparisons, sharing, export, duplication, and import
insights/…/chart_query.pyDefines chart models, validation, period behavior, normalization, and conversion from configuration to query shape
insights/…/chart_drill.pyDefines the row and breakdown reading flow for chart segments
insights/…/record_link.pyDefines when result columns can safely link to desk documents
frontend/…/ChartBuilder.vueShows the authoring surface and its relationship to chart state and preview
frontend/…/ChartConfigForm.vueMaps chart models to their field and presentation controls
frontend/…/ChartRenderer.vueShows how chart results become visible and interactive views
frontend/…/helpers.tsDefines shared presentation behavior for chart options, axes, legends, and colors
frontend/…/colors.tsDefines the shared palette and color conversion rules
frontend/…/ChartShareDialog.vueShows how an author enables public access and obtains a link or embed snippet
frontend/…/SharedChart.vueShows the guest-facing shared-chart rendering path
insights/…/shared.pyDefines public chart checks, dashboard reachability, and old-name resolution