jqplot Pie Chart data label format precision without trailing zeros

吃可爱长大的小学妹 提交于 2019-12-02 04:28:14

To close this topic I am posting my answer here. I managed to solved this issue, thanks to jQuery. Once again it appears to be a real life saver when it comes to doing the client side. :)

I have approached it similarly to my thought mentioned in my question, i.e. using parseFloat(label.toFixed(2)). Though I did it in a slightly inverted way. I decided to set the chart to use label for dataLabels parameter. I use the $.jqplot.postDrawHooks.push(...) to bind my function for execution once the chart is finished painting. My function modifies the legend labels to display names instead of percentage values which I calculate before I set them to data array.

This approach works perfectly as I would want it. To those interested, please find my jsfiddle showing the solution here.

If someone has a better solution I am very keen to move the accept from my answer at any time.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!