feat: adjust chart styling

lauritz-branch
98spag 2023-06-01 13:19:55 +02:00
parent ae7f64ac1e
commit 8d33371966
6 changed files with 127 additions and 38 deletions

View File

@ -608,7 +608,7 @@
"languageVersion": "2.19"
}
],
"generated": "2023-06-01T10:16:20.370625Z",
"generated": "2023-06-01T11:12:57.602326Z",
"generator": "pub",
"generatorVersion": "3.0.2"
}

View File

@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_foundation","path":"/Users/bogdan/.pub-cache/hosted/pub.dev/path_provider_foundation-2.2.2/","native_build":true,"dependencies":[]}],"android":[{"name":"path_provider_android","path":"/Users/bogdan/.pub-cache/hosted/pub.dev/path_provider_android-2.0.27/","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_foundation","path":"/Users/bogdan/.pub-cache/hosted/pub.dev/path_provider_foundation-2.2.2/","native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/bogdan/.pub-cache/hosted/pub.dev/path_provider_linux-2.1.10/","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/bogdan/.pub-cache/hosted/pub.dev/path_provider_windows-2.1.6/","native_build":false,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2023-05-31 22:57:37.224562","version":"3.7.9"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\FUCHSLAU\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.2.2\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"path_provider_android","path":"C:\\\\Users\\\\FUCHSLAU\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_android-2.0.27\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\FUCHSLAU\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.2.2\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\Users\\\\FUCHSLAU\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_linux-2.1.10\\\\","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\Users\\\\FUCHSLAU\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_windows-2.1.6\\\\","native_build":false,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2023-06-01 13:16:00.226015","version":"3.10.2"}

View File

@ -7,7 +7,7 @@ String getFoodListStringByFood(String foodName, int count, int calories){
}
String getWeeklyRankingString(String foodName){
int maxWidth = 50;
int maxWidth = 45;
String limitedText = foodName.length > maxWidth ? "${foodName.substring(0, maxWidth - 3)} ... " : foodName;
return limitedText;
}

View File

