Plot list of strings in oxyplot where YAxis is strings and XAxis is an integer

Viewed 98

I have a list containing Object Chip() and i would like to plot each value in a LinearAxis.

The object

public ChipPoint(double x, string y, Chip chip)
{
    X = x;
    Y_string = y;
    Value = double.NaN;
    Chip = chip;
}

I'm right now assigning the itemsource to the Object, but it does not seem to plot it the right way:

/// <summary>Sets the data displayed by the series based on the given data.</summary>
/// <param name="series">The <see cref="XYAxisSeries"/> that should display the data.</param>
/// <param name="data">A collection of <see cref="TestDataPoint"/> that should be displayed.</param>
/// <param name="allPoints">A collection of <see cref="TestDataPoint"/> containing all possible points.</param>
protected override void SetSeriesData(
     XYAxisSeries series,
    IEnumerable<TestDataPoint> data,
    IEnumerable<TestDataPoint> allPoints)
{
    Data = data;
    if (data.Where(d => d.CanConvertToDouble).Count() < 1)
    {
        //CreateAxes(); 
        series.ItemsSource = data
        .Select(p => new ChipPoint(p.Chip.Id, p.StringValue, p.Chip))
        .ToList();

        Model.Axes.Clear();

        // create the X axis (chips)
        XAxis = new LinearAxis();
        XAxis.Title = "Chip";
        XAxis.Position = AxisPosition.Bottom;
        XAxis.MajorGridlineColor = OxyColors.Gray;
        XAxis.MajorGridlineStyle = LineStyle.Dash;
        XAxis.MajorGridlineThickness = 1;
        XAxis.MinorGridlineColor = OxyColors.LightGray;
        XAxis.MinorGridlineStyle = LineStyle.Dash;
        XAxis.MinorGridlineThickness = 1;

        // chips are integers
        XAxis.MinimumMajorStep = 1;
        XAxis.MinimumMinorStep = 1;

        Model.Axes.Add(XAxis);

        YAxis = new LinearAxis();
        YAxis.Title = "Value";
        YAxis.Position = AxisPosition.Left;
        YAxis.MajorGridlineColor = OxyColors.Gray;
        YAxis.MajorGridlineStyle = LineStyle.Dash;
        YAxis.MajorGridlineThickness = 1;

        YAxis.IntervalLength = 20;
        YAxis.MinorTickSize = 0;
        YAxis.MinimumMajorStep = 0.0000001;

        Model.Axes.Add(YAxis);

        return;
    }

    CreateAxes();
    series.ItemsSource = data
        .Select(p => new ChipPoint(
            p.Chip.Id,
            p.DoubleValue,
            p.Chip))
        .ToList();
}

The plot im having:

Plot example

The YAxis should not have a double value, but a string value depending on what value each point has.

Do any of you guys have any suggestions?

0 Answers
Related