3

line使用系列和水平选择画笔 ( )设置折线图lineX似乎无法提供读取所选范围值的方法。将系列类型更改为barscatter似乎按预期工作。我想知道这是一个错误还是需要更多配置。

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>

4

1 回答 1

0

目前,支持的画笔类型包括:散点图、条形图、烛形图。(注意parallel自带画笔功能,不是画笔组件提供的。)

https://echarts.apache.org/en/option.html#brush

于 2022-01-04T09:39:19.027 回答