Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BeSafePlus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sebastian Kristensen
BeSafePlus
Commits
5e004cd4
Commit
5e004cd4
authored
1 week ago
by
MarcusStorvangJonassen
Browse files
Options
Downloads
Patches
Plain Diff
Added LineChart() as a supplement for BarChart() in ActivityHistoryPage
parent
3bf27b6d
No related branches found
Branches containing commit
No related tags found
1 merge request
!33
Frontend ui
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
BeSafePlus/Views/ActivityHistoryPage.xaml
+13
-5
13 additions, 5 deletions
BeSafePlus/Views/ActivityHistoryPage.xaml
BeSafePlus/Views/ActivityHistoryPage.xaml.cs
+48
-0
48 additions, 0 deletions
BeSafePlus/Views/ActivityHistoryPage.xaml.cs
with
61 additions
and
5 deletions
BeSafePlus/Views/ActivityHistoryPage.xaml
+
13
−
5
View file @
5e004cd4
...
...
@@ -35,7 +35,7 @@
FontAttributes="Bold"
HorizontalOptions="Center"/>
<Label Text="
Graf ove
r Ugentlige Skridt:"
<Label Text="
Søjlediagram fo
r Ugentlige Skridt:"
FontSize="20"
HorizontalOptions="Center"/>
...
...
@@ -43,10 +43,10 @@
HeightRequest="400"
WidthRequest="300"/>
<VerticalStackLayout Padding="
5
"
Spacing="
1
0">
<Label Text="Farveindikator:"
<VerticalStackLayout Padding="
10
"
Spacing="
2
0">
<Label Text="Farveindikator
er
:"
FontSize="20"
HorizontalOptions="Center"/>
...
...
@@ -124,6 +124,14 @@
</VerticalStackLayout>
</HorizontalStackLayout>
</VerticalStackLayout>
<Label Text="Linjediagram for Ugentlige Skridt:"
FontSize="20"
HorizontalOptions="Center"/>
<chart:ChartView x:Name="LineChart"
HeightRequest="400"
WidthRequest="300"/>
<Label Text="Samlet Skridt i denne uge:"
FontSize="20"
...
...
This diff is collapsed.
Click to expand it.
BeSafePlus/Views/ActivityHistoryPage.xaml.cs
+
48
−
0
View file @
5e004cd4
...
...
@@ -4,6 +4,7 @@ using Microcharts.Maui;
using
SkiaSharp
;
using
System.Collections.Generic
;
using
Microsoft.Maui.Controls
;
using
Microcharts
;
namespace
BeSafePlus
{
...
...
@@ -26,10 +27,14 @@ namespace BeSafePlus
e
.
PropertyName
==
nameof
(
ActivityHistoryViewModel
.
AccumulatedSteps
))
{
LoadChart
();
LoadLineChart
();
}
};
LoadChart
();
LoadLineChart
();
}
protected
override
async
void
OnAppearing
()
{
...
...
@@ -42,6 +47,8 @@ namespace BeSafePlus
_viewModel
.
AccumulatedSteps
=
await
_viewModel
.
GetStepCount
();
LoadChart
();
LoadLineChart
();
}
private
async
void
LoadChart
()
{
...
...
@@ -91,6 +98,47 @@ namespace BeSafePlus
MaxValue
=
stepGoal
};
}
private
async
void
LoadLineChart
()
{
if
(
_viewModel
?.
WeeklyStepData
==
null
||
!
_viewModel
.
WeeklyStepData
.
Any
())
return
;
var
entries
=
new
List
<
Microcharts
.
ChartEntry
>();
DateTime
today
=
DateTime
.
Now
.
Date
;
foreach
(
var
stepData
in
_viewModel
.
WeeklyStepData
)
{
if
(
DateTime
.
TryParse
(
stepData
.
Date
,
out
DateTime
stepDate
))
{
int
dayIndex
=
(
int
)
stepDate
.
DayOfWeek
;
// Konverter dagIndex til dansk ugedag
string
dayName
=
DaysOfWeek
[
dayIndex
==
0
?
6
:
dayIndex
-
1
];
bool
isToday
=
stepDate
.
Date
==
today
;
entries
.
Add
(
new
Microcharts
.
ChartEntry
(
stepData
.
Steps
)
{
Label
=
isToday
?
$"*
{
dayName
}
"
:
dayName
,
// Fremhæv dagens dag med *
ValueLabel
=
$"
{
stepData
.
Steps
}
"
,
Color
=
SKColors
.
Blue
,
TextColor
=
SKColors
.
Black
,
ValueLabelColor
=
SKColors
.
Black
});
}
}
LineChart
.
Chart
=
new
Microcharts
.
LineChart
{
Entries
=
entries
,
LineMode
=
Microcharts
.
LineMode
.
Straight
,
BackgroundColor
=
SKColors
.
White
,
LabelTextSize
=
20
,
ValueLabelTextSize
=
20
,
LabelColor
=
SKColors
.
Black
,
MaxValue
=
_viewModel
.
StepGoal
};
}
private
SKColor
GetStepColor
(
int
steps
,
int
stepGoal
)
{
if
(
steps
==
0
)
return
SKColors
.
White
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment