diff --git a/employee-app/health-monitor/environment/device-detail.html b/employee-app/health-monitor/environment/device-detail.html index b60206b..484b96b 100644 --- a/employee-app/health-monitor/environment/device-detail.html +++ b/employee-app/health-monitor/environment/device-detail.html @@ -367,6 +367,14 @@ function getXLabels7() { } return labels; } +function getXLabels30() { + var labels = [], now = new Date(2026, 5, 4); + for (var i = 29; i >= 0; i--) { + var d = new Date(now); d.setDate(d.getDate() - i); + labels.push((d.getMonth()+1) + '/' + d.getDate()); + } + return labels; +} /* X 坐标计算 */ function calcXPositions(count) { @@ -460,14 +468,13 @@ function renderTrend(metricName, period) { // AQI 非 24h → 柱状堆积图 if (cfg.isAQI && period !== '24h') { - var labels = period === '7d' ? getXLabels7() : Array.from({length:4}, function(_, i) { return '第' + (i+1) + '周'; }); + var labels = period === '7d' ? getXLabels7() : getXLabels30(); return renderAQIBarChart(timeData, labels); } var points = timeData.points; var n = points.length; - var labels = cfg.isAQI ? (period === '24h' ? xLabels24 : getXLabels7()) : (period === '24h' ? xLabels24 : getXLabels7()); - if (period === '30d' && n === 30) labels = (function() { var l = [], now = new Date(2026,5,4); for (var i = 29; i >= 0; i--) { var d = new Date(now); d.setDate(d.getDate() - i); l.push((d.getMonth()+1) + '/' + d.getDate()); } return l; })(); + var labels = period === '24h' ? xLabels24 : (period === '7d' ? getXLabels7() : getXLabels30()); var xPositions = calcXPositions(n); var yMax = cfg.yMax;