From 48784010adad0bfc957f39a254244f369aae26b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Mon, 9 Mar 2026 13:55:45 +0800 Subject: [PATCH] Fix chart data issues: 24-hour format, Y-axis bounds, rounding modes Co-Authored-By: Claude Opus 4.6 --- src/module/setChartData.js | 6 ++++-- src/stores/allMapData.ts | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/module/setChartData.js b/src/module/setChartData.js index d803c95..99256ea 100644 --- a/src/module/setChartData.js +++ b/src/module/setChartData.js @@ -58,6 +58,7 @@ export function setLineChartData(baseData, xMax, xMin, isPercent, yMax, yMin) { * @returns {number} The extrapolated and clamped Y minimum value. */ function calculateYMin(baseData, isPercent, yMin, yMax) { + if (baseData.length < 2) return yMin; let a = 0; let c = 1; let d = baseData[0].y; @@ -77,6 +78,7 @@ function calculateYMin(baseData, isPercent, yMin, yMax) { * @returns {number} The extrapolated and clamped Y maximum value. */ function calculateYMax(baseData, isPercent, yMin, yMax) { + if (baseData.length < 10) return yMax; let ma = 9; let mb = baseData[8].y; let mc = 10; @@ -119,12 +121,12 @@ function clampValue(value, isPercent, min, max) { * @param {Array<{x: string, y: number}>} baseData - The data points from * the backend with ISO timestamp x values. * @returns {Array<{x: string, y: number}>} Data with x values formatted - * as "YYYY/M/D hh:mm:ss". + * as "YYYY/M/D HH:mm:ss". */ export function setBarChartData(baseData) { let data = baseData.map((i) => { return { - x: getMoment(i.x).format("YYYY/M/D hh:mm:ss"), + x: getMoment(i.x).format("YYYY/M/D HH:mm:ss"), y: i.y, }; }); diff --git a/src/stores/allMapData.ts b/src/stores/allMapData.ts index b22ea44..01ef5f6 100644 --- a/src/stores/allMapData.ts +++ b/src/stores/allMapData.ts @@ -140,11 +140,11 @@ export const useAllMapDataStore = defineStore("allMapDataStore", { case "float": copy.min = copy.min !== null - ? Number(new Decimal(copy.min).toFixed(2, 1)) + ? Number(new Decimal(copy.min).toFixed(2, 3)) : null; copy.max = copy.max !== null - ? Number(new Decimal(copy.max).toFixed(2, 0)) + ? Number(new Decimal(copy.max).toFixed(2, 2)) : null; break; default: