You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@echarts.apache.org by GitBox <gi...@apache.org> on 2019/06/14 04:45:20 UTC

[GitHub] [incubator-echarts] linxinemily edited a comment on issue #4125: 如何在legend中显示value值?

linxinemily edited a comment on issue #4125: 如何在legend中显示value值?
URL: https://github.com/apache/incubator-echarts/issues/4125#issuecomment-501965703
 
 
   另外一種方法可以透過訪問 this (需使用 arrow function)獲取vue component實例
   就能拿到 options.series[0].data
   
   ```
   formatter: name => {
               const data = this.options.series[0].data
               const totalValue = data.reduce((acc, item) => { 
                  acc += item.value;
                  return acc;
                }, 0)
               let targetValue
               data.forEach(item => {
                 if (item.name === name) {
                   targetValue = item.value
                 }
               })
              	const p = (targetValue / totalValue * 100).toFixed(2);
               return name + ' ' +  p + '%'
             }
   ```
   
   

----------------------------------------------------------------
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: dev-unsubscribe@echarts.apache.org
For additional commands, e-mail: dev-help@echarts.apache.org