From 624d39df25075dba22a183409cbf69dfa2180ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Wed, 28 Sep 2022 22:11:11 +0200 Subject: [PATCH] Fix OnClickEvent for overtime* charts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- scripts/pi-hole/js/db_graph.js | 4 ++-- scripts/pi-hole/js/index.js | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/scripts/pi-hole/js/db_graph.js b/scripts/pi-hole/js/db_graph.js index a4a63257..7246f040 100644 --- a/scripts/pi-hole/js/db_graph.js +++ b/scripts/pi-hole/js/db_graph.js @@ -391,10 +391,10 @@ $("#querytime").on("apply.daterangepicker", function (ev, picker) { }); $("#queryOverTimeChart").click(function (evt) { - var activePoints = timeLineChart.getElementAtEvent(evt); + var activePoints = timeLineChart.getElementsAtEventForMode(evt, 'nearest', { intersect: true }, false); if (activePoints.length > 0) { //get the internal index in the chart - var clickedElementindex = activePoints[0]._index; + var clickedElementindex = activePoints[0].index; //get specific label by index var label = timeLineChart.data.labels[clickedElementindex]; diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js index bacc7ca7..f866a5da 100644 --- a/scripts/pi-hole/js/index.js +++ b/scripts/pi-hole/js/index.js @@ -1084,11 +1084,10 @@ $(function () { } $("#queryOverTimeChart").click(function (evt) { - var activePoints = timeLineChart.getElementAtEvent(evt); + var activePoints = timeLineChart.getElementsAtEventForMode(evt, 'nearest', { intersect: true }, false); if (activePoints.length > 0) { - //get the internal index of slice in pie chart - var clickedElementindex = activePoints[0]._index; - + //get the internal index + var clickedElementindex = activePoints[0].index; //get specific label by index var label = timeLineChart.data.labels[clickedElementindex]; @@ -1102,10 +1101,10 @@ $(function () { }); $("#clientsChart").click(function (evt) { - var activePoints = clientsChart.getElementAtEvent(evt); + var activePoints = clientsChart.getElementsAtEventForMode(evt, 'nearest', { intersect: true }, false); if (activePoints.length > 0) { - //get the internal index of slice in pie chart - var clickedElementindex = activePoints[0]._index; + //get the internal index + var clickedElementindex = activePoints[0].index; //get specific label by index var label = clientsChart.data.labels[clickedElementindex];