Skip to content

Graph Type: combine graph types, one type per series - #959

Merged
bflatastic merged 1 commit into
storytold:mainfrom
IHAGI-c:fix/graph-combine-types
Oct 10, 2026
Merged

bflatastic merged 1 commit into
storytold:mainfrom
IHAGI-c:fix/graph-combine-types

Conversation

@IHAGI-c

@IHAGI-c IHAGI-c commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Merge #947 first: this branch is on top of it (both change generate() in crates/engine/src/cmd/graph.rs).

Combine graph types, as Combine different graph types describes: pick a series with Group Selection (its legend swatch, then the whole series), then Object › Graph › Type sets the type of that series only. A column graph with a line series, for example.

  • graph.setType with only series of the graph selected applies type to those series, and they stay selected afterwards. The other options (column width, points, axis…) still apply to the whole graph. With the graph itself selected, anything else in the selection, or an explicit id, it changes the graph's type as before.
  • With only series selected, the query (graph.setType {}, which fills the Graph Type dialog) returns their type, so OK in the dialog keeps it.
  • The same works without a selection through a new seriesIndexes: [index] param (for MCP and scripts). It must be a non-empty list of existing series and comes with a type.
  • A series given the graph's own type follows the graph again, so nothing is stored for it.

Which types mix. The help page doesn't list them, so this is our own choice. Types that share the value axis mix: column, stacked column, line and area on the vertical axis, and bar and stacked bar on the horizontal one. Scatter, pie and radar lay out their data in their own way, so they take no other type. Asking for a type that doesn't mix is an error. If the graph's type is later changed to one the series type can't go in, the series is drawn as the graph's type and keeps its own type for when the graph changes back.

Drawing a mixed graph:

  • Plain columns keep their cluster. Stacked columns become one more slot of the cluster, so they sit beside the plain columns rather than on top of them. A graph of stacked columns only is unchanged.
  • Stacked columns stack with each other and areas with each other. The value axis covers both stack totals and every other series' values.
  • Series groups are layered with areas at the back and lines in front of columns. A graph of one type keeps its series order.
  • Category labels sit at the edges only when every series is drawn edge to edge (areas, or lines with Edge-to-Edge Lines). Otherwise the labels, and the areas and lines, sit at the category centres, lined up with the columns.

The page's note about stacked columns sharing one axis matters once a graph can have a right axis. That comes in the next PR, with Left/Right/Both and separate scales. Until then every series uses the one value axis.

File format. Series types go in a new seriesKinds field (one entry per series, null for "the graph's type"), written only when a series has its own type. A version that doesn't know the field ignores it and draws the whole graph as the graph's type, and files without it are unchanged.

Graphs of one type draw exactly as before. I checked this by dumping the generated art for all nine types, with Edge-to-Edge Lines on and off, on data with blanks and negatives, before and after this change: the two dumps are byte for byte the same.

ROADMAP: the Graphs entry says what combining does and that a second value axis remains open.

Tested:

  • New tests:
    • A line series in a column graph: the columns take the whole cluster, line points at the category centres, the line drawn in front, layering after swapping types, back to the graph's type, undo.
    • Group Selection retypes only the selected series and keeps it selected. The query returns the series' type, and sending the dialog's values back keeps it. The whole graph, a mixed selection or an explicit id change the graph's type.
    • Refused types (pie, radar, scatter and bar in a column graph). Bad seriesIndexes (missing series, empty, negative, not numbers, not a list) and seriesIndexes without type.
    • A series type kept through a change to pie and back.
    • Stacked columns with a line: the value axis covers the stack total, and with a plain column too the stack takes the cluster's last slot.
    • An area with columns: its points at the category centres, drawn behind. An area graph alone still spans the plot.
    • A bar graph with stacked bar series, including a negative one.
    • Series types through save and open. A file without seriesKinds reads, and none is written back. A stored type the graph can't take is drawn as the graph's type.
  • The new tests fail with series types ignored.
  • cargo xtask ci: all 7 steps (fmt, clippy, test, assets, brands, layers, wasm).

Graph Type on series picked with Group Selection (or listed in the new
`seriesIndexes` param) now sets the type of those series only, so a
column graph can carry a line series:
https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/visualize-data/combine-different-graph-types.html

- Column, stacked column, line and area mix on the vertical value axis;
  bar and stacked bar on the horizontal one. Scatter, pie and radar take
  no other type. The help page doesn't list which types mix, so this is
  our own choice: types that share the value axis.
- Stacked columns take one slot of the column cluster (a graph of
  stacked columns only is unchanged); stacked series stack with each
  other, areas with each other, and the value axis covers both totals.
- Areas draw at the back, lines in front of columns. Category labels,
  areas and lines sit at the category centres once a series that isn't
  edge to edge is in the graph.
- With only series selected, the Graph Type query returns their type,
  so the dialog's OK keeps it, and they stay selected after the change.
  An explicit `id`, or anything else in the selection, is the whole
  graph, as before.
- A series given the graph's own type follows the graph again. A type
  the graph's type can't take is drawn as the graph's and kept.

Series types are stored in a new `seriesKinds` field, written only when
a series has its own type; versions that don't know it draw the whole
graph as the graph's type. Graphs of one type draw the same art as
before.
@bflatastic
bflatastic force-pushed the fix/graph-combine-types branch from 6c947a0 to 01a65c4 Compare October 10, 2026 13:09
@bflatastic
bflatastic merged commit f81c0f5 into storytold:main Oct 10, 2026
1 check passed
@bflatastic

Copy link
Copy Markdown
Member

Thanks again, @IHAGI-c! Merged after a full CI run, rebased onto the current main (#947 had already landed). Combining types per series follows the documented Combine different graph types. Leaving scatter, pie and radar out of mixes is a reasonable reading where the docs only say scatter, and keeping a series' own type when the graph changes is a nice touch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants