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

Sfchart getting crashed in android

Not sure it was showing null in android but works fine in ios,Anything we have missed.

7 Replies

BK Bharathiraja K Syncfusion Team May 20, 2019 05:21 AM UTC

Hi Esperanza, 
 
Greetings from Syncfusion. Since we are not aware of your chart samples and application scenario, we are unable to proceed further with the given details. So, could you please share your application scenario, code snippet or mock-up project which is used in your application with replication steps. This will be helpful for us to investigate further and provide you a better solution at the earliest. 
 
Regards, 
Bharathi. 



ES Esperanza May 21, 2019 06:41 PM UTC

I am getting this exception while launching the app.
"  at Com.Syncfusion.Charts.SfChart.BaseInitialize () [0x00081] in <3857128fc7914fdfbd37196f0eefb893>:0   at Com.Syncfusion.Charts.ChartBase.Initialize () [0x00000] in <3857128fc7914fdfbd37196f0eefb893>:0   at Com.Syncfusion.Charts.ChartBase..ctor (Android.Content.Context context) [0x0002b] in <3857128fc7914fdfbd37196f0eefb893>:0   at Com.Syncfusion.Charts.SfChart..ctor (Android.Content.Context context) [0x00027] in <3857128fc7914fdfbd37196f0eefb893>:0   at Syncfusion.SfChart.XForms.Droid.SfChartExt..ctor (Android.Content.Context context) [0x00000] in <3857128fc7914fdfbd37196f0eefb893>:0   at Syncfusion.SfChart.XForms.Droid.SfChartRenderer.GetNativeChart (Syncfusion.SfChart.XForms.SfChart sfChart) [0x00029] in <3857128fc7914fdfbd37196f0eefb893>:0   at Syncfusion.SfChart.XForms.Droid.SfChartRenderer.OnElementChanged (Xamarin.Forms.Platform.Android.ElementChangedEventArgs`1[TElement] e) [0x00095] in <3857128fc7914fdfbd37196f0eefb893>:0   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000c3] in D:\\a\\1\\s\\Xamarin.Forms.Platform.Android\\VisualElementRenderer.cs:228   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00027] in D:\\a\\1\\s\\Xamarin.Forms.Platform.Android\\VisualElementRenderer.cs:127   at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x0001f] in D:\\a\\1\\s\\Xamarin.Forms.Platform.Android\\Platform.cs:338   at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x000af] in D:\\a\\1\\s\\Xamarin.Forms.Platform.Android\\VisualElementPackager.cs:120   at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x00139] in D:\\a\\1\\s\\Xamarin.Forms.Platform.Android\\VisualElementPackager.cs:268   at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () [0x00000] in D:\\a\\1\\s\\Xamarin.Forms.Platform.Android\\VisualElementPackager.cs:92   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) [0x00007] in D:\\a\\1\\s\\Xamarin.Forms.Platform.Android\\VisualElementRenderer.cs:414   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000e0] in D:\\a\\1\\s\\Xamarin.Forms.Platform.Android\\VisualElementRenderer.cs:231   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00027] in D:\\a\\1\\s\\Xamarin.Forms.Platform.Android\\VisualElementRenderer.cs:127   at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x0001f] in D:\\a\\1\\s\\Xamarin.Forms.Platform.Android\\Platform.cs:338   at Xamarin.Forms.Platform.Android.ScrollViewContainer.set_ChildView (Xamarin.Forms.View value) [0x0002f] in D:\\a\\1\\s\\Xamarin.Forms.Platform.Android\\Renderers\\ScrollViewContainer.cs:36   at Xamarin.Forms.Platform.Android.ScrollViewRenderer.LoadContent () [0x00000] in D:\\a\\1\\s\\Xamarin.Forms.Platform.Android\\Renderers\\ScrollViewRenderer.cs:347   at Xamarin.Forms.Platform.Android.ScrollViewRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x000a6] in D:\\a\\1\\s\\Xamarin.Forms.Platform.Android\\Renderers\\ScrollViewRenderer.cs:94   at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x0001f] in D:\\a\\1\\s\\Xamarin.Forms.Platform.Android\\Platform.cs:338   at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer


