Interval of 1000 hard crashes, and 1000000 does not. Changing to last date also stops it hitting the 0 difference. Removed unused currentDate #788

This commit is contained in:
burny0202
2025-05-18 10:36:24 +01:00
parent b98cc9b33a
commit 2ade2013dc
3 changed files with 4 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
double chartGetInterval(DateTime first, DateTime last, {divider = 3}) {
final dayDiff = last.difference(first);
return dayDiff.inMilliseconds == 0 ? 1000 : dayDiff.inMilliseconds.abs() / divider;
return dayDiff.inMilliseconds == 0 ? 1000000 : dayDiff.inMilliseconds.abs() / divider;
}

View File

@@ -142,7 +142,7 @@ class _MeasurementChartWidgetFlState extends State<MeasurementChartWidgetFl> {
widget._entries.last.date,
widget._entries.first.date,
)
: 1000,
: 1000000,
),
),
leftTitles: AxisTitles(

View File

@@ -27,9 +27,8 @@ import 'package:wger/models/workouts/log.dart';
class LogChartWidgetFl extends StatefulWidget {
final Map<num, List<Log>> _data;
final DateTime _currentDate;
const LogChartWidgetFl(this._data, this._currentDate);
const LogChartWidgetFl(this._data);
@override
State<LogChartWidgetFl> createState() => _LogChartWidgetFlState();
@@ -112,7 +111,7 @@ class _LogChartWidgetFlState extends State<LogChartWidgetFl> {
: DateTime.now(),
widget._data.containsKey(widget._data.keys.last) &&
widget._data[widget._data.keys.last]!.isNotEmpty
? widget._data[widget._data.keys.last]!.first.date
? widget._data[widget._data.keys.last]!.last.date
: DateTime.now(),
// widget._data[widget._data.keys.first]!.first.date,
// widget._data[widget._data.keys.last]!.first.date,