Skip to content

Commit f8986b2

Browse files
Review correction updated
Review correction updated
1 parent 4bafe15 commit f8986b2

4 files changed

Lines changed: 21 additions & 101 deletions

File tree

HeatMap/SchedulerHeatMap/Helper/MonthCellTemplateSelector.cs

Lines changed: 0 additions & 54 deletions
This file was deleted.

HeatMap/SchedulerHeatMap/MainWindow.xaml

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,53 +11,30 @@
1111
<Grid.DataContext>
1212
<local:HeatMapViewModel />
1313
</Grid.DataContext>
14-
<Grid.Resources>
15-
<DataTemplate x:Key="lightGrayTemplate">
16-
<Grid Background="#eeeeee">
17-
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Margin="5" Text="{Binding DateText}" />
18-
</Grid>
19-
</DataTemplate>
20-
<DataTemplate x:Key="lightGreenTemplate">
21-
<Grid Background="#c6e48b">
22-
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Margin="5" Text="{Binding DateText}" />
23-
</Grid>
24-
</DataTemplate>
25-
<DataTemplate x:Key="midGreenTemplate">
26-
<Grid Background="#7bc96f">
27-
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Margin="5" Text="{Binding DateText}" />
28-
</Grid>
29-
</DataTemplate>
30-
<DataTemplate x:Key="greenTemplate">
31-
<Grid Background="#239a3b">
32-
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Margin="5" Text="{Binding DateText}" />
33-
</Grid>
34-
</DataTemplate>
35-
<DataTemplate x:Key="darkGreenTemplate">
36-
<Grid Background="#196127">
37-
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Margin="5" Text="{Binding DateText}" />
38-
</Grid>
39-
</DataTemplate>
40-
<local:MonthCellTemplateSelector x:Key="monthCellTemplateSelector"
41-
LightGrayTemplate="{StaticResource lightGrayTemplate}"
42-
LightGreenTemplate="{StaticResource lightGreenTemplate}"
43-
MidGreenTemplate="{StaticResource midGreenTemplate}"
44-
GreenTemplate="{StaticResource greenTemplate}"
45-
DarkGreenTemplate="{StaticResource darkGreenTemplate}" />
46-
</Grid.Resources>
14+
4715
<Grid.RowDefinitions>
4816
<RowDefinition Height="*"/>
4917
<RowDefinition Height="100"/>
5018
</Grid.RowDefinitions>
5119
<Scheduler:SfScheduler x:Name="scheduler"
52-
ItemsSource="{Binding InternetDataCollection}"
20+
ItemsSource="{Binding InternetDataUsages}"
5321
AppointmentEditFlag="None">
22+
<!--The collection of internet data object can be assigned to the scheduler ItemsSource property in order to generate the details of appointments in the MonthCell which is used to get the details of the internet data usage for the day-->
5423
<Scheduler:SfScheduler.AppointmentMapping>
5524
<Scheduler:AppointmentMapping StartTime="Date"
5625
AppointmentBackground="Color"/>
5726
</Scheduler:SfScheduler.AppointmentMapping>
5827
<Scheduler:SfScheduler.MonthViewSettings>
59-
<Scheduler:MonthViewSettings AppointmentDisplayMode="None"
60-
MonthCellTemplateSelector="{StaticResource monthCellTemplateSelector}" />
28+
<Scheduler:MonthViewSettings AppointmentDisplayMode="None">
29+
<!--Declare the DataTemplate for the scheduler month cell in order to create the heatmap calendar-->
30+
<Scheduler:MonthViewSettings.MonthCellTemplate>
31+
<DataTemplate>
32+
<Grid Background="{Binding Appointments[0].Data.Color}">
33+
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Margin="5" Text="{Binding DateText}" />
34+
</Grid>
35+
</DataTemplate>
36+
</Scheduler:MonthViewSettings.MonthCellTemplate>
37+
</Scheduler:MonthViewSettings>
6138
</Scheduler:SfScheduler.MonthViewSettings>
6239
</Scheduler:SfScheduler>
6340
<Grid Grid.Row="1">

HeatMap/SchedulerHeatMap/SchedulerHeatMap.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<ItemGroup>
2626
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.0" />
2727
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22000.194" />
28+
<PackageReference Include="Syncfusion.Core.WinUI" Version="*" />
2829
<PackageReference Include="Syncfusion.Scheduler.WinUI" Version="*" />
2930
<Manifest Include="$(ApplicationManifest)" />
3031
</ItemGroup>

HeatMap/SchedulerHeatMap/ViewModel/HeatMapViewModel.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,27 @@ public HeatMapViewModel()
1919
this.GenerateData();
2020
}
2121

22-
public ObservableCollection<InternetData> InternetDataCollection { get; set; }
22+
public ObservableCollection<InternetData> InternetDataUsages { get; set; }
2323

2424
/// <summary>
2525
/// Generate random data for heat map calendar based on internet data usage.
2626
/// </summary>
2727
private void GenerateData()
2828
{
2929
//// Creating an instance for internet data collection.
30-
InternetDataCollection = new ObservableCollection<InternetData>();
30+
InternetDataUsages = new ObservableCollection<InternetData>();
3131
var startDate = DateTime.Now.Date.AddMonths(-2);
3232
var random = new Random();
33-
//// Data usage in terms of GB.
34-
var dataCollection = new ObservableCollection<int>()
35-
{
36-
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
37-
};
3833

3934
//// Adding random data to the internet data collection.
4035
for (int i = 0; i < 200; i++)
4136
{
42-
var dataUsage = dataCollection[random.Next(0, dataCollection.Count)];
4337
InternetData internetData = new InternetData();
4438
internetData.Date = startDate.AddDays(i);
45-
internetData.Usage = dataUsage;
46-
internetData.Color = GetColor(dataUsage);
47-
this.InternetDataCollection.Add(internetData);
39+
//// Data usage in terms of GB.
40+
internetData.Usage = random.Next(0, 15);
41+
internetData.Color = GetColor(internetData.Usage);
42+
this.InternetDataUsages.Add(internetData);
4843
}
4944
}
5045

@@ -54,6 +49,7 @@ private void GenerateData()
5449
/// <param name="data"></param>
5550
private Brush GetColor(int data)
5651
{
52+
//// Data usage in terms of GB.
5753
if (data < 3)
5854
{
5955
return new SolidColorBrush(Color.FromArgb(255, 238, 238, 238));

0 commit comments

Comments
 (0)