mirror of https://github.com/Lissy93/dashy.git
⚡ Only render non-zero values to chart
This commit is contained in:
parent
072ebbd68a
commit
1c252cc76d
|
@ -37,12 +37,26 @@ export default {
|
||||||
const remaining = totalAllowed - blockTotal;
|
const remaining = totalAllowed - blockTotal;
|
||||||
|
|
||||||
// Put data into a flat array for the chart
|
// Put data into a flat array for the chart
|
||||||
const chartColors = ['#ef476f', '#ffc43d', '#f8ffe5', '#1b9aaa', '#06d6a0'];
|
const chartColors = ['#ef476f', '#06d6a0'];
|
||||||
const chartValues = [blocked, safeBrowsing, safeSearch, parental, remaining];
|
const chartValues = [blocked, remaining];
|
||||||
const chartLabels = [
|
const chartLabels = ['Blocked', 'Allowed'];
|
||||||
'Blocked', 'Safe Browsing - Blocked', 'Safe Search - Blocked',
|
|
||||||
'Parental Controls - Blocked', 'Allowed',
|
// If additional blocked results are non-zero, append to chart data
|
||||||
];
|
if (safeBrowsing > 0) {
|
||||||
|
chartColors.push('#ffc43d');
|
||||||
|
chartValues.push(safeBrowsing);
|
||||||
|
chartLabels.push('Safe Search - Blocked');
|
||||||
|
}
|
||||||
|
if (safeSearch > 0) {
|
||||||
|
chartColors.push('#f8ffe5');
|
||||||
|
chartValues.push(safeSearch);
|
||||||
|
chartLabels.push('Safe Search - Blocked');
|
||||||
|
}
|
||||||
|
if (parental > 0) {
|
||||||
|
chartColors.push('#1b9aaa');
|
||||||
|
chartValues.push(parental);
|
||||||
|
chartLabels.push('Parental Controls - Blocked');
|
||||||
|
}
|
||||||
|
|
||||||
// Call generate chart function
|
// Call generate chart function
|
||||||
this.generateBlockPie(chartLabels, chartValues, chartColors);
|
this.generateBlockPie(chartLabels, chartValues, chartColors);
|
||||||
|
@ -60,7 +74,7 @@ export default {
|
||||||
strokeWidth: 20,
|
strokeWidth: 20,
|
||||||
colors,
|
colors,
|
||||||
tooltipOptions: {
|
tooltipOptions: {
|
||||||
formatTooltipY: d => `${Math.round(d)}%`,
|
formatTooltipY: d => `${Math.round(d)} queries`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue