Cleaner Alluvial Diagrams: CanvasXpress Now Draws Ribbons the Way ggalluvial Does
▶ Alluvial Plot with Factor-Ordered Strata▶ Alluvial Plot with Custom Stratum Order
If you build alluvial diagrams — those flowing ribbon charts that track how categorical groups shift across stages, like patient cohorts moving through treatment arms, or species classifications flowing across biogeographic regions — you already know how much the reading order of the ribbons matters. Two charts can have identical nodes, identical colors, identical data, and still feel completely different to look at, simply because the ribbons are stacked in a different vertical order within each column, or because one ribbon happens to paint on top of another at the wrong moment.
This is exactly the kind of subtle-but-important detail that separates a merely accurate chart from one that actually communicates. CanvasXpress's alluvial diagrams — built on its native Sankey engine — now follow the same ribbon-ordering conventions as ggalluvial, the widely used R package for alluvial plots. If you're porting a ggplot2/ggalluvial figure into CanvasXpress, or just want your alluvial diagrams to read the way the statistical-graphics community expects, this update closes that gap.
Why ribbon order matters
An alluvial diagram tells two stories at once: which category each flow belongs to, and how that flow's position changes as it moves from one axis to the next. Two things control how that story reads visually:
- Vertical order — where each ribbon sits within its column, relative to the others sharing that node.
- Draw order (z-order) — which ribbon paints last, and therefore which one appears "on top" wherever ribbons overlap.
ggalluvial has well-defined, documented defaults for both. Historically, CanvasXpress's Sankey layout used a different, general-purpose approach — barycenter-style crossing minimization — which produces a perfectly valid Sankey layout but doesn't reproduce the specific crossing and stacking pattern ggalluvial users are accustomed to. The result: a chart that's functionally correct but visually "off" compared to the R original.
What's new
CanvasXpress's alluvial diagrams (the geom_alluvium path, available from both the native API and from the ggplot-conversion viewer) now match ggalluvial's default ordering behavior out of the box. Two configuration options drive this, and you get sensible defaults without having to touch either:
var config = {
graphType: "Sankey",
sankeyLinkOrder: "color",
sankeyLodeGuidance: "zigzag"
};
sankeyLinkOrder: "color"groups ribbons by their fill color before drawing, so same-colored flows paint together and later groups sit on top — mirroring ggalluvial's draw-order rule. The default,"data", keeps the original build-order behavior for anyone who isn't aiming for ggalluvial parity.sankeyLodeGuidance: "zigzag"reproduces ggalluvial's "lode guidance" logic for stacking ribbons within a node: each ribbon's vertical position is chosen by looking at where its endpoints land on neighboring axes, using the same zigzag heuristic ggalluvial uses by default (withforward,backward, and other guidance styles also available, matching what you'd set vialode.guidancein R).
If you're generating your chart through CanvasXpress's ggplot-compatible layer, you don't need to set these manually — a geom_alluvium layer already applies them, and if your original ggplot2 code specified a non-default lode.guidance, that setting carries through automatically.
The net effect: the same data, visualized in CanvasXpress, now produces the same crossing pattern and the same "what's on top" relationships you'd get from ggalluvial — without you having to hand-tune node ordering or reach for a different library just to match a figure you already built in R.
A second fix: no more "solid line" ribbons
While refining ribbon rendering, we also tracked down a visual artifact that affected any Sankey or alluvial diagram with a lot of small-value flows: thin ribbons were rendering as solid, opaque lines instead of their true, softly-colored width. At a glance this looked like a transparency/overlap problem, but the actual cause was in how thin shapes get outlined — a ribbon thinner than the default outline width was being stroked solidly in its fill color, which visually inflated every low-value flow into a hard line and created a "mesh" of overlapping strokes wherever many small flows crossed.
That's now configurable:
var config = {
graphType: "Sankey",
sankeyLinkLineWidth: 0.25
};
Setting sankeyLinkLineWidth to a small value (CanvasXpress's alluvial charts already do this for you by default) lets thin flows render at their true width and color intensity instead of being stroked into solid lines. The default of null preserves prior behavior for charts that depend on it, so nothing changes unless you're using the alluvial path, where the improved rendering is applied automatically.
Try it yourself
If you already have a Sankey or alluvial chart in CanvasXpress, open its menu and use Save as JSON to capture the current configuration — a great way to compare before/after once you add sankeyLinkOrder and sankeyLodeGuidance to your config. If you're exploring via the ggplot-conversion viewer, look for the geom_alluvium examples; they already demonstrate the new ordering end-to-end, including multi-axis flows where the ordering differences are most visible.
For teams migrating figures from R, this means less manual rework: an alluvial diagram built with ggalluvial::geom_alluvium() and converted into CanvasXpress should now carry over its crossing pattern and layering faithfully, rather than requiring a fresh pass to "fix" how the ribbons sit relative to each other. And because these options are just configuration, you can toggle between CanvasXpress's general-purpose Sankey ordering and ggalluvial-style ordering on the same dataset — useful if you want to see both layouts side by side before deciding which communicates your data best.
Cleaner ribbon order, faithful draw order, and crisp rendering for thin flows — all in service of the same goal: charts that tell the right story the first time you look at them.