Commit 59bf0d01 authored by Administrator's avatar Administrator

some progress on athlete ecor chart (still displaying power data though)

parent 75b322fd
......@@ -12,6 +12,7 @@ import 'package:encrateia/widgets/athlete_widgets/athlete_settings_widget.dart';
import 'package:encrateia/widgets/athlete_widgets/athlete_power_per_heart_rate_widget.dart';
import 'package:encrateia/widgets/athlete_widgets/athlete_speed_per_heart_rate_widget.dart';
import 'package:encrateia/widgets/athlete_widgets/athlete_body_weight_widget.dart';
import 'package:encrateia/widgets/athlete_widgets/athlete_ecor_widget.dart';
import 'package:encrateia/screens/show_athlete_detail_screen.dart';
import 'package:encrateia/utils/icon_utils.dart';
import 'package:flushbar/flushbar.dart';
......@@ -92,6 +93,13 @@ class _ShowAthleteScreenState extends State<ShowAthleteScreen> {
nextWidget:
AthletePowerPerHeartRateWidget(athlete: widget.athlete),
),
navigationButton(
color: MyColor.navigate,
title: "Ecor",
icon: MyIcon.power,
nextWidget:
AthleteEcorWidget(athlete: widget.athlete),
),
navigationButton(
color: MyColor.navigate,
title: "Stride Ratio",
......
......@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:encrateia/models/activity.dart';
import 'package:encrateia/models/event.dart';
import 'package:encrateia/utils/num_utils.dart';
import '../charts/actitvity_charts/activity_form_power_chart.dart';
import 'package:encrateia/widgets/charts/actitvity_charts/activity_form_power_chart.dart';
import 'package:encrateia/utils/icon_utils.dart';
class ActivityFormPowerWidget extends StatefulWidget {
......
......@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:encrateia/models/activity.dart';
import 'package:encrateia/models/event.dart';
import 'package:encrateia/utils/num_utils.dart';
import '../charts/actitvity_charts/activity_ground_time_chart.dart';
import 'package:encrateia/widgets/charts/actitvity_charts/activity_ground_time_chart.dart';
import 'package:encrateia/utils/icon_utils.dart';
class ActivityGroundTimeWidget extends StatefulWidget {
......
......@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:encrateia/models/activity.dart';
import 'package:encrateia/models/event.dart';
import 'package:encrateia/utils/num_utils.dart';
import '../charts/actitvity_charts/activity_leg_spring_stiffness_chart.dart';
import 'package:encrateia/widgets/charts/actitvity_charts/activity_leg_spring_stiffness_chart.dart';
import 'package:encrateia/utils/icon_utils.dart';
class ActivityLegSpringStiffnessWidget extends StatefulWidget {
......
......@@ -2,7 +2,7 @@ import 'package:encrateia/models/athlete.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/models/activity.dart';
import 'package:encrateia/models/event.dart';
import '../charts/power_duration_chart.dart';
import 'package:encrateia/widgets/charts/power_duration_chart.dart';
class ActivityPowerDurationWidget extends StatelessWidget {
final Activity activity;
......
......@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:encrateia/models/activity.dart';
import 'package:encrateia/models/event.dart';
import 'package:encrateia/utils/num_utils.dart';
import '../charts/actitvity_charts/activity_stryd_cadence_chart.dart';
import 'package:encrateia/widgets/charts/actitvity_charts/activity_stryd_cadence_chart.dart';
import 'package:encrateia/utils/icon_utils.dart';
class ActivityStrydCadenceWidget extends StatefulWidget {
......
......@@ -3,7 +3,7 @@ import 'package:flutter/material.dart';
import 'package:encrateia/models/activity.dart';
import 'package:encrateia/models/event.dart';
import 'package:encrateia/utils/num_utils.dart';
import '../charts/actitvity_charts/activity_vertical_oscillation_chart.dart';
import 'package:encrateia/widgets/charts/actitvity_charts/activity_vertical_oscillation_chart.dart';
import 'package:encrateia/utils/icon_utils.dart';
class ActivityVerticalOscillationWidget extends StatefulWidget {
......
import 'package:encrateia/models/weight.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/models/athlete.dart';
import 'package:encrateia/models/activity.dart';
import 'package:encrateia/widgets/charts/athlete_charts/athlete_ecor_chart.dart';
class AthleteEcorWidget extends StatefulWidget {
final Athlete athlete;
AthleteEcorWidget({this.athlete});
@override
_AthleteEcorWidgetState createState() => _AthleteEcorWidgetState();
}
class _AthleteEcorWidgetState extends State<AthleteEcorWidget> {
List<Activity> activities = [];
double anyWeight;
@override
void initState() {
getData();
super.initState();
}
@override
Widget build(context) {
if (activities.length > 0) {
var ecorActivities = activities
.where((activity) =>
activity.db.avgPower != null &&
activity.db.avgPower > 0 &&
activity.db.avgSpeed != null)
.toList();
if (ecorActivities.length > 0 && anyWeight != null) {
return ListTileTheme(
iconColor: Colors.orange,
child: ListView(
padding: EdgeInsets.only(left: 25),
children: <Widget>[
AthleteEcorChart(activities: ecorActivities),
],
),
);
} else {
return Center(
child: Text("No Ecor available."),
);
}
} else {
return Center(
child: Text("Loading"),
);
}
}
getData() async {
Athlete athlete = widget.athlete;
activities = await athlete.activities;
anyWeight = await Weight.getBy(
athletesId: widget.athlete.db.id,
date: DateTime.now(),
);
setState(() {});
}
}
import 'package:flutter/material.dart';
import 'package:encrateia/models/athlete.dart';
import 'package:encrateia/models/activity.dart';
import '../charts/athlete_charts/athlete_power_chart.dart';
import 'package:encrateia/widgets/charts/athlete_charts/athlete_power_chart.dart';
class AthletePowerWidget extends StatefulWidget {
final Athlete athlete;
......
import 'package:flutter/material.dart';
import 'package:encrateia/models/athlete.dart';
import 'package:encrateia/models/activity.dart';
import '../charts/athlete_charts/athlete_speed_per_heart_rate_chart.dart';
import 'package:encrateia/widgets/charts/athlete_charts/athlete_speed_per_heart_rate_chart.dart';
class AthleteSpeedPerHeartRateWidget extends StatefulWidget {
final Athlete athlete;
......
import 'package:charts_flutter/flutter.dart';
import 'package:encrateia/models/activity_list.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/models/activity.dart';
import 'package:encrateia/utils/enums.dart';
class AthleteEcorChart extends StatelessWidget {
final List<Activity> activities;
AthleteEcorChart({@required this.activities});
@override
Widget build(BuildContext context) {
int xAxesDays = 60;
ActivityList(activities: activities).enrichGlidingAverage(
quantity: ActivityAttr.avgPower,
fullDecay: 30,
);
var recentActivities = activities
.where((activity) =>
DateTime.now().difference(activity.db.timeCreated).inDays <
xAxesDays)
.toList();
var data = [
Series<Activity, DateTime>(
id: 'ecor',
colorFn: (_, __) => MaterialPalette.blue.shadeDefault,
domainFn: (Activity activity, _) => activity.db.timeCreated,
measureFn: (Activity activity, _) => activity.db.avgPower,
data: recentActivities,
),
Series<Activity, DateTime>(
id: 'gliding_ecor',
colorFn: (_, __) => MaterialPalette.green.shadeDefault,
domainFn: (Activity activity, _) => activity.db.timeCreated,
measureFn: (Activity activity, _) => activity.glidingAvgPower,
data: recentActivities,
)..setAttribute(rendererIdKey, 'glidingAverageRenderer'),
];
return new Container(
height: 300,
child: TimeSeriesChart(
data,
animate: false,
defaultRenderer: LineRendererConfig(
includePoints: true,
includeLine: false,
),
customSeriesRenderers: [
LineRendererConfig(
customRendererId: 'glidingAverageRenderer',
dashPattern: [1, 2],
),
],
primaryMeasureAxis: NumericAxisSpec(
tickProviderSpec: BasicNumericTickProviderSpec(
zeroBound: false,
dataIsInWholeNumbers: false,
desiredTickCount: 6,
),
),
behaviors: [
ChartTitle(
'Ecor (W s/kg m)',
titleStyleSpec: TextStyleSpec(fontSize: 13),
behaviorPosition: BehaviorPosition.start,
titleOutsideJustification: OutsideJustification.end,
),
ChartTitle(
'Date',
titleStyleSpec: TextStyleSpec(fontSize: 13),
behaviorPosition: BehaviorPosition.bottom,
titleOutsideJustification: OutsideJustification.end,
),
],
),
);
}
}
......@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:encrateia/models/lap.dart';
import 'package:encrateia/models/event.dart';
import 'package:encrateia/utils/num_utils.dart';
import '../charts/lap_charts/lap_form_power_chart.dart';
import 'package:encrateia/widgets/charts/lap_charts/lap_form_power_chart.dart';
import 'package:encrateia/utils/icon_utils.dart';
class LapFormPowerWidget extends StatefulWidget {
......
......@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:encrateia/models/lap.dart';
import 'package:encrateia/models/event.dart';
import 'package:encrateia/utils/num_utils.dart';
import '../charts/lap_charts/lap_ground_time_chart.dart';
import 'package:encrateia/widgets/charts/lap_charts/lap_ground_time_chart.dart';
import 'package:encrateia/utils/icon_utils.dart';
class LapGroundTimeWidget extends StatefulWidget {
......
......@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:encrateia/models/lap.dart';
import 'package:encrateia/models/event.dart';
import 'package:encrateia/utils/num_utils.dart';
import '../charts/lap_charts/lap_leg_spring_stiffness_chart.dart';
import 'package:encrateia/widgets/charts/lap_charts/lap_leg_spring_stiffness_chart.dart';
import 'package:encrateia/utils/icon_utils.dart';
class LapLegSpringStiffnessWidget extends StatefulWidget {
......
......@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:encrateia/models/lap.dart';
import 'package:encrateia/models/event.dart';
import 'package:encrateia/utils/num_utils.dart';
import '../charts/lap_charts/lap_stryd_cadence_chart.dart';
import 'package:encrateia/widgets/charts/lap_charts/lap_stryd_cadence_chart.dart';
import 'package:encrateia/utils/icon_utils.dart';
class LapStrydCadenceWidget extends StatefulWidget {
......
......@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import 'package:encrateia/models/lap.dart';
import 'package:encrateia/models/event.dart';
import 'package:encrateia/utils/num_utils.dart';
import '../charts/lap_charts/lap_vertical_oscillation_chart.dart';
import 'package:encrateia/widgets/charts/lap_charts/lap_vertical_oscillation_chart.dart';
import 'package:encrateia/utils/icon_utils.dart';
class LapVerticalOscillationWidget extends StatefulWidget {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment