fix: chart flicker

This commit is contained in:
jialin
2026-04-29 09:29:04 +08:00
committed by jialin
parent 26880b4612
commit 3144328874
3 changed files with 17 additions and 3 deletions
+5 -1
View File
@@ -86,6 +86,10 @@ const DailyUsage: React.FC<DailyUsageProps> = (props) => {
return dayjs(v).format('MM-DD');
};
// Recompute only when data (or locale) changes, NOT when metric/groupBy/granularity change.
// Filter changes already trigger a refetch; deriving on stale data with new filters
// produces an inconsistent intermediate frame (e.g. grouped data flattened to total),
// which is the visible flicker.
const { seriesData, xAxisData, legendData } = useMemo(() => {
const items = timeSeriesData?.items || [];
if (items.length === 0) {
@@ -233,7 +237,7 @@ const DailyUsage: React.FC<DailyUsageProps> = (props) => {
xAxisData: xAxis,
legendData: dedupedLegend
};
}, [timeSeriesData, metric, groupBy, granularity, startDate, endDate, intl]);
}, [timeSeriesData, intl]);
const handleOnGroupByChange = (value: string) => {
onGroupByChange(value || null);