OxyPlot graph not displaying

PierreParmPierreParm FRMember ✭✭

Hi,

I have simple page with an OxyPlot graph in it :smile:
` <ContentPage xmlns="http://xamarin.com/schemas/2014/forms"

         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         x:Class="Xamareview.Views.StatisticsPage"
         xmlns:prism="clr-namespace:Prism.Mvvm;assembly=Prism.Forms" 
         prism:ViewModelLocator.AutowireViewModel="True" 
         NavigationPage.HasNavigationBar="false"
         xmlns:oxy="clr-namespace:OxyPlot.Xamarin.Forms;assembly=OxyPlot.Xamarin.Forms">
<Grid>
    <oxy:PlotView Model="{Binding GraphModel}" BackgroundColor="Blue"/>
</Grid>


`

I put the background color to blue to make sure it is present and the whole page becomes blue.

And here's how I set it. It's based on the samples :

`
this.graphModel = new PlotModel();
this.GraphModel.Title = "Test plot model";
this.GraphModel.Subtitle = "subtitle test";

        this.GraphModel.Axes.Add(new LinearAxis
        {
            Position = AxisPosition.Left,
            Minimum = -5.00,
            Maximum = 5.00,
            MajorStep = 1,
            MinorStep = 0.25,
            TickStyle = TickStyle.Inside
        });

        this.GraphModel.Axes.Add(new LinearAxis{
            Position = AxisPosition.Bottom,
            Minimum = 0,
            Maximum = 10.00,
            MajorStep = 1,
            MinorStep = 0.25,
            TickStyle = TickStyle.Inside
        });

        this.GraphModel.Series.Add(CreateNormalDistributionSeries(-5, 5, 0, 0.2));
        this.GraphModel.Series.Add(CreateNormalDistributionSeries(-5, 5, 0, 1));
        this.GraphModel.Series.Add(CreateNormalDistributionSeries(-5, 5, 0, 5));
        this.GraphModel.Series.Add(CreateNormalDistributionSeries(-5, 5, -2, 0.5));
    }` 

Did anyone experience the same issue ? Any idea why my graph is not showing ?

Thank you.

Best Answer

  • PierreParmPierreParm FRMember ✭✭
    Accepted Answer

    I actually successfuly displayed it in a grid.

        <oxy:PlotView Model="{Binding GraphModel}"
                     HorizontalOptions="FillAndExpand"
                     VerticalOptions="FillAndExpand"
                     Grid.Row="3"/>
    

Answers

  • MtiMti USMember ✭✭

    Don't put it in a Grid. Try simply like this :

    <ContentPage.Content>
    
            <oxy:PlotView x:Name="PlotView" />
    
    </ContentPage.Content>`
    
  • PierreParmPierreParm FRMember ✭✭
    Accepted Answer

    I actually successfuly displayed it in a grid.

        <oxy:PlotView Model="{Binding GraphModel}"
                     HorizontalOptions="FillAndExpand"
                     VerticalOptions="FillAndExpand"
                     Grid.Row="3"/>
    

Sign In or Register to comment.