echarts 单选legend 并排序

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了echarts 单选legend 并排序相关的知识,希望对你有一定的参考价值。

 

一、legend 单选设置:

   legend : {
        data : [‘周末双休‘, ‘周末轮休‘, ‘周末补休‘],
        selected : {
            ‘周末轮休‘ : false,
            ‘周末补休‘ : false
        },
        selectedMode : "single"
    }
 
二、排序
    有 arry1, arry2, arry3
 
series : [{
            name : ‘周末双休‘,
            type : ‘bar‘,
            itemStyle : dataStyle,
            data : (function () {
                var data = [];
                arry1.sort(function(a,b){
                                  if(a>b)
                                    return -1;      //降序
                                  else
                                   return 1;
 
                                })
                arry1.forEach(function (item) {
                    data.push(parseInt(item))
                })
                return data;
            })()
        }, {
            name : ‘周末轮休‘,
            type : ‘bar‘,
            itemStyle : dataStyle,
            data : (function () {
                var data = [];
                arry2.sort(function(a,b){
                  if(a>b)
                    return -1;
                  else
                   return 1;
 
                })
                arry2.forEach(function (item) {
                    data.push(parseInt(item))
                })
                return data;
            })()
        }, {
            name : ‘周末不修‘,
            type : ‘bar‘,
            itemStyle : dataStyle,
            data : (function () {
                var data = [];
                arry3.sort(function(a,b){
                      if(a>b)
                        return -1;
                      else
                       return  1;
 
                    })
                arry3.forEach(function (item) {
                    data.push(parseInt(item))
                })
                return data;
            })()
        }
    ]

以上是关于echarts 单选legend 并排序的主要内容,如果未能解决你的问题,请参考以下文章

echarts怎么通过改变legend改变xAxis的显示

echarts legend只截取前几个值

echarts饼图的legend形状可以修改么

echarts 设置自定义legend

echarts legend data数据过长,如何换行

echarts饼图的legend形状可以修改么