#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; // Native PNG and standalone SVG use bundled Archivo. // Add ChartFontAssets.StyleSheet once for other text on a host page. var mode = ThemeMode.Light; var theme = VisualTheme.Graphite(); var model = IndependentProgressRecipe.Create("compact", mode); var context = new VisualRenderContext( new VisualLayoutOptions(new VisualSize(390, 207)), theme, mode, new VisualFrame("Progress in each row\u0027s units", "Retained row domains preserve fraction, count and signed measurements", showLegend: null, showSurface: false), FontSpec.FromFamily(ChartFontStacks.ProductSans)); 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 /// Identified progress rows retain their own measurement domain and source units. public static class IndependentProgressRecipe { public static Chart Create(string variant = "wide", ThemeMode mode = ThemeMode.Light) { if (variant is not ("wide" or "compact")) throw new ArgumentOutOfRangeException(nameof(variant)); var rows = ChartSeries.CreateProgressBars(new ChartSeriesId("delivery"), "Delivery", new[] { new ChartProgressItem("Reviewed fraction", .72, 0, 1), new ChartProgressItem("Verified jobs", 1250, 0, 2000), new ChartProgressItem("Temperature change", -8, -20, 20) }).ObservationId(0, new ChartObservationId("reviewed")) .ObservationId(1, new ChartObservationId("verified")) .ObservationId(2, new ChartObservationId("temperature")); return Chart.Create().Size(variant == "compact" ? 390 : 760, 340).Title("Progress in each row's units") .Theme(VisualTheme.Graphite()).ThemeMode(mode).Legend(false).AddSeries(rows); } }