Skip to content

SeriesChart: chart-series contract and single-variable chart plugin - #293

Open
BhattaraiSijan wants to merge 11 commits into
developmentfrom
feat/series-chart
Open

SeriesChart: chart-series contract and single-variable chart plugin#293
BhattaraiSijan wants to merge 11 commits into
developmentfrom
feat/series-chart

Conversation

@BhattaraiSijan

@BhattaraiSijan BhattaraiSijan commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds the shared chart-series contract (src/essence/Tools/_shared/types/chartSeries.ts) and SeriesChart, a generic chart panel rendering it. SeriesChart knows nothing about data sources: any plugin listed in its sources tool variable that emits plugin:<id>:seriesLoading/seriesReady/seriesError/seriesCleared gets a chart card per chartId — loading, error, and ready states included. Payloads are treated as untrusted: malformed ones warn and drop rather than crash the panel.

Rendering (ECharts, already a dependency): one variable visible at a time (air-quality-domain convention, e.g. OpenAQ), with the single-select legend as the parameter picker — the y-axis renames to the picked variable's unit. Wheel + slider zoom (slim theme-primary scrubber), reset button in the card header, crosshair tooltips. All time labels are UTC by design: epoch-value axis with our own formatters, since ECharts' native time axis renders viewer-local. All colors route through --theme-* tokens (canvas via a resolved theme object; spec-asserted so literals can't regress in).

The default sources: ["fetch-timeseries"] forward-references the fetcher plugin from the stacked PR — inert until it merges.

Size note: ~360 lines are unit tests and ~230 are styles/config/docs; reviewable logic is ~600 (chartData.ts, panel, adapter).

Merge order

  1. Emit feature:click on the bus for every vector feature click #292 feature:click core event (independent of this one)
  2. this PRdevelopment
  3. FetchTimeseries: feature clicks to chart-series events #294 FetchTimeseries (stacked on this PR)

Testing

Contract guards and option-builder covered by tests/unit/chartSeries.spec.js + tests/unit/seriesChartData.spec.js (UTC handling, single-select legend, unit-named axis, themed scrubber, tooltip formatting). Full unit suite green. Manual recipe lives in the stacked FetchTimeseries PR, which provides the first emitter.

…sible variable

Large payloads no longer overflow the arg-spread extent (crashed past ~130k points); a bad render costs its card, not the panel; time tick granularity follows the picked variable instead of the union of all series. Also: space-separated timezone-less datetimes parse as UTC, CSV quotes lone CRs, one token list feeds both color paths, dead surface/default-export/slider-remap removed.
seriesReady is now flat like its three siblings (SeriesReadyPayload exported; the enveloped form is dropped with a warning, spec-pinned). The guard rejects duplicate series ids/labels that broke the single-select picker. Dual-y-axis promises removed, reserved payload fields marked, layout descriptions corrected, explicitly-empty sources disables all subscriptions.
The tool shipped on:false and unassigned to any panel, so the loader never mounted it. Now on and in the float-analysis panel next to Chart. FetchTimeseries' enable lands with its own PR.
BhattaraiSijan added a commit that referenced this pull request Aug 24, 2026
seriesReady drops its envelope to match the #293 contract. Fetches time out after 30s; destroy() emits seriesCleared so no spinner or stale card is stranded (the contract's first real seriesCleared emitter); the async click handler is caught and layers:getConfig goes through a hasHandler-guarded typed wrapper, so clicks during mission load are silent no-ops instead of unhandled rejections. First tests for the tool's I/O layer (mock bus + fetch): supersede, timeout, teardown, HTTP/template errors.
BhattaraiSijan added a commit that referenced this pull request Aug 24, 2026
on:true in the profile, plus metadata startHidden/modernLayoutSupport so the no-UI tool loads and subscribes without rendering a blank tool card. With #293's enable, the end-to-end click-to-chart path now runs from a clean checkout. Config descriptions corrected alongside.
@BhattaraiSijan

Copy link
Copy Markdown
Collaborator Author

Addressed the review findings on this PR:

  • Charts crashed past ~130k points — the arg-spread Math.min(...xs) extents are now loops (spec'd at 200k points), and every card is wrapped in an error boundary so a bad render costs that one card, not the whole panel; any fresh event for the chartId retries it.
  • seriesReady was the only enveloped message and the envelope was documented nowhere — flattened to match its three siblings. SeriesReadyPayload is exported so the contract file enumerates all four shapes, and the legacy enveloped form is dropped with a console warning (spec-pinned). FetchTimeseries' emit side updates in FetchTimeseries: feature clicks to chart-series events #294.
  • Duplicate series labels collapsed the single-select picker and mislabeled the footer/CSV — the payload guard now rejects duplicate ids or labels as malformed, and the README documents the uniqueness requirement.
  • Time tick granularity was computed from the union of all series while only one is ever visible — it now follows the picked variable's extent, so a two-day series next to a five-year one keeps hourly labels.
  • The docs promised behaviors the code doesn't have — dual-y-axis claims removed from the contract and README, subtitle/yLabel/meta marked reserved, and the config layout descriptions corrected (both layouts have the zoom strip + CSV; single has the reset button).
  • The tool shipped switched off — SeriesChart is now on and assigned to the float-analysis panel in the full-demo mission (FetchTimeseries' half lands in FetchTimeseries: feature clicks to chart-series events #294).
  • Minors: space-separated timezone-less datetimes parse as UTC, CSV quotes lone carriage returns, an explicitly-empty sources config now means "listen to nothing", one token list feeds both the canvas palette and the CSS vars, dead code removed.
  • +17 specs, including the previously untested chart adapter (mock bus) and the error boundary.

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