An unofficial interface for building D2 diagram files in C# and dotnet.
dotnet add package d2lang-cs
using d2;
var umbrella = new D2Shape("alphabet", "Alphabet Inc", Shape.Rectangle);
var company = new D2Shape("google", null, Shape.Rectangle);
company.Add(new D2Shape("gmail", "Gmail", Shape.Rectangle));
company.Add(new D2Shape("meet", "Meet", Shape.Rectangle));
company.Add(new D2Shape("deepmind", "DeepMind", Shape.Rectangle));
company.Icon = "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png";
var connection = new D2Connection(company.Name, umbrella.Name, Direction.TO, "BELONGS_TO");
var diagram = new D2Diagram(new[] { umbrella, company }, new[] { connection });
Console.WriteLine(diagram.ToString());
alphabet: Alphabet Inc {
shape: rectangle
}
google: {
gmail: Gmail {
shape: rectangle
}
meet: Meet {
shape: rectangle
}
deepmind: DeepMind {
shape: rectangle
}
icon: https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png
shape: rectangle
}
google -> alphabet: BELONGS_TO
- Shapes (nodes)
- Connections (edges)
- Styles
- Containers (nodes/links in nodes)
- Arrow directions
- Markdown / latex / block strings / code in shapes
- Shape icons
- SQL table shapes
- Class shapes
- Comments
If you like what I'm doing and you would like to thank me, please consider:
Thank you for your support!
Copyright © 2023 Stephan van Stekelenburg - Provided under MIT License