Timeseries: Revert annotations rendering changes (#67166)

This commit is contained in:
Adela Almasan 2023-04-24 17:38:30 -05:00 committed by GitHub
parent cd205e3f46
commit 1a347bfb7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,6 @@
import React, { useMemo } from 'react';
import { DataFrame, Field, PanelProps } from '@grafana/data';
import { Field, PanelProps } from '@grafana/data';
import { PanelDataErrorView } from '@grafana/runtime';
import { TooltipDisplayMode } from '@grafana/schema';
import { KeyboardPlugin, TimeSeries, TooltipPlugin, usePanelContext, ZoomPlugin } from '@grafana/ui';
@ -37,25 +37,6 @@ export const TimeSeriesPanel = ({
return getFieldLinksForExplore({ field, rowIndex, splitOpenFn: onSplitOpen, range: timeRange });
};
const { annotations, exemplars } = useMemo(() => {
let annotations: DataFrame[] | null = null;
let exemplars: DataFrame[] | null = null;
if (data?.annotations?.length) {
annotations = [];
exemplars = [];
for (let frame of data.annotations) {
if (frame.name === 'exemplar') {
exemplars.push(frame);
} else {
annotations.push(frame);
}
}
}
return { annotations, exemplars };
}, [data.annotations]);
const frames = useMemo(() => prepareGraphableFields(data.series, config.theme2, timeRange), [data, timeRange]);
const timezones = useMemo(() => getTimezones(options.timezone, timeZone), [options.timezone, timeZone]);
@ -107,7 +88,9 @@ export const TimeSeriesPanel = ({
/>
)}
{/* Renders annotation markers*/}
{annotations && <AnnotationsPlugin annotations={annotations} config={config} timeZone={timeZone} />}
{data.annotations && (
<AnnotationsPlugin annotations={data.annotations} config={config} timeZone={timeZone} />
)}
{/* Enables annotations creation*/}
{enableAnnotationCreation ? (
<AnnotationEditorPlugin data={alignedDataFrame} timeZone={timeZone} config={config}>
@ -149,11 +132,11 @@ export const TimeSeriesPanel = ({
defaultItems={[]}
/>
)}
{exemplars && (
{data.annotations && (
<ExemplarsPlugin
visibleSeries={getVisibleLabels(config, frames)}
config={config}
exemplars={exemplars}
exemplars={data.annotations}
timeZone={timeZone}
getFieldLinks={getFieldLinks}
/>