From 6af8c76c3f2157eb128f58a3ba60c0ff2420dc5e Mon Sep 17 00:00:00 2001 From: Mark Drobnak Date: Thu, 16 Aug 2018 17:38:02 -0400 Subject: [PATCH] Use random colors in client graph if presets run out Signed-off-by: Mark Drobnak --- scripts/pi-hole/js/index.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index 3b9a4529..196dced6 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -461,7 +461,17 @@ function updateClientsOverTime() { for (i = clientsChart.data.datasets.length; plotdata.length && i < plotdata[0].length; i++) { - clientsChart.data.datasets.push({data: [], backgroundColor: colors[i], pointRadius: 0, pointHitRadius: 5, pointHoverRadius: 5, label: labels[i], cubicInterpolationMode: "monotone" }); + clientsChart.data.datasets.push({ + data: [], + backgroundColor: i < colors.length + ? colors[i] + : '#' + parseInt("" + Math.random() * 0xffffff, 10).toString(16).padStart(6, "0"), + pointRadius: 0, + pointHitRadius: 5, + pointHoverRadius: 5, + label: labels[i], + cubicInterpolationMode: "monotone" + }); } // Add data for each dataset that is available