修复图表 reference-only 加载动画
This commit is contained in:
@@ -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({
|
function shouldKeepTemperatureChartLoading({
|
||||||
row,
|
row,
|
||||||
isHourlyLoading,
|
isHourlyLoading,
|
||||||
@@ -65,7 +85,7 @@ function shouldKeepTemperatureChartLoading({
|
|||||||
}) {
|
}) {
|
||||||
if (!row?.city) return false;
|
if (!row?.city) return false;
|
||||||
if (!isHourlyLoading) return false;
|
if (!isHourlyLoading) return false;
|
||||||
return !hasDrawableTemperatureChartContent({ activeSeries, probabilityOverlay, zoomedData });
|
return !hasDrawablePrimaryTemperatureChartContent({ activeSeries, probabilityOverlay, zoomedData });
|
||||||
}
|
}
|
||||||
|
|
||||||
function TemperatureChartSkeleton({ compact }: { compact: boolean }) {
|
function TemperatureChartSkeleton({ compact }: { compact: boolean }) {
|
||||||
@@ -225,7 +245,7 @@ function TemperatureChartCanvasComponent({
|
|||||||
});
|
});
|
||||||
const shouldRenderChart = canRenderChart && hasDrawableChartContent;
|
const shouldRenderChart = canRenderChart && hasDrawableChartContent;
|
||||||
const shouldShowEmptyState = Boolean(row?.city) && !isHourlyLoading && !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 shouldShowUnavailableState = Boolean(row?.city) && Boolean(detailError) && !isHourlyLoading && !hasDrawableChartContent;
|
||||||
const shouldShowBackgroundError =
|
const shouldShowBackgroundError =
|
||||||
showDetailErrorBadge && Boolean(row?.city) && !isHourlyLoading && hasDrawableChartContent &&
|
showDetailErrorBadge && Boolean(row?.city) && !isHourlyLoading && hasDrawableChartContent &&
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ export function runTests() {
|
|||||||
"temperature chart should render once a visible series has drawable values",
|
"temperature chart should render once a visible series has drawable values",
|
||||||
);
|
);
|
||||||
assert(
|
assert(
|
||||||
!__shouldKeepTemperatureChartLoadingForTest({
|
__shouldKeepTemperatureChartLoadingForTest({
|
||||||
row: { city: "Moscow" } as any,
|
row: { city: "Moscow" } as any,
|
||||||
isHourlyLoading: true,
|
isHourlyLoading: true,
|
||||||
activeSeries: [
|
activeSeries: [
|
||||||
@@ -283,6 +283,6 @@ export function runTests() {
|
|||||||
{ label: "05:00", ts: 2, current: 13 },
|
{ 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",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user