I am looking to use the Bar Chart and the 100% Stacked Bar Chart in my mobile app with the label above the corresponding bar. I need to do this conserve screen space as some of the labels might be long. I would like the Bar Chart and 100% Stacked Bar to be formatted similarly to this:Is there a way to have the labels like this in these charts?Thank you in advance for any help.

| <ContentPage.Resources> <ResourceDictionary> <DataTemplate x:Key="dataMarkerTemplate"> <StackLayout Orientation="Horizontal"> <Label Text="{Binding XValue}" VerticalOptions="Center" FontSize = "15"/> </StackLayout> </DataTemplate> </ResourceDictionary> </ContentPage.Resources> <chart:BarSeries x:Name="series1" Width="0.5" Color="Transparent" ItemsSource="{Binding Data}" XBindingPath="XValue" YBindingPath="YValue2"> <chart:BarSeries.DataMarker> <chart:ChartDataMarker ShowLabel="True" LabelTemplate="{StaticResource dataMarkerTemplate}"> <chart:ChartDataMarker.LabelStyle> <chart:DataMarkerLabelStyle LabelPosition="Outer" /> </chart:ChartDataMarker.LabelStyle> </chart:ChartDataMarker> </chart:BarSeries.DataMarker> </chart:BarSeries> |
| BarSeries barSeries = new BarSeries() { ItemsSource = viewModel.Data, XBindingPath = "XValue", YBindingPath = "YValue2", }; barSeries.DataMarker = new ChartDataMarker(); barSeries.DataMarker.ShowLabel = true; barSeries.DataMarker.LabelStyle.LabelPosition = DataMarkerLabelPosition.Outer; DataTemplate dataMarkerTemplate = new DataTemplate(() => { StackLayout stack = new StackLayout(); Label label = new Label(); label.SetBinding(Label.TextProperty, "XValue"); label.FontSize = 15; label.VerticalOptions = LayoutOptions.Center; stack.Children.Add(label); return stack; }); barSeries.DataMarker.LabelTemplate = dataMarkerTemplate; chart.Series.Add(barSeries); |