修复图表 reference-only 加载动画

This commit is contained in:
2569718930@qq.com
2026-06-16 05:43:19 +08:00
parent 153595ccfc
commit a9ed45a3d3
2 changed files with 24 additions and 4 deletions
@@ -50,6 +50,26 @@ function hasDrawableTemperatureChartContent({
);
}
function isFallbackReferenceSeries(series: EvidenceSeries) {
return series.key === "current" && series.label === "Current reference";
}
function hasDrawablePrimaryTemperatureChartContent({
activeSeries,
probabilityOverlay,
zoomedData,
}: {
activeSeries: EvidenceSeries[];
probabilityOverlay: ProbabilityOverlay | null;
zoomedData: Array<Record<string, any>>;
}) {
return hasDrawableTemperatureChartContent({
activeSeries: activeSeries.filter((series) => !isFallbackReferenceSeries(series)),
probabilityOverlay,
zoomedData,
});
}
function shouldKeepTemperatureChartLoading({
row,
isHourlyLoading,
@@ -65,7 +85,7 @@ function shouldKeepTemperatureChartLoading({
}) {
if (!row?.city) return false;
if (!isHourlyLoading) return false;
return !hasDrawableTemperatureChartContent({ activeSeries, probabilityOverlay, zoomedData });
return !hasDrawablePrimaryTemperatureChartContent({ activeSeries, probabilityOverlay, zoomedData });
}
function TemperatureChartSkeleton({ compact }: { compact: boolean }) {
@@ -225,7 +245,7 @@ function TemperatureChartCanvasComponent({
});
const shouldRenderChart = canRenderChart && hasDrawableChartContent;
const shouldShowEmptyState = Boolean(row?.city) && !isHourlyLoading && !hasDrawableChartContent;
const shouldShowBackgroundRefresh = isHourlyLoading && hasDrawableChartContent;
const shouldShowBackgroundRefresh = isHourlyLoading && hasDrawableChartContent && !shouldShowChartLoading;
const shouldShowUnavailableState = Boolean(row?.city) && Boolean(detailError) && !isHourlyLoading && !hasDrawableChartContent;
const shouldShowBackgroundError =
showDetailErrorBadge && Boolean(row?.city) && !isHourlyLoading && hasDrawableChartContent &&
@@ -265,7 +265,7 @@ export function runTests() {
"temperature chart should render once a visible series has drawable values",
);
assert(
!__shouldKeepTemperatureChartLoadingForTest({
__shouldKeepTemperatureChartLoadingForTest({
row: { city: "Moscow" } as any,
isHourlyLoading: true,
activeSeries: [
@@ -283,6 +283,6 @@ export function runTests() {
{ label: "05:00", ts: 2, current: 13 },
],
}),
"temperature chart must render seeded or cached data immediately while full detail continues loading in the background",
"temperature chart should keep the loading overlay when the only drawable series is the fallback Current reference line",
);
}