fix(echarts): pin categorical legend with right instead of design-canvas left - #99
Merged
Chenglong Wang (Chenglong-MS) merged 2 commits intoAug 15, 2026
Conversation
…vas left legend.left was `_width - gutter`, so chart.resize() overlapped the plot or clipped the legend. Anchor the legend and its title graphic with right: 16. At `_width` the gutter is unchanged; only fluid hosts change. Fixes microsoft#98.
Show that at `_width` the right-anchored legend matches the old left pixel layout; only the resized canvas changes.
Author
|
@microsoft-github-policy-service agree |
Chenglong Wang (Chenglong-MS)
approved these changes
Aug 15, 2026
Contributor
|
Awesome! Thanks! I haven't maintain ECharts very actively, glad to have you spot this. |
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.
Fixes #98.
What
Categorical ECharts legends (and the matching title
graphic) usedleft: designW - gutter. That is correct only when the host inits at_width. Afterchart.resize()the plot stretches (grid.rightis an inset) but the legend stays at the design-canvas x, so it overlaps the series or clips off the right edge.This PR pins them with
right: 16(CANVAS_BUFFER). EChartsrightis the inset to the legend box’s right edge — notdesignW - left(that value is the gutter to the legend’s left edge and would grow into the plot).Same change in streamgraph post-process and faceted legend repositioning.
Unchanged at
_widthAt the designed canvas the reserved gutter is the same. Gallery / MCP that still render at
_width × _heightshould look as they do today. The siteEChartsViewstill paints at the designed size because visualMap / rose / some radii remain design-px._width)resize()534 before/after should match (legend in the gutter). 800 before overlaps the series; 800 after keeps the gutter.
Out of scope
Sunburst/pie
radius: 'NNpx'is still design-absolute. Happy to follow up separately.Test
npm run test:js -- tests/slope.test.ts(33, including the new legend.right assertion)npm run typecheck:js