Stop distorting x axis

This commit is contained in:
amki 2021-02-05 16:38:58 +01:00
parent 788dd7a1a6
commit b888dafa66
4 changed files with 16 additions and 8 deletions

View File

@ -4,7 +4,7 @@
"windowsAuthentication": false, "windowsAuthentication": false,
"anonymousAuthentication": true, "anonymousAuthentication": true,
"iisExpress": { "iisExpress": {
"applicationUrl": "http://0.0.0.0:4223", "applicationUrl": "http://localhost:4223",
"sslPort": 0 "sslPort": 0
} }
}, },

Binary file not shown.

View File

@ -5,7 +5,7 @@
<title>ISPChk</title> <title>ISPChk</title>
<link href="bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"> <link href="bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<script src="jquery/jquery.js"></script> <script src="jquery/jquery.js"></script>
<script src="Chart.js/Chart.min.js"></script> <script src="Chart.js/Chart.bundle.min.js"></script>
</head> </head>
<body> <body>
<div class="container"> <div class="container">

View File

@ -47,11 +47,12 @@ async function fetchPings(hostId, start, end) {
async function transformChartData(pings) { async function transformChartData(pings) {
var res = { date: [], min: [], avg: [], max: [], failures: []}; var res = { date: [], min: [], avg: [], max: [], failures: []};
for (let ping of pings) { for (let ping of pings) {
res.date.push(ping.date); var jsDate = new Date(ping.date);
res.min.push(ping.min); //res.date.push(ping.date);
res.avg.push(ping.avg); res.min.push({ x: jsDate, y: ping.min });
res.max.push(ping.max); res.avg.push({ x: jsDate, y: ping.avg });
res.failures.push(ping.failures); res.max.push({ x: jsDate, y: ping.max });
res.failures.push({ x: jsDate, y: ping.failures });
} }
return res; return res;
} }
@ -71,7 +72,7 @@ async function updateGraphs() {
charts[host.hostId] = new Chart(ctx, { charts[host.hostId] = new Chart(ctx, {
type: 'line', type: 'line',
data: { data: {
labels: val.date, //labels: val.date,
datasets: [ datasets: [
{ {
label: 'min', label: 'min',
@ -102,6 +103,13 @@ async function updateGraphs() {
text: host.name text: host.name
}, },
scales: { scales: {
xAxes: [{
type: 'time',
distribution: 'linear',
time: {
unit: 'hour'
}
}],
yAxes: [ yAxes: [
{ {
id: "y-latency", id: "y-latency",