Native Multi-Panel Matrices in CanvasXpress: Grid Layouts That Align Themselves
If you've ever built a scatterplot matrix, a faceted comparison grid, or a "panel of panels" dashboard, you know the real difficulty isn't drawing the individual charts — it's getting them to line up. Axis labels of different lengths push plot bodies around, ticks crowd the margins unevenly, and what should be a clean grid ends up looking like a patchwork of slightly-misaligned rectangles.
CanvasXpress now renders these multi-panel matrix layouts natively, directly in the core rendering engine — no external layout wrapper, no manual margin tweaking, and no post-processing to make the panels line up. Give it a grid of panel specifications, and CanvasXpress handles the measurement, the axis placement, and the alignment for you.
What you get
When you hand CanvasXpress a matrix-style specification — a set of individual chart definitions organized into a cols × rows grid — it builds the full grid of canvases for you and renders each panel as a coordinated member of that grid, rather than as an independent, unaware chart. Two things make the result look like a single cohesive figure instead of a collection of separate plots:
Perimeter-only axes. Just like a well-designed scatterplot matrix, only the outer edge of the grid carries axis labels. The left column shows the y-axis (ticks, labels, and axis title); the bottom row shows the x-axis. Interior panels stay visually quiet — no redundant ticks competing for attention in the middle of the grid.
Aligned panel bodies. This is the harder problem, and it's the one CanvasXpress solves automatically. Every panel in the grid gets the same plotting-area origin and the same plotting-area size, regardless of how wide or narrow any individual panel's axis labels happen to be. CanvasXpress measures the actual rendered text for every panel's ticks and titles, takes the largest reserve needed across the whole grid, and applies that uniform margin to every cell. The result: column boundaries and row boundaries land in exactly the same pixel position across the entire matrix, the same way a well-built table layout keeps columns aligned regardless of what's inside each cell.
You don't have to configure any of this by hand. The alignment pass runs automatically whenever CanvasXpress recognizes a matrix-shaped specification, using the library's existing panel-alignment controls (the same mechanism long available for aligning companion charts, such as a heatmap next to its dendrogram) — just computed and applied across the whole grid instead of a single pair of panels.
Working with it
A matrix specification looks like a normal CanvasXpress construction call, except the payload is a collection of per-panel chart definitions along with the grid dimensions:
var cx = new CanvasXpress("matrixView", {
isGGMatrix: true,
cols: 3,
rows: 3,
datasets: [
/* one full chart specification per panel, row-major */
]
});
Each entry in datasets is a complete, independent chart definition — its own data, its own chart type, its own styling. CanvasXpress takes care of laying them into the grid, assigning each one its role (edge panel vs. interior panel), and reconciling their margins so the bodies align.
Once the matrix is on the page, it behaves like any other CanvasXpress visualization for the operations you already rely on. You can resize it:
cx.setDimensions(1000, 800);
and the alignment holds — CanvasXpress recomputes the uniform margins for the new dimensions rather than letting individual panels drift out of sync. You can also inspect the resolved configuration at any time:
var config = cx.getConfig();
which is useful if you're programmatically tuning the chart or confirming what settings were applied after construction.
It fits your existing workflow
Because a matrix chart is still a CanvasXpress object, it plugs into the same toolbar and File-menu actions you already use for single charts. You can use Save as JSON (or Save Current as JSON) to capture the entire matrix — grid layout, every panel's configuration, and current state — as a single portable file. Drop that saved file back onto the chart container later and it reloads exactly as it was. And if you want to inspect or share how the chart was built, the Reproduce toolbar action walks through its construction step by step.
Exporting also treats the matrix as what it visually is: one figure. Generating an image of the chart produces a single composited picture of the whole grid, not a set of disconnected per-panel snapshots — so the chart you export matches the chart you see on screen.
Why this matters
Multi-panel comparison grids are a staple of exploratory data analysis — correlation matrices, small-multiples faceting, side-by-side model diagnostics. The value of that format comes entirely from being able to compare panels visually, and that comparison breaks down the moment panel bodies don't align. By solving alignment at the rendering level — measuring real text metrics on the real device rather than guessing at fixed margins — CanvasXpress produces matrix layouts that hold together visually without any manual fuss, and that keep holding together as you resize, restyle, or rebuild the chart.
If you're coming from a statistical-graphics background, this will feel familiar: it's the same perimeter-axis, shared-track alignment behavior you'd expect from a polished faceted plotting grid — now available as a first-class capability inside CanvasXpress itself.