using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; using ChartForgeX.Core; using ChartForgeX.Primitives; using ChartForgeX.Rendering; using ChartForgeX.Themes; using ChartForgeX.Topology; using ChartForgeX.Typography; using ChartForgeX.VisualArtifacts; using ChartForgeX.VisualBlocks; // Optional exact gallery typography; copy the gallery's fonts directory beside this program. FontRegistry.Register("CFX Proof Carlito", "fonts/Carlito-Regular.ttf", 400); FontRegistry.Register("CFX Proof Carlito", "fonts/Carlito-Bold.ttf", 700); var mode = VisualThemeMode.Light; var theme = VisualTheme.Graphite(); var model = BubblePlotRegionsRecipe.Create("plot-regions", mode); var context = new VisualRenderContext( new VisualLayoutOptions(new VisualSize(800, 440)), theme, mode, new VisualFrame("Capacity and delay", "Bounded operating guidance leaves source values and bubble sizes independent", showLegend: null, showSurface: false), FontSpec.FromFamily("CFX Proof Carlito")); 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()); /// Shows work queues against bounded target and review regions. public static class BubblePlotRegionsRecipe { /// Creates the selected example without choosing a renderer or export backend. public static Chart Create(string variant = "plot-regions", VisualThemeMode mode = VisualThemeMode.Light) { if (variant is not ("plot-regions" or "compact-plot-regions")) throw new ArgumentOutOfRangeException(nameof(variant)); return PlotRegions().WithValueFormat(ChartValueFormat.Number("0.##", CultureInfo.InvariantCulture)); } private static Chart PlotRegions() { var queues = ChartSeries.CreateBubble(new ChartSeriesId("work-queues"), "Work queues", new[] { new ChartBubble(1.2, 8.2, 12), new ChartBubble(3.2, 5.1, 36), new ChartBubble(5.9, 4.2, 20), new ChartBubble(8.1, 3.8, 49), new ChartBubble(8.7, 7.9, 16) }); return Chart.Create().WithXAxisBounds(0, 10).WithYAxisBounds(0, 10).WithDataLabels(false) .WithXAxis("Delay (hours)").WithYAxis("Available capacity (score)").AddSeries(queues) .ConfigureBubble(options => { options.MinimumRadius = 5; options.MaximumRadius = 14; }) .AddPlotRegion(new(ChartColor.FromHex("#5487b8"), xMinimum: 2, xMaximum: 7, yMinimum: 3, yMaximum: 7, label: "Target", opacity: .16)) .AddPlotRegion(new(ChartColor.FromHex("#ba6d67"), xMinimum: 7, yMaximum: 3, label: "Review", opacity: .18)); } }