Files
gridcraft/docs/chart-parity.md
T
Aleksander HelgakerandClaude Opus 5.5 9bd3b7cf5d Charts: series drawn and saved by their own kind; XLSX groups per drawn kind (groundwork for ODS) (#4142)
* Charts: series drawn and saved by their own kind; XLSX groups per drawn kind

Chart::series_kind is the one rule for the kind each series is drawn as: in a
combo its own kind (the first a column and the rest lines by default; bars
stand upright as columns), elsewhere the chart's kind, keeping a line's own
markers or a scatter's own lines (same_family). The renderer, legend, data
table and trendline eligibility all ask it; chart.set drops the series kinds a
new type doesn't draw.

The XLSX writer writes one group per drawn kind on each axis (areas, stacked
columns kept), axes of the kind those groups need, a one-kind chart's
secondary series on their own axes, and a stock group only for 3 or 4 series.
The reader keeps each series' markers and lines, treats groups of one family
as one chart, takes the primary axes from the value axis on the left or
bottom, and orders series by c:order.

* XLSX charts: one pie group, one group per type per axis pair, scatter markers kept

Review fixes for the per-kind chart groups:
- Pies and doughnuts have no axes: series marked secondary stay in the one
  group, so a combo turned into a doughnut no longer writes two doughnuts.
- One group per type on a pair of axes, as Excel keeps them: clustered and
  stacked columns (lines and stacked lines, areas and stacked areas) share the
  first one's grouping instead of writing two groups on the same axes.
- A markers-only scatter (or bubble) series drawn among lines keeps its markers.
- chart-parity.md: the revision row moves under Revision history.

* Charts: one grouping per type and axis pair, drawn as saved; combo pies as columns

Second review round for the per-kind chart groups:
- Chart::series_kind gives the series of one type (columns, lines, areas) on
  one pair of axes in a combo the first one's grouping, as the XLSX writer
  saves them, so a stacked column beside clustered ones no longer un-stacks
  after save and reopen. Chart::series_kinds computes them in one pass.
- A combo's pies and doughnuts are drawn as columns (as the renderer does);
  only a chart without axes ignores secondary flags, so a combo with a
  secondary pie keeps its primary axes and writes the pie where it is drawn,
  and a pie + doughnut combo is one column group.
- Groups that fit the axes come before groups moved onto them, and each
  group writes its series in their own order.
- The unreachable bubble arm in series_xml is gone.

* Charts: combos drawn and saved on category axes; data tables by series_kinds

Third review round for the per-kind chart groups:
- A combination chart is drawn on category axes, so Chart::series_kind gives
  its scatter and radar series as lines (a markers-only scatter with markers)
  and its bubbles as columns, as the renderer draws them; the XLSX writer uses
  category axes for every combo, so a scatter or bubble series first no longer
  turns the other series into scatter series.
- supports_data_table uses series_kinds (one pass, it runs every frame).
- A same-family kind left in an older JSON workbook is drawn, tested and
  documented rather than migrated: it can't be told from a file's own.

* Charts: combo chartex series as columns; empty charts survive XLSX; a new type applies to every series

- `combo_series_kind` draws a combo's histogram, waterfall, funnel, treemap, sunburst and box &
  whisker series as clustered columns, as the XLSX writer already saved them: their grouping,
  combo-ness and data-table support no longer change on reopening.
- The XLSX writer writes one empty group of the chart's kind (a line group for stock) when a
  chart has no series, so the chart is read back rather than dropped.
- The XLSX reader looks the value axes' positions up in a map built once; a file with many
  chart groups took quadratic time to read.
- `chart.set` with a new type (other than a combo) clears every series' own kind, so choosing a
  type applies it to every series again (a file's markers no longer outlive a type change);
  setting the type a chart already has drops only the kinds it does not draw.
- docs/chart-parity.md: combo scatter series are lines with markers, and only stock series
  beside stacked lines are still saved stacked but drawn unstacked.

* Charts: one model rule reads per-series kinds back; empty charts keep their kind in XLSX

- `Chart::set_drawn_kinds` sets a chart's kind and its series' own kinds from the kinds a file
  draws each series as (one family: the first's kind, a series keeping its own only where it
  differs; otherwise a combo). The XLSX reader now uses it, so an ODS reader can share the rule
  instead of copying it.
- An empty line group writes `c:marker val="0"` when the chart has no markers, and an empty
  scatter group `scatterStyle val="marker"`: an empty Line chart no longer reopens with markers,
  an empty Scatter chart no longer with lines, an empty stock chart as a Line chart. The test
  now checks the kind read back; the previous commit's test listed Waterfall, which goes
  through the column writer there and proved nothing (empty chartex charts are still not kept,
  as before this branch; documented).
- `drop_foreign_series_kinds` is removed: since the previous commit, `chart.set` clears every
  series' kind on a change of type, and the helper only ran when the same type was set again,
  where `series_kind` already ignores kinds outside the chart's family.
- `series_kind`'s doc states the combo conversions and the same-family rule; the combo row in
  docs/chart-parity.md lists every conversion.

* XLSX charts: an empty group sets neither the chart's kind nor its axes

The reader took the chart's first kind and its primary axes from the first group even when that
group held no series, so a file with an empty bar group before a scatter group read as a scatter
chart whose only series was secondary, with the bar group's axis titles. Empty groups are now
left out when any group has series, and the axis titles come from the primary pair's axes
(found by id, in any order), else the first axis of their kind as before.

* XLSX charts: axis titles from shown axes, by the primary pair's kind

Corrects the previous commit's axis lookup. When a file's only series sit on a pair whose
category axis is deleted, beside an empty group on shown, titled axes, the x title came from the
deleted axis (none) instead of the shown one: a shown axis of a kind is now taken before a
deleted one. And whether the axes are a scatter's two value axes is now decided by the group on
the primary pair, not the first group with series, so a secondary line group listed before a
primary scatter no longer gives the y axis the scatter's x title.

* Charts: the stacked hairline-bar budget test draws stacked columns

Resolved series carry the kind they are drawn as (Chart::series_kind), and the test's data
defaulted every series to clustered columns, so after the merge with main it no longer drew a
stacked chart and passed without testing stacked spans. Its series are now stacked columns.

* Charts: SeriesData::kind says render draws every series by it

* XLSX charts: the many-groups test reaches the axis lookup and is timed

* chart.addElement: trendlines for every series check their kinds in one pass

A combo series' kind looks back for the first series of its group, so
asking it per series was quadratic in a chart with many series. The
all-series path now uses Chart::series_kinds() once.

Test: trendlines_for_every_series_are_checked_in_linear_time (120,000
series: 0.06 s with the fix, 17.8 s without in a debug build).

* xlsx: a lone stock series joins the line group on its axes, keeping its grouping

A stock series too few for a stock group falls back to a line. It used to
be kept in order with the other groups, so when it came first its plain
line group took in the stacked lines after it and saved them unstacked.
The fallback now joins after the other groups, so an existing line group
keeps its grouping; with none, it is still a plain line.

Test: a_lone_stock_series_does_not_unstack_the_lines_beside_it.

* model: set_drawn_kinds stores each combo series's kind as it is drawn

Series of one type on one pair of axes share the first one's grouping
(series_kinds draws and every format saves them so), but set_drawn_kinds
stored the file's kinds as given: a stacked column after a clustered one
on the same axes was kept as stacked while drawn and saved clustered. It
now stores the drawn kind; on the other axes a series keeps its own.

Test: drawn_kinds_of_one_type_share_a_grouping_per_pair_of_axes.

* tests: linear-time chart checks count their work at two sizes instead of timing it

`many_groups_are_read_in_linear_time` and
`trendlines_for_every_series_are_checked_in_linear_time` asserted a four-second
wall-clock bound, which fails on a busy machine and doesn't show how cost grows.
Each now counts the steps its code takes, with a counter that exists only in
tests, at n and 8n, and asserts the larger run did less than 16 times the
smaller one's work (linear is about 8 times, quadratic about 64). The output
checks stay.

- xlsx: a cfg(test) counter of value axes visited while finding the primary
  axes.
- model: a `work` counter of series a combo chart's kind lookups visit, behind
  a new `test-support` feature (as gridcraft-xlsx has) so engine tests can read
  it; engine's dev-dependency enables it. Shipped builds don't have it.

Against the quadratic versions (value axes scanned per group; series_kind
asked per series) the tests fail with 2,886,000 visits against 45,750 and
2,566,398 against 40,798.

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-23 16:21:55 -06:00

17 KiB
Raw Blame History

Chart parity

Last reviewed: 2026-10-18 · Last updated: 2026-11-16 · Change: minor (a selected chart outlines its series names, category labels and values in Excel's colours, and dragging a corner of the values outline changes the plotted block, #4389, #4390; earlier: combo series drawn and saved by their own kind; earlier: chart-data-table keys pass the series index to the shared combo plot-kind rule, restoring compilation after #1150; earlier: doughnut charts: every series is a concentric ring, the first series innermost; hole size and first slice angle kept; rotated slices cover their own sweep; legend names categories; earlier: charts resize from eight handles, chart data tables, legend keys and borders, native XLSX round-trip and print/PDF; earlier: selected chart source outlines stay beneath floating objects) · Target: Microsoft Excel (Microsoft 365), Excel for Mac 16.113.4

Excel's chart types and chart elements against GridCraft. Part of target-app-parity.md. Breadth ~50%, ready ~30%, 40–60 h (estimated).

Sources: crates/model/src/features.rs (ChartKind, Chart, Series), crates/chart/src (layout and rendering), crates/xlsx/src/chart.rs (DrawingML chart parts), merged PRs #62, #116, #158 and #161, and issue #190. Behaviour checked against Microsoft's Pareto and pie/doughnut support pages.

Chart types

Excel type Excel subtypes GridCraft Notes
Column clustered, stacked, 100% stacked, 3-D clustered/stacked/100%, 3-D column 3 of 7 no 3-D
Bar clustered, stacked, 100%, 3-D ×3 3 of 6 no 3-D
Line line, stacked, 100% stacked, with markers ×3, 3-D line 3 of 7 (line, with markers, stacked) no 100% stacked; smoothed lines landed (#62)
Pie pie, 3-D pie, pie of pie, bar of pie, doughnut 2 of 5 (pie, doughnut) no exploded, pie of pie, bar of pie; doughnut draws every series as a concentric ring, first series innermost; its legend names categories, matching Excel's default vary-by-category colours
Area area, stacked, 100%, 3-D ×3 3 of 6 no 3-D; 100% stacked drawn as shares of each category's total and kept as percentStacked in XLSX
X Y (scatter) markers, smooth lines (±markers), straight lines (±markers) 2 of 5 no smooth lines
Bubble bubble, 3-D bubble 1 of 2
Stock high-low-close, open-high-low-close, volume-HLC, volume-OHLC 1 kind
Surface 3-D surface, wireframe, contour, wireframe contour 0 of 4
Radar radar, with markers, filled 1 of 3
Treemap, Sunburst 1 each 2 of 2
Histogram, Pareto 2 1 of 2 no Pareto
Box & Whisker 1 1 of 1 exclusive (default) and inclusive quartiles per series; XLSX round-trip; chart.set {quartiles} changes all series
Waterfall, Funnel 2 2 of 2 lose their kind in XLSX (PR #161)
Box & Whisker 1 1 of 1
Waterfall, Funnel 2 2 of 2
Filled map 1 0 needs geographic boundary data (licensing decision)
Combo custom combinations, secondary axis yes: each series drawn as its own kind (column, stacked column, line, line with markers, area; bars stand upright as columns, pies, doughnuts, bubbles and chartex kinds are clustered columns, scatter series lines with markers, scatter-with-lines and radar series lines), secondary axis
Total ~60 subtypes 26 (~43%) usage-weighted breadth higher (~65%): column, bar, line, pie and scatter dominate

Chart elements and formatting

Element Excel GridCraft
Move and resize the chart object yes yes (eight handles, each moving only its own edges; Format Chart Area Size fields) (#190)
Selected chart source-data outline visible on uncovered cells, beneath floating objects painted above cells and below charts, shapes, pictures and slicers; retains pane clipping and right-to-left cell geometry (#2861); series names red, category labels purple, values one blue block (#4390); series that are not one block keep a blue outline per series
Drag the source-data outline to change the chart's data corner handles on the outline resize the plotted range the values outline's four corners show resize cursors; a drag previews the block and the release runs chart.setValuesRange as one undo step: series keep their formatting, a wider block adds series and a narrower one drops them, aligned names and category labels follow; Esc cancels (#4389). Moving the block by its edge and dragging the name or category outlines are not done
Chart title, axis titles text, linked to cells, full formatting text only
Legend position, overlay, formatting, per-entry delete position only
Data labels value, category, series, percentage, from cells, callouts, position one on/off flag
Gridlines major/minor per axis, formatting one on/off flag
Axis options min/max/units, log scale, reverse order, crossing point, display units, date axis, number format missing (auto only)
Multi-level category axis (a category range two or more columns wide beside the values: year beside month) the outer levels grouped under the labels with separators read (multiLvlStrRef), drawn (rows under the labels; columns beside them in bar charts; up to three outer levels), written back with Excel's level caches
Doughnut hole size, first slice angle 10–90% hole (Excel default 75%), 0–359° first slice Format Chart pane sliders; read from and written to c:holeSize / c:firstSliceAng; documents saved before the setting existed keep their old 50% hole
Secondary axis any series any combo series; a one-kind chart's secondary series keep their axis in XLSX
Trendlines linear, exponential, logarithmic, polynomial, power, moving average, equation and R² all six types, several per series, name, forward/backward forecast, set intercept, equation and R² label, line colour/width/dash; read, written and drawn on 2-D column, bar, line, area, scatter and bubble series; chart.addElement trendline adds/removes them. No Format Trendline pane, label position/number format not kept
Error bars fixed, %, standard deviation/error, custom missing
Up/down bars, high-low lines, drop lines, series lines yes missing
Data table under the chart yes yes for column, bar, line, area and compatible combo charts: live formatted values, blank cells, grouped category headers, optional legend keys, horizontal/vertical borders and outline; native c:dTable XLSX round-trip; shared UI/print/PDF rendering
Per-series / per-point fill, line, marker, effects Format pane for every element series colour only; Format Chart pane covers chart-level options
Chart styles and colour palettes ~16 styles × colour sets style number stored, own palettes
Chart sheets yes kept, not editable: not shown, and written back unchanged in their place on save (#727); left out when a sheet they plot is deleted or renamed. No F11 / Move Chart > New sheet
Chart templates (.crtx) yes missing
Recommended Charts yes dialog with recommendations from the data's shape (own heuristic) and an All Charts list, live previews (#215)
Switch Row/Column, Select Data yes yes (Switch on charts read from files landed in #116)
Recommended Charts yes partial (Insert ▸ Recommended)
Switch Row/Column, Select Data yes yes (Switch on charts read from files landed in #116); Select Data dialog: data range, remove series, Horizontal (Category) Axis Labels (#287). No series add/edit or hidden/empty cell options
Sparklines (line, column, win/loss, markers, axis) yes line, column, win/loss
PivotCharts yes Insert ▸ PivotChart (insert.pivotChart): bound to a PivotTable's report, rebuilt on refresh and layout changes, c:pivotSource round trip; no field buttons, innermost category level only
Animation on data change yes (Windows) no

Data tables are controlled by chart.addElement {element: "dataTable", on: true, dataTableKeys: true} or chart.set {dataTable: true}. chart.set also accepts dataTableKeys, dataTableHorizontalBorder, dataTableVerticalBorder and dataTableOutline. Changing to an unsupported chart kind removes the table (Undo restores it). The chart legend is independent. Bar charts keep their vertical category axis; other supported charts use the table headers instead of repeating category-axis labels. Individual labels and values that exceed a cell's width are shortened with an ellipsis. Tables are bounded to 128 categories, 32 series and half the available chart height; if they cannot fit, a “Data table needs more space” notice replaces the table. Enlarge the chart or reduce its source range. Table-specific font/fill styling and exact Excel layout fidelity are not implemented; Excel-side verification has not been performed.

Format reference: Microsoft's DrawingML data table documentation.

XLSX round-trip

Charts are read from and written to DrawingML chart parts, but only the fields the model holds survive: anything else (axis scaling, label options, error bars, per-point formats, chartex extensions) is lost when GridCraft saves a workbook it opened. That is the main reason charts are ~30% ready: a user who opens an Excel workbook with charts and saves it gets simpler charts back.

Series data, categories and names may refer to defined names, as dynamic (OFFSET) ranges do: Excel writes a workbook-scoped name as [0]!Name in <c:f>. GridCraft reads it as the bare name and writes it back with [0]!; a sheet-scoped name is written Sheet!Name. Excel needs the qualifier: with a bare name in <c:f> it draws the whole chart blank, without a repair prompt (observed in Excel for Windows, Microsoft 365). External books ([1]Sheet1!…) are kept as they are (#1686). Such series get no numCache/strCache on save (#1690).

Each series is drawn and saved as the kind Chart::series_kind gives it: in a combo chart its own kind (by default the first a column and the rest lines), elsewhere the chart's kind, with a line's own markers or a scatter's own lines kept. A combo chart is drawn on category axes: its bars as columns, its pies, doughnuts, bubbles and chartex kinds (histogram, waterfall, funnel, treemap, sunburst, box & whisker) as clustered columns, its scatter and radar series as lines (a markers-only scatter with markers). In a combo chart the series of one type on one pair of axes share the first one's grouping, as Excel keeps them: a stacked column after a clustered one is drawn clustered, and a stacked line after an unstacked one unstacked. Changing the chart type (to any type but a combo) applies it to every series, dropping their own kinds; setting the type a chart already has keeps them.

The XLSX writer writes one chart group per type on each pair of axes, with axes of the kind those groups need (category axes for a combo; category, horizontal-bar or value axes otherwise), a secondary pair whenever a series is on it, and a stock group only for 3 or 4 series. A pie or doughnut chart has no axes, so its series are one group whatever their secondary flags. A chart without series is written with one empty group of its kind, so it reopens as that kind (an empty combo as clustered columns, an empty stock chart as a line chart) rather than vanishing; chartex charts (histogram, waterfall and the rest) without series are still not kept. The reader takes the primary axes from the value axis on the left or bottom, and orders series by c:order, then sets the chart's kind and each series' own kind with Chart::set_drawn_kinds, the rule any reader of per-series kinds shares. A combo whose series all draw as one type reopens as a chart of that type (it draws the same).

Known gaps: a one-kind bar chart's secondary series get secondary axes in XLSX, which the renderer does not yet draw for horizontal charts; a stock series in a combo beside stacked lines is saved in the stacked line group but drawn unstacked; a stock series beside columns (other than a 3- or 4-series stock group) is saved as a line and reopens as one; a per-series line or scatter kind left in an older GridCraft JSON workbook by a type change is honoured (markers gained or lines lost) rather than migrated, since it can't be told from a file's own per-series kind; the Forecast Sheet's column chart draws and saves its forecast series as columns, not lines.

Work (40–60 h)

  1. Preserve unmodelled chart XML on round-trip (keep the original part, patch only edited fields): 6–10 h.
  2. Axis options, label options, gridlines per axis, legend formatting: 10–15 h.
  3. Error bars; Format Trendline pane (trendlines landed): 4–6 h.
  4. Per-element Format pane parity, smoothed lines, exploded pie, pie/bar of pie, 100% variants: 8–12 h.
  5. 3-D column/bar/pie/area, surface and contour, Pareto: 8–12 h.
  6. Chart sheets, templates and PivotChart field buttons: 5–8 h. Filled map: owner decision on boundary data.

Revision history

Date Change Summary
2026-11-16 minor A selected chart outlines its series names (red), category labels (purple) and values (one blue block), and the values outline has corner handles: dragging one changes the block the series plot through the new chart.setValuesRange command, keeping each series' formatting (#4389, #4390). Engine and real-input UI tests cover growing, shrinking, adding series, undo and Esc. No readiness score change.
2026-11-14 minor Combo series drawn and saved by their own kind (Chart::series_kind): areas, stacked columns and marker lines in combos round-trip XLSX; the series of one type on one pair of axes share the first one's grouping on screen and in the file (as Excel keeps them); combo charts are drawn and saved on category axes (pies, doughnuts, bubbles and chartex kinds as columns, scatter and radar as lines); one-kind charts keep secondary-axis series (pie and doughnut charts stay one group); changing the type applies it to every series; charts without series survive XLSX. No readiness score change.
2026-11-07 minor Chart-data-table keys use the shared plot-kind helper with their series index after #1150. A focused regression checks the first combo series uses a column key and later series use line keys. No readiness score change.
2026-11-02 minor Charts move and resize from eight handles, each moving only its own edges (#190); resizing leaves the work list (1–2 h, within the 40–60 h rounding)
2026-11-01 minor Chart data tables for column, bar, line, area and compatible combo charts: command/UI controls, formatted source values, blanks, grouped category headers, legend keys, independent borders, shared print/PDF rendering and native c:dTable import/export. Dense tables show a space notice; no readiness score change.
2026-10-29 minor Selected charts highlight their source cells beneath floating objects, so the blue outline no longer crosses the chart; uncovered source cells remain highlighted (#2861)
2026-10-24 minor 100% Stacked Area: inserted from the ribbon and All Charts, drawn as shares of each category's total, read and written as percentStacked
2026-10-18 trivial Stale notes: stock/combo, treemap/sunburst, box and waterfall kinds survive XLSX round-trip (PRs #158, #161)
2026-10-18 minor Doughnut charts: every series is a ring (first series innermost), hole size and first slice angle modelled, editable and round-tripped; rotated slices split at 12 o'clock without overlap; legend names categories like Excel's default (#1823)
2026-10-16 trivial Series that refer to defined names ([0]!Name, Sheet!Name) resolve instead of showing #NAME?, and are saved qualified, as Excel needs (#1686)
2026-10-16 minor Box & whisker quartiles default to exclusive, honor each series on draw and XLSX round-trip; chart.set {quartiles} changes the method (#1453)
2026-10-13 minor Multi-level category axes: read, drawn (outer levels under or beside the labels), written back with level caches
2026-10-12 trivial chart sheets are kept on save, still not editable (#727)
2026-10-11 minor Trendlines: all six types modelled, round-tripped through c:trendline, drawn with forecast and equation/R² labels; chart.addElement trendline
2026-10-11 minor PivotCharts (insert.pivotChart)
2026-10-11 minor Recommended Charts dialog with previews (#215)
2026-10-11 minor Select Data dialog with category axis labels; a blank top-left cell makes the first column the categories (#287)
2026-10-10 minor Smooth lines (#62) and Switch Row/Column on file charts (#116) landed; chart resize bug (#190)
2026-10-10 major Created from a source audit: 25 kinds (25 of ~60 subtypes), element gaps, round-trip loss