Repository navigation
Conversation
apache#21514 Co-Authored-By: Rahul Kashayp <rahulmkashyap@gmail.com>
|
Thanks for your contribution! 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
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.
Brief Information
This pull request is in the type of:
What does this PR do?
Fix the graph thumbnail being shifted and zoomed out when
series.symbolis an SVG path (path://) or an image (image://).Fixed issues
thumbnailzoom behaviour breaks on typegraphwhen SVG path is used assymbol#21514:thumbnailzoom behaviour breaks on typegraphwhen SVG path is used assymbolDetails
Before: What was the problem?
GraphView#_renderThumbnailcopied each node symbol withnew sub.constructor({shape, style}), settingshape.x/y/width/height. That only works for built-in symbols, whose shape describes their geometry:path://symbol is a zrenderSVGPathwhose path data lives in a per-instancebuildPath, so the constructor builds an empty path. Its bounding rect is(0, 0, 0, 0).image://symbol is aZRImage, whose geometry is instyle, 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 factorySymboluses. This lays out built-in,path://andimage://symbols correctly. The original style is still copied (except for images, whose geometry is in style), andz2stays 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 forpath://andimage://symbols matches the one forcircle. It fails before this change and passes after.Document Info
One of the following should be checked.
Misc
Security Checking
ZRender Changes
Related test cases or examples to use the new APIs
test/ut/spec/series/graph-thumbnail.test.ts; also visible intest/graph-thumbnail.htmlby settingsymbol: 'path://...'.Merging options
Other information
I wrote this fix with help from an AI coding assistant (Claude). I reviewed the change and ran
npx jest,tsc --noEmitand eslint locally.