Skip to content

fix(echarts): draw the series line style and symbol in the Plain Top/Bottom legend - #45648

Merged
EnxDev merged 9 commits into
apache:masterfrom
Aleem89:fix/timeseries-list-legend-icons
Oct 31, 2026
Merged

EnxDev merged 9 commits into
apache:masterfrom
Aleem89:fix/timeseries-list-legend-icons

Conversation

@Aleem89

@Aleem89 Aleem89 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

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; buildTimeseriesCustomLegend decides which icon each entry gets.
  • Icons follow the series opacity too, so time-shifted series read as lighter, as they do in the Scroll legend.
  • Labels use the same text color as the ECharts legend (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:

legend-line_list_top

Time comparison with time-shift colors, which uses every marker shape:

legend-tc_list_top

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:

legend-bar-scatter-area

TESTING INSTRUCTIONS

  1. Line chart with a couple of metrics and a Formula annotation with Style "Dashed". Under Customize set Legend Type to List and Legend Orientation to Top. The annotation shows as a dashed line in the legend and the metrics as a line with a hollow circle.
  2. Switch Legend Type to Scroll: the icons look the same.
  3. Turn on a few time comparisons with "Time shift color": the legend shows the triangle, diamond, square and pin markers with their dash patterns.
  4. Bar chart: rounded box. Scatter: a dot.
  5. Click an entry: it turns gray and its series hides.

Unit tests: plugins/plugin-chart-echarts/test/Timeseries/TimeseriesLegendIcon.test.tsx and the new cases in transformProps.test.ts.

ADDITIONAL INFORMATION

Aleem89 and others added 3 commits October 22, 2026 17:54
…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]>
@netlify

netlify Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 4e56b72
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6ae5a1d3ba76c3a04c03d201
😎 Deploy Preview https://deploy-preview-45648--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@codeant-ai-for-open-source

codeant-ai-for-open-source Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; no actionable issues were identified in the review.

Assessed commit: 4e56b724212b

@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.08257% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 84.76%. Comparing base (a846d75) to head (4e56b72).

Files with missing lines Patch % Lines
...rt-echarts/src/Timeseries/TimeseriesLegendIcon.tsx 98.70% 1 Missing ⚠️
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            
Flag Coverage Δ
javascript 81.06% <99.08%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Aleem89 and others added 2 commits October 22, 2026 20:01
… 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 EnxDev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Aleem89 and others added 2 commits October 28, 2026 22:45
…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]>
@villebro
villebro requested a review from EnxDev October 30, 2026 17:32

@EnxDev EnxDev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

@EnxDev EnxDev left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Image

Small nit: in the screenshot above, the shifted markers look slightly fainter than their line stubs. Their opacity gets applied twice (0.7 × 0.7 = 0.49). Could we keep both at 0.7 to match Scroll? Non-blocking.

… 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]>
@Aleem89

Aleem89 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @EnxDev , the fixes for 4 out of 5 of the points you mentioned are in a92eaf6:

  • Marker opacity: each drawn part now carries its own value (line = series opacity, symbol = marker opacity) instead of nesting inside the SVG, so shifted markers are back at 0.7 like Scroll.
    Screenshot below.
  • Vertical offset: dropped the fixed 3px and centered the icon on its label instead; it was actually sitting about 2.5px low before. The pin's head overflows its box, so the entry list keeps that much room under the sticky selector row, derived from the pin geometry.
  • Hidden markers: covered in the icon tests now.
  • Transparent-line comment: reworded.

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.

legend-final-opacity

@EnxDev EnxDev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@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.

@EnxDev
EnxDev merged commit 1d0fc23 into apache:master Oct 31, 2026
81 checks passed
@sfirke

sfirke commented Oct 31, 2026

Copy link
Copy Markdown
Member

@Aleem89 thank you for fixing this! I love the small-multiples screenshots.

villebro added a commit that referenced this pull request Oct 31, 2026
…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)
@Aleem89
Aleem89 deleted the fix/timeseries-list-legend-icons branch October 31, 2026 18:01
jprinet added a commit to jprinet/superset that referenced this pull request Nov 2, 2026
* 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
hainenber pushed a commit that referenced this pull request Nov 14, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Timeseries Plain legend (Top/Bottom) draws every item as a square, losing line style and series symbol (7.0.0rc2)

4 participants