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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

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

Thread ID:

Created:

Updated:

Platform:

Replies:

142027 Jan 15,2019 06:24 PM UTC Jan 17,2019 04:31 AM UTC Xamarin.Forms 4
loading
Tags: SfChart
Tom
Asked On January 15, 2019 06:25 PM UTC

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.)


chart.Series.Add(series)

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.


Michael Prabhu M [Syncfusion]
Replied On January 16, 2019 05:58 AM UTC

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. 
CodeSnippet[F#]: 
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: 


Regards, 
Michael 



Tom
Replied On January 16, 2019 11:31 AM UTC

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

Tom
Replied On January 16, 2019 05:54 PM UTC

Solved it.

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

Michael Prabhu M [Syncfusion]
Replied On January 17, 2019 04:31 AM UTC

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. 
 
Thanks, 
Michael  



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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon