Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自定义图例 custom: true,自定义图例点击事件隐藏 #3583

Closed
bin-sun opened this issue Aug 20, 2021 · 1 comment
Closed

自定义图例 custom: true,自定义图例点击事件隐藏 #3583

bin-sun opened this issue Aug 20, 2021 · 1 comment

Comments

@bin-sun
Copy link
Contributor

bin-sun commented Aug 20, 2021

chart.legend({
  custom: true,
  items: [
    {
      name: '城市 1',
      id: 'city-1',
      marker: { symbol: 'triangle', style: { r: 4, fill: 'red' } },
      
    },
    {
      name: '城市 2',
      id: 'city-2',
    },
  ],
});

chart.on('legend-item:click', (ev) => {
  const { type, view, gEvent, data, x, y, clientX, clientY, target} = ev;
  console.log('data', data); // undefind
});

自定义图例事件data获取不到,如何通过自定义事件隐藏相对于图形呢?

@hustcc
Copy link
Member

hustcc commented Sep 30, 2021

在 target 中可以拿到对应触发点击事件的 shape,在这个 shape 中有对应图例项的数据,然后就可以去做过滤了。

@hustcc hustcc closed this as completed Sep 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants