fix(web): show exact trend values and integer axis ticks

This commit is contained in:
kairee committed 2026-11-01 01:37:55 +08:00
1 parent fcca14c0f9
commit eff4b0149d
3 files changed
+11 -10

No files matched your search

+5 -3
View File
@@ -1,4 +1,4 @@
import { formatAxis, formatCount, formatDay } from "./format.js";
import { formatAxis, formatDay, formatNumber } from "./format.js";
const charts = new Map();
let resizeObserver = null;
@@ -78,7 +78,7 @@ export function lineChart(element, { dates, values, name = "数值", color, scal
if (!point) return "";
const value = point.value;
return `<strong>${point.axisValue}</strong><br>${name}:${
value === null || value === undefined ? "缺失" : formatCount(value)
value === null || value === undefined ? "缺失" : formatNumber(value)
}`;
},
},
@@ -98,6 +98,7 @@ export function lineChart(element, { dates, values, name = "数值", color, scal
yAxis: {
type: "value",
scale,
minInterval: 1,
splitLine: { lineStyle: { color: theme.grid, type: "dashed" } },
axisLabel: {
color: theme.muted,
@@ -147,7 +148,7 @@ export function barChart(element, { labels, values, name = "数值", color }) {
formatter(params) {
const point = params[0];
if (!point) return "";
return `<strong>${point.name}</strong><br>${name}:${formatCount(point.value)}`;
return `<strong>${point.name}</strong><br>${name}:${formatNumber(point.value)}`;
},
},
xAxis: {
@@ -165,6 +166,7 @@ export function barChart(element, { labels, values, name = "数值", color }) {
},
yAxis: {
type: "value",
minInterval: 1,
splitLine: { lineStyle: { color: theme.grid, type: "dashed" } },
axisLabel: {
color: theme.muted,