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

   <!-- 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?
   
   Makes the graph node scale compensation follow the animated view transform 
when `center`/`zoom` is changed via `setOption`, so nodes and labels no longer 
jump in size at the start of the animation.
   
   
   
   ### Fixed issues
   
   - #21894: Graph: node size jumps when the view zoom is animated via setOption
   
   
   ## Details
   
   ### Before: What was the problem?
   
   `GraphView.render` animates the main group to the new view transform 
(`applyViewCoordSysTransToElement` with `updateProps`), but 
`_updateNodeAndLinkScale` sets the compensation scale 
(`calcCompensationScaleToPreserveNodeSize`) for the end state at once. On the 
first frame, nodes and labels jump (e.g. to 1/3 of their size when zooming 1 → 
3 with `nodeScaleRatio` near 0) and then grow or shrink back during the 
animation. With the default `nodeScaleRatio` (0.6) it happens too, only less 
visibly.
   
   Measured max change of the node size between two 16 ms frames 
(canvas-relative):
   
   | Case | Before | After |
   |---|---|---|
   | `nodeScaleRatio: 0.0001`, zoom 1 → 3 | 67% | 0% |
   | `nodeScaleRatio: 0.0001`, zoom 3 → 1 | 200% | 0% |
   | `nodeScaleRatio: 0.0001`, zoom 1 → 0.3 | 233% | 0% |
   | `nodeScaleRatio: 0.6`, zoom 1 → 3 | 27% | 2.4% (gradual 1 → 2.2) |
   | interrupted animation, `backOut` easing, layout + `center` + `zoom` in one 
`setOption` | jumps | 0% |
   
   
   
   ### After: How does it behave after the fixing?
   
   - `applyViewCoordSysTransToElement` accepts an optional `during` callback 
that is passed to `updateProps`.
   - When `GraphView.render` animates the main group, it records the node scale 
relative to the canvas (`groupScale * nodeScale`) before and after the update. 
On each frame, it sets `nodeScale = lerp(from, to, percent) / 
currentGroupScale`, using the same eased percent as the transform animation. 
With `nodeScaleRatio` near 0, nodes keep their size during the animation. Other 
ratios change gradually. The end state is the same as before, and nothing 
changes without animation. The interpolation is stopped on roaming or on a new 
`setOption`, and an interrupted animation continues from the current size.
   
   Known limitation (unchanged): edge end points adjusted for `edgeSymbol` 
(`adjustEdge`) still use the final node size during the animation. Updating 
lines per frame would stop the lines' own update animation.
   
   
   
   ## 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/graph-roam-node-scale-animation.html`
   - `test/ut/spec/series/graph.test.ts`
   
   ### Merging options
   
   - [x] Please squash the commits into a single one when merging.
   
   ### Other information
   
   `nodeScaleRatio: 0` is still read as `1` (`|| 1` in 
`calcCompensationScaleToPreserveNodeSize`), while the docs say nodes then do 
not scale with zoom. That is left for a separate PR because it changes 
behavior. `TreeView` uses the same pattern and probably needs the same fix.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
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