Xamarin IOS Chart

marc 101 Reputation points
2020-12-06T22:37:27.64+00:00

I am trying to build a chart using the library described in this post from xamarin forum
https://forums.xamarin.com/discussion/105647/ioscharts-xamarin-implementations

but i cant really render any graphics so far, anyone knows how to do that?

public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var tmp = new iOSCharts.BarChartView();
            var data = new BarChartData();
            data.AddEntry(new ChartDataEntry(1,1), 1);
            tmp.Data = data;
            tmp.BackgroundColor = UIColor.Red;
            tmp.ChartDescription.Text = "eeeee";

            Test.AddSubview(tmp);

            // Perform any additional setup after loading the view, typically from a nib.
        }
Developer technologies .NET Xamarin
0 comments No comments
{count} votes

Accepted answer
  1. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,756 Reputation points
    2020-12-07T08:24:52.863+00:00

    Hello,

    Welcome to Microsoft Q&A!

    Take a look at this elegant chart plugin : Microcharts .

    First install Microcharts package in your ios project, then call the api .

    The usage is pretty simple as below .

       var entries = new[]  
       {  
           new ChartEntry(212)  
           {  
               Label = "UWP",  
               ValueLabel = "112",  
               Color = SKColor.Parse("#2c3e50")  
           },  
           new ChartEntry(248)  
           {  
               Label = "Android",  
               ValueLabel = "648",  
               Color = SKColor.Parse("#77d065")  
           },  
           new ChartEntry(128)  
           {  
               Label = "iOS",  
               ValueLabel = "428",  
               Color = SKColor.Parse("#b455b6")  
           },  
           new ChartEntry(514)  
           {  
               Label = "Forms",  
               ValueLabel = "214",  
               Color = SKColor.Parse("#3498db")  
           }  
       };  
         
                   var chart = new LineChart { Entries = entries };  
         
                   var chartView = new ChartView  
                   {  
                       Frame = new CGRect(0, 0, View.Bounds.Width, 250),  
                       AutoresizingMask = UIViewAutoresizing.FlexibleWidth,  
                       Chart = chart  
                   };  
         
                   View.AddSubview(chartView);  
    

    45617-capture.png

    Thank you.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.