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.
chart.PrimaryAxis <- new CategoryAxis()
chart.SecondaryAxis <- new NumericalAxis() |