Skip to content

Commit 75c2cba

Browse files
authored
feat(replay): Fix MemoryChart to not re-render as often (#87190)
Split `<MemoryChart>` into 2 components: * The outer component handles mouse events and setting hover/current time * The inner component renders the chart and is now memoized so that it does not re-render as often This fixes the issue where a playing replay re-renders the chart and makes the tooltip flicker. Additionally, we define `triggerLineEvent: true` on the series so that mousemove events work on the chart to update hover time. Closes #51465 Closes #68785
1 parent fc01d03 commit 75c2cba

File tree

2 files changed

+232
-147
lines changed

2 files changed

+232
-147
lines changed

static/app/components/charts/areaChart.tsx

+15-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import {forwardRef} from 'react';
12
import type {LineSeriesOption} from 'echarts';
23

3-
import type {Series} from 'sentry/types/echarts';
4+
import type {ReactEchartsRef, Series} from 'sentry/types/echarts';
45

56
import AreaSeries from './series/areaSeries';
67
import type {BaseChartProps} from './baseChart';
@@ -46,13 +47,16 @@ export function transformToAreaSeries({
4647
);
4748
}
4849

49-
export function AreaChart({series, stacked, colors, ...props}: AreaChartProps) {
50-
return (
51-
<BaseChart
52-
{...props}
53-
data-test-id="area-chart"
54-
colors={colors}
55-
series={transformToAreaSeries({series, stacked, colors})}
56-
/>
57-
);
58-
}
50+
export const AreaChart = forwardRef<ReactEchartsRef, AreaChartProps>(
51+
({series, stacked, colors, ...props}, ref) => {
52+
return (
53+
<BaseChart
54+
{...props}
55+
ref={ref}
56+
data-test-id="area-chart"
57+
colors={colors}
58+
series={transformToAreaSeries({series, stacked, colors})}
59+
/>
60+
);
61+
}
62+
);

0 commit comments

Comments
 (0)