Preview


800 × 440 pixels
Create this example
Register the included Carlito font files to reproduce the exported typography.
using ChartForgeX.Core;
using ChartForgeX.Primitives;
using ChartForgeX.Rendering;
using ChartForgeX.Themes;
using ChartForgeX.Typography;
// The generated gallery includes these licensed font fixtures beside the outputs.
FontRegistry.Register("CFX Proof Carlito", "fonts/Carlito-Regular.ttf", 400);
FontRegistry.Register("CFX Proof Carlito", "fonts/Carlito-Bold.ttf", 700);
var chart = Chart.Create();
chart.WithXLabels("Day 1", "Day 2", "Day 3", "Day 4", "Day 5", "Day 6", "Day 7");
chart.AddLine("Observed", new ChartPoint[] { new ChartPoint(1, 20), new ChartPoint(2, 23), new ChartPoint(3, 26), new ChartPoint(4, 29), new ChartPoint(5, 32), new ChartPoint(6, 35), new ChartPoint(7, 38) });
chart.Series[0].WithColor(ChartColor.FromHex("#1D8A52"));
chart.AddArea("Expected", new ChartPoint[] { new ChartPoint(1, 34), new ChartPoint(2, 38), new ChartPoint(3, 42), new ChartPoint(4, 46), new ChartPoint(5, 50), new ChartPoint(6, 54), new ChartPoint(7, 35) });
chart.Series[1].WithColor(ChartColor.FromHex("#C78404"));
chart.AddBar("Capacity", new ChartPoint[] { new ChartPoint(1, 48), new ChartPoint(2, 53), new ChartPoint(3, 58), new ChartPoint(4, 63), new ChartPoint(5, 68), new ChartPoint(6, 50), new ChartPoint(7, 55) });
chart.Series[2].WithColor(ChartColor.FromHex("#D4302F"));
var context = new VisualRenderContext(new VisualLayoutOptions(new VisualSize(800, 440)), VisualTheme.Graphite(), VisualThemeMode.Light,
new VisualFrame("Checks over the reporting period", "One prepared scene for SVG and native PNG", showSurface: false), FontSpec.FromFamily("CFX Proof Carlito"));
var prepared = chart.Prepare(context);
System.IO.File.WriteAllText("chart.svg", prepared.ToSvg());
System.IO.File.WriteAllBytes("chart.png", prepared.ToPng());
using ChartForgeX.Core;
using ChartForgeX.Primitives;
using ChartForgeX.Rendering;
using ChartForgeX.Themes;
using ChartForgeX.Typography;
// The generated gallery includes these licensed font fixtures beside the outputs.
FontRegistry.Register("CFX Proof Carlito", "fonts/Carlito-Regular.ttf", 400);
FontRegistry.Register("CFX Proof Carlito", "fonts/Carlito-Bold.ttf", 700);
var chart = Chart.Create();
chart.WithXLabels("Day 1", "Day 2", "Day 3", "Day 4", "Day 5", "Day 6", "Day 7");
chart.AddLine("Observed", new ChartPoint[] { new ChartPoint(1, 20), new ChartPoint(2, 23), new ChartPoint(3, 26), new ChartPoint(4, 29), new ChartPoint(5, 32), new ChartPoint(6, 35), new ChartPoint(7, 38) });
chart.Series[0].WithColor(ChartColor.FromHex("#4CC78A"));
chart.AddArea("Expected", new ChartPoint[] { new ChartPoint(1, 34), new ChartPoint(2, 38), new ChartPoint(3, 42), new ChartPoint(4, 46), new ChartPoint(5, 50), new ChartPoint(6, 54), new ChartPoint(7, 35) });
chart.Series[1].WithColor(ChartColor.FromHex("#EEB640"));
chart.AddBar("Capacity", new ChartPoint[] { new ChartPoint(1, 48), new ChartPoint(2, 53), new ChartPoint(3, 58), new ChartPoint(4, 63), new ChartPoint(5, 68), new ChartPoint(6, 50), new ChartPoint(7, 55) });
chart.Series[2].WithColor(ChartColor.FromHex("#F47171"));
var context = new VisualRenderContext(new VisualLayoutOptions(new VisualSize(800, 440)), VisualTheme.Graphite(), VisualThemeMode.Dark,
new VisualFrame("Checks over the reporting period", "One prepared scene for SVG and native PNG", showSurface: false), FontSpec.FromFamily("CFX Proof Carlito"));
var prepared = chart.Prepare(context);
System.IO.File.WriteAllText("chart.svg", prepared.ToSvg());
System.IO.File.WriteAllBytes("chart.png", prepared.ToPng());