mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
@@ -1,5 +1,9 @@
|
||||
import 'consts.dart';
|
||||
|
||||
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
|
||||
? CHART_MILLISECOND_FACTOR
|
||||
: dayDiff.inMilliseconds.abs() / divider;
|
||||
}
|
||||
|
||||
@@ -124,3 +124,9 @@ const MASTODON_URL = 'https://fosstodon.org/@wger';
|
||||
const WEBLATE_URL = 'https://hosted.weblate.org/engage/wger';
|
||||
const BUY_ME_A_COFFEE_URL = 'https://buymeacoffee.com/wger';
|
||||
const LIBERAPAY_URL = 'https://liberapay.com/wger';
|
||||
|
||||
/// Factor to multiply / divide in the charts when converting dates to milliseconds
|
||||
/// from epoch since fl_charts does not support real time series charts and using
|
||||
/// the milliseconds themselves can cause the application to crash since it runs
|
||||
/// out of memory...
|
||||
const double CHART_MILLISECOND_FACTOR = 100000.0;
|
||||
|
||||
@@ -20,6 +20,7 @@ import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:wger/helpers/charts.dart';
|
||||
import 'package:wger/helpers/consts.dart';
|
||||
import 'package:wger/l10n/generated/app_localizations.dart';
|
||||
|
||||
class MeasurementOverallChangeWidget extends StatelessWidget {
|
||||
@@ -142,7 +143,7 @@ class _MeasurementChartWidgetFlState extends State<MeasurementChartWidgetFl> {
|
||||
widget._entries.last.date,
|
||||
widget._entries.first.date,
|
||||
)
|
||||
: 1000,
|
||||
: CHART_MILLISECOND_FACTOR,
|
||||
),
|
||||
),
|
||||
leftTitles: AxisTitles(
|
||||
|
||||
@@ -78,13 +78,15 @@ List<Widget> getOverviewWidgetsSeries(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Indicator(
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
text: AppLocalizations.of(context).indicatorRaw,
|
||||
isSquare: true),
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
text: AppLocalizations.of(context).indicatorRaw,
|
||||
isSquare: true,
|
||||
),
|
||||
Indicator(
|
||||
color: Theme.of(context).colorScheme.tertiary,
|
||||
text: AppLocalizations.of(context).indicatorAvg,
|
||||
isSquare: true),
|
||||
color: Theme.of(context).colorScheme.tertiary,
|
||||
text: AppLocalizations.of(context).indicatorAvg,
|
||||
isSquare: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
];
|
||||
|
||||
@@ -112,7 +112,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,
|
||||
|
||||
Reference in New Issue
Block a user