|
| 1 | +<Window x:Class="ForecastFastLineChart.MainWindow" |
| 2 | + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
| 3 | + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
| 4 | + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
| 5 | + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
| 6 | + xmlns:local="clr-namespace:ForecastFastLineChart" |
| 7 | + mc:Ignorable="d" |
| 8 | + Title="MainWindow" Height="450" Width="800" |
| 9 | + xmlns:sync="clr-namespace:Syncfusion.UI.Xaml.Charts;assembly=Syncfusion.SfChart.WPF"> |
| 10 | + |
| 11 | + <Border Padding="15,15,25,15" Margin="10" BorderBrush="Black" BorderThickness="2" CornerRadius="10"> |
| 12 | + |
| 13 | + <sync:SfChart x:Name="chart" HorizontalHeaderAlignment="Left"> |
| 14 | + |
| 15 | + <sync:SfChart.DataContext> |
| 16 | + <local:ViewModel x:Name="viewModel"/> |
| 17 | + </sync:SfChart.DataContext> |
| 18 | + |
| 19 | + <sync:SfChart.Resources> |
| 20 | + <local:TooltipValueConverter x:Key="converter"/> |
| 21 | + <DataTemplate x:Key="labelTemplate"> |
| 22 | + |
| 23 | + <Border CornerRadius="5" BorderThickness="1" |
| 24 | + BorderBrush="Black" Background="White" Padding="10" Margin="8"> |
| 25 | + |
| 26 | + <StackPanel Orientation="Vertical"> |
| 27 | + <TextBlock Foreground="Black" Background="LightGray" FontSize="15" |
| 28 | + Text="{Binding Item, Converter={StaticResource converter}, ConverterParameter=0}"/> |
| 29 | + <Grid Margin="0, 5, 0, 0"> |
| 30 | + <Grid.RowDefinitions> |
| 31 | + <RowDefinition Height="20"/> |
| 32 | + <RowDefinition Height="20"/> |
| 33 | + <RowDefinition Height="20"/> |
| 34 | + <RowDefinition Height="20"/> |
| 35 | + <RowDefinition Height="20"/> |
| 36 | + <RowDefinition Height="20"/> |
| 37 | + </Grid.RowDefinitions> |
| 38 | + <Grid.ColumnDefinitions> |
| 39 | + <ColumnDefinition Width="15"/> |
| 40 | + <ColumnDefinition Width="80"/> |
| 41 | + <ColumnDefinition Width="50"/> |
| 42 | + </Grid.ColumnDefinitions> |
| 43 | + |
| 44 | + <StackPanel Background="{Binding Item, Converter={StaticResource converter}, ConverterParameter=7}" Height="10" Width="10" Margin="0, -2, 0, 0" Grid.Column="0" Grid.Row="0"/> |
| 45 | + <StackPanel Background="{Binding Item, Converter={StaticResource converter}, ConverterParameter=8}" Height="10" Width="10" Margin="0, -2, 0, 0" Grid.Column="0" Grid.Row="1"/> |
| 46 | + <StackPanel Background="{Binding Item, Converter={StaticResource converter}, ConverterParameter=9}" Height="10" Width="10" Margin="0, -2, 0, 0" Grid.Column="0" Grid.Row="2"/> |
| 47 | + <StackPanel Background="{Binding Item, Converter={StaticResource converter}, ConverterParameter=10}" Height="10" Width="10" Margin="0, -2, 0, 0" Grid.Column="0" Grid.Row="3"/> |
| 48 | + <StackPanel Background="{Binding Item, Converter={StaticResource converter}, ConverterParameter=11}" Height="10" Width="10" Margin="0, -2, 0, 0" Grid.Column="0" Grid.Row="4"/> |
| 49 | + <StackPanel Background="{Binding Item, Converter={StaticResource converter}, ConverterParameter=12}" Height="10" Width="10" Margin="0, -2, 0, 0" Grid.Column="0" Grid.Row="5"/> |
| 50 | + |
| 51 | + <TextBlock Foreground="Black" Text="Total" Grid.Row="0" Grid.Column="1"/> |
| 52 | + <TextBlock Foreground="Black" Text="Under 25" Grid.Row="1" Grid.Column="1"/> |
| 53 | + <TextBlock Foreground="Black" Text="Ages 25-64" Grid.Row="2" Grid.Column="1"/> |
| 54 | + <TextBlock Foreground="Black" Text="Under 15" Grid.Row="3" Grid.Column="1"/> |
| 55 | + <TextBlock Foreground="Black" Text="Under 4" Grid.Row="4" Grid.Column="1"/> |
| 56 | + <TextBlock Foreground="Black" Text="Above 65" Grid.Row="5" Grid.Column="1"/> |
| 57 | + |
| 58 | + <TextBlock Foreground="Black" Text="{Binding Item, Converter={StaticResource converter}, ConverterParameter=1}" Grid.Column="2" Grid.Row="0" HorizontalAlignment="Center"/> |
| 59 | + <TextBlock Foreground="Black" Text="{Binding Item, Converter={StaticResource converter}, ConverterParameter=2}" Grid.Column="2" Grid.Row="1" HorizontalAlignment="Center"/> |
| 60 | + <TextBlock Foreground="Black" Text="{Binding Item, Converter={StaticResource converter}, ConverterParameter=3}" Grid.Column="2" Grid.Row="2" HorizontalAlignment="Center"/> |
| 61 | + <TextBlock Foreground="Black" Text="{Binding Item, Converter={StaticResource converter}, ConverterParameter=4}" Grid.Column="2" Grid.Row="3" HorizontalAlignment="Center"/> |
| 62 | + <TextBlock Foreground="Black" Text="{Binding Item, Converter={StaticResource converter}, ConverterParameter=5}" Grid.Column="2" Grid.Row="4" HorizontalAlignment="Center"/> |
| 63 | + <TextBlock Foreground="Black" Text="{Binding Item, Converter={StaticResource converter}, ConverterParameter=6}" Grid.Column="2" Grid.Row="5" HorizontalAlignment="Center"/> |
| 64 | + </Grid> |
| 65 | + </StackPanel> |
| 66 | + </Border> |
| 67 | + |
| 68 | + </DataTemplate> |
| 69 | + |
| 70 | + </sync:SfChart.Resources> |
| 71 | + |
| 72 | + <sync:SfChart.Header> |
| 73 | + <Border BorderBrush="White" Margin="0, 0, 0, 10"> |
| 74 | + <StackPanel Orientation="Horizontal" Margin="-20, 0, 0, 0"> |
| 75 | + <Grid> |
| 76 | + <Ellipse Width="5" Height="5" Fill="Gray" Margin="0.5, 15, 0, 0"/> |
| 77 | + <Path Margin="0,35,0,0" Data="{Binding PathData1}" Stretch="Uniform" Stroke="Gray" StrokeThickness="1" |
| 78 | + Fill="Gray" Width="40" Height="18" RenderTransformOrigin="0.5,0.5"/> |
| 79 | + </Grid> |
| 80 | + <Path Margin="-19,-8,0,0" Data="{Binding PathData}" Stretch="Uniform" |
| 81 | + Fill="Gray" Width="60" Height="60" RenderTransformOrigin="0.5,0.5"/> |
| 82 | + <StackPanel> |
| 83 | + <TextBlock FontSize="22" Margin="5, 0, 0, 0" Text="Global Population by Age Group" FontWeight="Bold"/> |
| 84 | + <TextBlock FontSize="13" Margin="5, 0, 0, 0" Text="Exploring Population Trends from 1950 to 2023 and Future Projections to 2100." FontWeight="Medium" Foreground="Gray"/> |
| 85 | + </StackPanel> |
| 86 | + </StackPanel> |
| 87 | + </Border> |
| 88 | + </sync:SfChart.Header> |
| 89 | + |
| 90 | + <sync:SfChart.PrimaryAxis> |
| 91 | + <sync:NumericalAxis ShowGridLines="False" PlotOffsetEnd="5"> |
| 92 | + <sync:NumericalAxis.StripLines> |
| 93 | + <sync:ChartStripLine Start="2024" Width="100" Background="#dbd9d9" Opacity="0.2"/> |
| 94 | + </sync:NumericalAxis.StripLines> |
| 95 | + </sync:NumericalAxis> |
| 96 | + </sync:SfChart.PrimaryAxis> |
| 97 | + |
| 98 | + <sync:SfChart.SecondaryAxis> |
| 99 | + <sync:NumericalAxis Interval="2000000000" LabelCreated="NumericalAxis_LabelCreated_1"/> |
| 100 | + </sync:SfChart.SecondaryAxis> |
| 101 | + |
| 102 | + <sync:SfChart.Behaviors> |
| 103 | + <sync:ChartTrackBallBehavior/> |
| 104 | + </sync:SfChart.Behaviors> |
| 105 | + |
| 106 | + <sync:FastLineSeries x:Name="series" ShowTrackballInfo="False" ItemsSource="{Binding HistoricalPopulationData}" XBindingPath="Year" YBindingPath="TotalPopulation"/> |
| 107 | + <sync:FastLineSeries x:Name="series1" ShowTrackballInfo="True" ItemsSource="{Binding HistoricalPopulationData}" XBindingPath="Year" YBindingPath="Under25" TrackBallLabelTemplate="{StaticResource labelTemplate}"/> |
| 108 | + <sync:FastLineSeries x:Name="series2" ShowTrackballInfo="False" ItemsSource="{Binding HistoricalPopulationData}" XBindingPath="Year" YBindingPath="Between25to64"/> |
| 109 | + <sync:FastLineSeries x:Name="series3" ShowTrackballInfo="False" ItemsSource="{Binding HistoricalPopulationData}" XBindingPath="Year" YBindingPath="Under15"/> |
| 110 | + <sync:FastLineSeries x:Name="series4" ShowTrackballInfo="False" ItemsSource="{Binding HistoricalPopulationData}" XBindingPath="Year" YBindingPath="Under4"/> |
| 111 | + <sync:FastLineSeries x:Name="series5" ShowTrackballInfo="False" ItemsSource="{Binding HistoricalPopulationData}" XBindingPath="Year" YBindingPath="Above65"/> |
| 112 | + |
| 113 | + <sync:FastLineSeries x:Name="series6" ShowTrackballInfo="False" ItemsSource="{Binding ForecastPopulationData }" XBindingPath="Year" YBindingPath="TotalPopulation"/> |
| 114 | + <sync:FastLineSeries x:Name="series7" ShowTrackballInfo="True" ItemsSource="{Binding ForecastPopulationData }" XBindingPath="Year" YBindingPath="Under25" TrackBallLabelTemplate="{StaticResource labelTemplate}"/> |
| 115 | + <sync:FastLineSeries x:Name="series8" ShowTrackballInfo="False" ItemsSource="{Binding ForecastPopulationData }" XBindingPath="Year" YBindingPath="Between25to64"/> |
| 116 | + <sync:FastLineSeries x:Name="series9" ShowTrackballInfo="False" ItemsSource="{Binding ForecastPopulationData }" XBindingPath="Year" YBindingPath="Under15"/> |
| 117 | + <sync:FastLineSeries x:Name="series10" ShowTrackballInfo="False" ItemsSource="{Binding ForecastPopulationData }" XBindingPath="Year" YBindingPath="Under4"/> |
| 118 | + <sync:FastLineSeries x:Name="series11" ShowTrackballInfo="False" ItemsSource="{Binding ForecastPopulationData }" XBindingPath="Year" YBindingPath="Above65"/> |
| 119 | + |
| 120 | + </sync:SfChart> |
| 121 | + |
| 122 | + </Border> |
| 123 | +</Window> |
0 commit comments