You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@echarts.apache.org by GitBox <gi...@apache.org> on 2019/06/26 03:26:16 UTC

[GitHub] [incubator-echarts] lissali opened a new issue #10739: 折线图区域选择返回的dataIndex一直都是空

lissali opened a new issue #10739: 折线图区域选择返回的dataIndex一直都是空
URL: https://github.com/apache/incubator-echarts/issues/10739
 
 
   ### Version
   4.1.0-release
   
   ### Steps to reproduce
   1. 画折线图,options.series.type设置为‘line'
   2. 给折线图添加brush设置,并添加相应事件的函数
   3. 在图上操作区域选择
   
   https://www.echartsjs.com/examples/editor.html?c=dynamic-data2
   
   修改代码如下:
   ```js
   function randomData() {
       now = new Date( now   oneDay);
       value = value   Math.random() * 21 - 10;
       return {
           name: now.toString(),
           value: [
               [now.getFullYear(), now.getMonth()   1, now.getDate()].join('/'),
               Math.round(value)
           ]
       }
   }
   
   var data = [];
   var now =  new Date(2019, 5, 1);
   var oneDay = 24 * 3600 * 1000;
   var value = Math.random() * 1000;
   for (var i = 0; i < 10; i  ) {
       data.push(randomData());
   }
   debugger;
   option = {
       title: {
           text: '动态数据   时间坐标轴'
       },
       tooltip: {
           trigger: 'axis',
           formatter: function (params) {
               params = params[0];
               var date = new Date(params.name);
               return date.getDate()   '/'   (date.getMonth()   1)   '/'   date.getFullYear()   ' : '   params.value[1];
           },
           axisPointer: {
               animation: false
           }
       },
       xAxis: {
   
             type: 'category',
                   scale: true,
                   boundaryGap : false,
                   axisLine: {onZero: false},
                   splitLine: {show: false},
                   splitNumber: 20,
       },
       yAxis: {
           type: 'value',
           boundaryGap: [0, '100%'],
           splitLine: {
               show: false
           }
       },
       series: [{
           name: '模拟数据',
           type: 'line',
           showSymbol: false,
           hoverAnimation: false,
           data: data
       }],
       brush:{
           toolbox: ['lineX'],
         throttleType: 'debounce',
         throttleDelay: 10,
         outOfBrush: {
           colorAlpha: 0.1,
         },
       }
   };
   
   function renderBrushed(params) {
       var mainSeries = params.batch[0].selected[0];
   
       var selectedItems = [];
       debugger;
       for (var i = 0; i < mainSeries.dataIndex.length; i  ) {
           var rawIndex = mainSeries.dataIndex[i];
           var dataItem = convertedData[0][rawIndex];
           debugger;
           console.log(dataItem);
       }
   }
   
   myChart.on('brushselected', renderBrushed);
   ```
   
   ### What is expected?
   区域选择响应函数返回dataIndex,以便后期处理
   
   ### What is actually happening?
   区域选择响应函数返回dataIndex为空
   
   <!-- This issue is generated by echarts-issue-helper. DO NOT REMOVE -->
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@echarts.apache.org
For additional commands, e-mail: dev-help@echarts.apache.org