From de376df416e21cdc2ecd1ff2977615bcf4f5b786 Mon Sep 17 00:00:00 2001 From: andersonid Date: Mon, 27 Oct 2025 14:21:46 -0300 Subject: [PATCH] Fix: Adjust X-axis time range (last 24h from now) and Y-axis domain for Resource Utilization Trend --- app/static/index.html | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/app/static/index.html b/app/static/index.html index b8728a9..1efe0d7 100644 --- a/app/static/index.html +++ b/app/static/index.html @@ -3823,11 +3823,21 @@ const cpuData = data.filter(d => d.type === 'CPU'); const memoryData = data.filter(d => d.type === 'Memory'); + // Calculate domain for last 24 hours + const now = new Date(); + const yesterday = new Date(now.getTime() - 24 * 60 * 60 * 1000); + const xDomain = [yesterday.getTime(), now.getTime()]; + + // Calculate Y domain based on data (CPU and Memory should be on different scales) + const allYValues = data.map(d => d.y).filter(v => !isNaN(v) && isFinite(v)); + const maxY = Math.max(...allYValues, 10) * 1.1; // Add 10% padding + const chart = React.createElement(Victory.VictoryChart, { width: container.offsetWidth || 500, height: 300, theme: Victory.VictoryTheme.material, scale: { x: 'time' }, + domain: { x: xDomain, y: [0, maxY] }, padding: { top: 20, bottom: 60, left: 80, right: 40 }, domainPadding: { x: 0, y: 0 }, style: { @@ -3845,7 +3855,8 @@ axis: { stroke: '#666' }, tickLabels: { fill: '#ccc', fontSize: 16, angle: -45, textAnchor: 'end' } }, - tickFormat: (t) => `${t}%` + tickCount: 8, + tickFormat: (t) => Number(t).toFixed(1) }), React.createElement(Victory.VictoryAxis, { key: 'x-axis', @@ -3857,8 +3868,7 @@ }, tickFormat: (t) => new Date(t).toLocaleTimeString('pt-BR', { hour: '2-digit', - minute: '2-digit', - timeZone: 'UTC' + minute: '2-digit' }) }), React.createElement(Victory.VictoryLine, {