Search code examples
oxyplotlineseries

How to set dimensions of LineSeries


I have a line series that covers data from 1 to 20 along the X axis and 0 to 1 along the Y axis. My problem is that the x axis always starts at 0 and goes to the furthest value and the Y axis starts at 0 but only goes to the furthest value as well. How can I set these dimensions?


Solution

  • So for the Y axis this is what you want

    plotModel.Axes.Add(new LinearAxis()
            {
                Title = "Y axis Name",
                Position = AxisPosition.Left,
                MinorStep = 0.1,
                FilterMinValue = -1,
                FilterMaxValue = 1
            });
    

    As for the X axis it seems to be more annoying handLabeling seems to be the only way.

    plotModel.Axes.Add(new CategoryAxis() 
            {
               Title = "X axis name",
               Position = AxisPosition.Bottom,
               Labels = {"1","2","3","4","5","6" } // ... upto 20
            });
    

    Then every item you add index the value of the Category label. For example if I want an column of 64 on 3 in X axis then the code would look like this:

    var item =new ColumnItem(62, 2); // index 2 being value "3"