[Bug] Graph on cartesian2d is misplaced after setOption from a graph on the default (view) coordinate system

未关闭 适合新手
#21,857 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
66/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃

调研方向

原因在 GraphView.render 中已指明:只有当系列拥有自己的 View 坐标系时,视图坐标系的变换才会应用到 mainGroup,因此被复用的视图会保留旧的变换。请先阅读该分支,以及每次渲染之间该分组如何被重置。完成标准是:使用 notMerge: true 调用 setOption 之后,cartesian2d 图表与坐标轴的对齐方式,和直接用 cartesian 配置创建的图表一致。

由索引模型根据 Issue 内容生成。

描述

en pending
Version

6.1.0 (also current master 34f4d927e)

Link to Minimal Reproduction

https://echarts.apache.org/examples/en/editor.html?code=lZIxb8IwEIV3fsVtASkqSboFUQl1QB2qDnSrGExyEKuJHewLxEX8956TBmilVuoQS867e_ru-TKtLMFB4nFpRF3AHE4jAItGok3hzV8AyNWYQrDzFUEIpXC6If6htEK-W1dtdLmSH1yURGHXkgsSvh-UqHxvzXVtClEIjk84h3CR9r0UR1Gvxiyve5dSqvcOA6xuTDYYkTA79AD7gEu5ko_zbNTPkglDaKVQtwO1i1ay0WkYJROEO20cm210o3Jh3FLUKWxFaTEc6APBerDxRxasGZqd3A-ngygbZAyv_S-2TGuTS8UkK2cJqw7riz3J_8415qju-UuiX5Nidcgp7vMelPiqJLf56ZqkVpzYZR1mo-kUFltCwx6WiY6SsgJIAxV4TRq6Ee_giSwonaOFXKuAPBRCUwN3cRN3iJbjGVmkV1khhzEeT2D-AJV7LNjrjoWXjmH8_RG7ZdH0jAydApkG4TwJu42ZzD4B&enc=deflate

const viewGraph = {
  series: [{
    type: 'graph', layout: 'none', symbolSize: 20,
    data: [{ name: 'p', x: 0, y: 0 }, { name: 'q', x: 1000, y: 10 }],
    links: [{ source: 'p', target: 'q' }]
  }]
};
const cartesianGraph = {
  xAxis: { type: 'category', boundaryGap: false, data: ['a', 'b', 'c'] },
  yAxis: { type: 'value' },
  series: [{
    type: 'graph', layout: 'none', coordinateSystem: 'cartesian2d', symbolSize: 20,
    data: [10, 30, 20],
    links: [{ source: 0, target: 1 }, { source: 1, target: 2 }]
  }]
};
option = viewGraph;
// After 1 s, switch to the cartesian graph. Its nodes don't line up with the axes:
setTimeout(() => myChart.setOption(cartesianGraph, { notMerge: true }), 1000);
Steps to Reproduce
  1. Render a graph series on its default view coordinate system (layout: 'none' with x/y).
  2. setOption an option whose graph series is on cartesian2d (with notMerge: true here; with roam: true or false alike).
Current Behavior

The nodes and edges of the cartesian graph are scaled and translated by the transform of the previous view graph, so they do not
line up with the axes.

Expected Behavior

The graph is placed on the grid exactly as in a chart created directly with the cartesian option.

Environment
  • OS: any (also reproduced with the SVG renderer in Node.js SSR)
  • Browser: any
  • Framework: none
Any additional comments?

Cause: GraphView.render applies the view coordinate system's transform to its main group only when the series has its own View
coordinate system (if (ownCoordSys) applyViewCoordSysTransToElement(mainGroup, ...)). When the reused view later renders a graph on
an external coordinate system, the old transform is never reset. I can send a PR.

主要语言
TypeScript
星标
67.8k
派生
19.9k
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

apache/echarts 的其他 Issue

查看 apache/echarts 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。