antvis / G2Plot

:dango: An interactive and responsive charting library based on G2.
https://g2plot.antv.antgroup.com
MIT License
2.54k stars 604 forks source link

🤔 [QUESTION] 双轴图-柱线混合图表 数据点绘制时趋势错误 #3106

Open suran101 opened 2 years ago

suran101 commented 2 years ago

折线图与 柱状图 x轴的type数据不对应时,折线图绘制趋势混乱,是否有属性可以解决这个问题呢?还是需要用户传递数据的时候,x轴的type数据必须要一一对应呢?

图表链接:https://antv-g2plot.gitee.io/zh/examples/dual-axes/column-line#column-multi-line

代码部分只修改了transformData const transformData = [ { time: '2019-06', count: 380, name: 'a' }, { time: '2019-04', count: 600, name: 'a' }, { time: '2019-05', count: 400, name: 'a' }, { time: '2019-07', count: 220, name: 'a' }, { time: '2019-03', count: 800, name: 'a' }, // { time: '2019-03', count: 750, name: 'b' }, // { time: '2019-04', count: 650, name: 'b' }, // { time: '2019-05', count: 450, name: 'b' }, // { time: '2019-06', count: 400, name: 'b' }, // { time: '2019-07', count: 320, name: 'b' }, // { time: '2019-03', count: 900, name: 'c' }, // { time: '2019-04', count: 600, name: 'c' }, // { time: '2019-05', count: 450, name: 'c' }, // { time: '2019-06', count: 300, name: 'c' }, // { time: '2019-07', count: 200, name: 'c' }, ];

🚑 Any additional [like screenshots]

220 是最高的 800 反而是最低的

截屏2022-02-04 下午7 58 34 截屏2022-02-04 下午7 59 20
connono commented 2 years ago

目前G2版本情况下,由于两个view的scale同步 (syncScale)晚于两个view的data的处理(processData),因此当数据不对应时会导致错位。因此需要在传递数据时,将type数据一一对应

visiky commented 2 years ago
image

G2 设计上的问题, scale 同步之前,geometry 已经初始化结束了(processData 阶段无法拿到 syncScale 之后的 scale,导致绘制出错)