重置刷选

源码
import { Chart } from '@antv/g2';

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

chart.options({
  type: 'point',
  data: {
    type: 'fetch',
    value:
      'https://gw.alipayobjects.com/os/basement_prod/6b4aa721-b039-49b9-99d8-540b3f87d339.json',
  },
  encode: { x: 'height', y: 'weight', color: 'gender' },
  scale: {
    x: {
      domain: [140, 200],
    },
    y: {
      domain: [0, 150],
    },
  },
  interaction: { brushFilter: true },
});

chart.render();

// 刷选之后重置选区
const createButton = () => {
  const container = document.querySelector('#container');
  const button = document.createElement('button');
  button.innerText = 'reset';
  button.onclick = () => {
    chart.emit('brush:filter', {
      data: {
        selection: [
          [140, 200],
          [0, 150],
        ],
      },
    });
  };
  container.insertBefore(button, container.firstChild);
};

createButton();
全站搜索
文档与示例输入关键词开始搜索

输入关键词,查找文档、API 与示例

选择打开Esc关闭