简体   繁体   English

如何以编程方式清除echarts中的笔刷选择

[英]How to programmatically clear a brush selection in echarts

I'm using echarts library . 我正在使用echarts库 I'm creating histograms with bar charts, and using brush selection to highlight bars. 我正在使用条形图创建直方图,并使用笔刷选择突出显示条形图。 Also I want to programmatically select / unselect bars. 我也想以编程方式选择/取消选择栏。 Following echarts documentation and examples, I understand that this kind of actions are done by using chart.dispatchAction but no brush action is documented or showed. 根据echarts文档和示例,我了解到这种操作是通过使用chart.dispatchAction完成的,但是没有记录或显示任何笔刷操作。 The only related things documented is an option ( brush.removeOnClick ) which, only if brush.brushMode === 'single' allows to clear the brush selection on click. 记录的唯一相关内容是一个选项( brush.removeOnClick ),只有在brush.brushMode === 'single'允许单击时清除笔刷选择时,该选项。 How is it possible to programmatically create / clear brush selections? 如何以编程方式创建/清除画笔选择? thanks 谢谢

There is an undocumented brush action; 有一个未记录的brush操作;

Usage example: 用法示例:

Clear brush with the command clear : 使用命令clear清除刷子:

chart.dispatchAction({
  type: 'brush',
  command: 'clear',
  areas: [],
});

Create a brush selection (at least in a bar chart with axisType === 'category' ) with: 使用以下选项创建画笔选择(至少在带有axisType === 'category'的条形图中):

chart.dispatchAction({
  type: 'brush',
  areas: [
    {
      brushType: 'lineX',
      xAxisIndex: 0,
      coordRange: [from, to],
    },
  ],
});

Where coordRange is an array of 2 axis ticks indexes. 其中, coordRange是2个轴刻度索引的数组。

There are a lot of undocumented things in echarts. echarts中有很多未记录的东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM