Skip to content

fix(graph): fix thumbnail of graph with SVG path or image symbols - #21872

Open
itisrmk wants to merge 1 commit into
apache:masterfrom
itisrmk:fix/graph-thumbnail-path-symbol
Open

itisrmk wants to merge 1 commit into
apache:masterfrom
itisrmk:fix/graph-thumbnail-path-symbol

Conversation

@itisrmk

@itisrmk itisrmk commented Nov 26, 2026

Copy link
Copy Markdown

Brief Information

This pull request is in the type of:

  • bug fixing
  • new feature
  • others

What does this PR do?

Fix the graph thumbnail being shifted and zoomed out when series.symbol is an SVG path (path://) or an image (image://).

Fixed issues

Details

Before: What was the problem?

GraphView#_renderThumbnail copied each node symbol with new sub.constructor({shape, style}), setting shape.x/y/width/height. That only works for built-in symbols, whose shape describes their geometry:

  • A path:// symbol is a zrender SVGPath whose path data lives in a per-instance buildPath, so the constructor builds an empty path. Its bounding rect is (0, 0, 0, 0).
  • An image:// symbol is a ZRImage, whose geometry is in style, so the copy keeps the (-1, -1, 2, 2) box near the origin.

The thumbnail fits its view to bridgeGroup.getBoundingRect(). Because of those elements at the origin, that rect stretched from (0, 0) to the graph, so the content showed up in the bottom-right and zoomed out, and path symbols were not drawn at all.

After: How does it behave after the fixing?

Each thumbnail symbol is now made with createSymbol(symbolType, x - w / 2, y - h / 2, w, h, null, symbolKeepAspect), the same factory Symbol uses. This lays out built-in, path:// and image:// symbols correctly. The original style is still copied (except for images, whose geometry is in style), and z2 stays 151. Built-in symbols render exactly as before.

A unit test (test/ut/spec/series/graph-thumbnail.test.ts) checks that the thumbnail content bounding rect for path:// and image:// symbols matches the one for circle. It fails before this change and passes after.

Document Info

One of the following should be checked.

  • This PR doesn't relate to document changes
  • The document should be updated later
  • The document changes have been made in apache/echarts-doc#xxx

Misc

Security Checking

  • This PR uses security-sensitive Web APIs.

ZRender Changes

  • This PR depends on ZRender changes (ecomfe/zrender#xxx).

Related test cases or examples to use the new APIs

test/ut/spec/series/graph-thumbnail.test.ts; also visible in test/graph-thumbnail.html by setting symbol: 'path://...'.

Merging options

  • Please squash the commits into a single one when merging.

Other information

I wrote this fix with help from an AI coding assistant (Claude). I reviewed the change and ran npx jest, tsc --noEmit and eslint locally.

 apache#21514

Co-Authored-By: Rahul Kashayp <rahulmkashyap@gmail.com>
@echarts-bot

echarts-bot Bot commented Nov 26, 2026

Copy link
Copy Markdown

Thanks for your contribution!
The community will review it ASAP. In the meanwhile, please checkout the coding standard and Wiki about How to make a pull request.

Please DO NOT commit the files in dist, i18n, and ssr/client/dist folders in a non-release pull request. These folders are for release use only.

This branch has not been deployed

No deployments
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.

1 participant