grafana/public/app/plugins/panel/nodeGraph/NodeGraphPanel.tsx
Connor Lindsey 16aaffe0a1
Node Graph Panel: Add options to configure units and arc colors (#51057)
* Node Graph Panel: Add options to configure units and arc colors

* Add tests
2022-06-23 07:20:56 -06:00

34 lines
895 B
TypeScript

import memoizeOne from 'memoize-one';
import React from 'react';
import { PanelProps } from '@grafana/data';
import { useLinks } from '../../../features/explore/utils/links';
import { NodeGraph } from './NodeGraph';
import { NodeGraphOptions } from './types';
import { getNodeGraphDataFrames } from './utils';
export const NodeGraphPanel: React.FunctionComponent<PanelProps<NodeGraphOptions>> = ({
width,
height,
data,
options,
}) => {
const getLinks = useLinks(data.timeRange);
if (!data || !data.series.length) {
return (
<div className="panel-empty">
<p>No data found in response</p>
</div>
);
}
const memoizedGetNodeGraphDataFrames = memoizeOne(getNodeGraphDataFrames);
return (
<div style={{ width, height }}>
<NodeGraph dataFrames={memoizedGetNodeGraphDataFrames(data.series, options)} getLinks={getLinks} />
</div>
);
};