|
| 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:model="clr-namespace:SmartphoneShipmentsDemo" |
| 6 | + x:Class="SmartphoneShipmentsDemo.MainPage"> |
| 7 | + |
| 8 | + <ContentPage.BindingContext> |
| 9 | + <model:ViewModel></model:ViewModel> |
| 10 | + </ContentPage.BindingContext> |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | + <ContentPage.Content> |
| 15 | + <Border Background="#e8ebe0" |
| 16 | + StrokeThickness="4" |
| 17 | + StrokeShape="RoundRectangle 40" |
| 18 | + Margin="30"> |
| 19 | + |
| 20 | + <Grid RowDefinitions="1*,7*" Margin="10,15,0,0" RowSpacing="0"> |
| 21 | + <!--Align Header--> |
| 22 | + <Grid Grid.Row="0" RowDefinitions="*,*,*"> |
| 23 | + |
| 24 | + <Label Text="Creating a Stacked Column Chart for Global Smartphone Shipments" |
| 25 | + TextColor="Black" |
| 26 | + FontSize="18" |
| 27 | + FontFamily="TimeSpan" |
| 28 | + FontAttributes="Bold" |
| 29 | + Grid.Row="0" |
| 30 | + Margin="18,0,0,0"/> |
| 31 | + |
| 32 | + <Label Text="The stacked column chart showcases the quarterly smartphone shipments throughout 2022 (Q1 to Q4), while the line chart illustrates the corresponding market shares over the same period" |
| 33 | + TextColor="Black" |
| 34 | + FontSize="12" |
| 35 | + FontFamily="TimeSpan" |
| 36 | + Grid.Row="1" |
| 37 | + Margin="18,3,0,0"/> |
| 38 | + <StackLayout Orientation="Horizontal" Grid.Row="2" Spacing="10" Margin="18,0,0,0"> |
| 39 | + <BoxView BackgroundColor="#9aa573" |
| 40 | + HeightRequest="10" |
| 41 | + WidthRequest="10" |
| 42 | + HorizontalOptions="Start" |
| 43 | + VerticalOptions="Start" |
| 44 | + Margin="0,4,0,0" /> |
| 45 | + |
| 46 | + <Label Text="Smartphone Shipments 2022[Q1-Q4][in Millions]" |
| 47 | + TextColor="Black" |
| 48 | + FontSize="12"/> |
| 49 | + |
| 50 | + <BoxView BackgroundColor="#555d3c" |
| 51 | + HeightRequest="2" |
| 52 | + WidthRequest="30" |
| 53 | + HorizontalOptions="Start" |
| 54 | + VerticalOptions="Start" |
| 55 | + Margin="0,8,0,0"/> |
| 56 | + |
| 57 | + <Label Text="Smartphone Market Share 2022[in Percentage]" |
| 58 | + TextColor="Black" |
| 59 | + FontSize="12"/> |
| 60 | + </StackLayout> |
| 61 | + </Grid> |
| 62 | + |
| 63 | + |
| 64 | + <chart:SfCartesianChart Grid.Row="1" > |
| 65 | + <!--Customise Tooltip--> |
| 66 | + <chart:SfCartesianChart.Resources> |
| 67 | + <DataTemplate x:Key="tooltipTemplate"> |
| 68 | + <StackLayout Orientation="Horizontal"> |
| 69 | + <Label Text="{Binding Item.BrandName}" |
| 70 | + TextColor="White" |
| 71 | + FontAttributes="Bold" |
| 72 | + FontSize="12" |
| 73 | + HorizontalOptions="Center" |
| 74 | + VerticalOptions="Center"/> |
| 75 | + <Label Text=" : " |
| 76 | + TextColor="White" |
| 77 | + FontAttributes="Bold" |
| 78 | + FontSize="12" |
| 79 | + HorizontalOptions="Center" |
| 80 | + VerticalOptions="Center"/> |
| 81 | + <Label Text="{Binding Item.MarketShare,StringFormat='{0:F1} %'}" |
| 82 | + TextColor="White" |
| 83 | + FontAttributes="Bold" |
| 84 | + FontSize="12" |
| 85 | + Margin="3,0,0,0" |
| 86 | + HorizontalOptions="Center" |
| 87 | + VerticalOptions="Center"/> |
| 88 | + </StackLayout> |
| 89 | + </DataTemplate> |
| 90 | + </chart:SfCartesianChart.Resources> |
| 91 | + |
| 92 | + <!--X-Axis--> |
| 93 | + <chart:SfCartesianChart.XAxes> |
| 94 | + <chart:CategoryAxis IsVisible="True" |
| 95 | + ShowMajorGridLines="False" |
| 96 | + AxisLineOffset="30"> |
| 97 | + <chart:CategoryAxis.LabelStyle> |
| 98 | + <chart:ChartAxisLabelStyle FontAttributes="Bold" /> |
| 99 | + </chart:CategoryAxis.LabelStyle> |
| 100 | + </chart:CategoryAxis> |
| 101 | + </chart:SfCartesianChart.XAxes> |
| 102 | + |
| 103 | + <!--Y-Axis--> |
| 104 | + <chart:SfCartesianChart.YAxes> |
| 105 | + <chart:NumericalAxis ShowMajorGridLines="False" |
| 106 | + Maximum="270" |
| 107 | + Interval="20" |
| 108 | + EdgeLabelsDrawingMode="Fit"> |
| 109 | + <chart:NumericalAxis.LabelStyle> |
| 110 | + <chart:ChartAxisLabelStyle FontAttributes="Bold"/> |
| 111 | + </chart:NumericalAxis.LabelStyle> |
| 112 | + </chart:NumericalAxis> |
| 113 | + <chart:NumericalAxis Name="YAxis" |
| 114 | + CrossesAt="{Static x:Double.MaxValue}" |
| 115 | + ShowMajorGridLines="False" |
| 116 | + EdgeLabelsDrawingMode="Fit"> |
| 117 | + <chart:NumericalAxis.LabelStyle> |
| 118 | + <chart:ChartAxisLabelStyle LabelFormat="0'%" |
| 119 | + FontAttributes="Bold"/> |
| 120 | + </chart:NumericalAxis.LabelStyle> |
| 121 | + </chart:NumericalAxis> |
| 122 | + </chart:SfCartesianChart.YAxes> |
| 123 | + |
| 124 | + <!--Quater 1 Smartphone shipments value--> |
| 125 | + <chart:StackingColumnSeries ShowDataLabels="True" |
| 126 | + ItemsSource="{Binding ShipmentsData}" |
| 127 | + XBindingPath="BrandName" |
| 128 | + YBindingPath="Quarter1" |
| 129 | + StrokeWidth="7" |
| 130 | + Fill="#9aa573"> |
| 131 | + <chart:StackingColumnSeries.DataLabelSettings> |
| 132 | + <chart:CartesianDataLabelSettings LabelPlacement="Inner" |
| 133 | + UseSeriesPalette="False" |
| 134 | + BarAlignment="Bottom"> |
| 135 | + <chart:CartesianDataLabelSettings.LabelStyle> |
| 136 | + <chart:ChartDataLabelStyle LabelFormat="0.##'M" |
| 137 | + TextColor="Black"/> |
| 138 | + </chart:CartesianDataLabelSettings.LabelStyle> |
| 139 | + </chart:CartesianDataLabelSettings> |
| 140 | + </chart:StackingColumnSeries.DataLabelSettings> |
| 141 | + |
| 142 | + </chart:StackingColumnSeries> |
| 143 | + |
| 144 | + |
| 145 | + <chart:StackingColumnSeries ShowDataLabels="True" |
| 146 | + ItemsSource="{Binding ShipmentsData}" |
| 147 | + XBindingPath="BrandName" |
| 148 | + YBindingPath="Quarter2" |
| 149 | + StrokeWidth="7" |
| 150 | + Fill="#a5af83"> |
| 151 | + <chart:StackingColumnSeries.DataLabelSettings> |
| 152 | + <chart:CartesianDataLabelSettings LabelPlacement="Inner" |
| 153 | + UseSeriesPalette="False" |
| 154 | + BarAlignment="Bottom"> |
| 155 | + <chart:CartesianDataLabelSettings.LabelStyle> |
| 156 | + <chart:ChartDataLabelStyle LabelFormat="0.##'M" |
| 157 | + TextColor="Black"/> |
| 158 | + </chart:CartesianDataLabelSettings.LabelStyle> |
| 159 | + </chart:CartesianDataLabelSettings> |
| 160 | + </chart:StackingColumnSeries.DataLabelSettings> |
| 161 | + </chart:StackingColumnSeries> |
| 162 | + |
| 163 | + <chart:StackingColumnSeries ShowDataLabels="True" |
| 164 | + ItemsSource="{Binding ShipmentsData}" |
| 165 | + XBindingPath="BrandName" |
| 166 | + YBindingPath="Quarter3" |
| 167 | + Fill="#b0b992"> |
| 168 | + <chart:StackingColumnSeries.DataLabelSettings> |
| 169 | + <chart:CartesianDataLabelSettings LabelPlacement="Inner" |
| 170 | + UseSeriesPalette="False" |
| 171 | + BarAlignment="Bottom"> |
| 172 | + <chart:CartesianDataLabelSettings.LabelStyle> |
| 173 | + <chart:ChartDataLabelStyle LabelFormat="0.##'M" |
| 174 | + TextColor="Black"/> |
| 175 | + </chart:CartesianDataLabelSettings.LabelStyle> |
| 176 | + </chart:CartesianDataLabelSettings> |
| 177 | + </chart:StackingColumnSeries.DataLabelSettings> |
| 178 | + </chart:StackingColumnSeries> |
| 179 | + |
| 180 | + <chart:StackingColumnSeries ShowDataLabels="True" |
| 181 | + ItemsSource="{Binding ShipmentsData}" |
| 182 | + XBindingPath="BrandName" |
| 183 | + YBindingPath="Quarter4" |
| 184 | + Fill="#bbc3a2"> |
| 185 | + <chart:StackingColumnSeries.DataLabelSettings> |
| 186 | + <chart:CartesianDataLabelSettings LabelPlacement="Inner" |
| 187 | + UseSeriesPalette="False" |
| 188 | + BarAlignment="Bottom"> |
| 189 | + <chart:CartesianDataLabelSettings.LabelStyle> |
| 190 | + <chart:ChartDataLabelStyle TextColor="Black" |
| 191 | + LabelFormat="0.##'M"/> |
| 192 | + </chart:CartesianDataLabelSettings.LabelStyle> |
| 193 | + </chart:CartesianDataLabelSettings> |
| 194 | + |
| 195 | + </chart:StackingColumnSeries.DataLabelSettings> |
| 196 | + </chart:StackingColumnSeries> |
| 197 | + |
| 198 | + <chart:LineSeries XBindingPath="BrandName" |
| 199 | + YBindingPath="MarketShare" |
| 200 | + ItemsSource="{Binding ShipmentsData}" |
| 201 | + YAxisName="YAxis" |
| 202 | + ShowMarkers="True" |
| 203 | + EnableTooltip="True" |
| 204 | + TooltipTemplate="{StaticResource tooltipTemplate}" |
| 205 | + Fill="#555d3c"> |
| 206 | + <chart:LineSeries.MarkerSettings> |
| 207 | + <chart:ChartMarkerSettings Type="Circle" |
| 208 | + Height="8" |
| 209 | + Width="8"/> |
| 210 | + </chart:LineSeries.MarkerSettings> |
| 211 | + </chart:LineSeries> |
| 212 | + </chart:SfCartesianChart> |
| 213 | + </Grid> |
| 214 | + </Border> |
| 215 | + </ContentPage.Content> |
| 216 | +</ContentPage> |
0 commit comments