2022-04-22 21:33:13 +08:00
|
|
|
import memoizeOne from 'memoize-one';
|
2024-06-25 19:43:47 +08:00
|
|
|
import { useId } from 'react';
|
2022-04-22 21:33:13 +08:00
|
|
|
|
2021-01-19 23:34:43 +08:00
|
|
|
import { PanelProps } from '@grafana/data';
|
2025-05-30 01:13:25 +08:00
|
|
|
import { Trans } from '@grafana/i18n';
|
2022-04-22 21:33:13 +08:00
|
|
|
|
|
|
|
import { useLinks } from '../../../features/explore/utils/links';
|
|
|
|
|
2021-05-12 22:04:21 +08:00
|
|
|
import { NodeGraph } from './NodeGraph';
|
2025-04-02 22:56:22 +08:00
|
|
|
import { Options as NodeGraphOptions } from './panelcfg.gen';
|
2022-01-28 01:19:54 +08:00
|
|
|
import { getNodeGraphDataFrames } from './utils';
|
2021-01-19 23:34:43 +08:00
|
|
|
|
2023-03-16 22:56:26 +08:00
|
|
|
export const NodeGraphPanel = ({ width, height, data, options }: PanelProps<NodeGraphOptions>) => {
|
2021-03-25 19:42:14 +08:00
|
|
|
const getLinks = useLinks(data.timeRange);
|
2024-04-19 00:39:16 +08:00
|
|
|
const panelId = useId();
|
|
|
|
|
2021-01-19 23:34:43 +08:00
|
|
|
if (!data || !data.series.length) {
|
|
|
|
return (
|
|
|
|
<div className="panel-empty">
|
2025-05-30 01:13:25 +08:00
|
|
|
<p>
|
|
|
|
<Trans i18nKey="nodeGraph.node-graph-panel.no-data-found-in-response">No data found in response</Trans>
|
|
|
|
</p>
|
2021-01-19 23:34:43 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-01-28 01:19:54 +08:00
|
|
|
const memoizedGetNodeGraphDataFrames = memoizeOne(getNodeGraphDataFrames);
|
2021-01-19 23:34:43 +08:00
|
|
|
return (
|
|
|
|
<div style={{ width, height }}>
|
2024-04-19 00:39:16 +08:00
|
|
|
<NodeGraph
|
|
|
|
dataFrames={memoizedGetNodeGraphDataFrames(data.series, options)}
|
|
|
|
getLinks={getLinks}
|
|
|
|
panelId={panelId}
|
2024-11-15 16:43:28 +08:00
|
|
|
zoomMode={options.zoomMode}
|
2025-04-02 22:56:22 +08:00
|
|
|
layoutAlgorithm={options.layoutAlgorithm}
|
2024-04-19 00:39:16 +08:00
|
|
|
/>
|
2021-01-19 23:34:43 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|