Apache ECharts - 带折线图范围选择的刷子

问题描述 投票:0回答:2

使用

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>

javascript echarts apache-echarts
2个回答
0
投票

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

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


0
投票

对于 2024 年来到这里的任何人,您可能会在图表选项上搜索

dataZoom
属性:

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

© www.soinside.com 2019 - 2024. All rights reserved.