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 2020/11/03 13:55:19 UTC

[GitHub] [incubator-echarts] xxxs commented on issue #4125: 如何在legend中显示value值?

xxxs commented on issue #4125:
URL: https://github.com/apache/incubator-echarts/issues/4125#issuecomment-720879408


   var datas = [
                   {value: 335, name: '直接访问'},
                   {value: 310, name: '邮件营销'},
                   {value: 234, name: '联盟广告'},
                   {value: 135, name: '视频广告'},
                   {value: 1548, name: '搜索引擎'}
               ]
   option = {
       tooltip: {
           trigger: 'item',
           formatter: '{a} <br/>{b}: {c} ({d}%)'
       },
       legend: {
           orient: 'vertical',
           left: 10,
           data:datas,
          formatter:function(name){
               let singleData = datas.filter(function(item){
                   return item.name == name
               })
               return  name + '  ' + singleData[0].value;
           }
       },
       series: [
           {
               name: '访问来源',
               type: 'pie',
               radius: ['50%', '70%'],
               avoidLabelOverlap: false,
               label: {
                   show: false,
                   position: 'center'
               },
               emphasis: {
                   label: {
                       show: true,
                       fontSize: '30',
                       fontWeight: 'bold'
                   }
               },
               labelLine: {
                   show: false
               },
               data: [
                   {value: 335, name: '直接访问'},
                   {value: 310, name: '邮件营销'},
                   {value: 234, name: '联盟广告'},
                   {value: 135, name: '视频广告'},
                   {value: 1548, name: '搜索引擎'}
               ]
           }
       ]
   };
   


----------------------------------------------------------------
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



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org