Chart components and types
The chart family turns row-based data into readable views for comparison, trend, part-to-whole, flow, and summary questions. Its public components share a small set of data and interaction rules, while each chart type adds the geometry and options that match its purpose; see Charting for the wider chart system.
Chart family
Public chart components
The family exposes nine data views and four pieces of chart chrome. The data views accept plain row objects and use column names in their props, so the same result from a query can feed a saved chart or a live chart.
| Component | Main question | Core input |
|---|---|---|
BarChart | How do categories compare? | A category or time column plus one or more value series |
LineChart | How does a measure change? | An ordered category, time, or numeric x column plus value series |
AreaChart | How does volume or composition change? | The line-chart model with filled series |
DonutChart | How is a total divided? | One category column and one value column |
FunnelChart | Where does a process lose volume? | Ordered stages and their counts |
HeatmapChart | Where is a measure high or low across two dimensions? | An x category, a y category, and a value |
ScatterChart | How do two measures relate? | An x measure and a y measure, with optional size and groups |
SankeyChart | How does value move between nodes? | Source, target, and flow value columns |
NumberCard | What is one current reading and its change? | A value or text reading and optional comparison data |
ChartCard supplies the surface. ChartContainer supplies the title area, subtitle, title suffix and actions slots, axis labels, state views, and legend slot. It also keeps a custom or built-in plot in the same outer layout while a state view is visible. ChartLegend and ChartScale provide reusable content for the area below or beside a plot; the scale is used by heatmap views to explain a color ramp.
References: src/…/index.ts• L5-32 src/…/Overview.md• L36-60 src/…/types.ts• L978-1084 src/…/types.ts• L1089-1148 src/…/ChartContainer.vue• L11-45 src/…/ChartScale.vue• L1-40
Shared chart props
The chart props keep display concerns beside the data contract. Most plot components accept title, loading, error, and dir; plot charts also accept a subtitle. Chart-specific props name the data columns and control the visual reading. A value formatter can change how numbers print without changing the values used for scales or selection.
| Concern | Public behavior |
|---|---|
| Data | data is an array of row objects. Column props such as x, y, category, value, source, and target select fields from each row. |
| Titles | title heads the chart and subtitle adds context such as a time range. NumberCard uses its title as the reading label and has no subtitle prop. |
| States | loading shows a loading view. A non-empty error shows an error view. Empty plotted data shows an empty view. |
| Direction | dir forces ltr or rtl; otherwise the chart follows the document direction. |
| Number display | format or an axis formatter changes how numbers print in labels, tooltips, and readouts as defined by the chart type. |
| Tooltip context | tooltipColumns adds row values to axis-chart tooltips without creating marks, legend entries, palette slots, or scale effects. |
| Escape hatch | echartOptions can override the generated plot option when a supported high-level prop is not enough. |
The charts preserve the source rows for selection and tooltip context. This lets a chart summarize data without making the selected record unavailable to the parent application.
References: src/…/types.ts• L658-672 src/…/types.ts• L776-880 src/…/types.ts• L894-930 src/…/types.ts• L932-1046 src/…/types.ts• L1048-1084 src/…/ChartContainer.md• L43-56 src/…/ChartContainer.vue• L5-9
Axis chart model
Wide and long series data
BarChart, LineChart, and AreaChart use one axis model. Wide data names each value column in y, while long data uses one value column and a series column to split rows into series. The chart converts both shapes into the same visible series model, so the choice can follow the shape returned by the query.
This diagram shows how the two input shapes reach the same axis chart reading.
flowchart LR
A[Wide rows: x plus value columns] --> C[Axis chart series]
B[Long rows: x plus value and series columns] --> D[Group by series and align x values]
D --> C
C --> E[Bars, lines, or areas]
For long data, each distinct series value becomes a series. Missing x-and-series combinations remain missing rather than becoming zero, so line and area charts can show a real gap. maxSeries can keep the strongest groups and sum the rest into the reserved OTHERS_KEY identity, displayed as Others unless seriesConfig gives it another label. A y2 column is not split by splitBy; it supplies one series per named column and reads one value per x category.
References: src/…/types.ts• L776-856 src/…/seriesData.ts• L31-59 src/…/seriesData.ts• L118-155 src/…/seriesData.ts• L160-195 src/…/utils.ts• L1-10
Axis types and scales
An axis chart has one category-like x axis and one primary value axis. The x axis reads as category by default, becomes time when all x values are dates or ISO date strings, and becomes a measured value axis only when requested. A value x axis places points by their numbers instead of giving each row an equal slot.
The primary y axis can set min, max, title, and a number formatter. A series can use axis: 'y2' to read against a second scale for a different unit or magnitude. The second scale appears only when a y2 column is supplied or a series uses it, and it is not available for a horizontal bar chart.
Horizontal bars move the category axis to Y. This supports long category labels, but it is a bar-only layout and does not provide a second value axis. Category labels adapt to available space; time axes reduce tick density instead of tilting labels.
References: src/…/types.ts• L41-66 src/…/types.ts• L674-713 src/…/types.ts• L776-800 src/…/LineChart.md• L12-41 src/…/BarChart.md• L51-75
Series marks and styles
The three axis components are different defaults over one mark model. BarChart defaults to bars, LineChart to lines, and AreaChart to filled lines. seriesConfig[key].type can change one series to bar, line, or area, which makes a mixed chart without a separate combo component.
Series configuration also controls the display label, color, value axis, data labels, stack name, line pattern, line width, points, smoothing, and area fill. Chart-level style props provide defaults for every series, while a seriesConfig entry overrides them for one series. Properties that do not apply to the chosen mark are ignored. Named palettes use the chart color tokens, while an explicit color list gives the application direct control.
References: src/…/types.ts• L68-117 src/…/types.ts• L715-761 src/…/types.ts• L813-839 src/…/Overview.md• L29-34 src/…/BarChart.md• L77-88
Stacking and normalization
stacked makes supported marks share a common category position. Bars stack with bars and areas stack with areas; lines never stack. stackName separates independent stacks, so each named stack forms its own total.
stacked="normalized" changes the reading from totals to shares. Each stack reaches 100 percent and the value axis is fixed to 0–100. The original values remain available to the tooltip, and hidden series cause the visible shares to be recalculated. A series that has no peer in its stack keeps its own values and should use another axis when it must coexist with a normalized stack.
References: src/…/types.ts• L97-101 src/…/types.ts• L744-748 src/…/types.ts• L869-873 src/…/BarChart.md• L22-49 src/…/AreaChart.md• L8-23
Reference lines
referenceLines adds fixed annotations such as targets, thresholds, dates, or quadrant dividers. A line selects the scale through axis: y is the default, y2 uses the secondary value scale, and x marks the category or x-value scale. An annotation outside the current data range is not drawn, so the axis range must be pinned when the target must stay visible.
Reference lines are not series. They do not appear in the legend or tooltip, and users cannot hide them through series visibility controls.
References: src/…/types.ts• L119-164 src/…/types.ts• L875-878 src/…/types.ts• L1031-1037 src/…/BarChart.md• L90-103 src/…/LineChart.md• L53-67 src/…/ScatterChart.md• L33-57
Specialized chart geometries
Donut slices
DonutChart maps each row to a slice whose size comes from value and whose name comes from category. The full ring reads share of the visible total in its center. variant="half" changes only the geometry to a semicircle.
maxSlices limits the number of visible arcs, including Others. The chart keeps the largest maxSlices - 1 categories and sums the remaining rows into the reserved OTHERS_KEY slice. Hiding a slice removes it from the visible total, so the other percentages are recalculated. showInlineLabels moves the name and share beside the ring and removes the center readout because the labels already explain the parts. The public prop is showDataLabels; it controls this behavior.
References: src/…/types.ts• L215-249 src/…/types.ts• L894-929 src/…/DonutChart.md• L5-37 src/…/DonutChart.vue• L185-192 src/…/DonutChart.vue• L303-311
Funnel stages
FunnelChart reads one row as one ordered stage. The stage order is the row order, and the shape narrows according to the stage values. Percentages show each stage as a share of the first stage; the tooltip can also show the share of the preceding stage.
The chart can show absolute counts without percentages. Its selection target is the full stage column, not only the visible shape, so a stage remains easy to select even when its value makes a narrow section.
References: src/…/types.ts• L279-320 src/…/types.ts• L932-943 src/…/FunnelChart.md• L5-17 src/…/FunnelChart.vue• L86-107
Heatmap cells
HeatmapChart treats each row as one cell at the intersection of an x category and a y category. The cell color represents the numeric value. Both axes are category axes, and category formatters change only the displayed text; they do not merge categories that happen to print the same way.
The color range defaults to the data minimum and maximum. A sequential palette suits one-direction magnitude, while a diverging palette suits signed data and centers the meaning on zero unless min or max sets another range. The heatmap displays a ramp scale with its low and high values, so the colors have a visible numeric meaning. When the data is clipped by fixed bounds, the scale marks the affected end with ≤ or ≥. showValues prints cell values when the layout has enough room to avoid collisions. The public prop is showDataLabels; it controls these cell labels.
References: src/…/types.ts• L322-408 src/…/types.ts• L945-975 src/…/HeatmapChart.md• L5-29 src/…/ChartScale.vue• L1-40 src/…/HeatmapChart.vue• L24-48
Scatter points
ScatterChart places one point per row using two measured axes. It has no category axis, so the x and y values determine the point positions and both scales follow the data. An optional size column maps a third measure to symbol diameter across the whole plot. An optional splitBy column groups points for color and legend control.
label supplies a point name for tooltips and optional data labels. referenceLines can mark thresholds or create quadrants with one x line and one y line. Point labels that would overlap are dropped so a dense cloud does not become unreadable.
References: src/…/types.ts• L515-581 src/…/types.ts• L999-1045 src/…/ScatterChart.md• L5-77
Sankey links
SankeyChart treats each row as a directed link from source to target, with value controlling band width. Nodes are the distinct names found in either column, so a target that later becomes a source naturally forms a later stage in the same flow.
The default orientation runs left to right; vertical runs top to bottom. nodeAlign controls where terminal nodes sit. The flow must be acyclic: self-links and links that create a cycle are dropped because they cannot be placed into ordered Sankey stages.
References: src/…/types.ts• L451-513 src/…/types.ts• L978-996 src/…/SankeyChart.md• L5-30
Number card readings
NumberCard presents one current numeric or text value and an optional delta against a comparison period. A null value means that no reading exists and shows the empty state; it does not mean zero. negativeIsBetter changes the meaning of delta colors for measures such as churn or cost.
The card can add a prefix, suffix, target, precision, compact notation, and a line, bar, or area sparkline. A sparkline shows shape only and has no axes. The optional color identifies the reading without changing the card surface. The caption slot lets the application provide the control that chooses the comparison period.
References: src/…/types.ts• L410-449 src/…/types.ts• L1048-1084 src/…/NumberCard.md• L5-26
Interaction model
Loading and empty states
Every chart uses the same state contract around its plot. Error takes priority over loading, and loading takes priority over empty. ChartContainer exposes the active state as data-state and lets the application replace the loading, error, or empty view through slots.
State slots replace the complete state view, which lets an application add a retry action or its own loading shape without rebuilding the chart. The plot remains mounted but hidden while a state is shown, so the surrounding layout stays stable and the chart can return to the ready state without losing its plot context.
References: src/…/types.ts• L1100-1122 src/…/types.ts• L1159-1170 src/…/ChartContainer.md• L43-56 src/…/types.ts• L593-607 src/…/ChartContainer.vue• L67-124 src/…/ChartContainer.cy.ts• L168-241
Legends and visibility
Charts with more than one visible series show a legend below the plot. Each entry has a stable series identity, a display label, a color, and a hidden state. Pressing an entry toggles visibility, while hover or focus highlights that series.
The legend stays on one row so it does not reduce the plot's height. If all entries do not fit, it keeps the highest-weight entries on the row and places the rest behind a +N more control. That control opens the full list, with visible series checked; long lists can be searched. The owning chart still decides whether a requested hide is valid, so the last visible series remains protected.
Axis and scatter charts expose v-model:hiddenSeries for application-controlled visibility. A chart will not hide the last visible series, and names that no longer exist are removed from the hidden list. Donut slices expose the same control as v-model:hiddenSlices; their percentages use the remaining visible slices as the total.
References: src/…/types.ts• L589-597 src/…/types.ts• L841-845 src/…/types.ts• L907-915 src/…/types.ts• L1010-1015 src/…/types.ts• L1399-1405 src/…/types.ts• L1658-1663 src/…/hiddenSeries.ts• L1-26 src/…/ChartLegend.md• L16-54 src/…/ChartLegend.vue• L25-95 src/…/legendOverflow.ts• L15-39
Tooltips and selection
Built-in plot charts use an HTML tooltip with formatted values. The tooltip can be replaced through the chart's tooltip slot, while custom plots can use ChartTooltip directly. A tooltip row keeps both the displayed value and the underlying numeric value for custom calculations.
Each plot emits select from a click or from keyboard activation. The event includes the chart-specific mark and the source row or rows: an axis mark carries its series and row, a donut Others slice carries all grouped rows, and a Sankey node does not emit because only a link maps to one source row. Funnel, heatmap, and scatter selections carry the stage, cell, or point row that the mark represents.
References: src/…/types.ts• L599-639 src/…/types.ts• L1188-1325 src/…/ChartTooltip.md• L16-42 src/…/BarChart.md• L117-121
Keyboard navigation
Canvas-backed plots use one tab stop and arrow keys to walk their marks. Horizontal arrows move along the main order, vertical arrows move across a second dimension when the chart has one, and Home and End move to the first and last mark. Enter and Space select the current mark; Escape clears the current reading.
This model avoids creating one tab stop per point or slice. The chart also exposes the current mark through a text status reading, so the same value available in a pointer tooltip is available to a keyboard reader. Funnel stages use their own focusable columns but keep the same activation result.
ChartContainer does not add a tab stop of its own. Header actions and legend controls remain in the normal reading order, so keyboard focus moves from chart controls to the legend without stopping on the layout wrapper.
References: src/…/usePlotKeyboard.ts• L63-71 src/…/usePlotKeyboard.ts• L161-225 src/…/types.ts• L1188-1325 src/…/FunnelChart.vue• L86-107 src/…/ChartContainer.cy.ts• L331-346
Card and chart composition
ChartCard supplies a bordered surface, while ChartContainer arranges the title, subtitle, title suffix, plot, state view, axis titles, actions, and legend. Built-in charts use this composition, and custom plots can use the same pieces so a dashboard has one visual and interaction model.
The container shows axis titles only for a ready plot. It places them above the plot by default or below it when axisTitlePlacement="bottom"; the pair follows the value-axis sides in right-to-left layouts. A title suffix stays beside the title text, while actions stay at the end of the header row. Set card to false when a parent already provides the surface. Keep a height on the card or its plot area because the chart fills the space it receives.
References: src/…/types.ts• L1086-1148 src/…/types.ts• L1335-1347 src/…/ChartCard.md• L11-22 src/…/ChartContainer.md• L11-14 src/…/Overview.md• L62-88 src/…/ChartContainer.vue• L11-65 src/…/ChartContainer.vue• L117-140 src/…/ChartContainer.cy.ts• L42-165 src/…/ChartContainer.cy.ts• L285-321
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the flat prop names aligned with the wide and long data rules. A change to series identity affects
seriesConfig,hiddenSeries, legend entries, tooltip rows, and selection events together. - Keep
OTHERS_KEYstable when changingmaxSeriesormaxSlices. Saved chart settings may style or hide that identity. - Preserve the distinction between raw values and formatted labels. Axis and tooltip formatters must not change grouping, scale placement, or selection payloads.
- Recheck normalized stack behavior when changing hidden-series handling. The visible total and the fixed 0–100 axis must use the same visible series set.
- Keep chart-specific selection payloads and slot props aligned with the mark they describe. Grouped donut slices and Sankey links carry different row scopes.
- If a chart adds a mark or interaction, update the shared component types and the related legend, tooltip, state, and keyboard contracts together.
- Keep
ChartContainerstate precedence and slot behavior aligned with the visibledata-state. Changes to title or axis-title placement must preserve the plot area and the normal focus order for header and legend controls. - Keep
ChartScalebounds and clipping markers aligned with the color range. A displayed ramp must explain the sameminandmaxused to color the plot. - Keep
NumberCardvalue and delta formatting separate. A string value must remain readable as supplied, while numeric targets and deltas use their matching format rules.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
Long data is supplied with multiple y columns | Only the first value column is used for the grouping model | Use one value column with splitBy, or use wide data without splitBy |
maxSeries is used with a y column list | No named columns are capped | Use maxSeries only with long data |
| A normalized stack contains a lone mark or an unstacked line | That mark keeps its own magnitude while the stack uses a 0–100 scale | Give the mark its own value axis or avoid mixing these readings |
| A reference line is outside the current scale | The annotation is not drawn | Set the relevant axis range when the target must remain visible |
| A scatter point lacks x or y, or a heatmap row lacks a numeric value | The row produces no drawable mark or cell | Validate the required measures before building chart data |
| A Sankey link creates a cycle or points to itself | The link is dropped because the flow has no valid ordered layout | Aggregate data into one-way stages before plotting |
| All series or slices are hidden | The chart refuses the final hide action | Treat the last visible mark as required for a meaningful plot |
| Error, loading, and empty inputs are set together | The error view wins, so the chart does not show loading or empty content | Clear the old error before relying on a later state |
| A legend row overflows without using its overflow control | Series names can force the card to grow or become hard to reach | Keep the one-row ChartLegend behavior and its +N more access path |
A NumberCard receives null for a missing reading | The card shows empty state rather than a zero | Supply a numeric value when zero is the intended reading |
Key files
| File | Why to read it |
|---|---|
| src/…/index.ts | Public component, type, utility, and constant exports |
| src/…/types.ts | Shared public props, option types, slot contracts, and selection payloads |
| src/…/seriesData.ts | Wide and long axis-series rules and the Others cap |
| src/…/Overview.md | Family-level data shapes, marks, shared chrome, and custom chart model |
| src/…/BarChart.md | Axis chart behavior for stacking, combo marks, targets, labels, and visibility |
| src/…/LineChart.md | Time and numeric axes, dual scales, gaps, and filled series |
| src/…/DonutChart.md | Ring geometry, slice grouping, center readout, and half-ring behavior |
| src/…/HeatmapChart.md | Cell mapping, category formatting, and signed color scales |
| src/…/ScatterChart.md | Two-measure geometry, bubble size, groups, labels, and quadrants |
| src/…/SankeyChart.md | Directed flow model, orientation, node alignment, and cycle limits |
| src/…/FunnelChart.md | Ordered stages, conversion percentages, and stage selection |
| src/…/NumberCard.md | KPI value, delta meaning, and sparkline behavior |
| src/…/ChartContainer.md | Shared title, state, axis-label, action, and legend composition |
| src/…/ChartLegend.md | Visibility toggle, highlight behavior, and overflow access |
| src/…/ChartTooltip.md | Shared tooltip input, placement, and customization contract |
| src/…/ChartContainer.vue | Shared chart layout, state precedence, axis-title placement, and slot behavior |
| src/…/ChartLegend.vue | One-row legend fitting, overflow access, visibility toggles, and highlighting |
| src/…/ChartScale.vue | Shared horizontal and vertical color-ramp scale labels |
| src/…/legendOverflow.ts | Rules for ranking legend entries and fitting the overflow trigger |
| src/…/ChartContainer.cy.ts | User-facing checks for container states, header layout, focus order, and plot persistence |
| src/…/usePlotKeyboard.ts | Keyboard reading and activation rules for canvas-backed plots |