I'm trying to add SfChart to my Xamarin.Forms project by following the example here
I installed SfChart through the NuGet package manager in Visual Studio 2015 and then added PCL, iOS and Android references as shown in the example
My xaml file resembles the following:
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:local="clr-namespace:Test;assembly=Test"
xmlns:chart="clr-namespace:Syncfusion.SfChart.XForms;assembly=Syncfusion.SfChart.XForms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Test.PageName">
<ContentPage.Content>
<StackLayout ...>
...
<chart:SfChart>
<chart:SfChart.Title>
<chart:ChartTitle Text="Weather Analysis" />
</chart:SfChart.Title>
<chart:SfChart.PrimaryAxis>
<chart:CategoryAxis>
<chart:CategoryAxis.Title>
<chart:ChartAxisTitle Text="Month"/>
</chart:CategoryAxis.Title>
</chart:CategoryAxis>
</chart:SfChart.PrimaryAxis>
<chart:SfChart.SecondaryAxis>
<chart:NumericalAxis>
<chart:NumericalAxis.Title>
<chart:ChartAxisTitle Text="Month"/>
</chart:NumericalAxis.Title>
</chart:NumericalAxis>
</chart:SfChart.SecondaryAxis>
<chart:SfChart.Series>
<chart:ColumnSeries ItemsSource = "{Binding HighTemperature}"/>
</chart:SfChart.Series>
</chart:SfChart>
...
</StackLayout>
</ContentPage.Content>
</ContentPage>
My xaml.cs file resembles the follwing:
using Xamarin.Forms;
namespace Test
{
public partial class Page : ContentPage
{
public Page()
{
InitializeComponent();
}
}
}
<?xml version="1.0" encoding="utf-8" ?>
I've added to the iOS AppDelegate.cs and Android MainActivity.cs file:
new SfChartRenderer();
I've created a DataSource model:
namespace Test.Models
{
public class DataModel
{
public ObservableCollection<ChartDataPoint> HighTemperature { get; set; }
public DataModel ()
{
HighTemperature = new ObservableCollection<ChartDataPoint> ();
HighTemperature.Add (new ChartDataPoint ("Jan", 42));
HighTemperature.Add (new ChartDataPoint ("Feb", 44));
HighTemperature.Add (new ChartDataPoint ("Mar", 53));
HighTemperature.Add (new ChartDataPoint ("Apr", 64));
HighTemperature.Add (new ChartDataPoint ("May", 75));
HighTemperature.Add (new ChartDataPoint ("Jun", 83));
HighTemperature.Add (new ChartDataPoint ("Jul", 87));
HighTemperature.Add (new ChartDataPoint ("Aug", 84));
HighTemperature.Add (new ChartDataPoint ("Sep", 78));
HighTemperature.Add (new ChartDataPoint ("Oct", 67));
HighTemperature.Add (new ChartDataPoint ("Nov", 55));
HighTemperature.Add (new ChartDataPoint ("Dec", 45));
}
}
}
The application builds and deploys properly and all pages display properly - there is just now chart shown. Any ideas?
Thanks in advance!