Skip to content

[6/6] fix(trace): a legend that wraps below the plot stays clear of the time axis - #224

Open
thellert wants to merge 2 commits into
als/plot-layout-switchesfrom
als/bottom-legend-wrap
Open

thellert wants to merge 2 commits into
als/plot-layout-switchesfrom
als/bottom-legend-wrap

Conversation

@thellert

@thellert thellert commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

Sixth of six; based on [5/6] (als/plot-layout-switches).

The chart wraps the legend below the plot onto as many rows as its entries need, but the grid's bottom inset is a fixed 60 px, room for one row. Every further row is drawn over the time labels and then over the curves: with ten curves, two rows at 1400 px cover the time axis, and four or five at 590 px the bottom of the grid as well.

fix(trace): a legend that wraps below the plot stays clear of the time axis

  • The rows are laid out before the chart is: each entry's text is measured on a canvas as the chart measures it and wrapped by the chart's own rule at the chart's width. One row keeps the 60 px inset; each further row adds 22 px. An entry is taken a pixel or two wider than drawn, so the rows laid out are never fewer than the rows drawn.
  • Rows that would take more than 35 % of the chart's height become one row that pages instead.
  • The layout comes from the texts and the chart's size, not from the drawn legend, so the first frame, a resize and a new live value all have it in the same render. The projection, the drawing overlay and the time band's hit test read the same inset, and the projection is republished when it changes.

docs(trace): the legend below the plot wraps and pages

Testing

On this branch's tip with #208's own SDK pin (0.3.1-als.1; the lockfile re-resolved locally, since #208's committed lockfile does not install frozen):

…e axis

The chart wraps the legend below the plot onto as many rows as its entries
need, and the grid's bottom inset was a fixed 60 px, which is room for one
row. Every further row was drawn over the time labels and then over the
curves: with ten curves, two rows at 1400 px covered the time axis and four
or five at 590 px the bottom of the grid as well.

The rows are now laid out before the chart is: each entry's text is
measured on a canvas, as the chart measures it, and wrapped by the chart's
own rule at the chart's width. One row keeps the 60 px inset; each further
row adds 22 px, a row and its gap. An entry is taken a pixel or two wider
than it is drawn, so the rows laid out are never fewer than the rows drawn.
Rows that would take more than 35 % of the chart's height become one row
that pages instead. The layout comes from the texts and the chart's size
rather than from the drawn legend, so the first frame, a resize and a new
live value all have it in the same render.

The projection, the drawing overlay and the time band's hit-test read the
same inset, and the projection is republished when it changes.
The user guide's Legend entry for Bottom says what happens to names that
do not fit on one row: they wrap, the plot gives up the height, and past
about a third of the plot they become one row with paging arrows.
@thellert
thellert requested a review from a team as a code owner December 3, 2026 01:01

This branch has not been deployed

No deployments
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.

1 participant