grafana/public/app/plugins/panel/state-timeline/StateTimelinePanel.tsx

54 lines
1.2 KiB
TypeScript
Raw Normal View History

import React, { useMemo } from 'react';
import { PanelProps } from '@grafana/data';
2021-05-13 13:57:45 -05:00
import { useTheme2, ZoomPlugin } from '@grafana/ui';
import { TimelineMode, TimelineOptions } from './types';
import { TimelineChart } from './TimelineChart';
import { prepareTimelineFields } from './utils';
interface TimelinePanelProps extends PanelProps<TimelineOptions> {}
/**
* @alpha
*/
export const StateTimelinePanel: React.FC<TimelinePanelProps> = ({
2021-05-13 13:57:45 -05:00
data,
timeRange,
timeZone,
options,
width,
height,
onChangeTimeRange,
}) => {
const theme = useTheme2();
const { frames, warn } = useMemo(() => prepareTimelineFields(data?.series, options.mergeValues ?? true), [
data,
options.mergeValues,
]);
if (!frames || warn) {
return (
<div className="panel-empty">
<p>{warn ?? 'No data found in response'}</p>
</div>
);
}
return (
<TimelineChart
theme={theme}
frames={frames}
structureRev={data.structureRev}
timeRange={timeRange}
timeZone={timeZone}
width={width}
height={height}
{...options}
// hardcoded
mode={TimelineMode.Changes}
2021-05-13 13:57:45 -05:00
>
{(config) => <ZoomPlugin config={config} onZoom={onChangeTimeRange} />}
2021-05-13 13:57:45 -05:00
</TimelineChart>
);
};