Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

OxyPlot Example Line Plot Not Displaying

$
0
0

I followed the getting started guide as well as used the example code form the GIT repo to try to create a line graph. I put all the initializer calls in the corresponding projects. I cannot get a graph to display specifically on an android device. My XAML and code behind:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:OxyPlotExamples"
             xmlns:oxy="clr-namespace:OxyPlot.Xamarin.Forms;assembly=OxyPlot.Xamarin.Forms"
             x:Class="OxyPlotExamples.MainPage">

    <Grid>

        <Grid.RowDefinitions>

            <RowDefinition />

        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>

            <ColumnDefinition />

        </Grid.ColumnDefinitions>

        <oxy:PlotView Grid.Row="0" Grid.Column="0" 
                      Model="{Binding Model}" 
                      VerticalOptions="Center" 
                      HorizontalOptions="Center" 
                      WidthRequest="1000"
                      HeightRequest="500"/>

    </Grid>

</ContentPage>
using OxyPlot;
using OxyPlot.Series;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;

namespace OxyPlotExamples
{
    public partial class MainPage : ContentPage
    {
        public PlotModel Model { get; set; }

        public MainPage()
        {
            InitializeComponent();

            Model = new PlotModel
            {
                Title = "Test",
                LegendSymbolLength = 24
            };

            LineSeries s1 = new LineSeries
            {
                Title = "Series 1",
                Color = OxyColors.SkyBlue,
                MarkerType = MarkerType.Circle,
                MarkerSize = 6,
                MarkerStroke = OxyColors.White,
                MarkerFill = OxyColors.SkyBlue,
                MarkerStrokeThickness = 1.5
            };

            s1.Points.Add(new DataPoint(0, 10));
            s1.Points.Add(new DataPoint(10, 40));
            s1.Points.Add(new DataPoint(40, 20));
            s1.Points.Add(new DataPoint(60, 30));

            Model.Series.Add(s1);
        }
    }
}

Viewing all articles
Browse latest Browse all 91519

Trending Articles