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:
parent
82413df58b
commit
2bacf6337c
2 changed files with 9 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
defmodule Towerops.Alerts.AlertNotifierTest do
|
||||
use Towerops.DataCase
|
||||
use Towerops.DataCase, async: false
|
||||
|
||||
import Swoosh.TestAssertions
|
||||
import Towerops.AccountsFixtures
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue