Merge pull request #11895 from uberbrady/switch_dashboard_piechart_to_percent
Modified dashboard tooltips to add percentage as well as count
This commit is contained in:
commit
2b7c8cf82b
1 changed files with 7 additions and 1 deletions
|
@ -431,7 +431,13 @@
|
||||||
tooltips: {
|
tooltips: {
|
||||||
callbacks: {
|
callbacks: {
|
||||||
label: function(tooltipItem, data) {
|
label: function(tooltipItem, data) {
|
||||||
return data.labels[tooltipItem.datasetIndex] || '';
|
counts = data.datasets[0].data;
|
||||||
|
total = 0;
|
||||||
|
for(var i in counts) {
|
||||||
|
total += counts[i];
|
||||||
|
}
|
||||||
|
prefix = data.labels[tooltipItem.index] || '';
|
||||||
|
return prefix+" "+Math.round(counts[tooltipItem.index]/total*100)+"%";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue