itisrmk opened a new pull request, #21872:
URL: https://github.com/apache/echarts/pull/21872

   <!-- Please fill in the following information to help us review your PR more 
efficiently. -->
   
   ## Brief Information
   
   This pull request is in the type of:
   
   - [x] 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
   
   - #21514: `thumbnail` zoom behaviour breaks on type `graph` when SVG path is 
used as `symbol`
   
   
   ## 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.
   
   - [x] 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.
   
   <!-- PLEASE CHECK IT AGAINST: 
<https://github.com/apache/echarts/wiki/Security-Checklist-for-Code-Contributors>
 -->
   
   ### 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
   
   - [x] 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.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to