Home > Web Front-end > JS Tutorial > body text

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

不言
Release: 2018-10-19 17:35:55
forward
5291 people have browsed it

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 = '
Copy after login
'+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!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template