2022-04-22 08:33:13 -05:00
|
|
|
import memoizeOne from 'memoize-one';
|
2021-01-19 09:34:43 -06:00
|
|
|
import React from 'react';
|
2022-04-22 08:33:13 -05:00
|
|
|
|
2021-01-19 09:34:43 -06:00
|
|
|
import { PanelProps } from '@grafana/data';
|
2022-04-22 08:33:13 -05:00
|
|
|
|
|
|
|
import { useLinks } from '../../../features/explore/utils/links';
|
|
|
|
|
2021-05-12 09:04:21 -05:00
|
|
|
import { NodeGraph } from './NodeGraph';
|
2022-06-23 08:20:56 -05:00
|
|
|
import { NodeGraphOptions } from './types';
|
2022-01-27 11:19:54 -06:00
|
|
|
import { getNodeGraphDataFrames } from './utils';
|
2021-01-19 09:34:43 -06:00
|
|
|
|
2022-06-23 08:20:56 -05:00
|
|
|
export const NodeGraphPanel: React.FunctionComponent<PanelProps<NodeGraphOptions>> = ({
|
|
|
|
width,
|
|
|
|
height,
|
|
|
|
data,
|
|
|
|
options,
|
|
|
|
}) => {
|
2021-03-25 06:42:14 -05:00
|
|
|
const getLinks = useLinks(data.timeRange);
|
2021-01-19 09:34:43 -06:00
|
|
|
if (!data || !data.series.length) {
|
|
|
|
return (
|
|
|
|
<div className="panel-empty">
|
|
|
|
<p>No data found in response</p>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-01-27 11:19:54 -06:00
|
|
|
const memoizedGetNodeGraphDataFrames = memoizeOne(getNodeGraphDataFrames);
|
2021-01-19 09:34:43 -06:00
|
|
|
return (
|
|
|
|
<div style={{ width, height }}>
|
2022-06-23 08:20:56 -05:00
|
|
|
<NodeGraph dataFrames={memoizedGetNodeGraphDataFrames(data.series, options)} getLinks={getLinks} />
|
2021-01-19 09:34:43 -06:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|