Specify Both X And Y

sample image

When you need to specify both, X and Y coordinates, you can use the ObservablePoint class, in other examples in this repository you will notice that the library can also plot primitive types such as int or double, the library (usually) uses the index of the element in the array as the X coordinate and the value as the Y coordinate, so even we are passing an array of primitives, the library is mapping that object to and (X, Y) point, the library can build charts from any object, but we much teach LiveCharts how to handle that object, if you want to learn more, please read the Mappers article.

View Model

using LiveChartsCore;
using LiveChartsCore.Defaults;
using LiveChartsCore.SkiaSharpView;

namespace ViewModelsSamples.Lines.XY;

public class ViewModel
{
    public ISeries[] Series { get; set; } = [
        new LineSeries<ObservablePoint>
        {
            Values = [
                new ObservablePoint(0, 4),
                new ObservablePoint(1, 3),
                new ObservablePoint(3, 8),
                new ObservablePoint(18, 6),
                new ObservablePoint(20, 12)
            ]
        }
    ];
}

using Eto.Forms;
using LiveChartsCore.SkiaSharpView.Eto;
using ViewModelsSamples.Lines.XY;

namespace EtoFormsSample.Lines.XY;

public class View : Panel
{
    private readonly CartesianChart cartesianChart;

    public View()
    {
        var viewModel = new ViewModel();

        cartesianChart = new CartesianChart
        {
            Series = viewModel.Series,
        };

        Content = cartesianChart;
    }
}

Articles you might also find useful: