|
| 1 | +<?xml version="1.0" encoding="utf-8" ?> |
| 2 | +<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" |
| 3 | + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" |
| 4 | + xmlns:chart="clr-namespace:Syncfusion.Maui.Charts;assembly=Syncfusion.Maui.Charts" |
| 5 | + xmlns:local="clr-namespace:DoughnutChart" |
| 6 | + x:Class="DoughnutChart.MainPage"> |
| 7 | + |
| 8 | + <Border StrokeThickness="1" Stroke="Black" Margin="{OnPlatform Default=8, iOS=20}" > |
| 9 | + |
| 10 | + <Border.StrokeShape> |
| 11 | + <RoundRectangle CornerRadius="14" /> |
| 12 | + </Border.StrokeShape> |
| 13 | + |
| 14 | + <Grid> |
| 15 | + |
| 16 | + <chart:SfCircularChart Margin="{OnPlatform Default='10', iOS='-70, 10, 10, 10'}" > |
| 17 | + |
| 18 | + <chart:SfCircularChart.BindingContext> |
| 19 | + <local:DataViewModel /> |
| 20 | + </chart:SfCircularChart.BindingContext> |
| 21 | + |
| 22 | + <chart:SfCircularChart.Resources> |
| 23 | + <local:CenterViewDimension x:Key="dimension"/> |
| 24 | + </chart:SfCircularChart.Resources> |
| 25 | + |
| 26 | + <chart:SfCircularChart.Title> |
| 27 | + <Grid ColumnSpacing="10" Margin="5, 0, 0, 0"> |
| 28 | + |
| 29 | + <Grid.ColumnDefinitions> |
| 30 | + <ColumnDefinition Width="Auto" /> |
| 31 | + <ColumnDefinition Width="*" /> |
| 32 | + </Grid.ColumnDefinitions> |
| 33 | + |
| 34 | + <BoxView Color="#34ea61" WidthRequest="{OnPlatform Android=10, Default=15, iOS=10}" |
| 35 | + HeightRequest="{OnPlatform Android=35, WinUI=80, MacCatalyst=50, iOS=35}"/> |
| 36 | + |
| 37 | + <VerticalStackLayout Grid.Column="1" Margin="{OnPlatform Android='-5, 0, 0, 0'}"> |
| 38 | + <Label Text="Agriculture is the Biggest Employer in India" |
| 39 | + FontSize="{OnPlatform Android=Small, Default=Large, iOS=Small}" FontAttributes="Bold" |
| 40 | + Grid.Row="0"/> |
| 41 | + |
| 42 | + <Label Text="Share of workers in India, by broad industry of (2021-2022)" |
| 43 | + TextColor="DarkSlateGray" FontSize="{OnPlatform Android=Micro, Default=Small, iOS=Small}" |
| 44 | + Grid.Row="1"/> |
| 45 | + </VerticalStackLayout> |
| 46 | + |
| 47 | + </Grid> |
| 48 | + </chart:SfCircularChart.Title> |
| 49 | + |
| 50 | + <chart:SfCircularChart.Legend> |
| 51 | + <chart:ChartLegend Placement="{OnPlatform Android=Bottom, Default=Right, iOS=Bottom}" /> |
| 52 | + </chart:SfCircularChart.Legend> |
| 53 | + |
| 54 | + <chart:DoughnutSeries ItemsSource="{Binding DataCollection}" |
| 55 | + XBindingPath="Industry" |
| 56 | + YBindingPath="Percent" |
| 57 | + LabelContext="Percentage" |
| 58 | + InnerRadius="0.6" |
| 59 | + ShowDataLabels="True" |
| 60 | + PaletteBrushes="{Binding CustomBrushes}"> |
| 61 | + |
| 62 | + <chart:DoughnutSeries.DataLabelSettings> |
| 63 | + <chart:CircularDataLabelSettings LabelPosition="Outside" /> |
| 64 | + </chart:DoughnutSeries.DataLabelSettings> |
| 65 | + |
| 66 | + <chart:DoughnutSeries.CenterView> |
| 67 | + <StackLayout HeightRequest="{Binding CenterHoleSize, Converter={StaticResource dimension}}" WidthRequest="{Binding CenterHoleSize}" VerticalOptions="Center" HorizontalOptions="Center" Margin="{OnPlatform Default='0, -10, 0, 0', Android='0', MacCatalyst='0, 30, 0, 0', iOS='0'}"> |
| 68 | + <Image Source="agri.png" WidthRequest="{OnPlatform Android=40, iOS=40, WinUI=60, MacCatalyst=150}" IsVisible="{OnPlatform Default='True', Android='False', iOS='False'}"/> |
| 69 | + <Label Text="Agriculture employs 45.5% of India's workforce" MaxLines="4" FontSize="{OnPlatform Android=12, iOS=12, MacCatalyst=18}" VerticalOptions="Center" |
| 70 | + Margin="{OnPlatform Default='10, 0, 10, 0', MacCatalyst='0', Android='2, 27, 2, 0', iOS='0, 20, 0, 0'}" HorizontalTextAlignment="Center" |
| 71 | + MaximumWidthRequest="{OnPlatform MacCatalyst=280, iOS=90}"/> |
| 72 | + </StackLayout> |
| 73 | + </chart:DoughnutSeries.CenterView> |
| 74 | + |
| 75 | + <!--To enable the selection support--> |
| 76 | + <chart:DoughnutSeries.SelectionBehavior> |
| 77 | + <chart:DataPointSelectionBehavior SelectionChanging="DataPointSelectionBehavior_SelectionChanging"/> |
| 78 | + </chart:DoughnutSeries.SelectionBehavior> |
| 79 | + |
| 80 | + </chart:DoughnutSeries> |
| 81 | + |
| 82 | + </chart:SfCircularChart> |
| 83 | + </Grid> |
| 84 | + </Border> |
| 85 | +</ContentPage> |
0 commit comments