From 01aca3242f07f050c43f217d9b7e7fb9cbb2966d Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sun, 2 Aug 2020 20:05:49 +0200 Subject: [PATCH] Add link to Query Log from Clients over Time bar graph bars. Signed-off-by: DL6ER --- scripts/pi-hole/js/index.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index 4492f1da..459e9521 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -996,6 +996,24 @@ $(function () { return false; }); + $("#clientsChart").click(function (evt) { + var activePoints = clientsChart.getElementAtEvent(evt); + if (activePoints.length > 0) { + //get the internal index of slice in pie chart + var clickedElementindex = activePoints[0]._index; + + //get specific label by index + var label = clientsChart.data.labels[clickedElementindex]; + + //get value by index + var from = label / 1000 - 300; + var until = label / 1000 + 300; + window.location.href = "queries.php?from=" + from + "&until=" + until; + } + + return false; + }); + if (document.getElementById("queryTypePieChart")) { ctx = document.getElementById("queryTypePieChart").getContext("2d"); queryTypePieChart = new Chart(ctx, {