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