ChartImageRenderer Class
Draws the charts of Meziantou.Framework.Charts as images, or on a DrawingCanvas.
public static class ChartImageRendererRemarks
The plot is laid out with the fonts that draw it (ImageTextMeasurer), so the margins, the rotated labels and the truncated labels fit the text. Save the image in any format: image.Save("chart.png").
Methods
| Name | Description |
|---|---|
| CreateMeasurer(ChartImageOptions?) | Creates the text measurer of the fonts of the options, to lay a plot out with Plot.CreateScene. |
| DrawChart(DrawingCanvas, Plot, PointD, ChartImageOptions?) | Draws a plot on a canvas, as vector shapes and text. |
| DrawChartScene(DrawingCanvas, ChartScene, PointD, ChartImageOptions?) | Draws a scene on a canvas, as vector shapes and text. |
| MeasureChart(Plot, ChartImageOptions?) | Measures the rectangle that ChartImageRenderer.DrawChart covers. |
| ToImage(ChartScene, ChartImageOptions?) | Renders a scene as an image of its size times ChartImageOptions.Scale, rounded up. |
| ToImage(Plot, ChartImageOptions?) | Renders a plot as an image of its size times ChartImageOptions.Scale, rounded up. |
CreateMeasurer(ChartImageOptions?)
ChartImageRenderer.csCreates the text measurer of the fonts of the options, to lay a plot out with Plot.CreateScene.
public static ImageTextMeasurer CreateMeasurer(ChartImageOptions? options = null)Parameters
optionsChartImageOptions?- The options, or
nullfor the defaults.
Returns
ImageTextMeasurer The measurer.
DrawChart(DrawingCanvas, Plot, PointD, ChartImageOptions?)
ChartImageRenderer.csDraws a plot on a canvas, as vector shapes and text.
public static RectangleD DrawChart(this DrawingCanvas canvas, Plot plot, PointD position, ChartImageOptions? options = null)Parameters
canvasDrawingCanvas- The canvas.
plotPlot- The plot.
positionPointD- The top-left corner of the chart.
optionsChartImageOptions?- The options, or
nullfor the defaults.
Returns
RectangleD The rectangle the chart covers.
Remarks
The chart is drawn in the coordinates of the canvas, so the transform, clip and layers of the canvas apply.
DrawChartScene(DrawingCanvas, ChartScene, PointD, ChartImageOptions?)
ChartImageRenderer.csDraws a scene on a canvas, as vector shapes and text.
public static RectangleD DrawChartScene(this DrawingCanvas canvas, ChartScene scene, PointD position, ChartImageOptions? options = null)Parameters
canvasDrawingCanvas- The canvas.
sceneChartScene- The scene, laid out with
ChartImageRenderer.CreateMeasurerso its texts fit. positionPointD- The top-left corner of the chart.
optionsChartImageOptions?- The options, or
nullfor the defaults.
Returns
RectangleD The rectangle the chart covers.
MeasureChart(Plot, ChartImageOptions?)
ChartImageRenderer.csMeasures the rectangle that ChartImageRenderer.DrawChart covers.
public static RectangleD MeasureChart(Plot plot, ChartImageOptions? options = null)Parameters
plotPlot- The plot.
optionsChartImageOptions?- The options, or
nullfor the defaults.
Returns
RectangleD The size of the drawing, as a rectangle located at the origin.
ToImage overloads
ToImage(ChartScene, ChartImageOptions?)
ChartImageRenderer.csRenders a scene as an image of its size times ChartImageOptions.Scale, rounded up.
public static Image<Rgba32> ToImage(this ChartScene scene, ChartImageOptions? options = null)Parameters
sceneChartScene- The scene, laid out with
ChartImageRenderer.CreateMeasurerso its texts fit. optionsChartImageOptions?- The options, or
nullfor the defaults.
Returns
Image<Rgba32> A single-frame image. The caller owns it and must dispose it.
Exceptions
ArgumentOutOfRangeException- The image is too large.
ToImage(Plot, ChartImageOptions?)
ChartImageRenderer.csRenders a plot as an image of its size times ChartImageOptions.Scale, rounded up.
public static Image<Rgba32> ToImage(this Plot plot, ChartImageOptions? options = null)Parameters
plotPlot- The plot.
optionsChartImageOptions?- The options, or
nullfor the defaults.
Returns
Image<Rgba32> A single-frame image. The caller owns it and must dispose it.