Can't get OxyPlot.XamarinAndroid working.

May 30, 2014 at 10:30 AM
Hi there,
I'm trying to make a simple Testapplication that shows some stuff. I'm using the latest Xamarin.Android build and the latest OxyPlot build that i got via nuget. But i always get an
Unhandled Exception:
System.MissingMethodException: Method not found: 'OxyPlot.PlotModel.Update'.
What am i doing wrong?
Here is my source code.
My Model:
using System;
using System.Collections.Generic;
using System.Text;
using OxyPlot;
using OxyPlot.XamarinAndroid;
using OxyPlot.Series;
using OxyPlot.Axes;
using Android.App;
using Android.OS;
namespace OxyPlotTest.Resources
{
    public class MainViewModel
    {
        public PlotModel MyModel { get; set; }

        public MainViewModel()
        {
            // Below from http://oxyplot.org/doc/HelloWpf.html
            //MyModel = new PlotModel("Example 1");
            //MyModel.Series.Add(new FunctionSeries(Math.Cos, 0, 10, 0.1, "cos(x)"));

            // Below from http://oxyplot.codeplex.com/wikipage?title=WpfExample1
            PlotModel temp = new PlotModel("Square wave");
            var ls = new LineSeries("sin(x)+sin(3x)/3+sin(5x)/5+...");
            int n = 10;
            for (double x = -10; x < 10; x += 0.0001)
            {
                double y = 0;
                for (int i = 0; i < n; i++)
                {
                    int j = i * 2 + 1;
                    y += Math.Sin(j * x) / j;
                }
                ls.Points.Add(new DataPoint(x, y));
            }
            temp.Series.Add(ls);
            temp.Axes.Add(new LinearAxis(AxisPosition.Left, -4, 4));
            temp.Axes.Add(new LinearAxis(AxisPosition.Bottom));
            
            MyModel = temp;// this is raising the INotifyPropertyChanged event
        }
    }
}
The Activity:
[Activity(Label = "OxyPlotEx", MainLauncher = true)]
    public class OxyPlotEx : Activity
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            MainViewModel MyMainViewModel = new MainViewModel();
            SetContentView(Resource.Layout.OxyPlotEx);
            var plotView = FindViewById<PlotView>(Resource.Id.plotView_Temp);
            plotView.Model = MyMainViewModel.MyModel;
            
        }
    }
Coordinator
Jun 6, 2014 at 7:13 PM
Thanks for reporting a possible bug - I'll try to reproduce this! I cannot see any errors in your Activity class, it looks ok to me.

The Update method was recently removed from the public API because it should not be called by the client apps, only by the PlotView controls.
Jun 10, 2014 at 10:05 AM
Hi,
i got the latest commit and build the xamarainandroid and oxyplot .dll's and now it's working. I got OxyPlot via NuGet before. But i had to delete the
<input ="StyleCop...> in OxyPlot.csproj
Coordinator
Jun 10, 2014 at 11:41 AM
Thanks, I will check and update the NuGet packages. I am trying to get the Android and iOS components built on the Windows build server.
Make sure the OxyPlot and OxyPlot.XamarinAndroid packages have the same version number.
Coordinator
Jun 11, 2014 at 10:11 AM
Edited Jun 11, 2014 at 10:11 AM
StyleCop is a prerequisite to build the OxyPlot core library (but it is not needed to use the library).
Jun 11, 2014 at 1:28 PM
Edited Jun 11, 2014 at 2:26 PM
Hi,
as is said i removed it before building the library and it worked.

I may have found a bug, but I'm not sure if it really is one or I'm just don't use it right.
In my project I have a ColumnSeries and i put alot of ColumnItems in it (~50) and it should start from a desired position with the CategoryAxis.StartPosition property but there is nothing drawn in the PlotModel. It actually deletes the hole CategoryAxis. I need to set it to an explicit value from the items i get. I need to show data between specific ages (from 40 to 95) then i need to let it start from 40.

It would be good if the CategoryAxis labels could be invisible, with the amount of ColumnItems i have it looks really ugly, because they're overlaping. Or something like showing every fifth position.

Btw: Great Library, it's really really powerful. Excellent work.