Repository navigation
Declare dimensions on typed-array line series - #187
Merged
Merged
Conversation
Line and extension series carry their points as a flat Float64Array (25fb6c9). ECharts' development build asserts that typed-array data declares its dimensions ("dimensions must be given if data is TypedArray."), so in `pnpm dev` adding a trace crashed the plot. The production build strips the assert, which is why only dev broke. Both series now declare dimensions ['x', 'y']. They map to the axes in order, time then value, so no encode is needed, and [t, v] pairs read the same way: the main line keeps them when it switches to point data at an INVALID sample. PlotArea.option.test.tsx loads the option SinglePlot builds into a real server-side ECharts instance and reads the values back out of its store: an empty just-added trace, a line with its frozen (2048-anchor) and following (2-point) extension, a line switching between typed and point data on one chart, an INVALID-broken step line with its band, and LTTB sampling of a dense line keeping a one-sample spike.
main added its own PlotArea.option.test.tsx (chart theme and number formatting) with the CanopyChart migration. Keep it as is and move this branch's typed-array test to PlotArea.typedData.test.tsx, mocking CanopyChart through test/chartStub like the other PlotArea tests.
jbellister-slac
approved these changes
Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
PlotArea.tsx: the main line series and the extension-line series now declaredimensions: ['x', 'y'](one sharedXY_DIMENSIONSconstant, so the memoized series objects stay stable). The dimensions map to the axes in order, time then value, so noencodeis needed. The main line declares them in both of its forms, the flatFloat64Arrayand the[t, v]pairs used once an INVALID sample breaks it. The series merges by id when it switches between the two.New
PlotArea.typedData.test.tsx: mountsSinglePlotwith canopy-charts'CanopyChartstubbed out (test/chartStub), loads the captured option into a real server-side ECharts instance (Vitest runs withNODE_ENV=test, so the development asserts are live), and reads the values back out of ECharts' store. It covers:Every test also checks that each series with typed-array data declares
dimensions. All 6 tests fail without the fix with ECharts' assertion and pass with this change.Motivation
In
pnpm dev, clicking Add Trace crashed the plot withUncaught Error: dimensions must be given if data is TypedArray., thrown fromdetermineSourceDimensionsin ECharts'data/Source.js. Onmainthe page went blank.fc8d439 switched line series data to flat
Float64Arrays, which kept updates cheap while a plot scrolls. The extension lines use them too. ECharts needsdimensionsto know how many values make a point in typed data. Its development build asserts on this, but the assert sits underprocess.env.NODE_ENV !== 'production', so production builds were unaffected and only dev broke. The typed-array data is unchanged; there is no switch back to[t, v]pairs.Screenshots
Checked in
pnpm devagainst a local Canopy test backend with a simulated sine PV:Pre-merge checklist
pnpm test, 514 tests after mergingmain)pnpm lint;pnpm format:checkandpnpm exec tsc -balso pass)