cpd_2022_zi/lib/widgets/line_chart_widget.dart

32 lines
949 B
Dart
Raw Normal View History

2023-03-05 20:43:14 +01:00
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:provider/provider.dart';
import 'package:smoke_cess_app/providers/settings_provider.dart';
import 'package:syncfusion_flutter_charts/charts.dart';
class LineChart<T> extends StatelessWidget {
2023-03-05 20:54:08 +01:00
final List<LineSeries<T, DateTime>> series;
const LineChart({
super.key,
required this.series,
});
2023-03-05 20:43:14 +01:00
@override
Widget build(BuildContext context) {
SettingsProvider settingsProvider = context.watch<SettingsProvider>();
return SfCartesianChart(
primaryXAxis: DateTimeAxis(
minimum: settingsProvider.settings?.startedAt,
maximum: settingsProvider.settings?.startedAt
.add(const Duration(days: 7 * 6)),
interval: 7,
dateFormat: DateFormat.Md('de'),
),
primaryYAxis:
NumericAxis(isVisible: false, minimum: 0, maximum: 100, interval: 20),
2023-03-05 20:54:08 +01:00
series: series,
2023-03-05 20:43:14 +01:00
);
}
}