|
| 1 | +<!-- Copyright (c) Microsoft Corporation and Contributors. --> |
| 2 | +<!-- Licensed under the MIT License. --> |
| 3 | + |
| 4 | +<Window |
| 5 | + x:Class="PieChart_GroupedDataLabel.MainWindow" |
| 6 | + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| 7 | + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 8 | + xmlns:local="using:PieChart_GroupedDataLabel" |
| 9 | + xmlns:chart="using:Syncfusion.UI.Xaml.Charts" |
| 10 | + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
| 11 | + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
| 12 | + mc:Ignorable="d"> |
| 13 | + <Grid> |
| 14 | + <Grid.DataContext> |
| 15 | + <local:ViewModel x:Name="viewModel"/> |
| 16 | + </Grid.DataContext> |
| 17 | + <Grid.Resources> |
| 18 | + <local:DataLabelXValueConverter x:Key="dataLabelXValue"/> |
| 19 | + <local:DataLabelYValueConverter x:Key="dataLabelYValue" /> |
| 20 | + <DataTemplate x:Key="dataMarkerTemplate"> |
| 21 | + <StackPanel BorderBrush="Black" BorderThickness="1" CornerRadius="2" Orientation="Horizontal"> |
| 22 | + <TextBlock Foreground="Black" FontWeight="Bold" Text="{Binding Converter={StaticResource dataLabelXValue}}" /> |
| 23 | + <TextBlock Text=": " Foreground="Black" FontWeight="Bold"/> |
| 24 | + <TextBlock Foreground="Black" FontWeight="Bold" Text="{Binding Converter={StaticResource dataLabelYValue}}" /> |
| 25 | + </StackPanel> |
| 26 | + </DataTemplate> |
| 27 | + <BrushCollection x:Key="customBrushes"> |
| 28 | + <SolidColorBrush Color="#585DAC"/> |
| 29 | + <SolidColorBrush Color="#B28DD4"/> |
| 30 | + <SolidColorBrush Color="#5DAC88"/> |
| 31 | + <SolidColorBrush Color="#F2BB30"/> |
| 32 | + <SolidColorBrush Color="#E66C69"/> |
| 33 | + <SolidColorBrush Color="#27B9B4"/> |
| 34 | + <SolidColorBrush Color="#FB6690"/> |
| 35 | + </BrushCollection> |
| 36 | + </Grid.Resources> |
| 37 | + <Grid.ColumnDefinitions> |
| 38 | + <ColumnDefinition/> |
| 39 | + </Grid.ColumnDefinitions> |
| 40 | + <chart:SfCircularChart Margin="10"> |
| 41 | + <chart:SfCircularChart.Header> |
| 42 | + <TextBlock Text="Sales Percentage" FontWeight="Bold" /> |
| 43 | + </chart:SfCircularChart.Header> |
| 44 | + <chart:PieSeries XBindingPath="Product" ShowDataLabels="True" Radius="0.7" |
| 45 | + GroupTo="10" GroupMode="Percentage" YBindingPath="SalesPercentage" |
| 46 | + ItemsSource="{Binding Data}" |
| 47 | + PaletteBrushes="{StaticResource customBrushes}"> |
| 48 | + <chart:PieSeries.DataLabelSettings> |
| 49 | + <chart:CircularDataLabelSettings ShowConnectorLine="True" |
| 50 | + Context="DataLabelItem" |
| 51 | + Position="OutsideExtended" |
| 52 | + UseSeriesPalette="True" |
| 53 | + ContentTemplate="{StaticResource dataMarkerTemplate}" /> |
| 54 | + </chart:PieSeries.DataLabelSettings> |
| 55 | + |
| 56 | + </chart:PieSeries> |
| 57 | + </chart:SfCircularChart> |
| 58 | + </Grid> |
| 59 | +</Window> |
0 commit comments