Repository navigation
fix(echarts): render Plain Timeseries legends as HTML, not canvas - #43314
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #43314 +/- ##
==========================================
- Coverage 79.16% 79.08% -0.08%
==========================================
Files 2879 2878 -1
Lines 165765 165298 -467
Branches 38322 38259 -63
==========================================
- Hits 131224 130734 -490
- Misses 32064 32111 +47
+ Partials 2477 2453 -24
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:
|
|
🎪 Showtime deployed environment on GHA for 9b8da16 • Environment: http://44.243.198.58:8080 (admin/admin) |
|
🎪 Showtime deployed environment on GHA for f56c10f • Environment: http://35.94.59.81:8080 (admin/admin) |
Code Review Agent Run #8c6534Actionable Suggestions - 0Additional Suggestions - 1
Filtered by Review RulesBito filtered these suggestions based on rules created automatically for your feedback. Manage rules.
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
…erlap-timeseries # Conflicts: # superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts
|
🎪 Showtime deployed environment on GHA for 6965baf • Environment: http://54.213.84.123:8080 (admin/admin) |
|
🎪 Showtime deployed environment on GHA for 5f195cf • Environment: http://16.146.79.93:8080 (admin/admin) |
|
🎪 Showtime deployed environment on GHA for 2f0d78d • Environment: http://44.243.247.238:8080 (admin/admin) |
Code Review Agent Run #010b9eActionable Suggestions - 0Additional Suggestions - 4
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
|
Heya @sadpandajoe, the title and description here are still describing the original margin-cap approach in Otherwise this looks good to me. Capping the legend height instead of letting margin grow unbounded is the right call, and real |
|
Good catch — the description was stale from before the swap to the custom |
gabotorresruiz
left a comment
There was a problem hiding this comment.
LGTM, thanks Joe, and thanks for the description rewrite, it now matches the implementation exactly. I verified this end to end: 24 of the new tests fail on master so they genuinely pin the fix, the full Timeseries and collateral echarts suites pass locally (636 tests), and the branch merges cleanly with current master. The SSR grid-geometry assertions are a level of rigor we rarely get in this plugin. Two small non-blockers inline.
The custom Plain-legend renders as HTML, so it lost the native ECharts legend behavior of highlighting the hovered series. Wire onMouseEnter/ onMouseLeave to dispatch highlight/downplay actions by series name. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Code Review Agent Run #66fddbActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
SUMMARY
When a Time-Series chart's Legend Type is set to Plain (List) with Legend Orientation
Top or Bottom, and enough grouped dimensions are combined to produce many legend
entries, the legend could render on top of the chart's plot area instead of the
chart displaying properly. A Plain legend never paginates or hides entries, so any
legend taller than the space ECharts reserved for it painted directly over the plot.
An earlier iteration of this fix tried to address this by having the chart's
legend-layout estimator reserve more of ECharts' own grid margin for the legend, but
the legend and the plot still shared a single ECharts canvas/coordinate system, so a
legend taller than even the "full" computed margin could still overlap the plot.
This PR replaces that approach for the common case (Plain legend, Top/Bottom
orientation) with a custom HTML legend (
TimeseriesLegend) rendered outside theECharts canvas, in its own flexbox row via
WithLegend. Because the legend and thechart are now separate DOM elements instead of sharing ECharts' coordinate system,
the legend can no longer paint over the plot: it renders in a bounded, independently
scrollable box (
getTimeseriesLegendMaxHeight), and the ECharts canvas always getswhatever space remains, down to a small fixed minimum plot height. The custom legend
preserves the existing legend interactions (item toggle, "All"/"Inverse" selectors)
by dispatching the same ECharts legend actions the native legend used, and renders
real
<button>elements, which are more accessible than ECharts' canvas-drawn legend.It does not change how the legend type itself is resolved — an explicit Plain/List
selection is still always honored, never silently switched to a scrolling legend.
Plain legends with Left/Right orientation, and every other legend type/orientation
combination, are unaffected — they continue to use the pre-existing margin-reservation
approach (
resolveLegendLayout/getHorizontalPlainLegendLayout/getVerticalPlainLegendLayout). The change is scoped to the Timeseries chart plugin;the shared legend-layout helper's behavior for other chart types (Mixed Timeseries,
Gantt, Pie, Funnel, Radar, Bubble, Graph) is unchanged.
ROOT CAUSE
getHorizontalPlainLegendLayoutinplugins/plugin-chart-echarts/src/utils/series.tsestimates the number of horizontal legend rows and the margin needed to fit them, but
that margin is still consumed from inside ECharts' own grid — the legend and the plot
are laid out by the same coordinate system, so no margin calculation, however
accurate, can fully decouple the two. The Timeseries plugin now sidesteps that
coupling for Plain + Top/Bottom legends by rendering the legend as ordinary HTML next
to (not inside) the ECharts canvas, so the plot's height is simply "whatever's left"
after the legend takes its bounded, scrollable share — there's no margin the legend
can grow past.
LATENT ISSUES FOUND (not fixed here, noted for future work)
getVerticalPlainLegendLayoutsizes left/right margins from the longest label andselector width but does not account for the number of vertically stacked items — a
tall vertical Plain legend (still native-ECharts-rendered) can extend beyond the
plot. Separate, orientation-specific defect from this fix.
legend-layout resolver but don't render a custom HTML legend, so they retain the
legacy margin-reservation behavior rather than the structural fix added here.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before:
After:
Screen.Recording.2026-08-27.at.10.22.00.PM.mov
TESTING INSTRUCTIONS
whose combination produces many series (dozens or more) — e.g. two categorical
columns with a handful of distinct values each.
(repeat with Bottom).
instead of overlapping the plot area — the plot area shrinks to make room for
the legend instead of being painted over.
reserves only the minimal space it needs and isn't scrollable.
verify they still drive the chart the same way the native ECharts legend did.
previous margin-reservation behavior).
ADDITIONAL INFORMATION