OxyPlot initialize renderer error

SzbestaSzbesta Member ✭✭✭
edited March 2018 in Xamarin.Forms

I need to do some basic plotting in my App with the help of the OxyPlot NuGetPackage extension. I have followed the online tutorials on how to set it up and as far as i can tell i did it correctly. I put the Init call to initiate the renderer right after the Xamarin.Forms.Forms.Init in every of the 3 Folders(Android, IOS, UWP) like so(Android as example):
base.OnCreate(bundle); global::Xamarin.Forms.Forms.Init(this, bundle); OxyPlot.Xamarin.Forms.Platform.Android.PlotViewRenderer.Init(); LoadApplication(new App());

Now everytime i start the app i get an exception along the lines of:"Visualization error. Dont forget to initialize renderer in Android MainActivity.cs" which I clearly did. I'm getting really frustrated at this as i cant find any fix on the Interwebs and other plotting libraries seem way too cumbersome to use. I would appreciate any help i can get!
Thanks beforehand

Best Answer

  • SzbestaSzbesta ✭✭✭
    Accepted Answer

    Figured out the issue -> Problem is the Xamarin Live Player not the library itself. Apparently when you debug over USB Cable there is no issue whatsoever. This took me forever to figure out hopefully needs this info as well.

Answers

  • seanydaseanyda GBMember ✭✭✭✭✭

    I used OxyPlot in one of my apps about a year ago. It turned out that the most recent releases didn't work so I had to downgrade to version 1.0.0-unstable1983. Obviously there would be some more up-to-date releases since last year, but if they all seem to be broken you could try that one.

  • SzbestaSzbesta Member ✭✭✭

    @seanyda thanks I'll try that now!

  • SzbestaSzbesta Member ✭✭✭

    @seanyda Unfortunately the same error should I use the different Forms.Init() function or stick with the PlotViewRenderer.Init()

  • seanydaseanyda GBMember ✭✭✭✭✭

    @Szbesta said:
    @seanyda Unfortunately the same error should I use the different Forms.Init() function or stick with the PlotViewRenderer.Init()

    I used this one.

    OxyPlot.Xamarin.Forms.Platform.iOS.PlotViewRenderer.Init();

    I never got around to building this app in Android though, maybe your issue is android specific.

  • SzbestaSzbesta Member ✭✭✭

    @seanyda Yup using the same Init, thing is I don't think its Android specific as I'm testing on all three OS and on neither it says the renderer is initialized. I'll try to play around a bit more and see if i can get it running. Thanks for the help anyways much appreciated :smiley:
    PS: If something crosses your mind concerning this dont hesitate to inform me :)

  • seanydaseanyda GBMember ✭✭✭✭✭

    @Szbesta said:
    @seanyda Yup using the same Init, thing is I don't think its Android specific as I'm testing on all three OS and on neither it says the renderer is initialized. I'll try to play around a bit more and see if i can get it running. Thanks for the help anyways much appreciated :smiley:
    PS: If something crosses your mind concerning this dont hesitate to inform me :)

    No problem. The only thing I can think of that may be of use to you is how I create the chart.

    var model = new PlotModel { IsLegendVisible = true, LegendPosition = LegendPosition.TopLeft, };
    
                var ps = new PieSeries {
                    AreInsideLabelsAngled = true,
                    StrokeThickness = 0,
                    OutsideLabelFormat = null,
                };
    
                ps.Slices.Add (new PieSlice ("Open Order", Convert.ToDouble (accountOverviewList.Orders.OpenOrders)) { IsExploded = true, Fill = OxyColor.FromRgb (62, 104, 153) });
                ps.Slices.Add (new PieSlice ("Receivables Balance", Convert.ToDouble (accountOverviewList.Orders.Receivables)) { IsExploded = true, Fill = OxyColor.FromRgb (166, 182, 212) });
    
                model.Series.Add (ps);
    
                PlotView pv = new PlotView { Model = model, Margin = 30 };
    
  • SzbestaSzbesta Member ✭✭✭

    Wow not even changing anything in the MainActivity.cs does anything to the app if i remove the Xamarin.Forms.Forms.Init(this, bundle) as well as the LoadApplication(new App()). This is some serious bullshit going on....

  • seanydaseanyda GBMember ✭✭✭✭✭

    @Szbesta said:
    Wow not even changing anything in the MainActivity.cs does anything to the app if i remove the Xamarin.Forms.Forms.Init(this, bundle) as well as the LoadApplication(new App()). This is some serious bullshit going on....

    Weird one. Delete the bin and obj files from your project. Clean and Rebuild once that's done and delete the app from the simulator for a new install to be on the safe side. Then you'll be sure it's the most up-to-date build.

  • SzbestaSzbesta Member ✭✭✭

    @seanyda Will do thanks for the update..

  • SzbestaSzbesta Member ✭✭✭

    @seanyda did that didnt change I seriously think VS or Xamarin really wants to mess with me :/ Really appreciate your help in this thanks mate.

  • seanydaseanyda GBMember ✭✭✭✭✭

    @Szbesta said:
    @seanyda did that didnt change I seriously think VS or Xamarin really wants to mess with me :/ Really appreciate your help in this thanks mate.

    No worries mate. Did you delete the bin and obj folders from the platform specific folders as well as the shared ones? because in that case everything from the project has to be rebuilt for it generate a new build nothing would be cached.

    Long shot though, If your on Mac open Finder > Go > Go To Folder >~/Library/Caches and delete the VisualStudio cache.

  • SzbestaSzbesta Member ✭✭✭

    @seanyda Nope just from the plattform specific. I'll try it again this time deleting all of the bin obj folders. Will update!

  • SzbestaSzbesta Member ✭✭✭

    Unfortunately, this produced the same result :/

  • SzbestaSzbesta Member ✭✭✭

    Tried it as well with a completely blank app nothing added whatsoever and it still produces said error I have no idea what I'm doing wrong

  • seanydaseanyda GBMember ✭✭✭✭✭

    @Szbesta said:
    Tried it as well with a completely blank app nothing added whatsoever and it still produces said error I have no idea what I'm doing wrong

    It might be a simulator related problem. Have you tried debugging to a physical device?

  • SzbestaSzbesta Member ✭✭✭

    @seanyda I'm debugging on physical devices since the beginning my company provided me with 3 phones with the 3 different OS to test with. I already sent a message to the maker of the package regarding this problem.
    Still many thanks for your support its much appreciated :D

  • SzbestaSzbesta Member ✭✭✭
    Accepted Answer

    Figured out the issue -> Problem is the Xamarin Live Player not the library itself. Apparently when you debug over USB Cable there is no issue whatsoever. This took me forever to figure out hopefully needs this info as well.

Sign In or Register to comment.