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 = BubbleMarkerOptionsRecipe.Create("options", mode); var context = new VisualRenderContext( new VisualLayoutOptions(new VisualSize(800, 440)), theme, mode, new VisualFrame("Workload, time and request volume", "Equal request volumes share a radius; values above 100 retain their facts", 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()); /// Compares standard and priority observations with independent bubble markers. public static class BubbleMarkerOptionsRecipe { /// Creates the selected example without choosing a renderer or export backend. public static Chart Create(string variant = "options", VisualThemeMode mode = VisualThemeMode.Light) { if (variant is not ("options" or "compact-options")) throw new ArgumentOutOfRangeException(nameof(variant)); return MarkerOptions().WithValueFormat(ChartValueFormat.Number("0.##", CultureInfo.InvariantCulture)); } private static Chart MarkerOptions() { var standard = ChartSeries.CreateBubble(new ChartSeriesId("standard"), "Standard", new[] { new ChartBubble(1, 18, 9), new ChartBubble(2, 30, 36), new ChartBubble(3, 24, 81) }).ConfigureMarkers(markers => markers.Shape = ChartMarkerShape.Circle); var priority = ChartSeries.CreateBubble(new ChartSeriesId("priority"), "Priority", new[] { new ChartBubble(1.5, 32, 16), new ChartBubble(2.5, 20, 36), new ChartBubble(3.5, 36, 200) }).ConfigureMarkers(markers => markers.Shape = ChartMarkerShape.Diamond); return Chart.Create().WithXAxis("Workload batches").WithYAxis("Time (minutes)") .AddSeries(standard).AddSeries(priority) .ConfigureBubble(bubble => { bubble.WithSizeDomain(0, 100); bubble.MinimumRadius = 3; bubble.MaximumRadius = 24; }); } }