Preview


520 × 540 pixels
Create this example
Create a console project, add the ChartForgeX package, 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.
#region Setup
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using ChartForgeX;
using ChartForgeX.Core;
using ChartForgeX.Primitives;
using ChartForgeX.Rendering;
using ChartForgeX.Themes;
using ChartForgeX.Topology;
using ChartForgeX.Typography;
using ChartForgeX.VisualArtifacts;
using ChartForgeX.VisualBlocks;
var mode = ThemeMode.Light;
var theme = VisualTheme.Graphite();
var model = ChartGridRecipe.Create("compact", mode);
var context = new VisualRenderContext(
new VisualLayoutOptions(new VisualSize(520, 540)), theme, mode,
new VisualFrame("Requests and capacity", "Shared axes and a spanning panel in a compact viewport", showLegend: true, showSurface: false));
var prepared = model.Prepare(context);
File.WriteAllText("visual.svg", prepared.ToSvg());
File.WriteAllBytes("visual.png", prepared.ToPng());
File.WriteAllText("visual.html", prepared.ToArtifact("example", VisualArtifactKind.Chart).ToHtmlPage());
#endregion
/// <summary>A three-panel comparison with shared Cartesian axes.</summary>
public static class ChartGridRecipe {
public static ChartGrid Create(string variant = "wide", ThemeMode mode = ThemeMode.Light) {
var observations = Enumerable.Range(1, 6).Select(index => new ChartPoint(index, 20 + index * 7 % 29)).ToArray();
var requests = Chart.Create().Title("Observed requests").XLabels("Mon", "Tue", "Wed", "Thu", "Fri", "Sat")
.AddSeries(ChartSeries.CreateLine(new ChartSeriesId("requests"), "Requests", observations));
var reviewed = Chart.Create().Title("Reviewed requests").XLabels("North", "South", "East", "West", "Central", "Online")
.AddSeries(ChartSeries.CreateBar(new ChartSeriesId("orders"), "Orders", observations));
var capacity = Chart.Create().Title("Capacity used").XLabels("Mon", "Tue", "Wed", "Thu", "Fri", "Sat")
.AddSeries(ChartSeries.CreateArea(new ChartSeriesId("used-capacity"), "Used capacity", observations));
return ChartGrid.Create().Columns(2).Gap(16).PanelSize(600, 375)
.Add(requests).Add(reviewed).Add(capacity, 2).ShareAxes();
}
}
#region Setup
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using ChartForgeX;
using ChartForgeX.Core;
using ChartForgeX.Primitives;
using ChartForgeX.Rendering;
using ChartForgeX.Themes;
using ChartForgeX.Topology;
using ChartForgeX.Typography;
using ChartForgeX.VisualArtifacts;
using ChartForgeX.VisualBlocks;
var mode = ThemeMode.Dark;
var theme = VisualTheme.Graphite();
var model = ChartGridRecipe.Create("compact", mode);
var context = new VisualRenderContext(
new VisualLayoutOptions(new VisualSize(520, 540)), theme, mode,
new VisualFrame("Requests and capacity", "Shared axes and a spanning panel in a compact viewport", showLegend: true, showSurface: false));
var prepared = model.Prepare(context);
File.WriteAllText("visual.svg", prepared.ToSvg());
File.WriteAllBytes("visual.png", prepared.ToPng());
File.WriteAllText("visual.html", prepared.ToArtifact("example", VisualArtifactKind.Chart).ToHtmlPage());
#endregion
/// <summary>A three-panel comparison with shared Cartesian axes.</summary>
public static class ChartGridRecipe {
public static ChartGrid Create(string variant = "wide", ThemeMode mode = ThemeMode.Light) {
var observations = Enumerable.Range(1, 6).Select(index => new ChartPoint(index, 20 + index * 7 % 29)).ToArray();
var requests = Chart.Create().Title("Observed requests").XLabels("Mon", "Tue", "Wed", "Thu", "Fri", "Sat")
.AddSeries(ChartSeries.CreateLine(new ChartSeriesId("requests"), "Requests", observations));
var reviewed = Chart.Create().Title("Reviewed requests").XLabels("North", "South", "East", "West", "Central", "Online")
.AddSeries(ChartSeries.CreateBar(new ChartSeriesId("orders"), "Orders", observations));
var capacity = Chart.Create().Title("Capacity used").XLabels("Mon", "Tue", "Wed", "Thu", "Fri", "Sat")
.AddSeries(ChartSeries.CreateArea(new ChartSeriesId("used-capacity"), "Used capacity", observations));
return ChartGrid.Create().Columns(2).Gap(16).PanelSize(600, 375)
.Add(requests).Add(reviewed).Add(capacity, 2).ShareAxes();
}
}