Skip to content

🤔 [QUESTION] 双y轴线时如何使用相同刻度? #3565

Answered by hustcc
HOUSHENGREN asked this question in Q&A
Discussion options

You must be logged in to vote

如果是 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,就是保持同步。

Replies: 6 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@wangwufan
Comment options

Answer selected by hustcc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
Question Further information is requested
3 participants
Converted from issue

This discussion was converted from issue #3518 on May 23, 2023 01:21.