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';
|
2023-06-17 03:09:31 +02:00
|
|
|
import 'package:tests/theme/theme_constants.dart';
|
2023-06-15 00:55:02 +02:00
|
|
|
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,
|
2023-06-17 03:09:31 +02:00
|
|
|
intensity: 0.7,
|
2023-06-15 02:23:13 +02:00
|
|
|
surfaceIntensity: 0.25,
|
2023-06-17 03:09:31 +02:00
|
|
|
shadowLightColor: Theme.of(context).brightness == Brightness.light
|
|
|
|
? const NeumorphicStyle().shadowLightColor
|
|
|
|
: grey600,
|
|
|
|
shadowDarkColor: Theme.of(context).brightness == Brightness.dark
|
|
|
|
? const NeumorphicStyle().shadowDarkColor
|
|
|
|
: grey400,
|
|
|
|
color: Theme.of(context).brightness == Brightness.light
|
|
|
|
? grey200
|
|
|
|
: grey800,
|
2023-06-15 02:23:13 +02:00
|
|
|
),
|
|
|
|
child: SfCartesianChart(
|
2023-06-17 03:09:31 +02:00
|
|
|
backgroundColor: Theme.of(context).brightness == Brightness.light
|
|
|
|
? grey200
|
|
|
|
: grey700,
|
2023-06-15 02:23:13 +02:00
|
|
|
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,
|
|
|
|
),
|
|
|
|
];
|
|
|
|
}
|
2023-06-17 03:09:31 +02:00
|
|
|
}
|