From 6e37c09fc7ba5f30ecb6b9b42ff38dc2191bdc50 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Mon, 15 Apr 2024 12:53:28 +0200 Subject: [PATCH] paint difference wrt plan as surplus or deficit * there may not be a plan for a given macro. accommodate this nicely * a whole dedicated bar for 'planned' felt too much UI bloat --- lib/widgets/nutrition/charts.dart | 58 +++++++++++++------ .../nutrition/nutritional_plan_detail.dart | 8 ++- 2 files changed, 48 insertions(+), 18 deletions(-) diff --git a/lib/widgets/nutrition/charts.dart b/lib/widgets/nutrition/charts.dart index 6d3a9d4b6..9501cab71 100644 --- a/lib/widgets/nutrition/charts.dart +++ b/lib/widgets/nutrition/charts.dart @@ -206,25 +206,49 @@ class NutritionalDiaryChartWidgetFlState extends State plan) { + return BarChartRodData( + toY: val, + color: colorLoggedToday, + width: barsWidth, + rodStackItems: [ + BarChartRodStackItem(0, plan, color), + BarChartRodStackItem(plan, val, Colors.red), + ], + ); + } + + // paint a deficit + return BarChartRodData( + toY: plan, + color: colorLoggedToday, + width: barsWidth, + rodStackItems: [ + BarChartRodStackItem(0, val, color), + BarChartRodStackItem(val, plan, colorPlanned), + ], + ); + } + return BarChartGroupData( x: x, barsSpace: barsSpace, barRods: [ - BarChartRodData( - toY: planned.prop(prop), - color: colorPlanned, - width: barsWidth, - ), - BarChartRodData( - toY: loggedToday.prop(prop), - color: colorLoggedToday, - width: barsWidth, - ), - BarChartRodData( - toY: logged7DayAvg.prop(prop), - color: colorLogged7Day, - width: barsWidth, - ), + barChartRodData(plan, loggedToday.prop(prop), colorLoggedToday), + barChartRodData(plan, logged7DayAvg.prop(prop), colorLogged7Day), ], ); } @@ -235,8 +259,8 @@ class NutritionalDiaryChartWidgetFlState extends State