使用
line
系列和水平选择画笔 (lineX
) 设置折线图似乎没有提供读取所选范围值的方法。将系列类型更改为 bar
或 scatter
似乎按预期工作。我想知道这是否是一个错误或者是否需要更多配置。
var container = document.getElementById('main');
var chart = echarts.init(container);
chart.setOption({
xAxis: {
data: [3, 4, 5]
},
yAxis: {
},
brush: {
toolbox: ['lineX'],
type: 'lineX',
},
series: [{
type: 'line', // changing this to scatter or other types makes the brush selection work
data: [120, 200, 150]
}]
});
chart.on('brushSelected', function(params){
// this shows an empty array - while it should be the range selected
console.log(params.batch[0].selected[0].dataIndex)
});
#main {
width: 600px;
height: 400px;
border: 1px solid red;
}
<html>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/5.0.2/echarts.min.js"></script>
<div id="main"></div>
</body>
</html>
目前支持的画笔类型包括:散点图、条形图、烛台图。 (注意parallel本身就包含画笔功能,不是画笔组件提供的。)