mirror of
https://github.com/pi-hole/web.git
synced 2025-12-26 13:36:22 +00:00
Add zooming on the dashboard's two main graphs. You can zoom either with [Ctrl] + your mouse wheel (desktop) or the multi-touch "pinch" gesture (mobile). You can then drag with a single click (or finger) to move the graph up or down in case zooming wasn't that accurate
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -420,6 +420,35 @@ $(function () {
|
||||
// Pull in data via AJAX
|
||||
updateSummaryData();
|
||||
|
||||
const zoomPlugin = {
|
||||
/* Allow zooming only on the y axis */
|
||||
zoom: {
|
||||
enabled: true,
|
||||
wheel: {
|
||||
enabled: true,
|
||||
modifierKey: "ctrl" /* Modifier key required for zooming via mouse wheel */,
|
||||
},
|
||||
pinch: {
|
||||
enabled: true,
|
||||
},
|
||||
mode: "y",
|
||||
},
|
||||
/* Allow panning only on the y axis */
|
||||
pan: {
|
||||
enabled: true,
|
||||
mode: "y",
|
||||
},
|
||||
limits: {
|
||||
y: {
|
||||
/* Users are not allowed to zoom out further than the initial range */
|
||||
min: "original",
|
||||
max: "original",
|
||||
/* Users are not allowed to zoom in further than a range of 10 queries */
|
||||
minRange: 10,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
var gridColor = utils.getCSSval("graphs-grid", "background-color");
|
||||
var ticksColor = utils.getCSSval("graphs-ticks", "color");
|
||||
var ctx = document.getElementById("queryOverTimeChart").getContext("2d");
|
||||
@@ -477,6 +506,7 @@ $(function () {
|
||||
},
|
||||
},
|
||||
},
|
||||
zoom: zoomPlugin,
|
||||
},
|
||||
scales: {
|
||||
x: {
|
||||
@@ -510,6 +540,7 @@ $(function () {
|
||||
color: gridColor,
|
||||
drawBorder: false,
|
||||
},
|
||||
min: 0,
|
||||
},
|
||||
},
|
||||
elements: {
|
||||
@@ -572,6 +603,7 @@ $(function () {
|
||||
},
|
||||
},
|
||||
},
|
||||
zoom: zoomPlugin,
|
||||
},
|
||||
scales: {
|
||||
x: {
|
||||
@@ -605,6 +637,7 @@ $(function () {
|
||||
color: gridColor,
|
||||
drawBorder: false,
|
||||
},
|
||||
min: 0,
|
||||
},
|
||||
},
|
||||
elements: {
|
||||
|
||||
@@ -16,6 +16,8 @@ mg.include('header.lp','r')
|
||||
<script src="<?=pihole.fileversion('scripts/vendor/chart.umd.min.js')?>"></script>
|
||||
<script src="<?=pihole.fileversion('scripts/vendor/moment.min.js')?>"></script>
|
||||
<script src="<?=pihole.fileversion('scripts/vendor/chartjs-adapter-moment.js')?>"></script>
|
||||
<script src="<?=pihole.fileversion('scripts/vendor/hammer.min.js')?>"></script> <!-- Needed for chartjs-plugin-zoom --->
|
||||
<script src="<?=pihole.fileversion('scripts/vendor/chartjs-plugin-zoom.min.js')?>"></script>
|
||||
</head>
|
||||
<body class="<?=theme.name?> hold-transition sidebar-mini <? if pihole.boxedlayout() then ?>layout-boxed<? end ?> logged-in">
|
||||
<noscript>
|
||||
|
||||
7
scripts/vendor/chartjs-plugin-zoom.min.js
vendored
Normal file
7
scripts/vendor/chartjs-plugin-zoom.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
7
scripts/vendor/hammer.min.js
vendored
Normal file
7
scripts/vendor/hammer.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user