final beta Version
This commit is contained in:
124
lib/pages/graph/widgets/bar_chart_widget.dart
Normal file
124
lib/pages/graph/widgets/bar_chart_widget.dart
Normal file
@@ -0,0 +1,124 @@
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../utils/extensions/constants.dart';
|
||||
import '../graph_controller.dart';
|
||||
|
||||
class BarChartWidget extends StatelessWidget {
|
||||
final GraphController graphCtrl;
|
||||
const BarChartWidget({super.key, required this.graphCtrl});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AspectRatio(
|
||||
aspectRatio: 2,
|
||||
child: BarChart(
|
||||
BarChartData(
|
||||
//alignment: BarChartAlignment.center,
|
||||
maxY: 50,
|
||||
baselineY: 0,
|
||||
barTouchData: barTouchData,
|
||||
titlesData: titlesData,
|
||||
borderData: borderData,
|
||||
barGroups: barGroups,
|
||||
gridData: const FlGridData(show: false),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
BarTouchData get barTouchData => BarTouchData(
|
||||
enabled: false,
|
||||
touchTooltipData: BarTouchTooltipData(
|
||||
//tooltipBgColor: Colors.transparent,
|
||||
tooltipPadding: EdgeInsets.zero,
|
||||
tooltipMargin: 8,
|
||||
getTooltipItem:
|
||||
(
|
||||
BarChartGroupData group,
|
||||
int groupIndex,
|
||||
BarChartRodData rod,
|
||||
int rodIndex,
|
||||
) {
|
||||
return BarTooltipItem(
|
||||
rod.toY.round().toString(),
|
||||
const TextStyle(color: Colors.cyan, fontWeight: FontWeight.bold),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
Widget getTitles(double value, TitleMeta meta) {
|
||||
List<String> dayMonListString = graphCtrl.getHeadDescription();
|
||||
for (var i = 0; i < dayMonListString.length; i++) {
|
||||
if (i == value.toInt()) {
|
||||
graphCtrl.szBarTitle.value = dayMonListString[i];
|
||||
}
|
||||
}
|
||||
return SideTitleWidget(
|
||||
fitInside: SideTitleFitInsideData.fromTitleMeta(meta),
|
||||
space: 4,
|
||||
meta: meta,
|
||||
child: Text(graphCtrl.szBarTitle.value, style: kBarTitleStyle),
|
||||
);
|
||||
}
|
||||
|
||||
FlTitlesData get titlesData => FlTitlesData(
|
||||
show: true,
|
||||
bottomTitles: AxisTitles(
|
||||
sideTitles: SideTitles(
|
||||
showTitles: true,
|
||||
reservedSize: 30,
|
||||
getTitlesWidget: getTitles,
|
||||
),
|
||||
),
|
||||
leftTitles: const AxisTitles(sideTitles: SideTitles(showTitles: false)),
|
||||
topTitles: const AxisTitles(sideTitles: SideTitles(showTitles: false)),
|
||||
rightTitles: const AxisTitles(sideTitles: SideTitles(showTitles: false)),
|
||||
);
|
||||
|
||||
FlBorderData get borderData => FlBorderData(show: false);
|
||||
|
||||
LinearGradient get _barsGradient => LinearGradient(
|
||||
colors: [Colors.blue.shade400, Colors.red.shade300],
|
||||
begin: Alignment.bottomCenter,
|
||||
end: Alignment.topCenter,
|
||||
);
|
||||
|
||||
List<BarChartGroupData> get barGroups => [
|
||||
BarChartGroupData(
|
||||
x: 0,
|
||||
barRods: [BarChartRodData(toY: 8, gradient: _barsGradient)],
|
||||
showingTooltipIndicators: [0],
|
||||
),
|
||||
BarChartGroupData(
|
||||
x: 1,
|
||||
barRods: [BarChartRodData(toY: 10, gradient: _barsGradient)],
|
||||
showingTooltipIndicators: [0],
|
||||
),
|
||||
BarChartGroupData(
|
||||
x: 2,
|
||||
barRods: [BarChartRodData(toY: 14, gradient: _barsGradient)],
|
||||
showingTooltipIndicators: [0],
|
||||
),
|
||||
BarChartGroupData(
|
||||
x: 3,
|
||||
barRods: [BarChartRodData(toY: 15, gradient: _barsGradient)],
|
||||
showingTooltipIndicators: [0],
|
||||
),
|
||||
BarChartGroupData(
|
||||
x: 4,
|
||||
barRods: [BarChartRodData(toY: 13, gradient: _barsGradient)],
|
||||
showingTooltipIndicators: [0],
|
||||
),
|
||||
BarChartGroupData(
|
||||
x: 5,
|
||||
barRods: [BarChartRodData(toY: 10, gradient: _barsGradient)],
|
||||
showingTooltipIndicators: [0],
|
||||
),
|
||||
BarChartGroupData(
|
||||
x: 6,
|
||||
barRods: [BarChartRodData(toY: 16, gradient: _barsGradient)],
|
||||
showingTooltipIndicators: [0],
|
||||
),
|
||||
];
|
||||
}
|
||||
43
lib/pages/graph/widgets/chart_desc.dart
Normal file
43
lib/pages/graph/widgets/chart_desc.dart
Normal file
@@ -0,0 +1,43 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../utils/extensions/constants.dart';
|
||||
|
||||
|
||||
|
||||
class ChartDescription extends StatelessWidget {
|
||||
final double mnWidth;
|
||||
final Color backgroundColor;
|
||||
final String szDescText;
|
||||
final String szCurrentSumData;
|
||||
const ChartDescription({
|
||||
super.key,
|
||||
required this.mnWidth,
|
||||
required this.backgroundColor,
|
||||
required this.szDescText,
|
||||
required this.szCurrentSumData,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
width: mnWidth,
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: backgroundColor,
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
width: 70,
|
||||
height: 20,
|
||||
child: Center(
|
||||
child: Text(szCurrentSumData, style: kChartDescriptionFontStyle),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Text(szDescText, style: kTextStyle),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
49
lib/pages/graph/widgets/chart_lines.dart
Normal file
49
lib/pages/graph/widgets/chart_lines.dart
Normal file
@@ -0,0 +1,49 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:get/get.dart';
|
||||
import '../graph_controller.dart';
|
||||
|
||||
// 08.08.23 Mod. Line Chart with tree Lines
|
||||
class LineChartLines extends GetView<GraphController> {
|
||||
final Color firstLineColor;
|
||||
final Color secondLineColor;
|
||||
|
||||
const LineChartLines({
|
||||
super.key,
|
||||
required this.firstLineColor,
|
||||
required this.secondLineColor,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final GraphController gCtrl = controller;
|
||||
return AspectRatio(
|
||||
aspectRatio: 3,
|
||||
child: Obx(
|
||||
() => LineChart(
|
||||
LineChartData(
|
||||
lineBarsData: [
|
||||
LineChartBarData(
|
||||
color: firstLineColor,
|
||||
spots: gCtrl.pointsEuro
|
||||
.map((point) => FlSpot(point.x, point.y))
|
||||
.toList(),
|
||||
isCurved: false,
|
||||
dotData: const FlDotData(show: true),
|
||||
),
|
||||
LineChartBarData(
|
||||
isStepLineChart: false,
|
||||
color: secondLineColor,
|
||||
spots: gCtrl.pointsGasoline
|
||||
.map((point) => FlSpot(point.x, point.y))
|
||||
.toList(),
|
||||
isCurved: false,
|
||||
dotData: const FlDotData(show: true),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
36
lib/pages/graph/widgets/chart_single_lines.dart
Normal file
36
lib/pages/graph/widgets/chart_single_lines.dart
Normal file
@@ -0,0 +1,36 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../graph_controller.dart';
|
||||
|
||||
// 08.08.23 Mod. Line Chart with tree Lines
|
||||
class LineChartSingleLine extends GetView<GraphController> {
|
||||
final Color singleLineColor;
|
||||
|
||||
const LineChartSingleLine({super.key, required this.singleLineColor});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final GraphController gCtrl = controller;
|
||||
return AspectRatio(
|
||||
aspectRatio: 3.55,
|
||||
child: Obx(
|
||||
() => LineChart(
|
||||
LineChartData(
|
||||
lineBarsData: [
|
||||
LineChartBarData(
|
||||
color: singleLineColor,
|
||||
spots: gCtrl.pointsPerLiter
|
||||
.map((point) => FlSpot(point.x, point.y))
|
||||
.toList(),
|
||||
isCurved: false,
|
||||
dotData: const FlDotData(show: true),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
46
lib/pages/graph/widgets/my_list_tile_card.dart
Normal file
46
lib/pages/graph/widgets/my_list_tile_card.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../utils/extensions/constants.dart';
|
||||
import '../graph_controller.dart';
|
||||
|
||||
|
||||
class MyListTileCard extends StatelessWidget {
|
||||
const MyListTileCard({
|
||||
super.key,
|
||||
required this.graphCtrl,
|
||||
required this.index,
|
||||
});
|
||||
|
||||
final GraphController graphCtrl;
|
||||
final int index;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
shadowColor: Colors.grey.shade200,
|
||||
child: ListTile(
|
||||
title: Text(
|
||||
'${graphCtrl.sumListData[index].szMonth}',
|
||||
style: kTextStyle,
|
||||
),
|
||||
subtitle: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Monatsausgaben: ${graphCtrl.sumListData[index].szSumme} €',
|
||||
style: kTextStyleSub,
|
||||
),
|
||||
Text(
|
||||
'Monatsverbrauch: ${graphCtrl.sumListData[index].szVerbrauch} L',
|
||||
style: kTextStyleSub,
|
||||
),
|
||||
Text(
|
||||
'Tankungen: ${graphCtrl.sumListData[index].mnTankungen}',
|
||||
style: kTextStyleSub,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user