Overview

edit

Some types of Mermaid diagrams are charts of data. The package reads them into a model of its own, which keeps what the Mermaid text says so that MermaidWriter writes it back, and draws them with Meziantou.Framework.Charts:

ChartTypeMermaid keyword
Pie chartPieChartpie
XY chartXyChartxychart, xychart-beta
Quadrant chartQuadrantChartquadrantChart
Sankey chartSankeyChartsankey, sankey-beta
Radar chartRadarChartradar-beta
TreemapTreemapCharttreemap, treemap-beta

Every chart derives from MermaidChart, which gives it a Title, an accessible Description, the Theme of Mermaid whose colors it uses, and the SVG output.

Customize the drawing

ToPlot returns the Plot that draws the chart. Change it to go beyond what Mermaid can say, then draw it as any other plot:

var chart = (PieChart)MermaidDocument.Parse("""
    pie title Pets adopted by volunteers
        "Dogs" : 386
        "Cats" : 85
        "Rats" : 15
    """).Content;

var plot = chart.ToPlot();
plot.Subtitle = "Source: the shelter, 2025";
plot.Width = 600;
var svg = plot.ToSvg();

The charts look like the other charts of Meziantou.Framework.Charts, in the colors of the Mermaid theme: they are not drawn like Mermaid's own output.