Home  >  Article  >  Web Front-end  >  How echarts optimizes the style in data view dataView (code example)

How echarts optimizes the style in data view dataView (code example)

不言
不言forward
2018-10-19 17:35:555228browse

The content of this article is about how echarts optimizes the style (code example) in the data view dataView. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

During the process of using echart, there is a dataView view mode in the toolbox, and the data in it is not aligned, which affects the display effect. The situation is as follows:

How echarts optimizes the style in data view dataView (code example)

How echarts optimizes the style in data view dataView (code example)

##Change the solution to the problem to handle it in the optionTocontent callback function. The specific code is as follows:

toolbox:{
   show: true,
  feature: {
     dataView: {
         show: true,
         title: '数据视图',
         optionToContent: function (opt) {
         var axisData = opt.xAxis[0].data;
         var series = opt.series;
         var tdHeads = '<td>名称</td>';
         series.forEach(function (item) {
         tdHeads += '<td>'+item.name+'</td>';
         });
         var table = '
'+tdHeads+'';          var tdBodys = '';          for (var i = 0, l = axisData.length; i '+series[j].data[i].value+'';          }else{              tdBodys += '';             }         }         table += ''+ tdBodys +'';         tdBodys = '';        }        table += '
'+ series[j].data[i]+'
'+axisData[i]+'
';        return table;       }     },     mark: {show:true},     restore:{show:true},    magicType: {type: ['line', 'bar','pie']},    saveAsImage:{show:true}         }     } The modified effect is:

How echarts optimizes the style in data view dataView (code example)

The problem is perfectly solved, I hope it will be helpful to you!

The above is the detailed content of How echarts optimizes the style in data view dataView (code example). For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete