PieChart Class

A pie chart: slices whose angles are proportional to their values, labeled with their percentages, and a legend (Mermaid pie). The slices are drawn clockwise from the top, in their order.

public sealed class PieChart : MermaidChart

Remarks

As Mermaid, the slices smaller than 1% of the total are not drawn, but the legend lists them.

The chart is drawn with Plot: a pie of the radius of the pies of Mermaid, in the colors of the pie1 to pie12 theme variables of Mermaid, with the legend of Meziantou.Framework.Charts. MermaidChart.ToPlot returns the plot to customize it.

Inheritance
MermaidChart PieChart

Constructors

NameDescription
PieChart()

PieChart()

PieChart.cs
public PieChart()

No documentation is available.

Properties

NameDescription
DonutHoleGets or sets the radius of the hole in the middle of the pie, as a ratio of its radius, from 0 for a full pie to 0.9 (Mermaid donutHole). The default is 0.
HighlightedSliceGets or sets the label of the slice drawn highlighted: bigger and opaque (Mermaid highlightSlice).
LegendPositionGets or sets the position of the legend. The default is PieLegendPosition.Right. PieLegendPosition.Left and PieLegendPosition.Center are written back, but the legend is drawn on the right: Meziantou.Framework.Charts draws no legend there.
LegendTextColorGets or sets the color of the texts of the legend, which the title uses too (Mermaid pieLegendTextColor). The default depends on the theme.
LegendTextSizeGets or sets the font size of the texts of the legend (Mermaid pieLegendTextSize). The default is 17.
OpacityGets or sets the opacity of the slices, from 0 to 1 (Mermaid pieOpacity). The default is 0.7.
OuterStrokeColorGets or sets the color of the circle around the pie (Mermaid pieOuterStrokeColor). The default is black.
OuterStrokeWidthGets or sets the width of the circle around the pie (Mermaid pieOuterStrokeWidth). The default is 2.
SectionTextColorGets or sets the color of the percentages (Mermaid pieSectionTextColor). The default is the text color of the theme.
SectionTextSizeGets or sets the font size of the percentages (Mermaid pieSectionTextSize). The default is 17.
ShowDataGets or sets a value that indicates whether the legend writes the value of each slice after its label (Mermaid showData).
SliceColorsGets the colors of the slices, by position of the slice, which replace the colors of the theme (Mermaid pie1...pie12, for the positions 0 to 11). The colors repeat every 12 slices.
SlicesGets the slices, in the order they are drawn, clockwise from the top.
StrokeColorGets or sets the color of the borders of the slices (Mermaid pieStrokeColor). The default is black.
StrokeWidthGets or sets the width of the borders of the slices (Mermaid pieStrokeWidth). The default is 2.
TextPositionGets or sets the distance of the percentages from the center, from 0 at the center to 1 on the edge of the pie (Mermaid textPosition). The default is 0.75.

DonutHole

PieChart.cs

Gets or sets the radius of the hole in the middle of the pie, as a ratio of its radius, from 0 for a full pie to 0.9 (Mermaid donutHole). The default is 0.

public double DonutHole { get; set; }

Property value

double

HighlightedSlice

PieChart.cs

Gets or sets the label of the slice drawn highlighted: bigger and opaque (Mermaid highlightSlice).

public string? HighlightedSlice { get; set; }

Property value

string?

LegendPosition

PieChart.cs

Gets or sets the position of the legend. The default is PieLegendPosition.Right. PieLegendPosition.Left and PieLegendPosition.Center are written back, but the legend is drawn on the right: Meziantou.Framework.Charts draws no legend there.

public PieLegendPosition LegendPosition { get; set; }

Property value

PieLegendPosition

LegendTextColor

PieChart.cs

Gets or sets the color of the texts of the legend, which the title uses too (Mermaid pieLegendTextColor). The default depends on the theme.

public SceneColor? LegendTextColor { get; set; }

Property value

SceneColor?

LegendTextSize

PieChart.cs

Gets or sets the font size of the texts of the legend (Mermaid pieLegendTextSize). The default is 17.

public double? LegendTextSize { get; set; }

Property value

double?

Gets or sets the opacity of the slices, from 0 to 1 (Mermaid pieOpacity). The default is 0.7.

public double? Opacity { get; set; }

Property value

double?

OuterStrokeColor

PieChart.cs

Gets or sets the color of the circle around the pie (Mermaid pieOuterStrokeColor). The default is black.

public SceneColor? OuterStrokeColor { get; set; }

Property value

SceneColor?

OuterStrokeWidth

PieChart.cs

Gets or sets the width of the circle around the pie (Mermaid pieOuterStrokeWidth). The default is 2.

public double? OuterStrokeWidth { get; set; }

Property value

double?

SectionTextColor

PieChart.cs

Gets or sets the color of the percentages (Mermaid pieSectionTextColor). The default is the text color of the theme.

public SceneColor? SectionTextColor { get; set; }

Property value

SceneColor?

SectionTextSize

PieChart.cs

Gets or sets the font size of the percentages (Mermaid pieSectionTextSize). The default is 17.

public double? SectionTextSize { get; set; }

Property value

double?

ShowData

PieChart.cs

Gets or sets a value that indicates whether the legend writes the value of each slice after its label (Mermaid showData).

public bool ShowData { get; set; }

Property value

bool

SliceColors

PieChart.cs

Gets the colors of the slices, by position of the slice, which replace the colors of the theme (Mermaid pie1...pie12, for the positions 0 to 11). The colors repeat every 12 slices.

public IDictionary<int, SceneColor> SliceColors { get; }

Gets the slices, in the order they are drawn, clockwise from the top.

public IList<PieSlice> Slices { get; }

Property value

IList<PieSlice>

StrokeColor

PieChart.cs

Gets or sets the color of the borders of the slices (Mermaid pieStrokeColor). The default is black.

public SceneColor? StrokeColor { get; set; }

Property value

SceneColor?

StrokeWidth

PieChart.cs

Gets or sets the width of the borders of the slices (Mermaid pieStrokeWidth). The default is 2.

public double? StrokeWidth { get; set; }

Property value

double?

TextPosition

PieChart.cs

Gets or sets the distance of the percentages from the center, from 0 at the center to 1 on the edge of the pie (Mermaid textPosition). The default is 0.75.

public double TextPosition { get; set; }

Property value

double

Methods

NameDescription
AddSlice(string, double)Adds a slice after the last one.

AddSlice(string, double)

PieChart.cs

Adds a slice after the last one.

public PieSlice AddSlice(string label, double value)

Parameters

label string
The label of the slice.
value double
The value of the slice, positive or zero.

Returns

PieSlice The slice.