MermaidChart Class

A chart of Mermaid: a pie chart, an XY chart, a quadrant chart, a sankey chart, a treemap or a radar chart. It keeps what the Mermaid text says, so MermaidWriter writes it back, and draws it with a Plot of Meziantou.Framework.Charts, which MermaidChart.ToPlot returns to customize the drawing.

public abstract class MermaidChart : ISceneSource
Implements

Properties

NameDescription
AccessibleTitleGets or sets the accessible name of the chart when it differs from MermaidChart.Title, which is not drawn (Mermaid accTitle).
DescriptionGets or sets the description of the chart for assistive technologies (Mermaid accDescr), which is not drawn.
TextMeasurerGets or sets the measurer of the texts, or null for AfmTextMeasurer.Default.
ThemeGets or sets the theme of Mermaid whose colors and font the chart uses. The default is DiagramTheme.Default.
TitleGets or sets the title, drawn above the chart.

AccessibleTitle

MermaidChart.cs

Gets or sets the accessible name of the chart when it differs from MermaidChart.Title, which is not drawn (Mermaid accTitle).

public string? AccessibleTitle { get; set; }

Property value

string?

Description

MermaidChart.cs

Gets or sets the description of the chart for assistive technologies (Mermaid accDescr), which is not drawn.

public string? Description { get; set; }

Property value

string?

TextMeasurer

MermaidChart.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 theme of Mermaid whose colors and font the chart uses. The default is DiagramTheme.Default.

public DiagramTheme Theme { get; set; }

Property value

DiagramTheme

Gets or sets the title, drawn above the chart.

public string? Title { get; set; }

Property value

string?

Methods

NameDescription
CreateScene(ITextMeasurer?)Lays the chart out into drawing primitives.
ToPlot()Creates the plot that draws the chart. Each call returns a new plot, which you can change before drawing it.
ToSvg(SvgRenderOptions?)Returns the chart as SVG.
WriteSvg(Stream, SvgRenderOptions?)Writes the chart as SVG, encoded in UTF-8 without a byte order mark.
WriteSvg(TextWriter, SvgRenderOptions?)Writes the chart as SVG.

CreateScene(ITextMeasurer?)

MermaidChart.cs

Lays the chart out into drawing primitives.

public Scene CreateScene(ITextMeasurer? textMeasurer = null)

Parameters

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

Returns

Scene The scene.

Creates the plot that draws the chart. Each call returns a new plot, which you can change before drawing it.

public Plot ToPlot()

Returns

Plot The plot, with the title, the description and the colors of MermaidChart.Theme.

ToSvg(SvgRenderOptions?)

MermaidChart.cs

Returns the chart as SVG.

public string ToSvg(SvgRenderOptions? options = null)

Parameters

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

Returns

string The SVG document, without an XML declaration.

WriteSvg overloads

WriteSvg(Stream, SvgRenderOptions?)

MermaidChart.cs

Writes the chart 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 chart.

WriteSvg(TextWriter, SvgRenderOptions?)

MermaidChart.cs

Writes the chart 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 chart.