修复温度曲线三个渲染问题:数据点过少、张力过高、canvas被CSS拉伸
- 小时数据插值为每半小时一点(24→47点) - 全线 tension 从 0.28-0.32 降至 0.1-0.12 - 移除 canvas CSS width/height !important 声明,交由 Chart.js ResizeObserver 管理
This commit is contained in:
@@ -380,13 +380,22 @@ export function getTemperatureChartData(
|
||||
validEntries.forEach((entry) => {
|
||||
dataByHour.set(entry.tail, Number.isFinite(entry.value) ? entry.value : null);
|
||||
});
|
||||
const getHourTemp = (h: number): number | null => {
|
||||
const key = `${String(h).padStart(2, "0")}:00`;
|
||||
return dataByHour.has(key) ? dataByHour.get(key)! : null;
|
||||
};
|
||||
const times: string[] = [];
|
||||
const temps: Array<number | null> = [];
|
||||
for (let h = 0; h < 24; h++) {
|
||||
const hh = String(h).padStart(2, "0");
|
||||
const key = `${hh}:00`;
|
||||
times.push(key);
|
||||
temps.push(dataByHour.has(key) ? dataByHour.get(key)! : null);
|
||||
times.push(`${hh}:00`);
|
||||
temps.push(getHourTemp(h));
|
||||
if (h < 23) {
|
||||
const a = getHourTemp(h);
|
||||
const b = getHourTemp(h + 1);
|
||||
times.push(`${hh}:30`);
|
||||
temps.push(a != null && b != null ? Number((a + (b - a) * 0.5).toFixed(1)) : a ?? b);
|
||||
}
|
||||
}
|
||||
const suppressAnkaraMgmObservation = isTurkishMgmCity(detail);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user