Cleaner 3D Charts: Smarter Label Placement and Zoom-Safe Clipping in CanvasXpress

If you've ever rotated a 3D scatter plot in CanvasXpress and watched axis labels pile up in a corner — or zoomed in only to see your plot bleed over the legend — you'll want to know about the layout improvements now built into Scatter3D rendering.

3D charts are hard to get right precisely because they're not static. Every rotation changes which faces of the bounding box are visible, which edges are closest to the viewer, and how much room tick labels and axis titles actually need. A layout that looks perfect at one orientation can collide or clip at the next. CanvasXpress now handles this more intelligently, so your 3D scatter plots stay legible and contained no matter how your users interact with them.

The Problem With Static Label Placement

Axis tick labels and titles in a 3D chart have to live somewhere on the box that frames your data — typically along one of the edges. The trouble is that a 3D box has multiple parallel edges per axis, and depending on rotation, the "best" edge to draw labels on can change. If you just pick a single fixed edge and never reconsider it, you eventually end up with:

To find and fix these cases, we ran a dense sweep across hundreds of rotation combinations and measured actual label bounding boxes against each other. That data-driven approach is what shaped the fix below — not just visual spot-checks, but systematic detection of where labels from different axes would land on top of one another.

What Changed: Collision-Aware Label Placement

CanvasXpress now tracks the bounding box of every tick label as it's drawn in a 3D chart. Before a label is placed, it's checked against every other label already drawn in that render pass — on the same axis or a different one. If a label would overlap something already on the canvas, it's skipped rather than stacked illegibly on top of existing text.

The practical effect: as an axis becomes foreshortened by rotation (and its tick labels would naturally crowd together), the label set thins out gracefully instead of turning into an unreadable smear of overlapping text. You get fewer labels at extreme angles, but every label you do see is fully legible.

Axis titles follow the same logic — each title is drawn consistently alongside its own axis's ticks, with a small reserved gap, so the title and its ticks always travel together as a visual unit. Based on direct user feedback during development, axis edges are kept anchored (consistent, predictable sides for X, Y, and Z) rather than dynamically swapping sides as you rotate — so your chart's labels don't "jump" from one edge to another mid-interaction, which turned out to be more disorienting than helpful even when technically more "optimal" per rotation.

Zooming Without Breaking the Legend

The second half of this work addresses a different but related pain point: what happens to labels and plot content when you zoom a 3D chart.

Earlier behavior had a hard tradeoff — either cap how far you could zoom in (so the frame would always "contain" itself and never spill over), or let zoom run free and risk the surface or point cloud painting directly over the legend. Neither is great: a hard zoom cap feels broken ("why can't I zoom in further?"), while overpainting the legend hides information you need.

CanvasXpress now does what you'd expect from a well-behaved chart: zoom is free, and the plot content — grid, surface, points, labels, and titles — is clipped to the actual plotting area. The clip boundary is computed from the canvas dimensions minus the measured width of the legend band, so the legend is never overpainted regardless of zoom level. The legend and chart title are drawn after that clip is lifted, so they remain crisp and fully visible on top.

In short: zoom in as far as you like to inspect dense clusters of points, and the chart will clip gracefully at the plot boundary instead of drawing over your legend.

Trying It Out

No new configuration is required to get this behavior — it's part of how Scatter3D charts render today. A standard 3D scatter configuration benefits automatically:

var cx = new CanvasXpress("chartCanvas", data, {
  graphType: "Scatter3D"
});

Rotate the chart through a range of orientations and you'll notice tick labels no longer stack on each other at shared corners, and axis titles stay cleanly aligned with their ticks. Zoom in using the toolbar or your configured zoom controls, and the plot will clip at the legend boundary rather than drawing through it.

If you want to inspect or tweak the resolved configuration after rendering — for example, to confirm plot dimensions or legend settings — you can always read it back:

var config = cx.getConfig();

And if you resize the chart's container programmatically, the same clipping and label logic re-applies automatically:

cx.setDimensions(800, 600);

Why This Matters

3D visualizations are only useful if they stay readable while being explored — and exploration is the whole point of 3D. A chart that looks fine from one fixed angle but falls apart the moment a user drags to rotate it undermines the very interactivity that makes 3D views valuable in the first place.

These layout and clipping improvements were driven by systematic measurement across a wide range of rotations, not just a handful of manual checks, so the fix generalizes well beyond any single dataset or camera angle. The result is a Scatter3D experience that behaves predictably under rotation and zoom — exactly what you want when you're handing an interactive 3D chart to an end user who's going to spin it around looking for insight, not fighting with overlapping labels to find it.

If you're building dashboards or reports with 3D scatter plots in CanvasXpress, this update should mean less fiddling with camera angles to find a "safe" view, and more confidence that your chart will look right wherever your users choose to look.