mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Do not crash timeseries panel if there is no time series data in the response (#33993)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { DashboardCursorSync, Field, PanelProps } from '@grafana/data';
|
||||
import { anySeriesWithTimeField, DashboardCursorSync, Field, PanelProps } from '@grafana/data';
|
||||
import { TooltipDisplayMode, usePanelContext, TimeSeries, TooltipPlugin, ZoomPlugin } from '@grafana/ui';
|
||||
import { getFieldLinksForExplore } from 'app/features/explore/utils/links';
|
||||
import React from 'react';
|
||||
@@ -19,12 +19,12 @@ export const TimeSeriesPanel: React.FC<TimeSeriesPanelProps> = ({
|
||||
onChangeTimeRange,
|
||||
replaceVariables,
|
||||
}) => {
|
||||
const { sync } = usePanelContext();
|
||||
|
||||
const getFieldLinks = (field: Field, rowIndex: number) => {
|
||||
return getFieldLinksForExplore({ field, rowIndex, range: timeRange });
|
||||
};
|
||||
|
||||
const { sync } = usePanelContext();
|
||||
|
||||
if (!data || !data.series?.length) {
|
||||
return (
|
||||
<div className="panel-empty">
|
||||
@@ -33,6 +33,14 @@ export const TimeSeriesPanel: React.FC<TimeSeriesPanelProps> = ({
|
||||
);
|
||||
}
|
||||
|
||||
if (!anySeriesWithTimeField(data.series)) {
|
||||
return (
|
||||
<div className="panel-empty">
|
||||
<p>Missing time field in the data</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<TimeSeries
|
||||
frames={data.series}
|
||||
|
||||
Reference in New Issue
Block a user