mirror of
https://github.com/StefBuwalda/dashboard_test.git
synced 2025-10-30 03:09:59 +00:00
66 lines
2.1 KiB
HTML
66 lines
2.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en" data-bs-theme="dark">
|
|
|
|
<head>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" charset=" UTF-8">
|
|
<title>Simple Line Chart</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet"
|
|
integrity="sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB" crossorigin="anonymous">
|
|
<link rel="icon" type="image/svg+xml" href="/static/favicon.svg">
|
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/chartjs-adapter-date-fns"></script>
|
|
<script src="https://www.chartjs.org/docs/latest/samples/utils.js"></script>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<canvas id="myChart"></canvas>
|
|
|
|
</body>
|
|
|
|
<script>
|
|
|
|
const chartDates = ({{ dates | safe }}).map(dt => new Date(dt));
|
|
const data = {
|
|
labels: chartDates,
|
|
datasets: [{
|
|
label: 'Ping',
|
|
data: {{ values }},
|
|
}]
|
|
};
|
|
|
|
const ctx = document.getElementById('myChart').getContext('2d');
|
|
// Current time in UTC
|
|
const nowUTC = new Date();
|
|
|
|
// One hour ago in UTC
|
|
const oneDayAgoUTC = new Date(nowUTC.getTime() - 24 * 60 * 60 * 1000);
|
|
const min = "{{ min }}"
|
|
const max = "{{ max }}"
|
|
new Chart(ctx, {
|
|
type: 'line',
|
|
data: data,
|
|
options: {
|
|
scales: {
|
|
x: {
|
|
type: 'time', // Important for datetime axis
|
|
time: {
|
|
unit: 'minute',
|
|
tooltipFormat: 'HH:mm:ss',
|
|
displayFormats: { hour: 'HH:mm' }
|
|
},
|
|
min: min,
|
|
max: max,
|
|
ticks: { color: '#ffffff' }, // X-axis labels
|
|
grid: { color: 'rgba(255, 255, 255, 0.1)' } // X-axis grid lines
|
|
},
|
|
y: {
|
|
ticks: { color: '#ffffff' }, // Y-axis labels
|
|
grid: { color: 'rgba(255, 255, 255, 0.1)' } // Y-axis grid lines
|
|
}
|
|
}
|
|
}
|
|
});
|
|
</script>
|
|
|
|
</html> |