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

NameDescription
AccessibleTitleGets or sets the accessible name of the diagram when it differs from Diagram.Title, which is not drawn (Mermaid accTitle).
DescriptionGets or sets the accessible description of the diagram (Mermaid accDescr).
PaddingGets or sets the space around the diagram, in pixels. The default is 8.
TextMeasurerGets or sets the measurer of the texts, or null for AfmTextMeasurer.Default.
ThemeGets or sets the colors and the font of the diagram. The default is DiagramTheme.Default.
TitleGets or sets the title, drawn above the diagram. It is also the accessible name of the SVG.

AccessibleTitle

Diagram.cs

Gets 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

string?

Description

Diagram.cs

Gets or sets the accessible description of the diagram (Mermaid accDescr).

public string? Description { get; set; }

Property value

string?

Padding

Diagram.cs

Gets or sets the space around the diagram, in pixels. The default is 8.

public double Padding { get; set; }

Property value

double

Exceptions

ArgumentOutOfRangeException
The value is negative or not finite.

TextMeasurer

Diagram.cs

Gets or sets the measurer of the texts, or null for AfmTextMeasurer.Default.

public ITextMeasurer? TextMeasurer { get; set; }

Property value

ITextMeasurer?

Gets or sets the colors and the font of the diagram. The default is DiagramTheme.Default.

public DiagramTheme Theme { get; set; }

Property value

DiagramTheme

Gets or sets the title, drawn above the diagram. It is also the accessible name of the SVG.

public string? Title { get; set; }

Property value

string?

Methods

NameDescription
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.cs

Lays the diagram out into drawing primitives.

public Scene CreateScene(ITextMeasurer? textMeasurer = null)

Parameters

textMeasurer ITextMeasurer?
The measurer of the texts, or null for Diagram.TextMeasurer.

Returns

Scene The scene.

ToSvg(SvgRenderOptions?)

Diagram.cs

Returns the diagram as SVG.

public string ToSvg(SvgRenderOptions? options = null)

Parameters

options SvgRenderOptions?
The options, or null for the defaults, with the identifier prefix diagram.

Returns

string The SVG document, without an XML declaration.

WriteSvg overloads

WriteSvg(Stream, SvgRenderOptions?)

Diagram.cs

Writes the diagram as SVG, encoded in UTF-8 without a byte order mark.

public void WriteSvg(Stream stream, SvgRenderOptions? options = null)
Parameters
stream Stream
The destination. It is left open.
options SvgRenderOptions?
The options, or null for the defaults, with the identifier prefix diagram.

WriteSvg(TextWriter, SvgRenderOptions?)

Diagram.cs

Writes the diagram as SVG.

public void WriteSvg(TextWriter writer, SvgRenderOptions? options = null)
Parameters
writer TextWriter
The destination.
options SvgRenderOptions?
The options, or null for the defaults, with the identifier prefix diagram.