Skip to content

fix(viewer): latency chart spilled off pane edge — legend over end-of-line labels#175

Merged
ivanmkc merged 1 commit into
masterfrom
fix/latency-chart-robust
Jun 10, 2026
Merged

fix(viewer): latency chart spilled off pane edge — legend over end-of-line labels#175
ivanmkc merged 1 commit into
masterfrom
fix/latency-chart-robust

Conversation

@ivanmkc

@ivanmkc ivanmkc commented Jun 10, 2026

Copy link
Copy Markdown
Owner

Problem

The Latency by percentile pane (#sre/observability dashboard) renders its p50/p95/p99 lines + end-of-line text labels past the right edge of its pane at narrow widths.

A prior fix (#174) added x.scale.domainMax to reserve room for the labels, but that reservation is proportional to the x-range, not a fixed pixel amount — so it still spilled at narrow pane widths.

Root cause

The chart labelled each line's end with a text layer at the last data point. Vega's fit autosize (which the viewer injects for width:"container") contains the axes + legend but not a text mark whose pixel width extends past the data domain. No domainMax value reserves enough room at every width.

Fix

Drop the text layer entirely and restore the merged color + dash legend (remove color.legend:null, strokeDash.legend:null, and x.scale.domainMax). The fit-autosize always reserves room for a legend at any pane width, so the chart stays inside the pane.

Applied to both:

  • packages/viewer/src/demo/observability.json (demo seed)
  • plugin/skills/diagram-recipes/examples/observability-dashboard.panes.json (recipe example)

Reconciled the SKILL.md charting guidance to prefer a legend and warn that end-of-line text labels spill on narrow panes.

Verification

  • Rendered the pane at 480 / 760 / 1440px → canvas overflow 0px at every width; legend fully contained (screenshots below).
  • npx vitest run424/424 pass.
  • npm run build → exit 0.
480px (narrow) 1440px (wide)
legend contained, no spill legend contained, no spill

… end-of-line labels (#161)

The "Latency by percentile" pane (sre/observability dashboard) rendered its
p50/p95/p99 lines and end-of-line text labels past the right edge of the pane
at narrow widths.

Root cause: the chart labelled each line's end with a `text` layer at the last
data point and reserved room with `x.scale.domainMax`. Vega's `fit` autosize
(injected for `width:"container"`) contains the axes + legend but NOT a text
mark whose pixel width extends past the data domain, and `domainMax` reserves
room proportional to the x-range — so at a narrow pane width the fixed-pixel
labels still overflowed.

Fix: drop the `text` layer entirely and restore the merged color+dash legend
(remove `color.legend:null` + `strokeDash.legend:null` + `x.scale.domainMax`).
The fit-autosize always reserves room for a legend at any pane width, so the
chart now stays inside the pane from 480px to 1440px (verified: 0px overflow).

Applied to both the demo seed (packages/viewer/src/demo/observability.json) and
the recipe example (observability-dashboard.panes.json). Reconciled the
SKILL.md charting note to prefer a legend and warn against end-of-line text
labels (they spill on narrow panes).
@ivanmkc ivanmkc merged commit 9c5c8e4 into master Jun 10, 2026
5 checks passed
@ivanmkc ivanmkc deleted the fix/latency-chart-robust branch June 10, 2026 19:03
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