Fix chart data issues: 24-hour format, Y-axis bounds, rounding modes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-09 13:55:45 +08:00
parent 881dccc1ab
commit 48784010ad
2 changed files with 6 additions and 4 deletions

View File

@@ -58,6 +58,7 @@ export function setLineChartData(baseData, xMax, xMin, isPercent, yMax, yMin) {
* @returns {number} The extrapolated and clamped Y minimum value. * @returns {number} The extrapolated and clamped Y minimum value.
*/ */
function calculateYMin(baseData, isPercent, yMin, yMax) { function calculateYMin(baseData, isPercent, yMin, yMax) {
if (baseData.length < 2) return yMin;
let a = 0; let a = 0;
let c = 1; let c = 1;
let d = baseData[0].y; let d = baseData[0].y;
@@ -77,6 +78,7 @@ function calculateYMin(baseData, isPercent, yMin, yMax) {
* @returns {number} The extrapolated and clamped Y maximum value. * @returns {number} The extrapolated and clamped Y maximum value.
*/ */
function calculateYMax(baseData, isPercent, yMin, yMax) { function calculateYMax(baseData, isPercent, yMin, yMax) {
if (baseData.length < 10) return yMax;
let ma = 9; let ma = 9;
let mb = baseData[8].y; let mb = baseData[8].y;
let mc = 10; let mc = 10;
@@ -119,12 +121,12 @@ function clampValue(value, isPercent, min, max) {
* @param {Array<{x: string, y: number}>} baseData - The data points from * @param {Array<{x: string, y: number}>} baseData - The data points from
* the backend with ISO timestamp x values. * the backend with ISO timestamp x values.
* @returns {Array<{x: string, y: number}>} Data with x values formatted * @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) { export function setBarChartData(baseData) {
let data = baseData.map((i) => { let data = baseData.map((i) => {
return { 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, y: i.y,
}; };
}); });

View File

@@ -140,11 +140,11 @@ export const useAllMapDataStore = defineStore("allMapDataStore", {
case "float": case "float":
copy.min = copy.min =
copy.min !== null copy.min !== null
? Number(new Decimal(copy.min).toFixed(2, 1)) ? Number(new Decimal(copy.min).toFixed(2, 3))
: null; : null;
copy.max = copy.max =
copy.max !== null copy.max !== null
? Number(new Decimal(copy.max).toFixed(2, 0)) ? Number(new Decimal(copy.max).toFixed(2, 2))
: null; : null;
break; break;
default: default: