From 67da75fb3ea6a31dd056004cdbe3665e6a57282a Mon Sep 17 00:00:00 2001 From: 2211260 <2211260@hs-mannheim.de> Date: Fri, 2 Jun 2023 20:21:16 +0200 Subject: [PATCH] feat: add goal line to progress chart --- lib/android/config/statistics.dart | 5 +++++ lib/android/pages/nav_pages/progress_page.dart | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/lib/android/config/statistics.dart b/lib/android/config/statistics.dart index 09c289b..67df099 100644 --- a/lib/android/config/statistics.dart +++ b/lib/android/config/statistics.dart @@ -214,6 +214,11 @@ class StatisticsService { return sum as int; } + double getCaloryTargetForOneDay(){ + final Box userBox = Hive.box("USER_BOX"); + return userBox.get("USER").kalorien.toDouble(); + } + List getAllEatenIngredientsForTodayStatistics(double dayLen){ Box box = Hive.box(todayStatisticsBoxName); final Box userBox = Hive.box("USER_BOX"); diff --git a/lib/android/pages/nav_pages/progress_page.dart b/lib/android/pages/nav_pages/progress_page.dart index d2c200b..a19aafb 100644 --- a/lib/android/pages/nav_pages/progress_page.dart +++ b/lib/android/pages/nav_pages/progress_page.dart @@ -169,6 +169,20 @@ class ProgressPage extends StatelessWidget { barGroups: value, gridData: FlGridData(show: false), alignment: BarChartAlignment.spaceAround, + extraLinesData: ExtraLinesData( + horizontalLines: [ + HorizontalLine( + y: StatisticsService.instance.getCaloryTargetForOneDay(), // Specify the y-value where you want the line to be positioned + color: Colors.black, // Change the color as per your requirement + strokeWidth: 2, // Adjust the width as needed + dashArray: [3, 2], + label: HorizontalLineLabel( + show: true, + labelResolver: (x) => "Zielwert" + ) + ), + ], + ), ), ), ),