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.

System.TypeInitializationException trying to change Getting Started Example

Thread ID:

Created:

Updated:

Platform:

Replies:

128820 Feb 10,2017 04:33 PM Feb 15,2017 09:34 AM Xamarin.Forms 3
loading
Tags: SfChart
Fabrizio Frigerio
Asked On February 10, 2017 04:33 PM

I've tried Getting Started Example and it works fine but is too simple so i've tried to change the code to see if your control can be used in my new project.
I'm new to Xamarin.Forms so I've started step by step. First I've tried to use the DLL's installed by the trial version of Syncfusion Essential Studio 14.4.0.15 because the one's shipped with the demo package seem not to handle a collection of custom objects for the series ItemSource as explained here but I'm stuck, the simple code:

SfChart chart = new SfChart();

is now raising the exception "System.TypeInitializationException: The type initializer for 'Syncfusion.SfChart.XForms.SfChart' threw an exception".

Any ideas?

Thanks in advance

Parthiban Sundaram [Syncfusion]
Replied On February 13, 2017 07:35 AM

Hi Fabrizio,

Sorry for the inconvenience caused.

You can refer the below link for updated sample on getting started with SfChart. We kindly request you to rebuild the application and check if the issue still exists.

Sample: http://www.syncfusion.com/downloads/support/forum/128820/ze/Chart_GettingStarted-477584956  

Please refer the following UG link for more details.

Link : https://help.syncfusion.com/xamarin/sfchart/getting-started  

If you still facing any issues, please update us the modified sample similar to your requirement which will be helpful for providing further assistance.

Regards,
Parthiban S 


Fabrizio Frigerio
Replied On February 14, 2017 06:00 AM

Hi Parthiban,

I've tried the new sample and it works despite some issues with Nuget packages not updating. In the sample all the binding was performed in Xaml but I need to set and change bindings in code behind. I've tried to move the xaml code into the cs file but seem to be impossible to add series in code behind, or rather are added but not plotted. I've added a zip file with all the files I've changed in the example. 
This code;

            Chart.Series.Add(new SplineSeries()
            {
                ItemsSource = "{Binding Data}",
                YAxis = YAxis_Right,
                XBindingPath = "Name",
                YBindingPath = "Age",
                Color = Color.Green,
                Label = "Age"
            });

does not plot the series, I had to define the series in xaml like this 

      <chart:SfChart.Series>
        <chart:SplineSeries ItemsSource="{Binding Data}" Label="Heights" XBindingPath="Name" YBindingPath="Height" EnableTooltip="True">
          <chart:ColumnSeries.DataMarker>
            <chart:ChartDataMarker/>
          </chart:ColumnSeries.DataMarker>
        </chart:SplineSeries>
        <chart:SplineSeries ItemsSource="{Binding Data}" Label="Ages" XBindingPath="Name" YBindingPath="Age" EnableTooltip="True">
          <chart:ColumnSeries.DataMarker>
            <chart:ChartDataMarker/>
          </chart:ColumnSeries.DataMarker>
        </chart:SplineSeries>
      </chart:SfChart.Series>

and then change what I need in code bihind like this:

            SplineSeries serie = (SplineSeries)Chart.Series[0];

            //serie.YBindingPath = "Age";
            serie.Color = Color.Aqua;

            serie = (SplineSeries)Chart.Series[1];
            serie.YAxis = YAxis_Right;
            serie.Color = Color.Green;

Thanks for the support.
Bye
Fabrizio

Attachment: ChartSample_7860bde4.zip

Parthiban Sundaram [Syncfusion]
Replied On February 15, 2017 09:34 AM

Hi Fabrizio,

Thanks for the update.

We have modified the sample based on your requirement. Please download the sample from following location.

Sample: http://www.syncfusion.com/downloads/support/forum/128820/ze/SimpleSample-396999530  

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

Regards,
Parthiban S 


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.

;