Preview


760 × 440 pixels
Create this example
Create a console project, add the ChartForgeX and ChartForgeX.Interactivity.Html packages, and replace Program.cs with this source. Run it to write SVG, PNG and HTML with the default system fonts.
For the same typography as the gallery, download the gallery-font recipe and copy the gallery’s fonts directory beside your program.
using System;
using System.IO;
using ChartForgeX;
using ChartForgeX.Core;
using ChartForgeX.Primitives;
using ChartForgeX.Themes;
using ChartForgeX.Typography;
using ChartForgeX.Interactivity.Html;
var chart=HtmlOwnedFontRecipe.Create("wide",ThemeMode.Light);
Directory.CreateDirectory("output");File.WriteAllText("output/report.svg",chart.ToSvg());File.WriteAllBytes("output/report.png",chart.ToPng());
File.WriteAllText("output/report.html",chart.ToInteractiveHtmlPage(options=>options.TextPresentation=HtmlChartTextPresentation.Automatic));
/// <summary>A native report chart whose HTML adapter can deliver the caller's registered face.</summary>
public static class HtmlOwnedFontRecipe {
/// <summary>Creates the same native chart for static exports and configurable HTML text.</summary>
public static Chart Create(string variant, ThemeMode mode, string? family = null) {
if (variant is not ("wide" or "compact")) throw new ArgumentException("Unknown font report size.", nameof(variant));
var theme = VisualTheme.Graphite(); if (family != null) theme = theme.WithFontFamily(family);
return Chart.Create().Size(variant == "compact" ? 390 : 760, 440).Theme(theme).ThemeMode(mode)
.Title("Review progress").Subtitle("One prepared chart across report formats").XLabels("Received", "Checked", "Approved")
.DataLabels(true).AddBar("Requests", new[] { new ChartPoint(1, 32), new ChartPoint(2, 26), new ChartPoint(3, 21) });
}
}
using System;
using System.IO;
using ChartForgeX;
using ChartForgeX.Core;
using ChartForgeX.Primitives;
using ChartForgeX.Themes;
using ChartForgeX.Typography;
using ChartForgeX.Interactivity.Html;
var chart=HtmlOwnedFontRecipe.Create("wide",ThemeMode.Dark);
Directory.CreateDirectory("output");File.WriteAllText("output/report.svg",chart.ToSvg());File.WriteAllBytes("output/report.png",chart.ToPng());
File.WriteAllText("output/report.html",chart.ToInteractiveHtmlPage(options=>options.TextPresentation=HtmlChartTextPresentation.Automatic));
/// <summary>A native report chart whose HTML adapter can deliver the caller's registered face.</summary>
public static class HtmlOwnedFontRecipe {
/// <summary>Creates the same native chart for static exports and configurable HTML text.</summary>
public static Chart Create(string variant, ThemeMode mode, string? family = null) {
if (variant is not ("wide" or "compact")) throw new ArgumentException("Unknown font report size.", nameof(variant));
var theme = VisualTheme.Graphite(); if (family != null) theme = theme.WithFontFamily(family);
return Chart.Create().Size(variant == "compact" ? 390 : 760, 440).Theme(theme).ThemeMode(mode)
.Title("Review progress").Subtitle("One prepared chart across report formats").XLabels("Received", "Checked", "Approved")
.DataLabels(true).AddBar("Requests", new[] { new ChartPoint(1, 32), new ChartPoint(2, 26), new ChartPoint(3, 21) });
}
}