Custom S V G Scatter Points

sample image

MyGeometry.cs

using LiveChartsCore.Drawing;
using LiveChartsCore.SkiaSharpView.Drawing;

namespace ViewModelsSamples.Scatter.Custom;

public class MyGeometry : BoundedDrawnGeometry, IDrawnElement<SkiaSharpDrawingContext>
{
    public void Draw(SkiaSharpDrawingContext context)
    {
        var paint = context.ActiveSkiaPaint;
        var canvas = context.Canvas;
        var y = Y;

        while (y < Y + Height)
        {
            canvas.DrawLine(X, y, X + Width, y, paint);
            y += 10;
        }
    }
}

Code behind

using Eto.Forms;
using LiveChartsCore;
using LiveChartsCore.Defaults;
using LiveChartsCore.SkiaSharpView;
using LiveChartsCore.SkiaSharpView.Drawing.Geometries;
using LiveChartsCore.SkiaSharpView.Eto;
using SkiaSharp;
using LiveChartsCore.Drawing;
using ViewModelsSamples.Scatter.Custom;

namespace EtoFormsSample.Scatter.Custom;

public class View : Panel
{
    public View()
    {
        var values1 = Fetch();
        var values2 = Fetch();
        var values3 = Fetch();
        var pinPath = SVGPoints.Pin;

        var series = new ISeries[]
        {
            new ScatterSeries<ObservablePoint, HeartGeometry>
            {
                Values = values1,
                Stroke = null,
                GeometrySize = 40
            },
            new ScatterSeries<ObservablePoint, VariableSVGPathGeometry>
            {
                Values = values2,
                GeometrySvg = pinPath,
                GeometrySize = 40
            },
            new ScatterSeries<ObservablePoint, MyGeometry>
            {
                Values = values3,
                GeometrySize = 40
            }
        };

        var cartesianChart = new CartesianChart
        {
            Series = series
        };

        Content = cartesianChart;
    }

    private static ObservablePoint[] Fetch()
    {
        var r = new System.Random();
        var length = 10;
        var values = new ObservablePoint[length];
        for (var i = 0; i < length; i++)
        {
            var x = r.Next(0, 20);
            var y = r.Next(0, 20);
            values[i] = new ObservablePoint(x, y);
        }
        return values;
    }
}

Articles you might also find useful:

Cartesian chart control
Scatter series properties