Search code examples
c#androidxamarin.androidoxyplot

Xamarin android oxyplot having issues with device rotating and axis


I am new to mobile development. I am familiar with c#.net so i started working on xamarin. As far as now i am able to add 2 charts in it. Problems i am facing are as follows

  1. While rotating device the chart is fixed, i.e. i can't scroll (see bellow image)

enter image description here

In above image i can see the first chart but can't see the second chart full, as scroll is not working. How to enable scroll ?

  1. While on screen horizontal or vertical if I slide the chart, the axis moves automatically, which they should not do as i have set them to a fixed values. See the bellow image

enter image description here

enter image description here

As you can see in the above images when i slide the chart also does causing the axis to increase. I want to stop it.

Bellow is my code in which i have fixed my axis maximum and minimum values

plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom, Maximum = 10, Minimum = 0 });
plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Maximum = 10, Minimum = 0 });

Any help would be highly appreciated


Solution

  • If you want to enable scrolling try using a ScrollViewer surrounding your plots:

    <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Visible" >
        <oxy:PlotView .../>
        <oxy:PlotView .../>
    </ScrollViewer>
    

    And for your axis issue, if you want your plot axes to be fixed even when zooming, you have to use AbsoluteMaximum and AbsoluteMinimum properties on Axis:

    plotModel.Axes.Add(new LinearAxis()
    {
        Position = AxisPosition.Bottom,
        AbsoluteMaximum = 10,
        AbsoluteMinimum = 0,
    });