40 lines
1.2 KiB
JavaScript
40 lines
1.2 KiB
JavaScript
(function () {
|
|
"use strict";
|
|
|
|
window.PX360 = window.PX360 || {};
|
|
|
|
// Series value formatter: shows the raw count on each slice.
|
|
var countFormatter = function (val, opts) {
|
|
return opts.w.globals.series[opts.seriesIndex];
|
|
};
|
|
|
|
// Grand total formatter for the donut center.
|
|
var totalFormatter = function (w) {
|
|
return w.globals.seriesTotals.reduce(function (a, b) { return a + b; }, 0);
|
|
};
|
|
|
|
// Spread into donut chart configs: slice counts + center total.
|
|
PX360.donutValueLabels = function () {
|
|
return {
|
|
dataLabels: { enabled: true, formatter: countFormatter },
|
|
plotOptions: {
|
|
pie: {
|
|
donut: {
|
|
labels: {
|
|
show: true,
|
|
total: { show: true, label: "Total", formatter: totalFormatter }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
// Spread into pie chart configs: slice counts only (no center).
|
|
PX360.pieValueLabels = function () {
|
|
return {
|
|
dataLabels: { enabled: true, formatter: countFormatter }
|
|
};
|
|
};
|
|
})();
|