Fix equipment charts to display full 24-hour time range

Set explicit min/max bounds on chart x-axis to ensure all graphs
consistently show 24 hours of data, even when data points are sparse.

Also fix AlertNotifierTest race condition by disabling async execution.
This commit is contained in:
Graham McIntire 2026-01-15 13:12:29 -06:00
parent 82413df58b
commit 2bacf6337c
No known key found for this signature in database
2 changed files with 9 additions and 5 deletions

View file

@ -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

View file

@ -1,5 +1,5 @@
defmodule Towerops.Alerts.AlertNotifierTest do
use Towerops.DataCase
use Towerops.DataCase, async: false
import Swoosh.TestAssertions
import Towerops.AccountsFixtures