Skip to content

Commit a321c2d

Browse files
committed
ref(ui): Change useReleaseMarkLineSeries to use useReleaseStats hook
1 parent 293547d commit a321c2d

File tree

6 files changed

+468
-330
lines changed

6 files changed

+468
-330
lines changed

static/app/components/charts/baseChart.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {css, Global, useTheme} from '@emotion/react';
1010
import styled from '@emotion/styled';
1111
import type {
1212
AxisPointerComponentOption,
13+
CustomSeriesOption,
1314
ECharts,
1415
EChartsOption,
1516
GridComponentOption,
@@ -137,7 +138,7 @@ export interface BaseChartProps {
137138
* Additional Chart Series
138139
* This is to pass series to BaseChart bypassing the wrappers like LineChart, AreaChart etc.
139140
*/
140-
additionalSeries?: LineSeriesOption[];
141+
additionalSeries?: Array<CustomSeriesOption | SeriesOption>;
141142
/**
142143
* If true, ignores height value and auto-scales chart to fit container height.
143144
*/

static/app/views/dashboards/widgets/timeSeriesWidget/releaseBubbles/useReleaseBubbles.tsx

+17-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {ReactElement} from 'react';
1+
import {type MutableRefObject, type ReactElement, useCallback, useRef} from 'react';
22
import {type Theme, useTheme} from '@emotion/react';
33
import type {
44
CustomSeriesOption,
@@ -43,6 +43,9 @@ interface CreateReleaseBubbleMouseListenersParams {
4343
options: DrawerConfig['options']
4444
) => void;
4545
chartRenderer?: (rendererProps: {
46+
chartRef:
47+
| MutableRefObject<ReactEchartsRef | null>
48+
| ((e: ReactEchartsRef | null) => void);
4649
end: Date;
4750
releases: ReleaseMetaBasic[];
4851
start: Date;
@@ -322,10 +325,12 @@ ${t('Click to expand')}
322325
}
323326

324327
interface UseReleaseBubblesParams {
325-
chartRef: React.RefObject<ReactEchartsRef | null>;
326328
bubblePadding?: number;
327329
bubbleSize?: number;
328330
chartRenderer?: (rendererProps: {
331+
chartRef:
332+
| MutableRefObject<ReactEchartsRef | null>
333+
| ((e: ReactEchartsRef | null) => void);
329334
end: Date;
330335
releases: ReleaseMetaBasic[];
331336
start: Date;
@@ -335,7 +340,6 @@ interface UseReleaseBubblesParams {
335340
releases?: ReleaseMetaBasic[];
336341
}
337342
export function useReleaseBubbles({
338-
chartRef,
339343
chartRenderer,
340344
releases,
341345
minTime,
@@ -355,7 +359,16 @@ export function useReleaseBubbles({
355359
const releasesMaxTime = defined(selection.datetime.end)
356360
? new Date(selection.datetime.end).getTime()
357361
: Date.now();
362+
const chartRef = useRef<ReactEchartsRef | null>(null);
358363
const hasReleaseBubbles = organization.features.includes('release-bubbles-ui');
364+
const handleChartRef = useCallback((e: ReactEchartsRef | null) => {
365+
chartRef.current = e;
366+
367+
if (e?.getEchartsInstance) {
368+
createReleaseBubbleHighlighter(e.getEchartsInstance());
369+
}
370+
}, []);
371+
359372
const buckets =
360373
(hasReleaseBubbles &&
361374
releases?.length &&
@@ -377,7 +390,7 @@ export function useReleaseBubbles({
377390
const totalBubblePaddingY = bubblePadding * 2;
378391

379392
return {
380-
createReleaseBubbleHighlighter,
393+
createReleaseBubbleHighlighter: handleChartRef,
381394

382395
/**
383396
* An object map of ECharts event handlers. These should be spread onto a Chart component

static/app/views/dashboards/widgets/timeSeriesWidget/timeSeriesWidgetVisualization.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ export function TimeSeriesWidgetVisualization(props: TimeSeriesWidgetVisualizati
112112
releaseBubbleXAxis,
113113
releaseBubbleGrid,
114114
} = useReleaseBubbles({
115-
chartRef,
116115
chartRenderer: ({start: trimStart, end: trimEnd}) => {
117116
return (
118117
<TimeSeriesWidgetVisualization
@@ -167,7 +166,7 @@ export function TimeSeriesWidgetVisualization(props: TimeSeriesWidgetVisualizati
167166
registerWithWidgetSyncContext(echartsInstance);
168167

169168
if (hasReleaseBubblesSeries) {
170-
createReleaseBubbleHighlighter(echartsInstance);
169+
createReleaseBubbleHighlighter(e);
171170
}
172171
},
173172
[

0 commit comments

Comments
 (0)