Issue
I have successfully implemented the PieChart in my xamarin android project using the nuget package MPAndroidChart 3.1.0. When I try to set the colors I get the below error:
Cannot implicitly convert type 'System.Collections.Generic.IList<int>' to 'System.Collections.Generic.IList<Java.Lang.Integer>'. An explicit conversion exists (are you missing a cast?)
Here is my code that im using:
MikePhil.Charting.Data.PieDataSet pieDataSet = new MikePhil.Charting.Data.PieDataSet(datalist, "");
pieDataSet.Colors = ColorTemplate.ColorfulColors;
Any ideas how I can fix this?
Solution
This exception:
Cannot implicitly convert type 'System.Collections.Generic.IList' to 'System.Collections.Generic.IList<Java.Lang.Integer>'. An explicit conversion exists (are you missing a cast?)
means you have to convert ColorTemplate.ColorfulColors
to IList<Java.Lang.Integer>
Type first.
You can do it by using LINQ for simplicity.
using System.Xml;
...
MikePhil.Charting.Data.PieDataSet pieDataSet = new MikePhil.Charting.Data.PieDataSet(datalist, "");
pieDataSet.Colors = ColorTemplate.ColorfulColors.Select(c => new Java.Lang.Integer(c)).ToList();
...
Answered By - Rofiq Setiawan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.