🤔 [QUESTION] 双y轴线时如何使用相同刻度? #3565
-
🐛 Question description [Please make everyone to understand it]双轴线,既然两条数据全部相同,两个y轴刻度线划分为何不一致? 💻 Link to minimal reproductionhttps://codesandbox.io/s/competent-hooks-bpb2xd Please provide a link by forking these links g2plot or GitHub repo. What is a minimal reproduction, and why is it required? 🏞 Expected result左右y轴,刻度线划分一致。 🚑 Any additional [like screenshots]
|
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 1 reply
-
踩坑了😢,可以用mix组件,不用用双轴线 |
Beta Was this translation helpful? Give feedback.
-
关注中。我曾设置过两个y轴最大值和最小值一致,貌似一致了,但在点击图例时,隐藏或显示一部分数据后,不自动缩放了😢 |
Beta Was this translation helpful? Give feedback.
-
这个是啥意思,有没有demo看下 |
Beta Was this translation helpful? Give feedback.
-
项目里的图表,搬运起来太麻烦。就说一下吧,比如堆叠柱状图,点选类别图例时,会显示或隐藏一部分颜色的柱体,如果我设置了y轴最大值和最小值,图表就不会自动缩放了,其实不能缩放不是重点,也不是bug,我就想知道我什么时候重新计算y轴最大值和最小值合适。因为图表随时会自动回到初始状态(具体事件不清楚,知道了事件我就能在里面处理了) |
Beta Was this translation helpful? Give feedback.
-
🤦♀️ |
Beta Was this translation helpful? Give feedback.
-
如果是 G2Plot,这么处理,让两边 y scale 都保持同步即可。 const dualAxes = new DualAxes("container", {
data: [data, data],
xField: "time",
yField: ["value", "count"],
meta: {
value: {
sync: 'key1', // 👈🏻 这里设置 key 相同
},
count: {
sync: 'key1', // 👈🏻 这里设置 key 相同
}
},
geometryOptions: [
{
geometry: "column"
},
{
geometry: "line",
lineStyle: {
lineWidth: 2
}
}
]
}); 如果是 G2,则: chart.scale('value', { sync: 'key1' });
chart.scale('count', { sync: 'key1' }); sync 指定相同的 key,就是保持同步。 |
Beta Was this translation helpful? Give feedback.
如果是 G2Plot,这么处理,让两边 y scale 都保持同步即可。
如果是 G2,则:
sync 指定相同的 key,就是保持同步。