Class ChartSceneBuilder
Collects the marks, data points, axes, legend and table of a ChartScene.
public sealed class ChartSceneBuilder
- Inheritance
-
ChartSceneBuilder
- Inherited Members
Remarks
The first group of methods adds raw marks at plot percentages. The second group works in "band and value" terms and respects Horizontal, so one chart definition can draw both as columns and as bars.
Constructors
ChartSceneBuilder()
public ChartSceneBuilder()
Properties
Horizontal
Gets or sets whether values run left to right with categories stacked top to bottom (bars), instead of values running bottom to top with categories left to right (columns).
public bool Horizontal { get; set; }
Property Value
Shape
Gets or sets the proportions of the plot area.
public ChartShape Shape { get; set; }
Property Value
Table
Gets or sets the chart's data as a table.
public ChartTable? Table { get; set; }
Property Value
XAxis
Gets or sets the labels along the bottom of the plot area.
public ChartAxis? XAxis { get; set; }
Property Value
YAxis
Gets or sets the labels along the left of the plot area.
public ChartAxis? YAxis { get; set; }
Property Value
Methods
Add(IChartMark)
Adds any mark.
public void Add(IChartMark mark)
Parameters
markIChartMark
BandAxis(IReadOnlyList<string>, ChartBand, string?)
Adds category axis labels, one per slot. Along the bottom, labels are thinned out once there are too many to read.
public void BandAxis(IReadOnlyList<string> labels, ChartBand band, string? title = null)
Parameters
labelsIReadOnlyList<string>bandChartBandtitlestring
BandDatum(double, double, string, IReadOnlyList<ChartDatumRow>, ChartHover)
Adds an interactive data point covering one whole category slot.
public void BandDatum(double band, double size, string title, IReadOnlyList<ChartDatumRow> rows, ChartHover hover = ChartHover.Highlight)
Parameters
banddoublesizedoubletitlestringrowsIReadOnlyList<ChartDatumRow>hoverChartHover
Bar(double, double, double, double, ChartColor, ChartCorner?, bool)
Adds a bar across the category axis at band, spanning from to
to on the value axis. Unless corner is given, only the data end is rounded.
Set gap to false for a bar layered over another, which needs no separating gap.
public void Bar(double band, double thickness, double from, double to, ChartColor color, ChartCorner? corner = null, bool gap = true)
Parameters
banddoublethicknessdoublefromdoubletodoublecolorChartColorcornerChartCorner?gapbool
Baseline(double)
Adds the baseline that bars grow from.
public void Baseline(double value)
Parameters
valuedouble
Build()
Creates the scene.
public ChartScene Build()
Returns
Datum(double, double, double, double, string, IReadOnlyList<ChartDatumRow>, ChartHover)
Adds an interactive data point, positioned by its center.
public void Datum(double x, double y, double width, double height, string title, IReadOnlyList<ChartDatumRow> rows, ChartHover hover = ChartHover.Highlight)
Parameters
xdoubleydoublewidthdoubleheightdoubletitlestringrowsIReadOnlyList<ChartDatumRow>hoverChartHover
Datum(ChartDatum)
Adds an interactive data point built by the caller, such as one with a tooltip anchor.
public void Datum(ChartDatum datum)
Parameters
datumChartDatum
Dot(double, double, ChartColor, double, double, string?)
Adds a dot. diameter is in pixels.
public void Dot(double x, double y, ChartColor color, double diameter = 10, double opacity = 1, string? title = null)
Parameters
Glyph(double, double, Icon, ChartColor, double)
Adds an icon. size is in pixels.
public void Glyph(double x, double y, Icon icon, ChartColor color, double size = 20)
Parameters
xdoubleydoubleiconIconcolorChartColorsizedouble
Legend(string, ChartColor, int?, bool)
Adds a legend entry.
public void Legend(string label, ChartColor color, int? seriesIndex = null, bool hidden = false)
Parameters
labelstringcolorChartColorseriesIndexint?hiddenbool
Line(double, double, double, double, ChartColor, ChartStroke)
Adds a straight line.
public void Line(double x1, double y1, double x2, double y2, ChartColor color, ChartStroke stroke = ChartStroke.Hairline)
Parameters
x1doubley1doublex2doubley2doublecolorChartColorstrokeChartStroke
Marker(double, double, ChartColor, double, double, string?)
Adds a dot at a band and value position.
public void Marker(double band, double value, ChartColor color, double diameter = 10, double opacity = 1, string? title = null)
Parameters
Path(string, ChartColor, bool, double, ChartStroke, bool, string?)
Adds an SVG path.
public void Path(string data, ChartColor color, bool filled = false, double opacity = 1, ChartStroke stroke = ChartStroke.Normal, bool outline = false, string? title = null)
Parameters
datastringcolorChartColorfilledboolopacitydoublestrokeChartStrokeoutlinebooltitlestring
Point(double, double)
Converts a position along the category axis and a position along the value axis into a plot point.
public (double X, double Y) Point(double band, double value)
Parameters
Returns
Rect(double, double, double, double, ChartColor, ChartCorner, double)
Adds a filled rectangle. For the less common options, pass a ChartRect to Add(IChartMark).
public void Rect(double x, double y, double width, double height, ChartColor color, ChartCorner corner = ChartCorner.None, double opacity = 1)
Parameters
xdoubleydoublewidthdoubleheightdoublecolorChartColorcornerChartCorneropacitydouble
SectorDatum(ChartSector, string, IReadOnlyList<ChartDatumRow>, double?)
Adds an interactive data point that covers a ChartSector, so the pointer triggers it anywhere on the segment. Use it on a Square plot.
public void SectorDatum(ChartSector sector, string title, IReadOnlyList<ChartDatumRow> rows, double? anchorAngle = null)
Parameters
sectorChartSectortitlestringrowsIReadOnlyList<ChartDatumRow>anchorAngledouble?
Remarks
The tooltip points at the middle of the segment's thickness (65% of the way out on a wedge), at
anchorAngle or halfway round the segment when that is not given.
Segment(double, double, double, double, ChartColor, ChartStroke)
Adds a line between two band and value positions.
public void Segment(double band1, double value1, double band2, double value2, ChartColor color, ChartStroke stroke = ChartStroke.Normal)
Parameters
band1doublevalue1doubleband2doublevalue2doublecolorChartColorstrokeChartStroke
ShapeDatum(IReadOnlyList<(double X, double Y)>, string, IReadOnlyList<ChartDatumRow>, (double X, double Y)?)
Adds an interactive data point cut to an outline, so the pointer triggers it anywhere on an irregular shape such as an area, a ribbon or a hexagon.
public void ShapeDatum(IReadOnlyList<(double X, double Y)> outline, string title, IReadOnlyList<ChartDatumRow> rows, (double X, double Y)? anchor = null)
Parameters
outlineIReadOnlyList<(double X, double Y)>The corners of the shape, in order, as plot percentages.
titlestringThe title of the tooltip.
rowsIReadOnlyList<ChartDatumRow>The rows of the tooltip.
anchor(double X, double Y)?The plot position the tooltip points at. Without one it sits above the middle of the shape.
Text(double, double, string, ChartAnchor, ChartBaseline, ChartTextTone)
Adds a text label. For pixel offsets and emphasis, pass a ChartText to Add(IChartMark).
public void Text(double x, double y, string text, ChartAnchor anchor = ChartAnchor.Middle, ChartBaseline baseline = ChartBaseline.Middle, ChartTextTone tone = ChartTextTone.Muted)
Parameters
xdoubleydoubletextstringanchorChartAnchorbaselineChartBaselinetoneChartTextTone
TipLabel(double, double, string, bool)
Adds a value label just past the data end of a bar.
public void TipLabel(double band, double value, string text, bool rising = true)
Parameters
ValueAxis(IReadOnlyList<ChartTick>, string?)
Adds value axis labels and gridlines at the given positions along the value axis.
public void ValueAxis(IReadOnlyList<ChartTick> ticks, string? title = null)
Parameters
ticksIReadOnlyList<ChartTick>titlestring
ValueAxis(ChartScale, Func<double, string>, string?)
Adds value axis labels and gridlines from a scale.
public void ValueAxis(ChartScale scale, Func<double, string> format, string? title = null)
Parameters
scaleChartScaleformatFunc<double, string>titlestring