We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

SfChart Not Displaying

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!


7 Replies

GM Gobi M Syncfusion Team June 16, 2016 10:38 AM UTC

Hi Drew Wilson, 
 
Thanks for contacting Syncfusion support. 
 
We have prepared a xaml sample by following our getting started tutorial and it is working fine. The sample can be downloaded in below location. 
 
 
Please let us know for any queries.  
 
Regards, 
Gobi M 



DW Drew Wilson June 20, 2016 07:18 PM UTC

I was able to make this work using your example.

Thanks!


GM Gobi M Syncfusion Team June 21, 2016 03:58 AM UTC

Hi Drew Wilson, 
 
Thanks for the update. 
 
Please let us know for any queries. 
 
Regards, 
Gobi M 



TA tom anderson April 20, 2018 03:35 AM UTC

Hi,

This is very helpful. I am new to Xamarin so teaching myself how to work with charts.

In the above sample, I am not able to find ChartDataPoint. Can you please point me to the right direction?


PS Parthiban Sundaram Syncfusion Team April 23, 2018 06:50 AM UTC

Hi Tom Anderson,

Thanks for using Syncfusion products.

You can refer the following link to know about ChartDataPoint.

https://help.syncfusion.com/xamarin/sfchart/working-with-data#chart-data-point  

Also, we have prepared the simple sample for this. Please download it from following location.

Sample: https://www.syncfusion.com/downloads/support/forum/124585/ze/SimpleSample-732480229  

Please let us know, if you have further assistance on this.

Regards,
Parthiban S.


IS ikanih solomon February 19, 2019 04:44 PM UTC

am trying to add dummy data into my app...but I get this error "Unhandled Exception:

System.MissingMethodException: Default constructor not found for type Com.Syncfusion.Charts.SfChart".

Gone through the guidelines/documentation a couple of times, and cant find any reference to a constructor.



BK Bharathiraja K Syncfusion Team February 20, 2019 12:16 PM UTC

Hi ikanih, 
 
Can you please share your application scenario or code snippet to replicate the issue reported issue? Since we are not aware of your exact application scenario, we were not able to reproduce this issue at our end, so can you please revert us by modifying the sample based on your application along with replication procedure. This will be helpful for us to investigate further and provide you a better solution at the earliest. 
 
Sample link:   
 
Thanks, 
Bharathiraja.  


Loader.
Live Chat Icon For mobile
Up arrow icon