feat: add goal line to progress chart

pull/5/head
2211260 2023-06-02 20:21:16 +02:00
parent fd4e07fc8c
commit 67da75fb3e
2 changed files with 19 additions and 0 deletions

View File

@ -214,6 +214,11 @@ class StatisticsService {
return sum as int; return sum as int;
} }
double getCaloryTargetForOneDay(){
final Box userBox = Hive.box<User>("USER_BOX");
return userBox.get("USER").kalorien.toDouble();
}
List<double> getAllEatenIngredientsForTodayStatistics(double dayLen){ List<double> getAllEatenIngredientsForTodayStatistics(double dayLen){
Box box = Hive.box(todayStatisticsBoxName); Box box = Hive.box(todayStatisticsBoxName);
final Box userBox = Hive.box<User>("USER_BOX"); final Box userBox = Hive.box<User>("USER_BOX");

View File

@ -169,6 +169,20 @@ class ProgressPage extends StatelessWidget {
barGroups: value, barGroups: value,
gridData: FlGridData(show: false), gridData: FlGridData(show: false),
alignment: BarChartAlignment.spaceAround, 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"
)
),
],
),
), ),
), ),
), ),