Skip to content

fix(graph): drop the view transform when a graph moves to cartesian2d - #21867

Open
Xnadir wants to merge 1 commit into
apache:masterfrom
Xnadir:fix/graph-cartesian-after-view
Open

Xnadir wants to merge 1 commit into
apache:masterfrom
Xnadir:fix/graph-cartesian-after-view

Conversation

@Xnadir

@Xnadir Xnadir commented Nov 23, 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?

Resets the graph's main group transform when the series is not on its own view coordinate system, so a graph set on cartesian2d after a graph on the default view is placed on the grid.

Fixed issues

Details

Before: What was the problem?

GraphView.render calls applyViewCoordSysTransToElement on _mainGroup only when the series has its own view coordinate system (getOwnRoamViewCoordSys). On cartesian2d it left the group as it was. After a graph on the default view coordinate system, the group kept that view's scale and offset, so the nodes and edges of the cartesian graph did not line up with the axes. In the new unit test it kept x: 50, y: 30, scale: 0.3.

After: How does it behave after the fixing?

When there is no own view coordinate system, render stops any running transform animation on _mainGroup and resets it to x: 0, y: 0, scaleX: 1, scaleY: 1. The nodes are already laid out in global coordinates on cartesian2d, so this matches a chart created directly with the cartesian option.

New unit test test/ut/spec/series/graph.test.ts: render a graph on the view coordinate system, then setOption(cartesianOption, true). The main group's transform must equal that of a chart created directly with cartesianOption, which is the identity. It fails on master with [50, 30, 0.3, 0.3].

Ran locally:

  • npx jest --config test/ut/jest.config.cjs test/ut/spec (all unit tests pass);
  • eslint on the changed files;
  • tsc -p tsconfig.json --noEmit.

Document Info

  • This PR doesn't relate to document changes

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

N.A.

Merging options

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

Other information

This change was written with the help of Claude Code (AI). I reviewed it and ran the tests above.

🤖 Generated with Claude Code

…close apache#21857

GraphView applies its own view coordinate system's transform to its main
group, but left the group untouched when the series has no view of its
own. After a graph on the default view coordinate system, a graph set on
cartesian2d kept that scale and offset, so its nodes and edges did not
line up with the axes.

The main group's transform is now reset when the series is not on its
own view coordinate system.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@echarts-bot

echarts-bot Bot commented Nov 23, 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