Skip to content

Commit 23e26dd

Browse files
committed
Adding Sample
1 parent b47a162 commit 23e26dd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1516
-0
lines changed

TreeMapChart/TreeMapChart.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.14.36202.13 d17.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TreeMapChart", "TreeMapChart\TreeMapChart.csproj", "{F79FF125-B33F-4F0B-8B3B-0100B7696170}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{F79FF125-B33F-4F0B-8B3B-0100B7696170}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{F79FF125-B33F-4F0B-8B3B-0100B7696170}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{F79FF125-B33F-4F0B-8B3B-0100B7696170}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{F79FF125-B33F-4F0B-8B3B-0100B7696170}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {51B713FF-7F9C-4A8E-B2DC-9009C52BB0A1}
24+
EndGlobalSection
25+
EndGlobal

TreeMapChart/TreeMapChart/App.xaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version = "1.0" encoding = "UTF-8" ?>
2+
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
4+
xmlns:local="clr-namespace:TreeMapChart"
5+
x:Class="TreeMapChart.App">
6+
<Application.Resources>
7+
<ResourceDictionary>
8+
<ResourceDictionary.MergedDictionaries>
9+
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
10+
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
11+
</ResourceDictionary.MergedDictionaries>
12+
</ResourceDictionary>
13+
</Application.Resources>
14+
</Application>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace TreeMapChart
2+
{
3+
public partial class App : Application
4+
{
5+
public App()
6+
{
7+
InitializeComponent();
8+
}
9+
10+
protected override Window CreateWindow(IActivationState? activationState)
11+
{
12+
return new Window(new AppShell());
13+
}
14+
}
15+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<Shell
3+
x:Class="TreeMapChart.AppShell"
4+
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
6+
xmlns:local="clr-namespace:TreeMapChart"
7+
FlyoutBehavior="Disabled"
8+
Title="TreeMap Chart">
9+
10+
<ShellContent
11+
ContentTemplate="{DataTemplate local:MainPage}"
12+
Route="MainPage" />
13+
14+
</Shell>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace TreeMapChart
2+
{
3+
public partial class AppShell : Shell
4+
{
5+
public AppShell()
6+
{
7+
InitializeComponent();
8+
}
9+
}
10+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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:treemap="clr-namespace:Syncfusion.Maui.TreeMap;assembly=Syncfusion.Maui.TreeMap"
5+
xmlns:local="clr-namespace:TreeMapChart"
6+
x:Class="TreeMapChart.MainPage">
7+
8+
<ContentPage.Content>
9+
<!-- Border around entire content -->
10+
<Border Margin="10,18,10,10" Padding="5" Stroke="{OnPlatform Default=Black, iOS=White}" StrokeThickness="2" StrokeShape="RoundRectangle 10">
11+
12+
<Grid RowDefinitions="Auto,*">
13+
<!-- Title Section -->
14+
<HorizontalStackLayout Grid.Row="0">
15+
<Image Source="cup.png" WidthRequest="50" HeightRequest="60" VerticalOptions="Center" HorizontalOptions="Center"/>
16+
<Label Text="ICC Men's World Cup Winners 1975 - 2025"
17+
VerticalTextAlignment="Center"
18+
HorizontalTextAlignment="Center"
19+
FontSize="{OnPlatform Default=25, Android=15, iOS=15}"
20+
Padding="3"
21+
FontAttributes="Bold"/>
22+
</HorizontalStackLayout>
23+
24+
<!-- TreeMap Section -->
25+
<treemap:SfTreeMap x:Name="treeMapChart"
26+
DataSource="{Binding CountryTitles}"
27+
Grid.Row="1"
28+
Margin="8"
29+
RangeColorValuePath="TotalTitles"
30+
PrimaryValuePath="TotalTitles"
31+
ShowToolTip="True"
32+
SelectionMode="Single"
33+
SelectionChanged="TreeMapChart_SelectionChanged">
34+
35+
<!-- Leaf Item Settings -->
36+
<treemap:SfTreeMap.LeafItemSettings>
37+
<treemap:TreeMapLeafItemSettings LabelPath="Country" Spacing="3">
38+
<treemap:TreeMapLeafItemSettings.TextStyle>
39+
<treemap:TreeMapTextStyle TextColor="White" FontSize="{OnPlatform Default=18, Android=12, iOS=11}" FontAttributes="Bold"/>
40+
</treemap:TreeMapLeafItemSettings.TextStyle>
41+
</treemap:TreeMapLeafItemSettings>
42+
</treemap:SfTreeMap.LeafItemSettings>
43+
44+
<!-- Tooltip Template -->
45+
<treemap:SfTreeMap.ToolTipTemplate>
46+
<DataTemplate>
47+
<StackLayout Orientation="Horizontal">
48+
<Rectangle HeightRequest="30" WidthRequest="8" Fill="{Binding Background}"/>
49+
<StackLayout Orientation="Vertical">
50+
<Label Text="{Binding PrimaryValueText}" FontSize="12.5" Padding="5,0,0,0" FontAttributes="Bold" TextColor="White"/>
51+
<Label Text="{Binding Item.TotalTitles, StringFormat='Titles : {0}'}" FontSize="12" Padding="5,0,0,0" Margin="0,2,0,0" TextColor="White"/>
52+
</StackLayout>
53+
</StackLayout>
54+
</DataTemplate>
55+
</treemap:SfTreeMap.ToolTipTemplate>
56+
57+
</treemap:SfTreeMap>
58+
</Grid>
59+
</Border>
60+
</ContentPage.Content>
61+
</ContentPage>
62+
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
using Syncfusion.Maui.TreeMap;
2+
3+
namespace TreeMapChart
4+
{
5+
public partial class MainPage : ContentPage
6+
{
7+
private readonly ViewModel _viewModel;
8+
9+
public MainPage()
10+
{
11+
InitializeComponent();
12+
_viewModel = new ViewModel();
13+
this.BindingContext = _viewModel;
14+
15+
treeMapChart.LeafItemBrushSettings = new TreeMapPaletteBrushSettings()
16+
{
17+
Brushes = new List<Brush>()
18+
{
19+
new SolidColorBrush(Color.FromArgb("#FFB100")),
20+
new SolidColorBrush(Color.FromArgb("#1E90FF")),
21+
new SolidColorBrush(Color.FromArgb("#800000")),
22+
new SolidColorBrush(Color.FromArgb("#006600")),
23+
new SolidColorBrush(Color.FromArgb("#35CAFE")),
24+
new SolidColorBrush(Color.FromArgb("#0033A0")),
25+
new SolidColorBrush(Color.FromArgb("#2F4F4F")),
26+
new SolidColorBrush(Color.FromArgb("#228B22")),
27+
}
28+
};
29+
}
30+
31+
private void TreeMapChart_SelectionChanged(object sender, TreeMapSelectionChangedEventArgs e)
32+
{
33+
if (sender is SfTreeMap treeMap)
34+
{
35+
// Retrieve the selected item's country name
36+
string? selectedCountry = treeMap.SelectedItems.FirstOrDefault()?.PrimaryValueText;
37+
38+
if (selectedCountry != null)
39+
{
40+
// Update data based on the selected country
41+
UpdateDataBasedOnSelection(selectedCountry);
42+
_viewModel.SelectedCountry = selectedCountry;
43+
44+
// Navigate to DrillDownPage with updated data
45+
Navigation.PushAsync(new TitleBreakDownPage(_viewModel));
46+
}
47+
}
48+
}
49+
50+
/// <summary>
51+
/// Updates the ViewModel's data based on the selected country.
52+
/// </summary>
53+
/// <param name="country">The selected country.</param>
54+
private void UpdateDataBasedOnSelection(string country)
55+
{
56+
_viewModel.SelectedCountryTotalTitles = country switch
57+
{
58+
"Australia" => 10,
59+
"India" => 7,
60+
"England" => 3,
61+
"West Indies" => 5,
62+
"Pakistan" => 3,
63+
"Sri Lanka" => 3,
64+
"South Africa" => 2,
65+
"New Zealand" => 2,
66+
_ => 0
67+
};
68+
69+
_viewModel.SelectedCountryDetails = country switch
70+
{
71+
"Australia" =>
72+
[
73+
new() { Category = "ODI World Cups", Titles = 6 },
74+
new() { Category = "T20 World Cups", Titles = 1 },
75+
new() { Category = "Champions Trophies", Titles = 2 },
76+
new() { Category = "WTC", Titles = 1 }
77+
],
78+
"India" =>
79+
[
80+
new() { Category = "ODI World Cups", Titles = 2 },
81+
new() { Category = "T20 World Cups", Titles = 2 },
82+
new() { Category = "Champions Trophies", Titles = 3 },
83+
],
84+
"England" =>
85+
[
86+
new() { Category = "ODI World Cups", Titles = 1 },
87+
new() { Category = "T20 World Cups", Titles = 2 },
88+
],
89+
"West Indies" =>
90+
[
91+
new() { Category = "ODI World Cups", Titles = 2 },
92+
new() { Category = "T20 World Cups", Titles = 2 },
93+
new() { Category = "Champions Trophies", Titles = 1 },
94+
],
95+
"Pakistan" =>
96+
[
97+
new() { Category = "ODI World Cups", Titles = 1 },
98+
new() { Category = "T20 World Cups", Titles = 1 },
99+
new() { Category = "Champions Trophies", Titles = 1 },
100+
],
101+
"Sri Lanka" =>
102+
[
103+
new() { Category = "ODI World Cups", Titles = 1 },
104+
new() { Category = "T20 World Cups", Titles = 1 },
105+
new() { Category = "Champions Trophies", Titles = 1 },
106+
],
107+
"South Africa" =>
108+
[
109+
new() { Category = "Champions Trophies", Titles = 1 },
110+
new() { Category = "WTC", Titles = 1 }
111+
],
112+
"New Zealand" =>
113+
[
114+
new() { Category = "Champions Trophies", Titles = 1 },
115+
new() { Category = "WTC", Titles = 1 }
116+
],
117+
_ => throw new NotImplementedException()
118+
};
119+
}
120+
}
121+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Microsoft.Extensions.Logging;
2+
using Syncfusion.Maui.Core.Hosting;
3+
namespace TreeMapChart
4+
{
5+
public static class MauiProgram
6+
{
7+
public static MauiApp CreateMauiApp()
8+
{
9+
var builder = MauiApp.CreateBuilder();
10+
builder
11+
.UseMauiApp<App>()
12+
.ConfigureSyncfusionCore()
13+
.ConfigureFonts(fonts =>
14+
{
15+
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
16+
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
17+
});
18+
19+
#if DEBUG
20+
builder.Logging.AddDebug();
21+
#endif
22+
23+
return builder.Build();
24+
}
25+
}
26+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace TreeMapChart
2+
{
3+
public class WorldCupStats
4+
{
5+
public string? Country { get; set; }
6+
public int TotalTitles { get; set; }
7+
public string? Category { get; set; }
8+
public int Titles { get; set; }
9+
}
10+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"></application>
4+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
5+
<uses-permission android:name="android.permission.INTERNET" />
6+
</manifest>

0 commit comments

Comments
 (0)