You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2019/12/06 08:51:40 UTC

[GitHub] [incubator-echarts] fxxjdedd opened a new issue #11806: 希望能优化legend.selected,对于隐藏的系列不要参与到首次渲染之中

fxxjdedd opened a new issue #11806: 希望能优化legend.selected,对于隐藏的系列不要参与到首次渲染之中
URL: https://github.com/apache/incubator-echarts/issues/11806
 
 
   ### What problem does this feature solve?
   对于系列特别多的情况,通常会使用`legend.selected`将那些不重要(但是必须得有)的系列给隐藏掉,借此来优化显示效果和渲染性能。但是实践发现,虽然隐藏掉系列会带来一些性能提升,但是在大数据量的情况下性能依然糟糕。
   
   实验1:1000个系列
   1. 只保留一个选中,其他都隐藏:耗时434ms
   2. 全部选中:耗时788ms
   
   实验2:1个系列
   1. 全部选中:29ms
   
   代码如下:
   ```js
   // 生成1000个系列
   const ids = Array.from(Array(1000), (_, i) => {
       return '指标'   i
   })
   option = {
       title: {
           text: '折线图堆叠'
       },
       tooltip: {
           trigger: 'axis'
       },
       legend: {
           data: ids,
           // 只保留第一个选中,其他都不选中
           selected: ids.slice(1).reduce((base, next) => {
               base[next] = false
               return base
           }, {}),
           type: 'scroll',
       },
       grid: {
           left: '3%',
           right: '4%',
           bottom: '3%',
           containLabel: true
       },
       toolbox: {
           feature: {
               saveAsImage: {}
           }
       },
       xAxis: {
           type: 'category',
           boundaryGap: false,
           data: ['周一','周二','周三','周四','周五','周六','周日']
       },
       yAxis: {
           type: 'value'
       },
       series: [
           
           ...ids.map(id => {
               return {
                   name: id,
                   type: 'line',
                   data: [220, 182, 191, 234, 290, 330, 310]
               }
           })
   
       ]
   };
   
   ```
   
   ### What does the proposed API look like?
   不管有多少个系列,图表的渲染时间只跟“显示”的系列的数量相关。
   
   <!-- 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: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org