|
| 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 | + x:Class="RangeColumnChartDemo.MainPage" |
| 5 | + xmlns:chart="clr-namespace:Syncfusion.Maui.Charts;assembly=Syncfusion.Maui.Charts" |
| 6 | + xmlns:local="clr-namespace:RangeColumnChartDemo"> |
| 7 | + |
| 8 | + <ContentPage.BindingContext> |
| 9 | + <local:ViewModel/> |
| 10 | + </ContentPage.BindingContext> |
| 11 | + |
| 12 | + <ContentPage.Content> |
| 13 | + |
| 14 | + <Border BackgroundColor="White" Stroke="#BEB1AE" Margin="10,20,10,10" Padding="10"> |
| 15 | + |
| 16 | + <Border.StrokeShape> |
| 17 | + <RoundRectangle CornerRadius="30"/> |
| 18 | + </Border.StrokeShape> |
| 19 | + |
| 20 | + <Grid> |
| 21 | + <Grid.RowDefinitions> |
| 22 | + <RowDefinition Height="8*"/> |
| 23 | + <RowDefinition Height="20"/> |
| 24 | + </Grid.RowDefinitions> |
| 25 | + |
| 26 | + <chart:SfCartesianChart Margin="10" BackgroundColor="White" EnableSideBySideSeriesPlacement="True"> |
| 27 | + |
| 28 | + <chart:SfCartesianChart.Title> |
| 29 | + <Grid> |
| 30 | + <Grid.RowDefinitions> |
| 31 | + <RowDefinition Height="Auto"/> |
| 32 | + </Grid.RowDefinitions> |
| 33 | + <HorizontalStackLayout Grid.Column="0"> |
| 34 | + <Image Source="cloud.jpg" WidthRequest="40" HeightRequest="40"/> |
| 35 | + <Label VerticalOptions="Center" |
| 36 | + Text="Average Temperature Variations in Rome: 2021 vs. 2022" FontSize="18"/> |
| 37 | + </HorizontalStackLayout> |
| 38 | + </Grid> |
| 39 | + </chart:SfCartesianChart.Title> |
| 40 | + |
| 41 | + <chart:SfCartesianChart.Legend> |
| 42 | + <chart:ChartLegend ItemTemplate="{StaticResource LegendTemplate}"> |
| 43 | + </chart:ChartLegend> |
| 44 | + </chart:SfCartesianChart.Legend> |
| 45 | + |
| 46 | + <chart:SfCartesianChart.Resources> |
| 47 | + <ResourceDictionary> |
| 48 | + <DataTemplate x:Key="LegendTemplate"> |
| 49 | + <Grid ColumnDefinitions="Auto,Auto" ColumnSpacing="5"> |
| 50 | + <HorizontalStackLayout> |
| 51 | + <Ellipse HorizontalOptions="Center" VerticalOptions="Center" |
| 52 | + HeightRequest="13" WidthRequest="13" Margin="0,3,3,0" |
| 53 | + Fill="{Binding IconBrush}"/> |
| 54 | + <Label Grid.Column="1" FontSize="16" VerticalTextAlignment="Center" |
| 55 | + Text="{Binding Item.Label}" TextColor="Black" |
| 56 | + HorizontalOptions="Center" HorizontalTextAlignment="Start"/> |
| 57 | + </HorizontalStackLayout> |
| 58 | + </Grid> |
| 59 | + </DataTemplate> |
| 60 | + </ResourceDictionary> |
| 61 | + </chart:SfCartesianChart.Resources> |
| 62 | + |
| 63 | + <chart:SfCartesianChart.XAxes> |
| 64 | + <chart:CategoryAxis LabelPlacement="BetweenTicks"> |
| 65 | + <chart:CategoryAxis.LabelStyle> |
| 66 | + <chart:ChartAxisLabelStyle TextColor="Black" FontSize="Caption"/> |
| 67 | + </chart:CategoryAxis.LabelStyle> |
| 68 | + </chart:CategoryAxis> |
| 69 | + </chart:SfCartesianChart.XAxes> |
| 70 | + |
| 71 | + <chart:SfCartesianChart.YAxes> |
| 72 | + <chart:NumericalAxis Minimum="-5" Maximum="40" ShowMajorGridLines="False"> |
| 73 | + <chart:NumericalAxis.LabelStyle> |
| 74 | + <chart:ChartAxisLabelStyle TextColor="Black" FontSize="Caption"/> |
| 75 | + </chart:NumericalAxis.LabelStyle> |
| 76 | + </chart:NumericalAxis> |
| 77 | + </chart:SfCartesianChart.YAxes> |
| 78 | + |
| 79 | + <chart:RangeColumnSeries Width="{x:OnPlatform Android='0.9', iOS='0.9', Default='0.8'}" Fill="#98fb98" ShowDataLabels="True" Label="2021" |
| 80 | + ItemsSource="{Binding TemperatureCollection}" |
| 81 | + XBindingPath="Month" High="High2021" Low="Low2021"> |
| 82 | + <chart:RangeColumnSeries.DataLabelSettings> |
| 83 | + <chart:CartesianDataLabelSettings UseSeriesPalette="False"> |
| 84 | + <chart:CartesianDataLabelSettings.LabelStyle> |
| 85 | + <chart:ChartDataLabelStyle TextColor="Black"/> |
| 86 | + </chart:CartesianDataLabelSettings.LabelStyle> |
| 87 | + </chart:CartesianDataLabelSettings> |
| 88 | + </chart:RangeColumnSeries.DataLabelSettings> |
| 89 | + </chart:RangeColumnSeries> |
| 90 | + |
| 91 | + <chart:RangeColumnSeries Width="{x:OnPlatform Android='0.9', iOS='0.9', Default='0.8'}" Fill="#ff1493" ShowDataLabels="True" Label="2022" |
| 92 | + ItemsSource="{Binding TemperatureCollection}" |
| 93 | + XBindingPath="Month" High="High2022" Low="Low2022"> |
| 94 | + <chart:RangeColumnSeries.DataLabelSettings> |
| 95 | + <chart:CartesianDataLabelSettings UseSeriesPalette="False"> |
| 96 | + <chart:CartesianDataLabelSettings.LabelStyle> |
| 97 | + <chart:ChartDataLabelStyle TextColor="White" FontAttributes="Bold"/> |
| 98 | + </chart:CartesianDataLabelSettings.LabelStyle> |
| 99 | + </chart:CartesianDataLabelSettings> |
| 100 | + </chart:RangeColumnSeries.DataLabelSettings> |
| 101 | + </chart:RangeColumnSeries> |
| 102 | + |
| 103 | + </chart:SfCartesianChart> |
| 104 | + |
| 105 | + <Label Grid.Row="1" FontSize="Caption" FontAttributes="Italic" |
| 106 | + Text="Monthly temperature range at a weather station in Rome (Sallustiano), Italy, in 2021 and 2022, in °C."> |
| 107 | + </Label> |
| 108 | + |
| 109 | + </Grid> |
| 110 | + |
| 111 | + </Border> |
| 112 | + |
| 113 | + </ContentPage.Content> |
| 114 | + |
| 115 | +</ContentPage> |
0 commit comments