简体   繁体   English

Echarts.js:如何以编程方式激活笔刷选择

[英]Echarts.js: How to programmatically activate brush selection

I have a chart of financial data, eg prices of a stock, using the great echarts.js library. 我使用echarts.js库提供了财务数据图表,例如股票价格。

I wish the user will be able to select a portion of this chart with the mouse, by clicking and dragging. 我希望用户能够通过单击并拖动鼠标来选择该图表的一部分。 The selected range isn't needed to zoom the chart, but only tell the user some information, eg max price, minimum price in the selection. 缩放图表不需要选择范围,而只需告诉用户一些信息,例如选择中的最高价格,最低价格。

I think I can accomplish this using brush and brushType:'lineX' . 我想我可以使用brush和brushType:'lineX'完成此操作。

My concern is now regarding the toolbox. 我现在关心的是工具箱。 I don't want it. 我不要 I can hide it, by setting show:false , but without toolbox buttons I cannot select the 'lineX' brush. 我可以通过设置show:false来隐藏它,但是如果没有工具箱按钮,我将无法选择'lineX'画笔。

Is it possible to activate programmatically the 'lineX' brush? 是否可以通过编程方式激活“ lineX”画笔? I wish that the chart will always have this brush active, and that the user can reset the brush selected range, just by clicking. 我希望图表将始终启用此笔刷,并且用户只需单击即可重置笔刷选择的范围。 Without deactivating the 'lineX' selection. 无需停用“ lineX”选择。 Is this possible? 这可能吗?

Try below: 请尝试以下方法:

myChart.dispatchAction({
    type: 'takeGlobalCursor',
    key: 'brush',
    brushOption: {
        brushType: 'lineX',
        brushMode: 'single'
    }
}); 

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

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