Repository navigation
fix(echarts): keep zoom, legend and brush over the theme switch; statistic labels by line height - #236
Merged
Conversation
…statistic labels by height ECharts' setTheme builds the chart from its option again and drops the zoom, the legend selection and the brush; PSU also mounts the component again on the first light/dark switch after a page loads. viewState.js reads the view before and sets it again with silent actions, around setTheme and across that remount (same id, other mode, same task). markLine statistic labels were placed above or below by series index, so close lines overlapped when the second was higher. They now follow the drawn values: the highest line's label above, the lowest's below, one in between away from its nearer neighbour, per statistic and value axis, stacked series by their stacked values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The theme effect runs before the option effect on mount; ECharts has no model then, and readView threw, so the chart did not render on PSU. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r the mode On PSU the remount comes before data-theme changes, so the new chart started in the old mode and the mode check dropped the view. The view is now handed over only when the component unmounts (an effect declared before the chart's sets the flag), not when the chart is made again for another renderer or locale. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ion, unmount flag, real render test - A statistic line without another series' line of the same statistic on its axis gets no label of its own, so a position from -Options for the series' markLine applies as before. - The unmount flag lives in useUnmounting and is false again after React's trial unmount in StrictMode. - A test draws two close averages with the module's ECharts and checks that the labels do not overlap (fails on main). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s change made smaller Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 25, 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.
Summary
Two bugs in the ECharts module that I measured on PSU main during #234.
1. Zoom, legend selection and brush were lost on PSU's light/dark switch. The comment in
EChart.jsxsaid they stay. They did not, for two reasons:setThemecallsGlobalModel.setTheme, which runs_resetOption('recreate'). The chart is built again from its option, and the state that actions set is dropped. I reproduced this with ECharts' server-side rendering: 40–60 becomes 0–100, and the legend selection is empty.id. The old chart is disposed whiledata-themestill has the old value. PSU sets the new value in the same task.The new
Components/viewState.jsreads the view (zoom per dataZoom, the selection of all legends, the brush areas) and sets it again with silent actions, so-OnZoom,-OnSelectand-OnLegendChangedo not fire:setTheme(setThemeKeepingView), andid, and a chart with the sameidmounted in the same task takes it after its firstsetOption. The view is handed over only when the component unmounts (useUnmounting). A chart made again for another renderer or locale starts as before.2.
-MarkLinestatistic labels overlapped.markLineOfplaced series 0 atinsideEndTopand series 1 atinsideEndBottom. When the second line was higher, the labels faced each other. The side now follows where the lines are drawn. The highest line's label goes above, the lowest one's below, and one in between faces away from its nearer neighbour. Each statistic is ranked on its own, among the series on the same value axis. A stacked series counts with its stacked values, as ECharts'markerHelper.jscomputes them. A line with no other line of its statistic on its axis keeps the series' position, as before.The showcase's workaround from #234 (
insideStartBottomfor the previous period) stays for now. The demo requires ECharts 0.3.1, which is already released and does not have this fix. With the new module, the item-level position wins and the workaround has no effect. With 0.3.1 it still keeps the labels apart. It can go once the demo requires the next ECharts release.Whole-change check
I read each touched file and function whole.
viewState.js(new)readView,applyView,setThemeKeepingView); hand it over across a remount (handOverView,takeHandedOverView).EChart.jsx,EChartsetThemeKeepingView. The init effect takes and hands over the view. The option effect applies a handed-over view once.toggleFullscreen:useFullscreen(the full-screen listener, unchanged) anduseUnmounting(the new flag).EChartis 3 lines shorter than its baseline (251 against 254). The comment that promised zoom and legend over a theme change is now true and names what survives.optionParts.js,markLineOfinsideEndTop.seriesIndexparameter are gone.optionParts.js,addStatisticLines,placeStatisticLabels,labelSide,drawnValues,pointOfcartesian(), which is 4 lines shorter. ReusesAGGREGATES,quantileandnum.cartesian.js,cartesianthemes.md,lines-and-time.mdGrowth guard:
javascriptreportsEChartandcartesiansmaller than the baseline. I could not lower it:node build/growth.js --updatewas blocked in my session. That CI step stays red until someone runs it on this branch.Not changed, worth a follow-up (it existed before, but now it also affects the label ranking): with
-Band, the band series are put in front of the series list. Theseries.slice(1)loop therefore gives statistic lines to band and trend helper series and overwrites a trend's own mark line. Those helper series now also take part in the ranking.Neutral review
A read-only reviewer (its own worktree, brief: "behaviour must not change except the two fixes") reviewed all commits up to
a38a3c0.markLine.label.positionfrom-Optionsstopped applying even for one series. Fixed: groups with one line are left alone. A test covers this.idin the same task gets the view, possibly also aNew-UDDynamicrefresh of a chart with a fixed-Id. Kept and open: the mode check had to go, because PSU remounts before it changesdata-theme. A chart without-Idgets a new id on every server render, so it is not affected. Whether a refresh of a chart with a fixed-Idremounts it is not checked.useUnmountingsets it to false on mount).viewState.jsheader still described the theme-only case. Fixed.javascriptjob, which installs only the root packages (same pattern as the pivot tests). A CI step that runs them in the ECharts build job would be a follow-up.Checked on PowerShell Universal
PSU 2026.3.4. The ECharts module built from this branch at
a38a3c0(index.9d997e19…), the three apps that use it restarted, Chromium./echarts-demois the module's app.setTheme).40-60 40-60after each switch on "Opened per day" (time axis), and40-60on the period chart.{"P1":false,"Opened":true}and{"This period":false,…}after each switch.[1793491200000,1793836800000]after each switch.insideEndTop, "This period" (16.17) atinsideEndBottom. Screenshots light at 1400 px and dark at 390 px: both labels readable, apart.psu.specagainst/echarts-demo1eb0849setOption. Fixed in7eea5e9, with a test.Not checked on PSU: the last commit
524015f(lone lines keep their position, the StrictMode reset, the hook extraction). The test window on the instance had ended. Its effects are covered by the unit tests and the rendering test above.Afterwards I deployed the build of main (
index.7ffb21e4…) again and restarted the three apps./echarts-demo/tickets,/echartsand/echarts-smokeload their charts without render errors.Checklist
docs/and the module'sCHANGELOG.mddescribe the new stateTest plan
npm run lint(0 problems),npm test(236 tests, 230 pass, 0 fail, 6 skipped),npm run growth(only "smaller than the baseline", see above),Invoke-Pester -Path tests/powershell(376 passed, 0 failed, 11 skipped),Invoke-ScriptAnalysis.ps1(exit 0),Build-Module.ps1for ECharts andTest-BuiltModule.ps1,Build-Site.ps1and the Zensical build ("No issues found"),npm run test:browser -- --project=chromium(29 passed, 71 skipped)🤖 Generated with Claude Code