diff --git a/public/app/plugins/panel/nodeGraph/NodeGraph.test.tsx b/public/app/plugins/panel/nodeGraph/NodeGraph.test.tsx index 2f530436669..58fa20e928f 100644 --- a/public/app/plugins/panel/nodeGraph/NodeGraph.test.tsx +++ b/public/app/plugins/panel/nodeGraph/NodeGraph.test.tsx @@ -14,12 +14,14 @@ jest.mock('react-use/lib/useMeasure', () => { }); describe('NodeGraph', () => { - it('doesnt fail without any data', async () => { + it('shows no data message without any data', async () => { render( []} />); + + await screen.findByText('No data'); }); it('can zoom in and out', async () => { - render( []} />); + render( []} />); const zoomIn = await screen.findByTitle(/Zoom in/); const zoomOut = await screen.findByTitle(/Zoom out/); diff --git a/public/app/plugins/panel/nodeGraph/NodeGraph.tsx b/public/app/plugins/panel/nodeGraph/NodeGraph.tsx index bbd682ca892..7e011c9d322 100644 --- a/public/app/plugins/panel/nodeGraph/NodeGraph.tsx +++ b/public/app/plugins/panel/nodeGraph/NodeGraph.tsx @@ -44,6 +44,15 @@ const getStyles = (theme: GrafanaTheme2) => ({ user-select: none; `, + noDataMsg: css` + height: 100%; + width: 100%; + display: grid; + place-items: center; + font-size: ${theme.typography.h4.fontSize}; + color: ${theme.colors.text.secondary}; + `, + mainGroup: css` label: mainGroup; will-change: transform; @@ -67,6 +76,9 @@ const getStyles = (theme: GrafanaTheme2) => ({ padding-bottom: 5px; margin-right: 10px; `, + viewControlsWrapper: css` + margin-left: auto; + `, alert: css` label: alert; padding: 5px 8px; @@ -177,42 +189,46 @@ export function NodeGraph({ getLinks, dataFrames, nodeLimit }: Props) { ) : null} - - - - {!config.gridLayout && ( - + + {!config.gridLayout && ( + + )} + - )} - - - {/*We split the labels from edges so that they are shown on top of everything else*/} - {!config.gridLayout && } - - + + {/*We split the labels from edges so that they are shown on top of everything else*/} + {!config.gridLayout && } + + + ) : ( +
No data
+ )}
- {nodes.length && ( + {nodes.length ? (
- )} + ) : null} - - config={config} - onConfigChange={(cfg) => { - if (cfg.gridLayout !== config.gridLayout) { - setFocusedNodeId(undefined); - } - setConfig(cfg); - }} - onMinus={onStepDown} - onPlus={onStepUp} - scale={scale} - disableZoomIn={isMaxZoom} - disableZoomOut={isMinZoom} - /> +
+ + config={config} + onConfigChange={(cfg) => { + if (cfg.gridLayout !== config.gridLayout) { + setFocusedNodeId(undefined); + } + setConfig(cfg); + }} + onMinus={onStepDown} + onPlus={onStepUp} + scale={scale} + disableZoomIn={isMaxZoom} + disableZoomOut={isMinZoom} + /> +
{hiddenNodesCount > 0 && (