Repository navigation
fix(echarts): draw the series line style and symbol in the Plain Top/Bottom legend - #45648
Conversation
…e and symbol Red step for apache#45488. A Plain Top/Bottom legend item should describe the icon the ECharts legend would draw: a line in the series' dash style with its symbol, the symbol alone for scatter, a box for bars. The component tests pin the SVG geometry to ECharts' legend item (25x14, symbol at 80%). Co-Authored-By: Claude Fable 5.1 <[email protected]>
…Bottom legend Since apache#43314 the List legend for Top/Bottom is HTML, and its swatch was a fixed 12px square that only knew the series colour. A dashed annotation line and a solid data series looked the same, unlike the Scroll legend. buildTimeseriesCustomLegend now derives an icon per item from the final series (type, lineStyle.type/width, symbol), and TimeseriesLegendIcon renders it as a small SVG following ECharts' own legend icon rules: a 25x14 item, a 2px line dashed the way zrender expands dashed/dotted, the symbol at 80% of the height, hollow "empty" symbols, a rounded box for bars, and the disabled colour when the item is deselected. Fixes apache#45488 Co-Authored-By: Claude Fable 5.1 <[email protected]>
…legend The pin now follows ECharts' geometry: its cusp sits at the symbol centre and its head rises above the line (the svg no longer clips it). Icons also inherit the series opacity, so time-shifted series read as lighter in the legend, as they do in the Scroll legend and in 6.1. Co-Authored-By: Claude Fable 5.1 <[email protected]>
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #45648 +/- ##
========================================
Coverage 84.75% 84.76%
========================================
Files 3071 3072 +1
Lines 206037 206140 +103
Branches 48506 48549 +43
========================================
+ Hits 174625 174725 +100
- Misses 28109 28112 +3
Partials 3303 3303
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
… union The conditional type used to pull `lineType` out of TimeseriesLegendIcon collapsed to `never` once the icon became an intersection, which only the CI type check (run after the plugin build) caught. Co-Authored-By: Claude Fable 5.1 <[email protected]>
The ECharts theme built in Echart.tsx gives legend labels colorTextSecondary and deselected labels colorTextDisabled. The HTML legend used colorText, so its labels read darker than the Scroll legend next to it and than 6.1. Co-Authored-By: Claude Fable 5.1 <[email protected]>
EnxDev
left a comment
There was a problem hiding this comment.
Went through this against the ECharts legend code (getLegendIcon, the pin and roundRect builders, the zrender dash expansion) and the geometry and dash patterns line up. Bar, scatter, time-shift and dark mode all map to what the Scroll legend draws.
Two small notes inline, nothing blocking: one edge case where the line icon's symbol opacity differs from Scroll, and a naming nit.
…markers The ECharts legend paints a line icon's symbol with the series' itemStyle.opacity and the line with lineStyle.opacity. The Plain legend icon used the line opacity for both, so a line chart with rich tooltip and markers both off (where transformSeries keeps invisible symbols for click handling) showed a hollow circle that the Scroll legend does not. The line icon now carries a separate symbolOpacity; the symbol is skipped at 0 and faded on its own in between. Also renames the inner Symbol component to LegendSymbol so it no longer shadows the global. Co-Authored-By: Claude Fable 5.1 <[email protected]>
EnxDev
left a comment
There was a problem hiding this comment.
Checked the two notes from last time against the ECharts 6.1 legend code: both are addressed, including the symbol now reading itemStyle.opacity.
That fix does expose one issue: the symbol opacity multiplies with the opacity on the whole SVG, so time-shifted and dimmed markers come out lighter than in Scroll.
The theme tokens follow the migration rules, but Plain Top/Bottom doesn't pick up the ECharts theme overrides that the canvas legend honours, so custom legend styling can differ between layouts. The fixed vertical offset, missing coverage for hidden markers, and the transparent-line comment are smaller points.
… icon The symbol opacity added for hidden markers nested inside the opacity on the whole SVG, so a time-shifted marker rendered at 0.49 instead of the 0.7 the ECharts legend uses. Each drawn part now carries its own value: the line takes the series opacity, the symbol takes the marker opacity, and box and scatter icons keep the single value on their one part. The icon is centred on its label instead of being nudged down by a fixed 3px, which sat it about 2.5px low. The pin's head rises above the icon box, so the entry list keeps that much room under the sticky selector row, derived from the pin geometry rather than hard-coded. Also covers hidden markers in the tests and rewords the opacity comment. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Thanks @EnxDev , the fixes for 4 out of 5 of the points you mentioned are in a92eaf6:
On the theme overrides: agreed, the HTML legend has never seen the ECharts option overrides (that predates this PR, from #43314), and plumbing the merged legend options into it is a bigger change. This would probably fit better in its own PR, which I'd be happy to do in the next few days if agreed.
|
EnxDev
left a comment
There was a problem hiding this comment.
@Aleem89 thanks for the updates! The code looks good to me, with no blocking concerns. The failing checks appear to be the known tsc and ReportModal flakes, unrelated to this PR. I'm going to rerun the CI before merge this. The remaining test coverage and wrapped-label alignment details are minor and can be addressed separately.
|
@Aleem89 thank you for fixing this! I love the small-multiples screenshots. |
…Bottom legend (#45648) Co-authored-by: Claude Fable 5.1 <[email protected]> Co-authored-by: Ville Brofeldt <[email protected]> Co-authored-by: Enzo Martellucci <[email protected]> (cherry picked from commit 1d0fc23)
* origin/master: (303 commits) fix(dashboard): don't hang forever when saved native filter state request stalls (apache#45928) chore(deps): bump actions/setup-python from 7.0.0 to 7.1.0 in the gh-actions group (apache#45941) chore(deps): bump Kesin11/actions-timeline from 3.2.0 to 3.2.1 (apache#45942) chore(deps-dev): bump the babel group across 2 directories with 2 updates (apache#45943) chore(deps-dev): bump webpack in /docs (apache#45944) chore(deps): bump unist-util-visit from 5.1.0 to 5.2.0 in /docs (apache#45945) chore(deps): bump antd from 6.6.7 to 6.6.8 in /docs (apache#45946) chore(deps): bump antd from 6.6.7 to 6.6.8 in /superset-frontend (apache#45948) fix(dataset): do not apply the dataset timezone to DATE columns (apache#45203) chore(deps-dev): update pyathena requirement from <5,>=4.1.0 to >=4.2.1,<5 (apache#45915) chore(deps): bump flask-appbuilder from 5.2.3 to 5.3.0 (apache#45922) perf(explore): use useDeferredValue for TextControl inputs (apache#44878) chore(deps-dev): bump pandas-gbq from 0.35.2 to 0.35.3 (apache#45917) chore(deps-dev): bump pymssql from 2.4.4 to 2.4.5 (apache#45919) chore(deps): bump wtforms from 3.2.2 to 3.3.0 (apache#45920) chore(deps-dev): bump grpcio from 1.84.0 to 1.84.1 (apache#45918) chore(deps-dev): bump fonttools from 4.62.0 to 4.67.0 (apache#45921) chore(deps): bump the security group across 2 directories with 2 updates (apache#45924) fix(echarts): draw the series line style and symbol in the Plain Top/Bottom legend (apache#45648) fix(ci): grant contents: read to Python jobs that declare id-token permissions (apache#45899) ... # Conflicts: # .github/workflows/chromatic.yml # .github/workflows/superset-e2e.yml # .github/workflows/superset-frontend.yml # superset-frontend/package.json
…Bottom legend (#45648) Co-authored-by: Claude Fable 5.1 <[email protected]> Co-authored-by: Ville Brofeldt <[email protected]> Co-authored-by: Enzo Martellucci <[email protected]>


SUMMARY
(Written with help from Claude Code Fable 5.1. I reviewed the code and the design decisions, wrote the tests first, and checked the result against local 6.1.0 and 7.0.0rc2 containers.)
Since #43314 the List legend at the top or bottom of a Timeseries chart is plain HTML, and every entry got the same filled square. That lost what the legend used to tell you at a glance: which line is solid, dashed or dotted, and which marker belongs to which series. A dashed "reporting limit" annotation and a solid data series looked identical, while all Scroll type, List right, List left legends still showed the difference.
This PR draws each entry the way the ECharts legend does: a short line in the series' dash style with its marker on it, a filled marker for scatter charts, and a rounded box for bars. Deselected entries go gray as before. The icon is a small inline SVG built from the series settings the legend already receives, so toggling, All/Inverse and hover are untouched.
TimeseriesLegendIcon(new) draws the icon;buildTimeseriesCustomLegenddecides which icon each entry gets.colorTextSecondary), so they no longer read darker than the Scroll legend next to them (another related regression that was found during this fix).Fixes #45488
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Same charts on 6.1.0, 7.0.0rc2 before this fix, 7.0.0rc2 after with this change, and the Scroll legend on rc2 for reference.
Line chart with solid, dashed and dotted annotation lines:
Time comparison with time-shift colors, which uses every marker shape:
The issue report used a line chart, but bar, scatter and area lost their icons the same way. They are back to what 6.1 and the Scroll legend show:
TESTING INSTRUCTIONS
Unit tests:
plugins/plugin-chart-echarts/test/Timeseries/TimeseriesLegendIcon.test.tsxand the new cases intransformProps.test.ts.ADDITIONAL INFORMATION