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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to place the Xamarin.Forms Chart DataMarker label at the top and bottom of the marker alternatively?

Platform: Xamarin.Forms |
Control: SfChart |
Published Date: July 26, 2019 |
Last Revised Date: August 21, 2019

You can place the ChartDataMarkerLabel at the top and bottom positions of the marker alternatively using the converter and the ChartDataMarker LabelTemplate.


The following code sample demonstrates how to place the data marker label at the top and bottom positions of the marker alternatively.



                <local:MarginConverter x:Key="marginConverter"/>
      <chart:LineSeries x:Name="series" ItemsSource="{Binding Data}">
                        <chart:ChartDataMarker ShowMarker="True" MarkerHeight="10"                        
                                            MarkerWidth="10" MarkerColor="Blue">
                                     <chart:DataMarkerLabelStyle LabelPosition="Center"/>
                                            <StackLayout BackgroundColor="Transparent">
                                                  <Label Text="{Binding YValue}" BackgroundColor="Aqua" 
                                                              Margin="{Binding Converter={StaticResource      
                                                                         marginConverter}, Mode=Default}"/>



public class MarginConverter : IValueConverter
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
            if (value != null)
                var data = value as Model;
                if (data.Index % 2 == 0)
                    value = new Thickness(0, 0, 0, 30);
                    value = new Thickness(0, 30, 0, 0);
            return value;
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
            return value;


Placing SfChart DataMarker label position at top and bottom of the marker alternatively

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

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

Up arrow icon

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