This is the lightweight C# chart rendering library for Xamarin iOS.
At this moment there are two views of charts:
- LineChartView - simple enough, used to display line charts. Allows you flexibly customize its style.
- ChartView - allows you to display any type of charts by implementing custom render.
- Install nuget package XCharts.iOS
- Add ChartView to View. You can do it in xib or by code like:
var lineChart = new LineChartView();
lineChart.TranslatesAutoresizingMaskIntoConstraints = false;
this.View.AddSubview(lineChart);
NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[]
{
lineChart.TopAnchor.ConstraintEqualTo(View.TopAnchor),
lineChart.BottomAnchor.ConstraintEqualTo(View.BottomAnchor),
lineChart.LeftAnchor.ConstraintEqualTo(View.LeftAnchor),
lineChart.RightAnchor.ConstraintEqualTo(View.RightAnchor)
});
- Set chart datasource:
var points = new List<double>();
var r = new Random();
for (int i = 0; i < 1000; i++)
{
points.Add(r.Next(0, 10000));
}
lineChart.DataSource = new IndexValueDataSource(points);