Meziantou.Framework.Charts
1.0.2
Prefix Reserved
dotnet add package Meziantou.Framework.Charts --version 1.0.2
NuGet\Install-Package Meziantou.Framework.Charts -Version 1.0.2
<PackageReference Include="Meziantou.Framework.Charts" Version="1.0.2" />
<PackageVersion Include="Meziantou.Framework.Charts" Version="1.0.2" />
<PackageReference Include="Meziantou.Framework.Charts" />
paket add Meziantou.Framework.Charts --version 1.0.2
#r "nuget: Meziantou.Framework.Charts, 1.0.2"
#:package Meziantou.Framework.Charts@1.0.2
#addin nuget:?package=Meziantou.Framework.Charts&version=1.0.2
#tool nuget:?package=Meziantou.Framework.Charts&version=1.0.2
Meziantou.Framework.Charts
Creates charts and writes them as SVG, with a grammar of graphics: a plot is made of marks (bars, lines, dots, arcs, rectangles...), whose channels are mapped by scales and placed by Cartesian or polar coordinates. Bar, line, area, scatter, bubble, pie, donut, radar, gauge, packed circles, treemap, sunburst, icicle, histogram, box plot, heatmap, waterfall, funnel and candlestick charts are combinations of these pieces. The output is deterministic.
Usage
The types are in the Meziantou.Framework.Charts namespace.
public sealed record Sale(string Region, int Year, double Amount);
Sale[] sales =
[
new("North", 2024, 150),
new("South", 2024, 95),
new("East", 2024, 105),
new("West", 2024, 160),
];
var plot = new Plot { Title = "Sales by region", Subtitle = "2024, in thousands of euros" };
plot.Add(new BarMark<Sale>(sales, x: sale => sale.Region, y: sale => sale.Amount));
var svg = plot.ToSvg();
The scales, axes, margins and legend are inferred from the marks. Stack bars with a transform:
var plot = new Plot { Title = "Sales by region, stacked by year" };
plot.Add(new BarMark<Sale>(SampleData.Sales, x: sale => sale.Region, y: sale => sale.Amount)
{
Fill = sale => sale.Year,
Transform = new StackTransform(),
});
A pie is an arc mark, in the polar coordinates the plot uses by default for it:
Share[] shares = [new("Chrome", 64), new("Safari", 19), new("Edge", 5), new("Firefox", 3), new("Other", 9)];
var plot = new Plot { Title = "Browser market share", Width = 400, Height = 400 };
plot.Add(new ArcMark<Share>(shares, value: share => share.Value)
{
Fill = share => share.Name,
Label = share => share.Value.ToString(CultureInfo.InvariantCulture) + "%",
});
Text measurement
The layout measures the texts with the metrics of Helvetica (AfmTextMeasurer), embedded in
Meziantou.Framework.Fonts: no font file is needed, and the result is the same on every machine. FontFaceTextMeasurer
measures with a font file instead, for other scripts or fonts.
Images
Meziantou.Framework.Imaging.VectorGraphics draws the same charts as PNG, WebP or JPEG images, or on an image canvas.
Both renderers draw the Scene that Plot.CreateScene lays out.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. net11.0 is compatible. |
-
net10.0
- Meziantou.Framework.Geo (>= 1.0.2)
- Meziantou.Framework.VectorGraphics (>= 1.0.1)
-
net11.0
- Meziantou.Framework.Geo (>= 1.0.2)
- Meziantou.Framework.VectorGraphics (>= 1.0.1)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Meziantou.Framework.Charts:
| Package | Downloads |
|---|---|
|
Meziantou.Framework.Imaging.Charts
Renders the charts of Meziantou.Framework.Charts with Meziantou.Framework.Imaging: images in any format (PNG, WebP, JPEG...), or vector drawing on a canvas, with embedded Liberation Sans fonts. |
|
|
Meziantou.Framework.Mermaid
Reads and writes the Mermaid text format: the 25 diagram types of Meziantou.Framework.Diagrams, and the pie, XY, quadrant, sankey and radar charts and treemaps of Mermaid drawn with Meziantou.Framework.Charts, with the front matter, the directives and the themes of Mermaid. |
GitHub repositories
This package is not used by any popular GitHub repositories.