vfrz / dotnetgraph Goto Github PK
View Code? Open in Web Editor NEWCreate GraphViz DOT graph with .NET / C#
License: MIT License
Create GraphViz DOT graph with .NET / C#
License: MIT License
Currently the pos attribute is missing, which allows the position of a node to be specified.
I want to add this attribute, but it is specified with a point type, which is simply a string in a specified format:
"%f,%f('!')?" representing the point (x,y). The optional '!' indicates the node position should not change (input-only).
I'm not sure how and where to implement this point type and would therefore appreciate some advice.
In particular, I wonder if the point type should become its own class or is it sufficient if the DotPosAttribute contains the necessary conversion
GraphViz has support for the following layouts: dot, neato, fdp, sfdp, twopi, circo.
Could it be possible to allow the DotGraph object to be configured with an optional layout style?
As far as I can tell, this doesn't support records? Is that correct?
I could only manage half a workaround; by using a custom "record" shape, and a manually encoded node label (e.g., <f0> a|<f1> b|<f2> c)
) I could handle the nodes, but I can't figure out any way to get it to write edges as "node":f0 -> "node":f1
or node:f0 -> node:f1
.
As far as the api goes, edge .From and .To just need to accept optional ports, and nodes need to accept a list of port names and labels (that can be nested in complicated ways, to be fair; they can be grouped in order to switch between horizontal fields and vertical fields).
When the graph type is set to undirected, DotArrow still compiles to ->, which is a syntax error.
is there a way to use the HTML-attribute "port", so that edges will point from one port to another (e.g., connecting two cells within a big HTML-table), as opposed to connecting the whole node to another one?
e.g.: node1:port1 -> node2:port5
This is just minor, but maybe worth correcting ;)
REAMDE says
var mySubGraph = new DotSubGraph().WithIdentifier("cluster_0");
Class is called
DotSubgraph
First of all, thank you for this library, but it seems that some features are missing.
digraph a {
// default
node[shape=box];
}
IDotElement.AddAttribute(string(or DotAttribute enum), object)
?[shape=box style="filled, rounded"]
. (marking enums as flags?)label=<<TABLE>...</TABLE>>
, but since the label value is automatically encapsulated with double quotes this is not possible. Maybe adding a HtmlLabelAttribute?Great library -- thanks for sharing it!
Have you given any thought to allowing for default styles or themes so that users don't have to redefine the same styles for each node and edge?
I'm asking because I'm considering integrating your library in with my state management library. Ideally, my users would be able to define a set of styles for states (nodes), transitions (edges), and conditional transitions (specialized nodes and edges) before calling an export method and end up with something like this diagram.
Let me know your thoughts and I might be able to help implement this functionality.
The constructor of DotNode
takes an optional string identifier parameter. If none is provided, the identifier is set to null
. However, if you do not set an identifiert, the compiled dot file is invalid, as the nodes can not be identified.
I see multiple solutions and was wondering what you think would be the preferred one:
Since the identifier is not visible in the rendered graph from a dot file and since picking a unique name for each node can be a bit annoying, I'd suggest to leave it optional and just generate GUID if not set.
While we're on the topic of uniqueness, currently there are no checks to ensure that the graph has unique identifiers. So if you add two nodes with the same identifier, only one will be rendered. Any ideas on how to solve this?
I am not comfortable shipping assemblies that are not signed, since solutions using such assemblies are more prone to attacks.
From OpenAI:
Signing assemblies is a way to ensure the authenticity and integrity of an assembly. It allows you to verify that an assembly has not been tampered with and that it comes from a trusted source. Signing assemblies can also enable some features, such as putting them in the Global Assembly Cache (GAC) or using them in a strongly named application domain.
There are different ways to sign an assembly with a strong name, such as using Visual Studio, the Assembly Linker tool, or assembly attributes. You need a cryptographic key pair to sign an assembly, which can be generated by tools like sn.exe or Visual Studio.
Some of the benefits of signing assemblies are:
You can prevent name spoofing attacks, where a malicious assembly tries to impersonate another assembly by using the same name and version.
You can ensure that your application only loads the correct version of an assembly, and avoid loading an incompatible or outdated version.
You can use code access security (CAS) policies to grant permissions to assemblies based on their strong names.
You can use the GAC to share assemblies across applications and reduce disk space usage.
Some of the drawbacks of signing assemblies are:
Signed assemblies can only reference other signed assemblies, which can limit your choice of third-party libraries or components.
Signed assemblies are tied to a specific version of an assembly, which can cause problems when you want to update or patch an assembly without recompiling the application.
Signing assemblies can introduce a slight performance overhead due to the verification of the signature.
It would be wonderful if the solution automatically escaped strings used as labels and the title. I mean quote characters, line breaks, and others that I forgot to mention.
What I noticed so far is:
I didn't familiarize with the DOT syntax enough, but from my experience with the library:
\n
(some suggest using <br />
, but it didn't work for me),"
-> \"
,\
-> \\
HttpUtility.HtmlEncode(label)
to handle special HTML characters like <
, >
, national characters (they also caused issues), etc.Only then did the online visualizer http://www.webgraphviz.com/ stop reporting errors and warnings.
By the way, I love your library, it is so helpful! Cheers!
Hello,
Thanks for the great work! very useful !
do you know how i can align to the left, the label in a node
for example i have a multiline text in a label, and when it's displayed, everything is "centered" .. ! and i would like to align all text to the left !
thanks !
Nice project, exactly what I was looking for.
Very often I need a graph turned on its side to display text better.
graph g {
graph[rankdir=LR];
A -- B
}
As suggestion to easier build bigger graphs without needing to always keep the previously created objects in the code block or pass them along I could think of either:
Hi there! I have a very disconnected graph and am looking for a good way to use less horizontal space.
Graphviz has a CLI tool called unflatten
that adds invisible edges and other adjustments, which could be pretty cool a a compiler option in DotNetGraph!
The code for unflatten is here and the configuration params are here.
I might have a bash and see how I go if it sounds like a good idea :).
Hey,
I am using the latest from DotNetGraph from Nuget and compiling into a dotnet v 4.6.2 project.
Getting this error:
[Error : Unity Log] TypeLoadException: Parent class failed to load, due to: Could not load type of field 'DotNetGraph.Attributes.DotColorAttribute:<Color>k__BackingField' (0) due to: Could not resolve type with token 0100002e (from typeref, class/assembly System.Drawing.Color, netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51) assembly:netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 type:System.Drawing.Color member:(null) signature:<none>
...
Stack trace:
DotNetGraph.Compiler.DotCompilerWorker.CompileNode (DotNetGraph.Node.DotNode node, System.Int32 indentationLevel) (at <aa62545a0724477d9ad05e69e648d004>:0)
DotNetGraph.Compiler.DotCompilerWorker.CompileGraph () (at <aa62545a0724477d9ad05e69e648d004>:0)
DotNetGraph.Compiler.DotCompilerWorker.Compile () (at <aa62545a0724477d9ad05e69e648d004>:0)
DotNetGraph.Compiler.DotCompiler.Compile (System.IO.TextWriter writer, System.Boolean indented, System.Boolean formatStrings) (at <aa62545a0724477d9ad05e69e648d004>:0)
DotNetGraph.Compiler.DotCompiler.Compile (System.Boolean indented, System.Boolean formatStrings) (at <aa62545a0724477d9ad05e69e648d004>:0)
DotNetGraph.Extensions.DotGraphExtensions.Compile (DotNetGraph.DotGraph graph, System.Boolean indented, System.Boolean formatStrings) (at <aa62545a0724477d9ad05e69e648d004>:0)
Any clue what I can do about this?
One of the previous versions had the option to choose during compilation, whether to minify the diagram or not. It would be great if you allowed generating a non-minified diagram.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.