2021-05-11 14:40:04 -05:00
|
|
|
import React from 'react';
|
2021-04-06 18:06:46 -05:00
|
|
|
import { PanelProps } from '@grafana/data';
|
2021-05-13 13:57:45 -05:00
|
|
|
import { useTheme2, ZoomPlugin } from '@grafana/ui';
|
2021-05-10 11:34:42 -05:00
|
|
|
import { TimelineOptions } from './types';
|
|
|
|
import { TimelineChart } from './TimelineChart';
|
2021-04-06 18:06:46 -05:00
|
|
|
|
|
|
|
interface TimelinePanelProps extends PanelProps<TimelineOptions> {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @alpha
|
|
|
|
*/
|
2021-05-13 13:57:45 -05:00
|
|
|
export const TimelinePanel: React.FC<TimelinePanelProps> = ({
|
|
|
|
data,
|
|
|
|
timeRange,
|
|
|
|
timeZone,
|
|
|
|
options,
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
onChangeTimeRange,
|
|
|
|
}) => {
|
2021-05-10 11:34:42 -05:00
|
|
|
const theme = useTheme2();
|
|
|
|
|
2021-04-06 18:06:46 -05:00
|
|
|
if (!data || !data.series?.length) {
|
|
|
|
return (
|
|
|
|
<div className="panel-empty">
|
|
|
|
<p>No data found in response</p>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2021-04-07 01:16:14 -05:00
|
|
|
<TimelineChart
|
2021-05-10 11:34:42 -05:00
|
|
|
theme={theme}
|
2021-05-05 03:44:31 -05:00
|
|
|
frames={data.series}
|
2021-04-26 06:30:04 -05:00
|
|
|
structureRev={data.structureRev}
|
2021-04-06 18:06:46 -05:00
|
|
|
timeRange={timeRange}
|
|
|
|
timeZone={timeZone}
|
|
|
|
width={width}
|
|
|
|
height={height}
|
|
|
|
{...options}
|
2021-05-13 13:57:45 -05:00
|
|
|
>
|
2021-05-14 01:27:03 -05:00
|
|
|
{(config) => <ZoomPlugin config={config} onZoom={onChangeTimeRange} />}
|
2021-05-13 13:57:45 -05:00
|
|
|
</TimelineChart>
|
2021-04-06 18:06:46 -05:00
|
|
|
);
|
|
|
|
};
|