Skip to content

XYPlot: several numeric series against labelled axes - #484

Merged
tannevaled merged 1 commit into
mainfrom
xyplot
Oct 8, 2026
Merged

tannevaled merged 1 commit into
mainfrom
xyplot

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

What

A new chart widget, XYPlot: one or more numeric series drawn against labelled axes.

  • 1-2-5 "nice" ticks on both axes, with labels (FormatX/FormatY, default %g to four digits; a computed zero prints as 0), and a light grid
  • optional captions (XLabel under the x ticks, YLabel above the y axis)
  • three styles per series: PlotLine, PlotStem (from y = 0, as a spectrum is usually shown), PlotMarkers
  • a legend for the series that carry a Label; it is skipped when it would not fit inside the plot
  • hover: a rule, a marker and an x y readout for the first series' nearest point (Hover()/HoverIndex(), set by OnEvent on EventMouseMove, like the other charts)
  • Series() is a shared mvvm.ObservableList[PlotSeries]; SetSeries replaces all of them
  • a series longer than the plot is wide is drawn as a per-column min/max envelope: a 65 536-point signal costs one stroke per pixel column and a single-sample spike still shows
  • NaN and Inf points are gaps, not jumps

Why

The existing charts cover one series with no axis text (LineChart), or one series against time (TimeSeriesChart). The go-fft WASM playground plots a signal against time and its spectrum against frequency, with several curves (real/imag, or the round trip over the input). Without this it would have had to draw its axes by hand, which the fleet's rule forbids.

Gates

  • XYPlot is in mvvmMigratedWidgets (XLabel/YLabel are config; the series and hover state are mvvm handles) and in the bounds sweep
  • A11y: RoleImg, name = YLabel, value = "N series, M points"
  • 100% statement coverage of the package (local), -race, gofmt, vet, js/wasm build

Tests check pixels: each style's ink lands on the surface; each stem reaches the zero row; a one-sample spike in a 20 000-point series survives the envelope; a too-wide legend is not drawn; hover draws its rule at the hovered point.

Not included in the metric-scale run-length audit: the widget draws tick labels, which that audit excludes by design.

🤖 Generated with Claude Code

A chart for a signal against time or a spectrum against frequency: nice
1-2-5 ticks on both axes with their labels, a light grid, optional axis
captions, a legend for labelled series, three styles (line, stem,
markers), and a hover readout of the first series' nearest point.

The series are a shared mvvm.ObservableList; SetSeries swaps them all.
A series longer than the plot is wide is drawn as a per-column min/max
envelope, so a 65536-point signal costs one stroke per pixel column and
still shows a single-sample spike. NaN/Inf points are gaps, not jumps.

Gated in TestMigratedWidgetsHaveNoImperativeState (XLabel/YLabel are
config) and swept by TestWidgetsStayWithinBounds. 100% coverage.

Wanted by the go-fft WASM playground, which plots signals and spectra
and otherwise would have had to draw its axes by hand.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@tannevaled
tannevaled merged commit 05344f8 into main Oct 8, 2026
1 check passed
@tannevaled
tannevaled deleted the xyplot branch October 8, 2026 17:18
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