Paul-Kijtapart opened a new issue #8103: [Pie] How to Get percent values from echart instance URL: https://github.com/apache/incubator-echarts/issues/8103 First of all, Thank you for creating this library. it is awesome! ### Version & Environment [版本及环境] + ECharts version [ECharts 版本]: 4.0.4 + Browser version [浏览器类型和版本]: Chrome + OS Version [操作系统类型和版本]: Window 10 ### One-line summary [问题简述] How to get "percent' value from echart instance with a serie name. ###jsFiddle### http://jsfiddle.net/coolbean/2wkd4bab/8/ ### Description ### From the jsFiddle above, you can see that when you hover over each section of the Pie chart, you are able to view both its value and its percent. This is done via "formatter" fields of the echart's tooltip. I am wondering if there is way to access this same "percent" value directly from the echart instance. ``` var myChart = echarts.init(document.getElementById('main')); var option = { ... } myChart.setOption(option); // This is what I want - accessing params of a data directly from echart instance myChart.getData('aaa').getPercent() ``` ### ECharts option [ECharts配置项] <!-- [下方贴你的option,注意不要删掉下方 ```javascript 和 尾部的 ``` 字样。最好是我们能够直接运行的 option。如何得到能运行的 option 参见上方的 guidelines for contributing] --> ```javascript option = { title: { text: 'ECharts 入门示例' }, tooltip: { show: true, formatter: function(params) { let res = ""; res += "Value : " + params.value.toLocaleString() + '</br>'; res += "Percent : " + params.percent + '</br>'; return res; } }, series: [{ name: '销量', type: 'pie', data: [{ name: "aaa", value: 74900 }, { name: "bbb", value: 112350 }, { name: "ccc", value: 187250 } ] }] }; ```
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on 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]
