microsoft / microsoft/automatic-graph-layout
Graph is not refreshing after inserting new nodes
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 1.5k
- Forks
- 319
- Avg merge
- 38m
- Merged PRs (30d)
- 1
Description
I have a graph in which I have added a few nodes. After adding the nodes, I assign the graph to the viewer and they are displayed.
However, if later I want to add more nodes, the graph is not automaticately updated, so I have to assign again the graph to the viewer to refresh it.
This is how I have created the viewer and graph:
Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
viewer.Graph = new Microsoft.Msagl.Drawing.Graph();
viewer.Graph.Attr.BackgroundColor = Microsoft.Msagl.Drawing.Color.Transparent;
viewer.BackColor = System.Drawing.Color.Transparent;
viewer.OutsideAreaBrush = Brushes.Transparent;
viewer.ToolBarIsVisible = true;
viewer.Dock = DockStyle.Fill;
this.SuspendLayout();
panelGraph.Controls.Add(viewer);
this.ResumeLayout();
And this is how I'm adding new Nodes. These nodes are not rendered in the graph automaticatly:
[...]
Node node = viewer.Graph.AddNode(entity.Hostname);
[...]
So, in order to refresh the graph, I have to do this:
private void UpdateGraph()
{
this.Invoke((MethodInvoker)delegate
{
Graph tmp = viewer.Graph;
viewer.Graph = null;
viewer.Graph = tmp; // workarround to force updating
});
}
Am I doing this wrong? What is the proper way to add the nodes to the graph and them being displayed automaticatly without having to reasign the 'Graph' property of the viewer?
Thank you,
Manuel
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the provided WinForms setup using GViewer.Graph and Graph.AddNode, then inspect how the viewer observes graph changes and refreshes layout. Done means newly added nodes appear without setting the Graph property to null and reassigning it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- computer-graphics, desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100