cpd_app_gruppe_finanzplaner/lib/chart/expense_chart.dart

54 lines
1.5 KiB
Dart
Raw Normal View History

2023-06-15 02:23:13 +02:00
import 'package:easy_localization/easy_localization.dart';
2023-06-15 00:55:02 +02:00
import 'package:syncfusion_flutter_charts/charts.dart';
import 'expense_data.dart';
2023-06-15 02:23:13 +02:00
import 'package:flutter_neumorphic/flutter_neumorphic.dart';
2023-06-15 00:55:02 +02:00
class MonthlyExpensesChart extends StatelessWidget {
final List<ExpenseData> data;
2023-06-15 02:23:13 +02:00
const MonthlyExpensesChart({Key? key, required this.data}) : super(key: key);
2023-06-15 00:55:02 +02:00
@override
Widget build(BuildContext context) {
return SizedBox(
2023-06-15 02:23:13 +02:00
height: 240,
child: Neumorphic(
style: NeumorphicStyle(
shape: NeumorphicShape.flat,
depth: 8,
intensity: 0.6,
surfaceIntensity: 0.25,
shadowLightColor: Colors.white,
shadowDarkColor: Colors.black87,
color: Colors.grey[100],
),
child: SfCartesianChart(
primaryXAxis: CategoryAxis(),
series: _buildChartSeries(),
tooltipBehavior: TooltipBehavior(enable: true),
title: ChartTitle(
text: 'monthlyexpenses'.tr(),
textStyle: const TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14,
),
2023-06-15 00:55:02 +02:00
),
2023-06-15 02:23:13 +02:00
legend: Legend(
isVisible: false,
),
),
2023-06-15 00:55:02 +02:00
),
);
}
2023-06-15 02:23:13 +02:00
List<ChartSeries<ExpenseData, String>> _buildChartSeries() {
return [
ColumnSeries<ExpenseData, String>(
dataSource: data,
xValueMapper: (ExpenseData expense, _) => expense.month,
yValueMapper: (ExpenseData expense, _) => expense.amount,
color: Colors.blue.shade200,
),
];
}
}