NodeGraphPanel.tsx 850 B

12345678910111213141516171819202122232425262728
  1. import memoizeOne from 'memoize-one';
  2. import React from 'react';
  3. import { PanelProps } from '@grafana/data';
  4. import { useLinks } from '../../../features/explore/utils/links';
  5. import { NodeGraph } from './NodeGraph';
  6. import { Options } from './types';
  7. import { getNodeGraphDataFrames } from './utils';
  8. export const NodeGraphPanel: React.FunctionComponent<PanelProps<Options>> = ({ width, height, data }) => {
  9. const getLinks = useLinks(data.timeRange);
  10. if (!data || !data.series.length) {
  11. return (
  12. <div className="panel-empty">
  13. <p>No data found in response</p>
  14. </div>
  15. );
  16. }
  17. const memoizedGetNodeGraphDataFrames = memoizeOne(getNodeGraphDataFrames);
  18. return (
  19. <div style={{ width, height }}>
  20. <NodeGraph dataFrames={memoizedGetNodeGraphDataFrames(data.series)} getLinks={getLinks} />
  21. </div>
  22. );
  23. };