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 2018/10/12 07:49:26 UTC

[GitHub] Gamehu opened a new issue #9215: 当鼠标松开时能捕捉到brush end事件

Gamehu opened a new issue #9215: 当鼠标松开时能捕捉到brush end事件
URL: https://github.com/apache/incubator-echarts/issues/9215
 
 
   One-line summary [问题简述]
   目前echarts的brushSelected能捕捉到框选的结果,但是没有brush end的事件,无法预测框选结束。
   
   Version & Environment [版本及环境]
   ECharts version [ECharts 版本]:3.8.5
   Browser version [浏览器类型和版本]:69.0.3497.81
   OS Version [操作系统类型和版本]:windows10
   Expected behaviour [期望结果]
   框选图表,当鼠标松开时能捕捉到brush end事件
   
   ECharts option [ECharts配置项]
    
   
   var xAxisData = [];
   var data1 = [];
   var data2 = [];
   var data3 = [];
   var data4 = [];
   
   for (var i = 0; i < 10; i++) {
       xAxisData.push('Class' + i);
       data1.push((Math.random() * 2).toFixed(2));
       data2.push(-Math.random().toFixed(2));
       data3.push((Math.random() * 5).toFixed(2));
       data4.push((Math.random() + 0.3).toFixed(2));
   }
   
   var itemStyle = {
       normal: {
       },
       emphasis: {
           barBorderWidth: 1,
           shadowBlur: 10,
           shadowOffsetX: 0,
           shadowOffsetY: 0,
           shadowColor: 'rgba(0,0,0,0.5)'
       }
   };
   option = {
   
       backgroundColor: '#eee',
       legend: {
           data: ['bar', 'bar2', 'bar3', 'bar4'],
           align: 'left',
           left: 10
       },
       brush: {
           toolbox: ['lineX', 'clear'],
           xAxisIndex: 0
       },
       tooltip: {},
       xAxis: {
           data: xAxisData,
           name: 'X Axis',
           silent: false,
           axisLine: {onZero: true},
           splitLine: {show: false},
           splitArea: {show: false}
       },
       yAxis: {
    
       },
       grid: {
           left: 100
       },
       series: [
           {
               name: 'bar',
               type: 'line',
               stack: 'one',
               itemStyle: itemStyle,
               data: data1
           }
       ]
   };
   
   myChart.on('brushSelected', renderBrushed);
   
   function renderBrushed(params) {
       var brushed = [];
       var brushComponent = params.batch[0];
   
       for (var sIdx = 0; sIdx < brushComponent.selected.length; sIdx++) {
           var rawIndices = brushComponent.selected[sIdx].dataIndex;
           brushed.push('[Series ' + sIdx + '] ' + rawIndices.join(', '));
       }
   
       myChart.setOption({
           title: {
               backgroundColor: '#333',
               text: 'SELECTED DATA INDICES: \n' + brushed.join('\n'),
               bottom: 0,
               right: 0,
               width: 100,
               textStyle: {
                   fontSize: 12,
                   color: '#fff'
               }
           }
       });
   }
   }

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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