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

No Charts

I have been trying to get even the most simple chart to appear in my app, to no avail.  I've been over the samples and can't find what I'm missing.  

When I run this the green background shows up, so the chart control is there, in theory.  Nothing else though, no Axis, no grids, no lines, no errors.

thanks.


class DashboardChartsCV : ContentView
    {
        public DashboardChartsCV()
        {
            this.Content = GetChart();   
        }

        private static SfChart GetChart()
        {
            SfChart chart = new SfChart();

            chart.BackgroundColor = Color.Green;
            chart.VerticalOptions = LayoutOptions.FillAndExpand;
            chart.HorizontalOptions = LayoutOptions.FillAndExpand;

            chart.PrimaryAxis = new CategoryAxis();
            chart.SecondaryAxis = new NumericalAxis();

            SplineSeries pointsSeries = new SplineSeries();

            ObservableCollection cdps = new ObservableCollection();

            for (int x = 0; x < 5; x++ )
            {
                cdps.Add(new ChartDataPoint("cat" + x.ToString(), x));    
            }

            pointsSeries.ItemsSource = cdps;
            pointsSeries.StrokeColor = Color.Maroon;
            pointsSeries.StrokeWidth = 3;

            chart.Series.Add(pointsSeries);

            return chart;
        }
    }


3 Replies

SB Suresh B Syncfusion Team October 10, 2014 09:29 AM UTC

Hi Michael,

 

Thank you for using Syncfusion product.

 

We have analysed your sample code and you have to load the Syncfusion.SfChart.XForms.iOS and Syncfusion.SfChart.XForms.WinPhone assemblies manually by creating instance for SfChartRenderer  in WP and iOS as Xamarin is not loading it automatically.

 

Code Snippet[C#]:

 

In WinPhone Project

Create an instance of SfChartRenderer in MainPage constructor,

 

Public MainPage()

{

            new SfChartRenderer();

             …

}

 

In iOS Project

Create an instance of SfChartRenderer in FinishedLaunching overridden method of AppDelegate class,

 

public override bool FinishedLaunching(UIApplication app, NSDictionary options)

            {

                          new SfChartRenderer ();

 

                           ...

             }                                             

 

For your reference, we have also prepared the sample and please find the sample in the below location,

Sample:  http://www.syncfusion.com/downloads/support/directtrac/general/SimpleChartSample1527441337.zip

 

For more details please refer the below document link:

http://help.syncfusion.com/ug/xamarin/default.htm#!documents/gettingstarted.htm

 

Please let us know if you need any further assistance.


Thanks,

Suresh B



MO Michael O'Connor October 10, 2014 04:10 PM UTC

That was the missing ingredient, thanks very much!


PR Prabakaran R Syncfusion Team October 11, 2014 04:33 AM UTC

Hi Michael,

Thank you for your update.

We are glad to know that your issue has been fixed .

Please let us know if you need further assistance on this.

Thanks,
Prabakaran

Loader.
Live Chat Icon For mobile
Up arrow icon