Articles in this section
Category / Section

How to return the percentages of the total for each data points in the series and bind the data labels to this

1 min read

We can display the percentage of each data points by using the DataTemplate. The Following code snippet explains the same.

XAML

<DataTemplate x:Key="LabelsTemplate">
<Grid>
<TextBlock Margin="7.5,3,7.5,3" TextWrapping="Wrap" Text="{Binding Converter={StaticResource labelconvert}}" FontSize="12" Foreground="Black" Opacity="0.5" FontFamily="Segoe UI Symbol" FontWeight="Regular" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</Grid>
</DataTemplate>

We can bind the Text of the Data Template with a Converter class. In the above code snippet “labelconverter” is the Converter class. The following is an example code snippet

C#

public class Labelconvertor : IValueConverter

{

public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

{

double a, b;

b = System.Convert.ToDouble(value);

a = (b / 3000000) * 100;

return String.Format("{0} %", a);

}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)

{

throw new NotImplementedException();

}

}

 

 

http://www.syncfusion.com/downloads/Support/DirectTrac/101773/clip_image001-955269359.png

Figure: Pivot Grid shows the percentages of total for each of data points

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied