morrisjs / morris.js

Pretty time-series line graphs
http://morrisjs.github.com/morris.js/
6.92k stars 1.23k forks source link

Display percentage in donut chart #667

Open dylan666 opened 8 years ago

dylan666 commented 8 years ago

I'm creating a donut chart with using this query: SELECT type as ItemName, count(type) as TotalItems FROM myTable group by type

So I can display the ItemName and the quantity of each specific item. But I can't have the percentage of each (I have the graphical representation but not the number).

Is it possibile to add a option to display also the numerical value of percentage?

Thanks

satyendrakumarsingh commented 7 years ago

Calculate percentage within your MySQL query and then use that value in chart after that in chart use formatter to add "%" sign -

formatter: function (y) { return y+"%"}

Reference to MySQL query - http://stackoverflow.com/questions/20532187/how-to-calculate-percent-of-total-within-group-by-statement