Diagram Class
A diagram: a flowchart, a class diagram, a state diagram... Diagram.CreateScene lays it out into a Scene; Diagram.ToSvg writes it as SVG. The output is deterministic: the same diagram always gives the same SVG.
public abstract class Diagram : ISceneSource- Implements
Properties
| Name | Description |
|---|---|
| AccessibleTitle | Gets or sets the accessible name of the diagram when it differs from Diagram.Title, which is not drawn (Mermaid accTitle). |
| Description | Gets or sets the accessible description of the diagram (Mermaid accDescr). |
| Padding | Gets or sets the space around the diagram, in pixels. The default is 8. |
| TextMeasurer | Gets or sets the measurer of the texts, or null for AfmTextMeasurer.Default. |
| Theme | Gets or sets the colors and the font of the diagram. The default is DiagramTheme.Default. |
| Title | Gets or sets the title, drawn above the diagram. It is also the accessible name of the SVG. |
AccessibleTitle
Diagram.csGets or sets the accessible name of the diagram when it differs from Diagram.Title, which is not drawn (Mermaid accTitle).
public string? AccessibleTitle { get; set; }Property value
Description
Diagram.csPadding
Diagram.csGets or sets the space around the diagram, in pixels. The default is 8.
public double Padding { get; set; }TextMeasurer
Diagram.csGets or sets the measurer of the texts, or null for AfmTextMeasurer.Default.
public ITextMeasurer? TextMeasurer { get; set; }Property value
Theme
Diagram.csGets or sets the colors and the font of the diagram. The default is DiagramTheme.Default.
public DiagramTheme Theme { get; set; }Property value
Title
Diagram.csMethods
| Name | Description |
|---|---|
| CreateScene(ITextMeasurer?) | Lays the diagram out into drawing primitives. |
| ToSvg(SvgRenderOptions?) | Returns the diagram as SVG. |
| WriteSvg(Stream, SvgRenderOptions?) | Writes the diagram as SVG, encoded in UTF-8 without a byte order mark. |
| WriteSvg(TextWriter, SvgRenderOptions?) | Writes the diagram as SVG. |
CreateScene(ITextMeasurer?)
Diagram.csLays the diagram out into drawing primitives.
public Scene CreateScene(ITextMeasurer? textMeasurer = null)Parameters
textMeasurerITextMeasurer?- The measurer of the texts, or
nullforDiagram.TextMeasurer.
Returns
Scene The scene.
ToSvg(SvgRenderOptions?)
Diagram.csReturns the diagram as SVG.
public string ToSvg(SvgRenderOptions? options = null)Parameters
optionsSvgRenderOptions?- The options, or
nullfor the defaults, with the identifier prefixdiagram.
Returns
string The SVG document, without an XML declaration.
WriteSvg overloads
WriteSvg(Stream, SvgRenderOptions?)
Diagram.csWrites the diagram as SVG, encoded in UTF-8 without a byte order mark.
public void WriteSvg(Stream stream, SvgRenderOptions? options = null)Parameters
streamStream- The destination. It is left open.
optionsSvgRenderOptions?- The options, or
nullfor the defaults, with the identifier prefixdiagram.
WriteSvg(TextWriter, SvgRenderOptions?)
Diagram.csWrites the diagram as SVG.
public void WriteSvg(TextWriter writer, SvgRenderOptions? options = null)Parameters
writerTextWriter- The destination.
optionsSvgRenderOptions?- The options, or
nullfor the defaults, with the identifier prefixdiagram.