microsoft / microsoft/automatic-graph-layout
Help Getting Started rendering SVG
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 1.5k
- Forks
- 319
- Avg merge
- 38m
- Merged PRs (30d)
- 1
Description
Hi, I'm rewriting this question because I think the original question was not clear enough. I am trying to create an SVG, but not render directly to file. I've found some snippets of code but not a clear way of achieving my goals.
First: I'm using .NET core on a mac
I am using this "tutorial" to get started, I would really appreciate being pointed to better alternatives.
I'm setting up my graph like this:
GeometryGraph graph = new GeometryGraph();
graph.Nodes.Add(CreateNode("Bob"));
graph.Nodes.Add(CreateNode("Sally"));
graph.Nodes.Add(CreateNode("Rob"));
graph.Nodes.Add(CreateNode("Vincent"));
graph.Edges.Add(CreateEdge(graph.FindNodeByUserData("Bob"), graph.FindNodeByUserData("Sally")));
graph.Edges.Add(CreateEdge(graph.FindNodeByUserData("Sally"), graph.FindNodeByUserData("Vincent")));
graph.Edges.Add(CreateEdge(graph.FindNodeByUserData("Sally"), graph.FindNodeByUserData("Rob")));
var settings = new Microsoft.Msagl.Prototype.Ranking.RankingLayoutSettings();
settings.NodeSeparation = 50;
Microsoft.Msagl.Miscellaneous.LayoutHelpers.CalculateLayout(graph, settings, null);
private Edge CreateEdge(Node source, Node target)
{
return new Edge(source, target);
}
private Node CreateNode(string id)
{
return new Node(CurveFactory.CreateRectangle(200, 80, new Point()), id);
}
private ICurve CreateCurve(double w, double h)
{
return CurveFactory.CreateRectangle(w, h, new Point());
}
Now the question is, how do I get an SVG (or XElement or something along those lines) so I can embed this SVG. I Cannot write it to file some my attempts at SvgGraphWriter.Write have failed. I can't use the constructor because I can't pass in my graph and I can't create a GraphRenderer beause I'm using dotnet core.
Any help would be much appreciated.
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 with the GeometryGraph and LayoutHelpers.CalculateLayout setup in the issue, then inspect the mentioned SvgGraphWriter and GraphRenderer entry points for .NET Core support. Determine whether either API can produce an in-memory SVG or XElement instead of writing a file; done means the laid-out graph can be embedded as SVG.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- computer-graphics
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100