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

[Solved] SfChart working in UWP but not working on Android

Hello, I'm trying to get some charts working for an internal demo. We're using F# with all elements declared in code (not in XAML). 

The charts seem to work well in our UWP app but they don't display in our Android app.

Here's the sample code I'm using for the chart itself:

type DataPoint = { Name : string; Value : float }

let dps : DataPoint list = [{Name="1"; Value=5.};{Name="2"; Value=10.};{Name="3"; Value=15.};{Name="4"; Value=20.}]

let series:BarSeries = new BarSeries()

series.ItemsSource <- dps

series.XBindingPath <- "Name"

series.YBindingPath <- "Value"

series.DataMarker <- new ChartDataMarker()

series.EnableTooltip <- true

let chart:SfChart = new SfChart()

chart.Legend <- new ChartLegend()

chart.Legend.LabelStyle.FontSize <- (float32)14.

chart.Legend.DockPosition <- LegendPlacement.Bottom

chart.Legend.Orientation <- ChartOrientation.Horizontal

chart.Legend.LabelStyle.Margin <- new Thickness(10., 0.)


The chart is then put inside a ContentView - 

new ContentView(Content = chart, Padding = new Thickness(defaultSpacing), MinimumHeightRequest = 500., HeightRequest = 500., MinimumWidthRequest = 500., WidthRequest = 500., HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, BackgroundColor = Color.Transparent)

Which is the added to a Grid with these properties set (among others) - 

self.BackgroundColor <- (defaultArg style.BackgroundColor Colors.Transparent).Xamarin

self.Opacity <- defaultArg style.Opacity 1.

self.HorizontalOptions <- LayoutOptions.Fill

self.VerticalOptions <- LayoutOptions.Fill

self.ColumnSpacing <- defaultSpacing

self.RowSpacing <- defaultSpacing

self.Padding <- Thickness(defaultSpacing * 3., defaultSpacing * 1.6)

There don't seem to be any errors in logcat.

4 Replies

MP Michael Prabhu M Syncfusion Team January 16, 2019 12:58 AM

Hi Tom, 
Greetings from Syncfusion, we have analyzed your code snippet and found that you have missed to add the Axis for the chart Bar series.  
In UWP, chart is working due to the default axis support provided in UWP, but for Android and iOS, there is no default axis support. We need to set the axis for the chart using the chart PrimaryAxis and SecondaryAxis or using the series’s XAxis and YAxis, except for the accumulation series type (Pie, Doughnut,..) which doesn’t require axis. For all other series axis is mandatory, the series will render based on the axis only if we didn’t set any axis then series will not render properly. 
Please check by adding the axis for the chart as like in below code snippet. If you still face any issue get back with us. 
chart.PrimaryAxis <- new CategoryAxis() 
chart.SecondaryAxis <- new NumericalAxis() 
Change the axis type for Primary and secondary axis as per your need. 
Please refer the below UG link for more details: 


TO Tom January 16, 2019 06:31 AM

Thank you for your quick response. 

I've tried adding the 2 lines you've suggested but that made no difference. I've also tried different chart type - pie, doughnut, radar, bar. All work fine in UWP but none display on Android.

Thank you

TO Tom January 16, 2019 12:54 PM

Solved it.

I had the Syncfusion.Xamarin.SfChart.Android library in the Android project. Replaced that with Syncfusion.Xamarin.SfChart and it worked.

MP Michael Prabhu M Syncfusion Team January 16, 2019 11:31 PM

Hi Tom, 
Glad you found the solution, please contact us any time if you need another assistance from us. We are happy to help you. 

Live Chat Icon For mobile
Up arrow icon