Can't get OxyPlot.XamarinAndroid working.

Oystein Bjorke 10 років тому 0
This discussion was imported from CodePlex

Death69 wrote at 2014-05-30 12:30:

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;
            
        }
    }

objo wrote at 2014-06-06 21:13:

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.

Death69 wrote at 2014-06-10 12:05:

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

objo wrote at 2014-06-10 13:41:

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.

objo wrote at 2014-06-11 12:11:

StyleCop is a prerequisite to build the OxyPlot core library (but it is not needed to use the library).

Death69 wrote at 2014-06-11 15:28:

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.