Skip to content

Commit

Permalink
#12: First draft of analytic chart
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidSchmidt00 committed Oct 8, 2023
1 parent 2336b3e commit da63438
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 4 deletions.
2 changes: 2 additions & 0 deletions WorkTimer/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using WorkTimer.Database;
using WorkTimer.View;
using WorkTimer.ViewModel;
using SkiaSharp.Views.Maui.Controls.Hosting;

namespace WorkTimer;
public static class MauiProgram
Expand All @@ -11,6 +12,7 @@ public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseSkiaSharp(true)
.UseMauiApp<App>()
.ConfigureFonts(fonts =>
{
Expand Down
10 changes: 6 additions & 4 deletions WorkTimer/View/AnalyticsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
Title="Analyse"
xmlns:viewmodel="clr-namespace:WorkTimer.ViewModel"
x:DataType="viewmodel:AnalyticsViewModel"
xmlns:local="clr-namespace:WorkTimer">
xmlns:local="clr-namespace:WorkTimer"
xmlns:lvc="clr-namespace:LiveChartsCore.SkiaSharpView.Maui;assembly=LiveChartsCore.SkiaSharpView.Maui">
<Grid RowDefinitions="*,auto"
Padding="10">
<Grid ColumnDefinitions="3*,2,*"
<Grid ColumnDefinitions="*,2,*"
Grid.Row="0">
<Grid RowDefinitions="auto,*"
Padding="10"
Expand Down Expand Up @@ -39,7 +40,7 @@
</CollectionView>
</Grid>
<Line Grid.Column="1" BackgroundColor="Black"></Line>
<Grid Grid.Column="2" RowDefinitions="Auto,Auto" VerticalOptions="Center">
<!-- <Grid Grid.Column="2" RowDefinitions="Auto,Auto" VerticalOptions="Center">
<Label Text="{Binding OvertimeText}"
TextColor="{Binding OvertimeTextColor}"
FontAttributes="Bold"
Expand All @@ -51,7 +52,8 @@
HorizontalTextAlignment="Center"
VerticalTextAlignment="Center"
Grid.Row="1"/>
</Grid>
</Grid> -->
<lvc:CartesianChart Series="{Binding Series}" Grid.Column="2"></lvc:CartesianChart>
</Grid>
<StackLayout Orientation="Horizontal"
Padding="20"
Expand Down
26 changes: 26 additions & 0 deletions WorkTimer/ViewModel/AnalyticsViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using CommunityToolkit.Mvvm.Messaging;
using LiveChartsCore.SkiaSharpView;
using LiveChartsCore;
using System.Collections.ObjectModel;
using System.Diagnostics;
using WorkTimer.Models;
Expand Down Expand Up @@ -60,5 +62,29 @@ async Task Back()
{
await Shell.Current.GoToAsync("..");
}

public ISeries[] Series { get; set; } =
{
new ColumnSeries<WorktimeAggregatedByWeek>
{
Values = WorktimeAggregatedList,
Mapping = (element, point) =>
{
point.PrimaryValue = element.
}
Stroke = null,
Name = "Arbeitszeit",
MaxBarWidth = double.MaxValue,
IgnoresBarPosition = true
},
new ColumnSeries<int>
{
Values = new[] { 2, 4, 8, 9, 5, 2, 4, 7 },
Stroke = null,
Name = "Pausenzeit",
MaxBarWidth = 30,
IgnoresBarPosition = true
}
};
}
}
1 change: 1 addition & 0 deletions WorkTimer/WorkTimer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@

<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
<PackageReference Include="LiveChartsCore.SkiaSharpView.Maui" Version="2.0.0-rc1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
<PackageReference Include="sqlite-net-pcl" Version="1.8.116" />
</ItemGroup>
Expand Down

0 comments on commit da63438

Please sign in to comment.