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

System.TypeInitializationException trying to change Getting Started Example

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

3 Replies

PS Parthiban Sundaram Syncfusion Team February 13, 2017 12:35 PM UTC

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 



FF Fabrizio Frigerio February 14, 2017 11:00 AM UTC

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


PS Parthiban Sundaram Syncfusion Team February 15, 2017 02:34 PM UTC

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 


Loader.
Up arrow icon