BK Bharathiraja K Syncfusion Team May 22, 2019 06:02 AM UTC

Hi Esperanza, 
 
We are suspecting that you are installed both native and forms packages in your project. Please uninstall all the packages and follow the below guide lines, 
 
Xamarin.Forms 
Xamarin.Android 
Xamarin.iOS 
 
If it not solves your problem, please revert us with chart configuration code snippet.  
 
Regards, 
Bharathi. 



ES Esperanza May 24, 2019 05:15 AM UTC

The above is the xaml code which I have used 
<?xml version="1.0" encoding="UTF-8"?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" 
             xmlns:local="clr-namespace:Daatos;assembly=Daatos" 
                 xmlns:chart="clr-namespace:Syncfusion.SfChart.XForms;assembly=Syncfusion.SfChart.XForms"
             x:Class="Daatos.ChartPage">
    <ContentPage.Content>
           <StackLayout Orientation="Vertical" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand">
  <chart:SfChart x:Name="Chart" HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" >

    <chart:SfChart.BindingContext>
      <local:NutrientViewModel/>
    </chart:SfChart.BindingContext>

    <chart:SfChart.Legend>
      <chart:ChartLegend />
    </chart:SfChart.Legend>

    <chart:SfChart.Title>
      <chart:ChartTitle Text="Chart"/>
    </chart:SfChart.Title>

    <chart:SfChart.PrimaryAxis>
      <chart:CategoryAxis>
        <chart:CategoryAxis.Title>
          <chart:ChartAxisTitle Text="Nutrients"/>
        </chart:CategoryAxis.Title>
      </chart:CategoryAxis>
    </chart:SfChart.PrimaryAxis>

    <chart:SfChart.SecondaryAxis>
      <chart:NumericalAxis>
        <chart:NumericalAxis.Title>
          <chart:ChartAxisTitle Text="value"/>
        </chart:NumericalAxis.Title>
      </chart:NumericalAxis>
    </chart:SfChart.SecondaryAxis>

    <chart:SfChart.Series>
      <chart:ColumnSeries ItemsSource="{Binding Data}" Label="Nutrients" XBindingPath="Nutrients" YBindingPath="value" EnableTooltip="True">
        <chart:ColumnSeries.DataMarker>
          <chart:ChartDataMarker/>
        </chart:ColumnSeries.DataMarker>
      </chart:ColumnSeries>
    </chart:SfChart.Series>
  </chart:SfChart>
            

            </StackLayout>
    </ContentPage.Content>
</ContentPage>


The view model class is as below

public class NutrientViewModel
    {
        public List<NutrientsClass> Data { get; set; }

        public List<NutrientsClass> ColData { get; set; }

        public  NutrientResponse nutrientResponse { get; set; }
        public NutrientViewModel()
        {
          
            nutrientResponse = NutritionOverview.nutrientResponse;

            if (nutrientResponse != null)
            {
                Data = new List<NutrientsClass>()
            {
                new NutrientsClass { Nutrients = "calories", value =""+nutrientResponse.Content[0].calories },
                new NutrientsClass { Nutrients = "carbs", value = ""+nutrientResponse.Content[0].carbs },
                new NutrientsClass { Nutrients = "protein", value = ""+nutrientResponse.Content[0].protein },
                new NutrientsClass { Nutrients = "fat", value= ""+nutrientResponse.Content[0].fat }
            };
            }
            else {
                Data = new List<NutrientsClass>()
            {
                new NutrientsClass { Nutrients = "calories", value ="20" },
                new NutrientsClass { Nutrients = "carbs", value = "20" },
                new NutrientsClass { Nutrients = "protein", value = "20" },
                new NutrientsClass { Nutrients = "fat", value= "20"}
            };
            }

            ColData = Data;

 


        }
    }




