From afc761746d106468cd5a78e869a7e613b8b7c348 Mon Sep 17 00:00:00 2001 From: "Grot (@grafanabot)" <43478413+grafanabot@users.noreply.github.com> Date: Thu, 3 Mar 2022 08:53:13 -0500 Subject: [PATCH] NodeGraph: Include frames with name edges or nodes in node graph (#46047) (#46164) * Include frames with name edges or nodes in node graph (cherry picked from commit cb1649e9b8ceddb89e71e6ef096983181a27a50b) Co-authored-by: Connor Lindsey --- docs/sources/visualizations/node-graph.md | 2 +- public/app/plugins/panel/nodeGraph/utils.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/sources/visualizations/node-graph.md b/docs/sources/visualizations/node-graph.md index 1f4ba8c435b..2545d108325 100644 --- a/docs/sources/visualizations/node-graph.md +++ b/docs/sources/visualizations/node-graph.md @@ -76,7 +76,7 @@ Click on the node and select "Show in Graph layout" option to switch back to gra This visualization needs a specific shape of the data to be returned from the data source in order to correctly display it. -Data source needs to return two data frames, one for nodes and one for edges, and you also have to set `frame.meta.preferredVisualisationType = 'nodeGraph'` on both data frames if you want them to be automatically shown in node graph in Explore. +Data source needs to return two data frames, one for nodes and one for edges. You have to set `frame.meta.preferredVisualisationType = 'nodeGraph'` on both data frames or name them `nodes` and `edges` respectively for the node graph to render. ### Node parameters diff --git a/public/app/plugins/panel/nodeGraph/utils.ts b/public/app/plugins/panel/nodeGraph/utils.ts index c1005a326f0..c79274427f1 100644 --- a/public/app/plugins/panel/nodeGraph/utils.ts +++ b/public/app/plugins/panel/nodeGraph/utils.ts @@ -323,5 +323,14 @@ export function getNodeGraphDataFrames(frames: DataFrame[]) { // processing pipeline which ends up populating redux state with proper data. As we move towards more dataFrame // oriented API it seems like a better direction to move such processing into to visualisations and do minimal // and lazy processing here. Needs bigger refactor so keeping nodeGraph and Traces as they are for now. - return frames.filter((frame) => frame.meta?.preferredVisualisationType === 'nodeGraph'); + return frames.filter((frame) => { + if (frame.meta?.preferredVisualisationType === 'nodeGraph') { + return true; + } + if (frame.name === 'nodes' || frame.name === 'edges') { + return true; + } + + return false; + }); }