@ -292,8 +292,7 @@ class StatisticsService {
if(value > maxValue){
maxValue = value;
}
result[i][j] = (value * 175) ~/ 100;
result[i][j] = value;
}
}
}
@ -313,8 +312,6 @@ class StatisticsService {
color: Colors.green,
toY: result[0][2].toDouble(), // Second segment color
),],
showingTooltipIndicators: [0],
groupVertically: true
),
BarChartGroupData(
x: 1,
@ -332,7 +329,6 @@ class StatisticsService {
color: Colors.green,
toY: result[1][2].toDouble(), // Second segment color
),],
showingTooltipIndicators: [0],
),
BarChartGroupData(
x: 2,
@ -349,7 +345,6 @@ class StatisticsService {
color: Colors.green,
toY: result[2][2].toDouble(), // Second segment color
),],
showingTooltipIndicators: [0],
),
BarChartGroupData(
x: 3,
@ -383,7 +378,6 @@ class StatisticsService {
color: Colors.green,
toY: result[4][2].toDouble(), // Second segment color
),],
showingTooltipIndicators: [0],
),
BarChartGroupData(
x: 5,
@ -399,7 +393,7 @@ class StatisticsService {
width: 7.5, // Adjust the width of the bar if needed
color: Colors.green,
toY: result[5][2].toDouble(), // Second segment color
),], showingTooltipIndicators: [0],
),],
),
BarChartGroupData(
x: 6,

View File

@ -37,18 +37,15 @@ class ProgressPage extends StatelessWidget {
return Container(
height: 100,
width: 400,
decoration: BoxDecoration(
border: Border.all(),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const TitleComponent("Kalorien"),
const TitleComponent("Täglicher Durchschnitt (in kcal)"),
const SizedBox(
height: 10,
),
const SecondaryTextComponent("Durchschnittlich"),
SecondaryBigTextComponent(value.toString()),
SecondaryBigTextComponent("${value.toString()} kcal/Tag"),
],
),
);
@ -58,24 +55,94 @@ class ProgressPage extends StatelessWidget {
valueListenable: StatisticsService.instance.barChartData,
builder: (context, value, child) {
return SizedBox(
height: 205,
height: 325,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 200,
child: BarChart(
BarChartData(
barTouchData: barTouchData,
titlesData: titlesData,
borderData: borderData,
barGroups: value,
gridData: FlGridData(show: false),
alignment: BarChartAlignment.spaceAround,
maxY: 200,
height: 15, // Adjust the height of the legend as needed
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
margin: const EdgeInsets.symmetric(horizontal: 8.0), // Adjust the spacing between legend items
child: Row(
children: [
Container(
width: 12,
height: 12,
decoration: const BoxDecoration(
color: Colors.red, // Use the color of the first bar rod for the legend item
shape: BoxShape.circle,
),
),
const SizedBox(width: 4.0), // Adjust the spacing between the color indicator and the legend label
const Text(
'Frühstück', // Replace with your desired legend label
style: TextStyle(fontSize: 12), // Adjust the font size of the legend labels
),
],
),
),
Container(
margin: const EdgeInsets.symmetric(horizontal: 8.0), // Adjust the spacing between legend items
child: Row(
children: [
Container(
width: 12,
height: 12,
decoration: const BoxDecoration(
color: Colors.green, // Use the color of the first bar rod for the legend item
shape: BoxShape.circle,
),
),
const SizedBox(width: 4.0), // Adjust the spacing between the color indicator and the legend label
const Text(
'Mittagessen', // Replace with your desired legend label
style: TextStyle(fontSize: 12), // Adjust the font size of the legend labels
),
],
),
),
Container(
margin: const EdgeInsets.symmetric(horizontal: 8.0), // Adjust the spacing between legend items
child: Row(
children: [
Container(
width: 12,
height: 12,
decoration: const BoxDecoration(
color: Colors.yellow, // Use the color of the first bar rod for the legend item
shape: BoxShape.circle,
),
),
const SizedBox(width: 4.0), // Adjust the spacing between the color indicator and the legend label
const Text(
'Abendessen', // Replace with your desired legend label
style: TextStyle(fontSize: 12), // Adjust the font size of the legend labels
),
],
),
),
],
),
),
Padding(
padding: const EdgeInsets.only(top:50.0), // Adjust the margin value as needed
child: SizedBox(
height: 250,
child: BarChart(
BarChartData(
barTouchData: barTouchData,
titlesData: titlesData,
borderData: borderData,
barGroups: value,
gridData: FlGridData(show: false),
alignment: BarChartAlignment.spaceAround,
),
),
),
)
),
],
),
);
@ -124,7 +191,7 @@ class ProgressPage extends StatelessWidget {
return BarTooltipItem(
rod.toY.round().toString(),
const TextStyle(
color: Colors.orange,
color: Colors.transparent,
fontWeight: FontWeight.bold,
),
);
@ -134,7 +201,7 @@ class ProgressPage extends StatelessWidget {
Widget getTitles(double value, TitleMeta meta) {
const style = TextStyle(
color: Colors.red,
color: Colors.orange,
fontWeight: FontWeight.bold,
fontSize: 14,
);
@ -181,20 +248,48 @@ class ProgressPage extends StatelessWidget {
getTitlesWidget: getTitles,
),
),
leftTitles: AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
topTitles: AxisTitles(
sideTitles: SideTitles(showTitles: false),
),
rightTitles: AxisTitles(
sideTitles: SideTitles(showTitles: false),
sideTitles: SideTitles(
showTitles: false,
),
),
leftTitles: AxisTitles(
sideTitles: SideTitles(
showTitles: true,
getTitlesWidget: (value, _) {
// Return a custom widget for each axis value
return Container(
constraints: BoxConstraints.tightFor(width: double.infinity),
child: Padding(
padding: const EdgeInsets.only(right: 3.0), // Adjust the margin value as needed
child: FittedBox(
fit: BoxFit.scaleDown,
alignment: Alignment.centerLeft,
child: Text(
value.toInt().toString(),
style: const TextStyle(
color: Colors.orange,
fontWeight: FontWeight.bold,
),
),
),
),
);
},
),
)
);
FlBorderData get borderData => FlBorderData(
show: false,
);
show: true, // Set to true to display the chart border
border: const Border(
bottom: BorderSide(color: Colors.black, width: 1),
left: BorderSide(color: Colors.black, width: 1),// Hide the left border
),
);
}

View File

@ -27,7 +27,7 @@ void main() async {
await Hive.openBox(dotenv.env['STATISTICS_MAIN_BOX'] ?? 'STATISTICS_MAIN_BOX');
await Hive.openBox(dotenv.env['MEALPLAN_BOX'] ?? 'MEALPLAN');
await Hive.openBox<User>('USER_BOX');
//Hive.deleteFromDisk();
setupTodayBox();
if (defaultTargetPlatform == TargetPlatform.android) {