Quantcast
Channel: OxyPlot (moved to GitHub)
Viewing all articles
Browse latest Browse all 2061

New Post: Can't get OxyPlot.XamarinAndroid working.

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

Viewing all articles
Browse latest Browse all 2061

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>