← Gallery

Scatter

Processing time by workload

Explore the example, download the output or use the C# source in your own project.

Preview
Processing time by workloadChart with 9 data series: Circle, Square, Diamond, Triangle, Plus, Cross, Heart, Pin, Star.Processing time by workloadNine marker shapes with source labels01234Sample position01234Example levelCircleSquareDiamondTrianglePlusCrossHeartPinStar
Processing time by workload
Processing time by workloadChart with 9 data series: Circle, Square, Diamond, Triangle, Plus, Cross, Heart, Pin, Star.Processing time by workloadNine marker shapes with source labels01234Sample position01234Example levelCircleSquareDiamondTrianglePlusCrossHeartPinStar
Processing time by workload
800 × 440 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.

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;

var mode = VisualThemeMode.Light;
var theme = VisualTheme.Graphite();
var model = ScatterMarkerShapesRecipe.Create("options", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(800, 440)), theme, mode,
    new VisualFrame("Processing time by workload", "Nine marker shapes with source labels", showLegend: false, 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());

/// <summary>Shows the available scatter marker shapes with captions.</summary>
public static class ScatterMarkerShapesRecipe {
    /// <summary>Creates the selected example without choosing a renderer or export backend.</summary>
    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 MarkerShapes().WithValueFormat(ChartValueFormat.Number("0.##", CultureInfo.InvariantCulture));
    }

    private static Chart MarkerShapes() {
        var chart = Chart.Create().WithXAxis("Sample position").WithYAxis("Example level");
        var shapes = Enum.GetValues<ChartMarkerShape>();
        for (var index = 0; index < shapes.Length; index++) {
            var shape = shapes[index];
            var sample = ChartSeries.CreateScatter(new ChartSeriesId("marker-" + shape.ToString().ToLowerInvariant()), shape.ToString(),
                new[] { new ChartPoint(index % 3 + 1, index / 3 + 1) });
            sample.WithPointLabel(0, shape.ToString()).WithDataLabels()
                .ConfigureMarkers(markers => { markers.Shape = shape; markers.Radius = 8; markers.StrokeWidth = 1; });
            chart.AddSeries(sample);
        }
        chart.Options.XAxis.WithBounds(0, 4);
        chart.Options.YAxis.WithBounds(0, 4);
        return chart;
    }
}
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;

var mode = VisualThemeMode.Dark;
var theme = VisualTheme.Graphite();
var model = ScatterMarkerShapesRecipe.Create("options", mode);
var context = new VisualRenderContext(
    new VisualLayoutOptions(new VisualSize(800, 440)), theme, mode,
    new VisualFrame("Processing time by workload", "Nine marker shapes with source labels", showLegend: false, 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());

/// <summary>Shows the available scatter marker shapes with captions.</summary>
public static class ScatterMarkerShapesRecipe {
    /// <summary>Creates the selected example without choosing a renderer or export backend.</summary>
    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 MarkerShapes().WithValueFormat(ChartValueFormat.Number("0.##", CultureInfo.InvariantCulture));
    }

    private static Chart MarkerShapes() {
        var chart = Chart.Create().WithXAxis("Sample position").WithYAxis("Example level");
        var shapes = Enum.GetValues<ChartMarkerShape>();
        for (var index = 0; index < shapes.Length; index++) {
            var shape = shapes[index];
            var sample = ChartSeries.CreateScatter(new ChartSeriesId("marker-" + shape.ToString().ToLowerInvariant()), shape.ToString(),
                new[] { new ChartPoint(index % 3 + 1, index / 3 + 1) });
            sample.WithPointLabel(0, shape.ToString()).WithDataLabels()
                .ConfigureMarkers(markers => { markers.Shape = shape; markers.Radius = 8; markers.StrokeWidth = 1; });
            chart.AddSeries(sample);
        }
        chart.Options.XAxis.WithBounds(0, 4);
        chart.Options.YAxis.WithBounds(0, 4);
        return chart;
    }
}