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

feat(interaction): brushFilter emit filter event #4933

Merged
merged 1 commit into from
May 4, 2023

Conversation

pearmini
Copy link
Member

@pearmini pearmini commented May 4, 2023

Emit brush:filter

brushFilter 交互抛出当前选中的数据。

开始使用

const chart = new Chart({
  theme: 'classic',
  container,
});

chart.options({
  type: 'point',
  data: {
    type: 'fetch',
    value: 'data/penguins.csv',
  },
  encode: {
    color: 'species',
    x: 'culmen_length_mm',
    y: 'culmen_depth_mm',
  },
  state: { inactive: { stroke: 'gray' } },
  interaction: { brushFilter: true },
});

chart.on('brush:filter', (event) => { // 监听事件
  const { selection } = event.data;
  const [domainX, domainY] = selection;
  const [minX, maxX] = domainX;
  const [minY, maxY] = domainY;
  console.log(minX, maxX, minY, maxY);
});

注意

当每次刷选重置的时候都会触发这个事件。

@pearmini pearmini requested a review from hustcc May 4, 2023 07:00
@pearmini pearmini added the V5 label May 4, 2023
@pearmini pearmini force-pushed the feat/emit-brush-events branch from f46b9c5 to cee6d68 Compare May 4, 2023 07:01
@pearmini pearmini self-assigned this May 4, 2023
@hustcc
Copy link
Member

hustcc commented May 4, 2023

其他的交互都有这样的事件抛出吗?

@pearmini
Copy link
Member Author

pearmini commented May 4, 2023

其他的交互都有这样的事件抛出吗?

其他交互的事件抛出会在这两周完成。

@pearmini pearmini merged commit 0e8f2d9 into v5 May 4, 2023
@pearmini pearmini deleted the feat/emit-brush-events branch May 4, 2023 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants