Commit e98adb37 authored by Administrator's avatar Administrator

clean up lap charts

parent 825e7ac2
......@@ -39,4 +39,21 @@ class GraphUtils {
height: 100,
child: Center(child: Text("Loading")),
);
static axis({String measureTitle}) {
return [
ChartTitle(
measureTitle,
titleStyleSpec: TextStyleSpec(fontSize: 13),
behaviorPosition: BehaviorPosition.start,
titleOutsideJustification: OutsideJustification.end,
),
ChartTitle(
'Distance (m)',
titleStyleSpec: TextStyleSpec(fontSize: 13),
behaviorPosition: BehaviorPosition.bottom,
titleOutsideJustification: OutsideJustification.end,
),
];
}
}
......@@ -8,7 +8,7 @@ class MyLineChart extends LineChart {
@required maxDomain,
@required laps,
@required domainTitle,
@required measureTitle,
measureTitle,
measureTickProviderSpec,
domainTickProviderSpec
......
import 'package:charts_flutter/flutter.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/models/event.dart';
import 'package:encrateia/utils/graph_utils.dart';
class LapFormPowerChart extends StatelessWidget {
final List<Event> records;
......@@ -27,30 +28,19 @@ class LapFormPowerChart extends StatelessWidget {
return new Container(
height: 300,
padding: EdgeInsets.all(2),
child: LineChart(
data,
primaryMeasureAxis: NumericAxisSpec(
tickProviderSpec: BasicNumericTickProviderSpec(
zeroBound: false,
dataIsInWholeNumbers: true,
desiredTickCount: 6),
zeroBound: false,
dataIsInWholeNumbers: true,
desiredTickCount: 6,
),
),
animate: false,
behaviors: [
ChartTitle(
'Form Power (W)',
titleStyleSpec: TextStyleSpec(fontSize: 13),
behaviorPosition: BehaviorPosition.start,
titleOutsideJustification: OutsideJustification.end,
),
ChartTitle(
'Distance (m)',
titleStyleSpec: TextStyleSpec(fontSize: 13),
behaviorPosition: BehaviorPosition.bottom,
titleOutsideJustification: OutsideJustification.end,
),
],
behaviors: GraphUtils.axis(
measureTitle: 'Form Power (W)',
),
),
);
}
......
import 'package:charts_flutter/flutter.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/models/event.dart';
import 'package:encrateia/utils/graph_utils.dart';
class LapGroundTimeChart extends StatelessWidget {
final List<Event> records;
......@@ -10,7 +11,8 @@ class LapGroundTimeChart extends StatelessWidget {
@override
Widget build(BuildContext context) {
var nonZero = records
.where((value) => value.db.groundTime != null && value.db.groundTime > 0)
.where(
(value) => value.db.groundTime != null && value.db.groundTime > 0)
.toList();
var offset = nonZero.first.db.distance.round();
......@@ -27,7 +29,6 @@ class LapGroundTimeChart extends StatelessWidget {
return new Container(
height: 300,
padding: EdgeInsets.all(2),
child: LineChart(
data,
animate: false,
......@@ -38,20 +39,9 @@ class LapGroundTimeChart extends StatelessWidget {
desiredTickCount: 5,
),
),
behaviors: [
ChartTitle(
'Ground Time (ms)',
titleStyleSpec: TextStyleSpec(fontSize: 13),
behaviorPosition: BehaviorPosition.start,
titleOutsideJustification: OutsideJustification.end,
),
ChartTitle(
'Distance (m)',
titleStyleSpec: TextStyleSpec(fontSize: 13),
behaviorPosition: BehaviorPosition.bottom,
titleOutsideJustification: OutsideJustification.end,
),
],
behaviors: GraphUtils.axis(
measureTitle: 'Ground Time (ms)',
),
),
);
}
......
import 'package:charts_flutter/flutter.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/models/event.dart';
import 'package:encrateia/utils/graph_utils.dart';
class LapHeartRateChart extends StatelessWidget {
final List<Event> records;
......@@ -24,7 +25,6 @@ class LapHeartRateChart extends StatelessWidget {
return new Container(
height: 300,
padding: EdgeInsets.all(2),
child: LineChart(
data,
primaryMeasureAxis: NumericAxisSpec(
......@@ -34,20 +34,9 @@ class LapHeartRateChart extends StatelessWidget {
desiredTickCount: 6),
),
animate: false,
behaviors: [
ChartTitle(
'Heart Rate (bpm)',
titleStyleSpec: TextStyleSpec(fontSize: 13),
behaviorPosition: BehaviorPosition.start,
titleOutsideJustification: OutsideJustification.end,
),
ChartTitle(
'Distance (m)',
titleStyleSpec: TextStyleSpec(fontSize: 13),
behaviorPosition: BehaviorPosition.bottom,
titleOutsideJustification: OutsideJustification.end,
),
],
behaviors: GraphUtils.axis(
measureTitle: 'Heart Rate (bpm)',
),
),
);
}
......
import 'package:charts_flutter/flutter.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/models/event.dart';
import 'package:encrateia/utils/graph_utils.dart';
class LapLegSpringStiffnessChart extends StatelessWidget {
final List<Event> records;
......@@ -10,7 +11,9 @@ class LapLegSpringStiffnessChart extends StatelessWidget {
@override
Widget build(BuildContext context) {
var nonZero = records
.where((value) => value.db.legSpringStiffness != null && value.db.legSpringStiffness > 0)
.where((value) =>
value.db.legSpringStiffness != null &&
value.db.legSpringStiffness > 0)
.toList();
var offset = nonZero.first.db.distance.round();
......@@ -27,7 +30,6 @@ class LapLegSpringStiffnessChart extends StatelessWidget {
return new Container(
height: 300,
padding: EdgeInsets.all(2),
child: LineChart(
data,
animate: false,
......@@ -38,20 +40,9 @@ class LapLegSpringStiffnessChart extends StatelessWidget {
desiredTickCount: 5,
),
),
behaviors: [
ChartTitle(
'Leg Spring Stiffness (kN/m)',
titleStyleSpec: TextStyleSpec(fontSize: 13),
behaviorPosition: BehaviorPosition.start,
titleOutsideJustification: OutsideJustification.end,
),
ChartTitle(
'Distance (m)',
titleStyleSpec: TextStyleSpec(fontSize: 13),
behaviorPosition: BehaviorPosition.bottom,
titleOutsideJustification: OutsideJustification.end,
),
],
behaviors: GraphUtils.axis(
measureTitle: 'Leg Spring Stiffness (kN/m)',
),
),
);
}
......
import 'package:charts_flutter/flutter.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/models/event.dart';
import 'package:encrateia/utils/graph_utils.dart';
class LapPowerChart extends StatelessWidget {
final List<Event> records;
......@@ -27,7 +28,6 @@ class LapPowerChart extends StatelessWidget {
return new Container(
height: 300,
padding: EdgeInsets.all(2),
child: LineChart(
data,
primaryMeasureAxis: NumericAxisSpec(
......@@ -37,20 +37,9 @@ class LapPowerChart extends StatelessWidget {
desiredTickCount: 6),
),
animate: false,
behaviors: [
ChartTitle(
'Power (W)',
titleStyleSpec: TextStyleSpec(fontSize: 13),
behaviorPosition: BehaviorPosition.start,
titleOutsideJustification: OutsideJustification.end,
),
ChartTitle(
'Distance (m)',
titleStyleSpec: TextStyleSpec(fontSize: 13),
behaviorPosition: BehaviorPosition.bottom,
titleOutsideJustification: OutsideJustification.end,
),
],
behaviors: GraphUtils.axis(
measureTitle: 'Power (W)',
),
),
);
}
......
import 'package:charts_flutter/flutter.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/models/event.dart';
import 'package:encrateia/utils/graph_utils.dart';
class LapStrydCadenceChart extends StatelessWidget {
final List<Event> records;
......@@ -27,7 +28,6 @@ class LapStrydCadenceChart extends StatelessWidget {
return new Container(
height: 300,
padding: EdgeInsets.all(2),
child: LineChart(
data,
animate: false,
......@@ -38,20 +38,9 @@ class LapStrydCadenceChart extends StatelessWidget {
desiredTickCount: 5,
),
),
behaviors: [
ChartTitle(
'Cadence (spm)',
titleStyleSpec: TextStyleSpec(fontSize: 13),
behaviorPosition: BehaviorPosition.start,
titleOutsideJustification: OutsideJustification.end,
),
ChartTitle(
'Distance (m)',
titleStyleSpec: TextStyleSpec(fontSize: 13),
behaviorPosition: BehaviorPosition.bottom,
titleOutsideJustification: OutsideJustification.end,
),
],
behaviors: GraphUtils.axis(
measureTitle: 'Cadence (spm)',
),
),
);
}
......
import 'package:charts_flutter/flutter.dart';
import 'package:flutter/material.dart';
import 'package:encrateia/models/event.dart';
import 'package:encrateia/utils/graph_utils.dart';
class LapVerticalOscillationChart extends StatelessWidget {
final List<Event> records;
......@@ -10,7 +11,9 @@ class LapVerticalOscillationChart extends StatelessWidget {
@override
Widget build(BuildContext context) {
var nonZero = records
.where((value) => value.db.verticalOscillation != null && value.db.verticalOscillation > 0)
.where((value) =>
value.db.verticalOscillation != null &&
value.db.verticalOscillation > 0)
.toList();
var offset = nonZero.first.db.distance.round();
......@@ -27,7 +30,6 @@ class LapVerticalOscillationChart extends StatelessWidget {
return new Container(
height: 300,
padding: EdgeInsets.all(2),
child: LineChart(
data,
animate: false,
......@@ -38,20 +40,9 @@ class LapVerticalOscillationChart extends StatelessWidget {
desiredTickCount: 5,
),
),
behaviors: [
ChartTitle(
'Vertical Oscillation (cm)',
titleStyleSpec: TextStyleSpec(fontSize: 13),
behaviorPosition: BehaviorPosition.start,
titleOutsideJustification: OutsideJustification.end,
),
ChartTitle(
'Distance (m)',
titleStyleSpec: TextStyleSpec(fontSize: 13),
behaviorPosition: BehaviorPosition.bottom,
titleOutsideJustification: OutsideJustification.end,
),
],
behaviors: GraphUtils.axis(
measureTitle: 'Vertical Oscillation (cm)',
),
),
);
}
......
......@@ -26,13 +26,13 @@ class PowerDurationChart extends StatelessWidget {
)
];
final staticTicks = <TickSpec<int>>[
final staticTicks = StaticNumericTickProviderSpec([
TickSpec(PowerDuration.scaled(seconds: 1), label: '1s'),
TickSpec(PowerDuration.scaled(seconds: 10), label: '10s'),
TickSpec(PowerDuration.scaled(seconds: 60), label: '1min'),
TickSpec(PowerDuration.scaled(seconds: 600), label: '10min'),
TickSpec(PowerDuration.scaled(seconds: 3600), label: '1h'),
];
]);
final chartTitles = [
ChartTitle(
......@@ -61,8 +61,7 @@ class PowerDurationChart extends StatelessWidget {
desiredTickCount: 10,
desiredMinTickCount: 6),
),
domainAxis: NumericAxisSpec(
tickProviderSpec: StaticNumericTickProviderSpec(staticTicks)),
domainAxis: NumericAxisSpec(tickProviderSpec: staticTicks),
animate: false,
behaviors: chartTitles,
),
......
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