SM Saravanan Madheswaran Syncfusion Team May 24, 2019 01:53 PM UTC

Hi Esperanza, 
 
Thanks for your patience.  
 
We have validated your chart code snippet, and we figured that you were bind string value for YBindingPath.  
We would like to let you know that the numeric axis will not support for string value, but it partially works when the value is able to convert as double.  
 
So, we suggested to convert the string value to double and bind it to the chart. 
[C#] 
public class NutrientsClass 
{ 
    public double value { get; set; } 
 
    public string Nutrients { get; set; } 
} 
 
[Xaml] 
      <chart:ColumnSeries ItemsSource="{Binding Data}" Label="Nutrients" XBindingPath="Nutrients" YBindingPath="value" EnableTooltip="True"> 
                        <chart:ColumnSeries.DataMarker> 
                            <chart:ChartDataMarker/> 
                        </chart:ColumnSeries.DataMarker> 
                    </chart:ColumnSeries> 
 
Note: Are you trying to add any string values to display it in chart axis? If yes, we can change the format of axis labels by using LabelFormat of LabelStyle class 
 
  <chart:NumericalAxis x:Name="numericalAxis"  > 
                    . . .  
                    <chart:NumericalAxis.LabelStyle> 
                        <chart:ChartAxisLabelStyle LabelFormat="## kCal"/> 
                    </chart:NumericalAxis.LabelStyle> 
 </chart:NumericalAxis> 
 
 
Regards, 
Saravanan.  
 



ES Esperanza replied to Saravanan Madheswaran May 25, 2019 12:01 PM UTC

Hi Esperanza, 
 
Thanks for your patience.  
 
We have validated your chart code snippet, and we figured that you were bind string value for YBindingPath.  
We would like to let you know that the numeric axis will not support for string value, but it partially works when the value is able to convert as double.  
 
So, we suggested to convert the string value to double and bind it to the chart. 
[C#] 
public class NutrientsClass 
{ 
    public double value { get; set; } 
 
    public string Nutrients { get; set; } 
} 
 
[Xaml] 
      <chart:ColumnSeries ItemsSource="{Binding Data}" Label="Nutrients" XBindingPath="Nutrients" YBindingPath="value" EnableTooltip="True"> 
                        <chart:ColumnSeries.DataMarker> 
                            <chart:ChartDataMarker/> 
                        </chart:ColumnSeries.DataMarker> 
                    </chart:ColumnSeries> 
 
Note: Are you trying to add any string values to display it in chart axis? If yes, we can change the format of axis labels by using LabelFormat of LabelStyle class 
 
  <chart:NumericalAxis x:Name="numericalAxis"  > 
                    . . .  
                    <chart:NumericalAxis.LabelStyle> 
                        <chart:ChartAxisLabelStyle LabelFormat="## kCal"/> 
                    </chart:NumericalAxis.LabelStyle> 
 </chart:NumericalAxis> 
 
 
Regards, 
Saravanan.  
 


HI Done the same but no use. Still getting crash in android can you mention the sfchart version that i need to use. Attached iOS screenshot.



Attachment: ios_38a37448.zip


BK Bharathiraja K Syncfusion Team May 27, 2019 07:37 AM UTC

Hi Esperanza,  
 
Please use our latest NuGet package version 17.1.0.48 and let us know whether the issue reproduced or not. Still you are facing the issue, please share the below details. 
 
1.     Share the Android OS version, Syncfusion NuGet version 
2.     Device details 
3.     Share the Mock-up project to reproduce the issue our side  
 
This will be helpful for us to investigate further and provide you a better solution at the earliest. 
 
Regards, 
Bharathi. 


Loader.
Live Chat Icon For mobile
Up arrow icon