)
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

How to display underlying model values in Xamarin.Forms Chart data marker?

Platform: Xamarin.Forms |
Control: SfChart |
Published Date: April 25, 2018 |
Last Revised Date: August 21, 2019

The data marker label is entirely customizable using data template. The binding context of data template will be the respective underlying object, so you can bind any property from the model to the elements of data template. Refer to the documentation to learn more about data markers.

The following code example and screenshot show how to display the X value along with Y value in data label.

 

<chart:PieSeries ItemsSource="{Binding Data}" XBindingPath="Name" YBindingPath="Height">
    <chart:PieSeries.ColorModel>
        <chart:ChartColorModel Palette="Natural" />
    </chart:PieSeries.ColorModel>
    <chart:PieSeries.DataMarker>
        <chart:ChartDataMarker>
            <chart:ChartDataMarker.LabelTemplate>
                <DataTemplate>
                    <StackLayout Orientation="Horizontal">
                        <Label FontSize="12" TextColor="White" Text="{Binding Name, StringFormat='{0} : '}" />
                        <Label FontSize="12" TextColor="White" Text="{Binding Height}" />
                    </StackLayout>
                </DataTemplate>
            </chart:ChartDataMarker.LabelTemplate>
        </chart:ChartDataMarker>
    </chart:PieSeries.DataMarker>
</chart:PieSeries>

 

Output:

C:\Users\prabakaranr\AppData\Local\Microsoft\Windows\INetCache\Content.Word\Screen Shot 2018-04-25 at 11.32.50 AM.PNG

 

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
ADD COMMENT
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
Live Chat Icon