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>