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.
Unfortunately, activation email could not send to your email. Please try again.

No Charts

Thread ID:

Created:

Updated:

Platform:

Replies:

117387 Oct 10,2014 12:38 AM Oct 11,2014 12:33 AM Xamarin.Forms 3
loading
Tags: SfChart
Michael O'Connor
Asked On October 10, 2014 12:38 AM

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;
        }
    }


Suresh B [Syncfusion]
Replied On October 10, 2014 05:29 AM

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


Michael O'Connor
Replied On October 10, 2014 12:10 PM

That was the missing ingredient, thanks very much!

Prabakaran R [Syncfusion]
Replied On October 11, 2014 12:33 AM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;