Skip to content

feat(plot): give each 1D curve a colour no other curve of its grid uses - #151

Merged
olivhoenen merged 5 commits into
iterorganization:developfrom
olivhoenen:feat/color_round_robin
Oct 9, 2026
Merged

olivhoenen merged 5 commits into
iterorganization:developfrom
olivhoenen:feat/color_round_robin

Conversation

@olivhoenen

Copy link
Copy Markdown
Contributor

Fixes #150

Issue:
A curve was added without a colour, so Plotly coloured it by its index in the grid, and SimplePlotly then wrote that colour back onto the stored trace. Removing a curve and adding it back gave it the colour of its new index, which another curve could already hold.

Fixed behaviour:

  • the colour is now chosen when the curve is added, the first colour of Plotly's 10-colour palette no other curve of the grid uses, or the least used one once all are taken. Curves keep their colour as others come and go. Traces still without one, from older saved configurations, get theirs the same way when drawn, so error bands always match their curve
  • initPlotColors no longer reads colours back from the legend SVG, and "Reset plot colors" hands out distinct palette colours in trace order
  • covered by unit tests (plotColors.test.ts) and an e2e spec (plot-colors.spec.ts) removing and re-adding curves and resetting colours in the customization panel

A curve was added without a colour, so Plotly coloured it by its index in
the grid, and SimplePlotly then wrote that colour back onto the stored
trace. Removing a curve and adding it back gave it the colour of its new
index, which another curve could already hold.

The colour is now chosen when the curve is added: the first colour of
Plotly's 10-colour palette no other curve of the grid uses, or the least
used one once all are taken. Curves keep their colour as others come and
go. Traces still without one, from older saved configurations, get theirs
the same way when drawn, so error bands always match their curve.

initPlotColors no longer reads colours back from the legend SVG, and
"Reset plot colors" hands out distinct palette colours in trace order.

Covered by unit tests (plotColors.test.ts) and an e2e spec
(plot-colors.spec.ts) removing and re-adding curves and resetting colours
in the customization panel.

Assisted-by: Claude/opus-5
@olivhoenen
olivhoenen requested a review from paulotex October 8, 2026 12:17
…name

A curve's name is its node's last segment and its URI label, so
constraints/diamagnetic_flux/measured and constraints/ip/measured of one
entry are both measured_URI-0. The customization and metadata panels used
that name as the tab value, so both tabs were selected together, and every
edit (colour, mode, shape, smoothing, heatmap) went to the first of them.

Tabs and edits now key on the curve's nodeUri, unique in a grid, as the
data operations already did. Curves that share a name get the shortest end
of their node path that tells them apart as tab label
(diamagnetic_flux/measured_URI-0, ip/measured_URI-0); the others keep their
name. Each tab shows a dot in its curve's colour and the full node URI on
hover. Trace names and the legend are unchanged.

Assisted-by: Claude/opus-5
…n on

Legend text is purple for curves on the right axis and grey for the left
one. The axis was found by looking up the curve by its legend text, so two
curves sharing a name (diamagnetic_flux/measured in Wb and ip/measured in
A, both measured_URI-0) both took the first one's colour, and the right
axis curve was shown as a left axis one.

Each entry now reads the axis of the trace Plotly bound to it. The plot div
is held in state so the legend observer attaches once the plot mounts, the
div being rendered only when there is data to draw.

Assisted-by: Claude/opus-5
@olivhoenen

olivhoenen commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor Author

Two more fix/improvement:

  • disambiguation of tabs identifying curves in the visual customization menu (previously if two fields had the same name, e.g. measured and reconstructed inside several sub structures of the equilibrium/time_slice/constraints) the user could not select tabs individually as they shared the same name/ID (tabs now also have a color dot to better identify the data w.r.t the curve)
  • in the case of a plot with several curves on both y (grey) and y2 (purple) axis, the legend did not indicate clearly to which axis the curves belong to when the fields have the same name (but different units as they belong to different structures: e.g. above on equilibrium constraints), now it uses the same color scheme (grey vs purple)

Loading a state file or plotting a heavy node such as
equilibrium/time_slice/profiles_2d/psi could take a second or more with
no feedback. A loader next to the configuration selector now spins once
work has been running for 300 ms: every backend request (except the
10 s server-status poll), and loading a configuration or checking a tree
node until the resulting grids have been drawn.

The busy counter lives outside the Zustand store so toggling it never
re-runs store selectors.

Assisted-by: Claude/opus-5
A trace in 'lines' mode with one drawable point showed nothing at all.
buildTraces now draws such a trace as 'lines+markers'; the stored mode is
left untouched, so the plain line comes back once there are more points.

Closes iterorganization#114

Assisted-by: Claude/opus-5
@olivhoenen
olivhoenen marked this pull request as ready for review October 9, 2026 07:12
@olivhoenen

olivhoenen commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Last two updates on this PR:

@olivhoenen olivhoenen linked an issue Oct 9, 2026 that may be closed by this pull request

@paulotex paulotex left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested: main issue approved; disambiguation of tabs approved; single point approved; spinning wheel aproved
Could not test: disambiguation with y1 and y2 (could not find data that would trigger the issue).

@paulotex
paulotex self-requested a review October 9, 2026 09:44
@olivhoenen
olivhoenen merged commit 2c7fd0c into iterorganization:develop Oct 9, 2026
13 checks passed
@olivhoenen
olivhoenen deleted the feat/color_round_robin branch October 9, 2026 12:32
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.

Default line color selection Default back to markers when there is a single point of data

2 participants