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: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
