diff --git a/assets/js/app.js b/assets/js/app.js index dd795052..86955cbc 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -194,6 +194,10 @@ const SensorChart = { } } + // Calculate 24-hour time range for consistent x-axis + const now = Date.now() + const twentyFourHoursAgo = now - (24 * 60 * 60 * 1000) + this.chart = new Chart(ctx, { type: chartType, data: { datasets }, @@ -240,11 +244,11 @@ const SensorChart = { scales: { x: { type: 'linear', + min: twentyFourHoursAgo, + max: now, ticks: { - callback: function(value, index) { - const point = this.chart.data.datasets[0]?.data[index] - if (!point) return '' - const date = new Date(point.x) + callback: function(value) { + const date = new Date(value) return date.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', hour12: false }) }, maxTicksLimit: 12 diff --git a/test/towerops/alerts/alert_notifier_test.exs b/test/towerops/alerts/alert_notifier_test.exs index b4ddfb16..61cc498c 100644 --- a/test/towerops/alerts/alert_notifier_test.exs +++ b/test/towerops/alerts/alert_notifier_test.exs @@ -1,5 +1,5 @@ defmodule Towerops.Alerts.AlertNotifierTest do - use Towerops.DataCase + use Towerops.DataCase, async: false import Swoosh.TestAssertions import Towerops.AccountsFixtures