Hi,
We are planning to integrate SyncFusion chart in our xamarin forms app. We followed the steps given in the document to create sample chart but when we build our application throws the following error,
"The type 'Xamarin.Forms.Platform.iOS.ViewRenderer`2<T0,T1>' is defined in an assembly that is not referenced. You must add a reference to assembly 'Xamarin.Forms.Platform.iOS.Classic, Version=1.3.4.0, Culture=neutral, PublicKeyToken=null'. "
sample we worked out is listed below
AppDelegate.cs:
In AppDelegate FinishedLaunching method we created SfChartRenderer instance as mentioned in the document.
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
new SfChartRenderer();
global::Xamarin.Forms.Forms.Init();
LoadApplication(new App());
return base.FinishedLaunching(app, options);
}
Charts.xaml.cs:
public partial class Chart : ContentPage
{
public Chart()
{
// InitializeComponent();
//Initializing chart
SfChart chart = new SfChart();
chart.Title= new ChartTitle(){Text="WeatherAnalysis"};
//Initializing Primary Axis
CategoryAxis primaryAxis= new CategoryAxis();
primaryAxis.Title=new ChartAxisTitle(){Text="Month"};
chart.PrimaryAxis=primaryAxis;
//Initializing Secondary Axis
NumericalAxis secondaryAxis=new NumericalAxis();
secondaryAxis.Title=new ChartAxisTitle(){Text="Temperature"};
chart.SecondaryAxis=secondaryAxis;
DataModel dataModel=new DataModel();
//Adding Column Series to the chart for displaying precipitation
chart.Series.Add(new ColumnSeries(){
ItemsSource= dataModel.Precipitation,
Label="Precipitation",
YAxis=new NumericalAxis(){OpposedPosition=true,
ShowMajorGridLines = false}
});
//Adding the Spline Series to the chart for displaying high temperature
chart.Series.Add(new SplineSeries(){
ItemsSource= dataModel.HighTemperature,
Label="High"
});
//Adding the Spline Series to the chart for displaying low temperature
chart.Series.Add(new SplineSeries(){
ItemsSource=dataModel.LowTemperature,
Label="Low"
});
//Adding Chart Legend for the Chart
chart.Legend=new ChartLegend();
this.Content=chart;
}
}
public class DataModel
{
public ObservableCollection<ChartDataPoint> HighTemperature;
public ObservableCollection<ChartDataPoint> LowTemperature;
public ObservableCollection<ChartDataPoint> Precipitation;
public DataModel()
{
HighTemperature=new ObservableCollection<ChartDataPoint>();
HighTemperature.Add(new ChartDataPoint("Jan",42));
HighTemperature.Add(new ChartDataPoint("Feb",44));
LowTemperature=new ObservableCollection<ChartDataPoint>();
LowTemperature.Add(new ChartDataPoint("Jan",27));
LowTemperature.Add(new ChartDataPoint("Feb",28));
Precipitation=new ObservableCollection<ChartDataPoint>();
Precipitation.Add(new ChartDataPoint("Jan",3.03));
Precipitation.Add(new ChartDataPoint("Feb",2.48));
}
}
If anyone come across this issue kindly share or suggest me some ideas that would be helpful for me. Thanks in advance.