#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 = QuadrantPointStylesRecipe.Create("wide", mode);
var context = new VisualRenderContext(
new VisualLayoutOptions(new VisualSize(800, 500)), theme, mode,
new VisualFrame("Native point marker authoring", "One native source series retains independent markers and located axis captions", showLegend: null, 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
/// Native Core authoring for independent quadrant captions and source-owned Scatter marker styles.
public static class QuadrantPointStylesRecipe {
/// Creates the native example. The separately shared Mermaid fixture proves parsed-source mapping.
public static Chart Create(string variant = "wide", ThemeMode mode = ThemeMode.Light) {
if (variant is not ("wide" or "compact")) throw new ArgumentOutOfRangeException(nameof(variant));
var observations = ChartSeries.CreateScatter(new ChartSeriesId("proposed-work"), "Proposed work", new[] {
new ChartPoint(.22, .74), new ChartPoint(.76, .72), new ChartPoint(.28, .26), new ChartPoint(.72, .24)
});
var labels = new[] { "Opportunity", "Investment", "Experiment", "Review" };
for (var index = 0; index < labels.Length; index++)
observations.ObservationId(index, new ChartObservationId(labels[index].ToLowerInvariant())).PointLabel(index, labels[index]);
observations.Markers(marker => { marker.Radius = 5; marker.StrokeWidth = 0; });
observations.PointMarkers(0, marker => {
marker.Radius = 9; marker.Fill = ChartColor.FromHex("#B45309");
marker.Stroke = ChartColor.FromHex("#7C2D12"); marker.StrokeWidth = 2;
});
observations.PointMarkers(1, marker => {
marker.Radius = 7; marker.Fill = ChartColor.FromHex("#0369A1");
marker.Stroke = ChartColor.FromHex("#075985"); marker.StrokeWidth = 1;
});
observations.PointMarkers(2, marker => { marker.Radius = 6; marker.Fill = ChartColor.FromHex("#7C3AED"); });
var chart = Chart.Create().Size(variant == "compact" ? 390 : 800, 500)
.Theme(VisualTheme.Graphite()).ThemeMode(mode).Title("Native work priorities")
.Subtitle("One source series, independent marker options and endpoint captions")
.Legend(false).ShowGrid(false).DataLabels().XAxis(x => x.Bounds(0, 1)).YAxis(y => y.Bounds(0, 1))
.AddSeries(observations);
chart.XAxis(axis => { axis.TickCount = 2; axis.Labels.Add(new ChartAxisLabel(.25, "Low effort")); axis.Labels.Add(new ChartAxisLabel(.75, "High effort")); });
chart.YAxis(axis => { axis.TickCount = 2; axis.Labels.Add(new ChartAxisLabel(.25, "Low impact")); axis.Labels.Add(new ChartAxisLabel(.75, "High impact")); });
chart.AddPlotRegion(new ChartPlotRegion(0, xMinimum: .5, yMinimum: .5, label: "Plan"))
.AddPlotRegion(new ChartPlotRegion(1, xMaximum: .5, yMinimum: .5, label: "Prioritize"))
.AddPlotRegion(new ChartPlotRegion(2, xMaximum: .5, yMaximum: .5, label: "Consider"))
.AddPlotRegion(new ChartPlotRegion(3, xMinimum: .5, yMaximum: .5, label: "Reassess"));
// Keyed value replacement preserves Investment's authored radius, paint and identity.
observations.ApplyPointChanges(new[] {
ChartObservationChange.Replace(new ChartObservationId("investment"), new ChartPoint(.78, .76))
});
return chart;
}
}