-
diff --git a/scripts/pi-hole/js/index.js b/scripts/pi-hole/js/index.js
index 9f8cb8c6..7636ed9d 100644
--- a/scripts/pi-hole/js/index.js
+++ b/scripts/pi-hole/js/index.js
@@ -178,6 +178,16 @@ function updateQueryTypesPie() {
queryTypePieChart.update();
// Don't use rotation animation for further updates
queryTypePieChart.options.animation.duration=0;
+ // Generate legend in separate div
+ $("#query-types-legend").html(queryTypePieChart.generateLegend());
+ $("#query-types-legend > ul > li").on("click",function(e){
+ $(this).toggleClass("strike");
+ var index = $(this).index();
+ var ci = e.view.queryTypePieChart;
+ var curr = ci.data.datasets[0]._meta[3].data[index];
+ curr.hidden = !curr.hidden;
+ ci.update();
+ });
}).done(function() {
// Reload graph after minute
setTimeout(updateQueryTypesPie, 60000);
@@ -392,6 +402,16 @@ function updateForwardDestinationsPie() {
forwardDestinationPieChart.update();
// Don't use rotation animation for further updates
forwardDestinationPieChart.options.animation.duration=0;
+ // Generate legend in separate div
+ $("#forward-destinations-legend").html(forwardDestinationPieChart.generateLegend());
+ $("#forward-destinations-legend > ul > li").on("click",function(e){
+ $(this).toggleClass("strike");
+ var index = $(this).index();
+ var ci = e.view.forwardDestinationPieChart;
+ var curr = ci.data.datasets[0]._meta[3].data[index];
+ curr.hidden = !curr.hidden;
+ ci.update();
+ });
}).done(function() {
// Reload graph after one minute
setTimeout(updateForwardDestinationsPie, 60000);
@@ -960,8 +980,7 @@ $(document).ready(function() {
},
options: {
legend: {
- display: true,
- position: "right"
+ display: false
},
tooltips: {
enabled: true,
@@ -998,8 +1017,7 @@ $(document).ready(function() {
},
options: {
legend: {
- display: true,
- position: "right"
+ display: false
},
tooltips: {
enabled: true,
diff --git a/style/pi-hole.css b/style/pi-hole.css
index 541d5c6e..59389e9e 100644
--- a/style/pi-hole.css
+++ b/style/pi-hole.css
@@ -115,3 +115,31 @@ a.lookatme {
-webkit-animation: fa-spin 1s infinite linear;
animation: fa-spin 1s infinite linear;
}
+
+.chart-legend {
+ height:250px;
+ overflow:auto;
+}
+
+.chart-legend ul {
+ list-style-type: none;
+}
+
+.chart-legend li {
+ cursor:pointer;
+}
+
+.chart-legend li span {
+ display: inline-block;
+ width: 20px;
+ height: 12px;
+ margin-right: 5px;
+}
+
+.strike {
+ text-decoration: line-through !important;
+}
+
+.float-left{
+ float:left;
+}