Commit 3ca5ec0d authored by Stefan Haslinger's avatar Stefan Haslinger

more compact bargraphs

parent f6e71453
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_secure_storage","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-3.3.3/","dependencies":[]},{"name":"path_provider","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.8/","dependencies":[]},{"name":"shared_preferences","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.7+2/","dependencies":[]},{"name":"sqflite","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.0+1/","dependencies":[]},{"name":"uni_links","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/uni_links-0.4.0/","dependencies":[]},{"name":"url_launcher","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.4.7/","dependencies":[]}],"android":[{"name":"flutter_secure_storage","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-3.3.3/","dependencies":[]},{"name":"path_provider","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.8/","dependencies":[]},{"name":"shared_preferences","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.7+2/","dependencies":[]},{"name":"sqflite","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.0+1/","dependencies":[]},{"name":"uni_links","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/uni_links-0.4.0/","dependencies":[]},{"name":"url_launcher","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.4.7/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.4+2/","dependencies":[]},{"name":"shared_preferences_macos","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-0.0.1+8/","dependencies":[]},{"name":"sqflite","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.0+1/","dependencies":[]},{"name":"url_launcher_macos","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.0.1+5/","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"shared_preferences_web","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-0.1.2+5/","dependencies":[]},{"name":"url_launcher_web","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-0.1.1+5/","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_secure_storage","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]},{"name":"uni_links","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_web","url_launcher_macos"]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]}],"date_created":"2020-06-05 16:15:42.073736","version":"1.17.0-4.0.pre.7"}
\ No newline at end of file
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_secure_storage","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-3.3.3/","dependencies":[]},{"name":"path_provider","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.8/","dependencies":[]},{"name":"shared_preferences","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.7+2/","dependencies":[]},{"name":"sqflite","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.0+1/","dependencies":[]},{"name":"uni_links","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/uni_links-0.4.0/","dependencies":[]},{"name":"url_launcher","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.4.7/","dependencies":[]}],"android":[{"name":"flutter_secure_storage","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_secure_storage-3.3.3/","dependencies":[]},{"name":"path_provider","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-1.6.8/","dependencies":[]},{"name":"shared_preferences","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences-0.5.7+2/","dependencies":[]},{"name":"sqflite","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.0+1/","dependencies":[]},{"name":"uni_links","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/uni_links-0.4.0/","dependencies":[]},{"name":"url_launcher","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-5.4.7/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.4+2/","dependencies":[]},{"name":"shared_preferences_macos","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_macos-0.0.1+8/","dependencies":[]},{"name":"sqflite","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/sqflite-1.3.0+1/","dependencies":[]},{"name":"url_launcher_macos","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.0.1+5/","dependencies":[]}],"linux":[],"windows":[],"web":[{"name":"shared_preferences_web","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/shared_preferences_web-0.1.2+5/","dependencies":[]},{"name":"url_launcher_web","path":"/daten/flutter/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_web-0.1.1+5/","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_secure_storage","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos"]},{"name":"path_provider_macos","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]},{"name":"uni_links","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_web","url_launcher_macos"]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]}],"date_created":"2020-06-06 07:55:46.592738","version":"1.17.0-4.0.pre.7"}
\ No newline at end of file
import 'package:encrateia/models/bar_zone.dart';
import 'package:encrateia/utils/icon_utils.dart';
import 'package:encrateia/utils/my_color.dart';
import 'package:flutter/material.dart';
......@@ -58,7 +57,8 @@ class BarChartPainter extends CustomPainter {
double lowerInPixel;
double upperInPixel;
if (value < barZone.lower) continue;
if (value < barZone.lower)
continue;
if (value >= barZone.upper) {
lowerInPixel = (width - 2 * strokeWidth) /
(maximum - minimum) *
......
......@@ -32,7 +32,6 @@ class _ActivityBarGraphWidgetState extends State<ActivityBarGraphWidget> {
List<BarZone> _heartRateDistributions = <BarZone>[];
List<BarZone> _powerDistributions = <BarZone>[];
@override
void initState() {
getData();
......@@ -42,108 +41,123 @@ class _ActivityBarGraphWidgetState extends State<ActivityBarGraphWidget> {
@override
Widget build(BuildContext context) {
if (_powerZones.isNotEmpty && _laps.isNotEmpty) {
return SingleChildScrollView(
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: DataTable(
showCheckboxColumn: false,
columnSpacing: 20,
onSelectAll: (_) {},
columns: const <DataColumn>[
DataColumn(label: Text('Title'), numeric: false),
DataColumn(label: Text('Average Power'), numeric: false),
DataColumn(label: Text('Watts'), numeric: true),
DataColumn(label: Text('Power Zone Distribution'), numeric: false),
DataColumn(label: Text('Average Heart Rate'), numeric: false),
DataColumn(label: Text('bpm'), numeric: true),
DataColumn(label: Text('Heart Rate Zone Distribution'), numeric: false),
DataColumn(label: Text('Average Pace'), numeric: false),
DataColumn(label: Text('min/km'), numeric: true),
],
rows: <DataRow>[
DataRow(cells: <DataCell>[
const DataCell(Text('Activity')),
DataCell(
MyBarChart(
value: widget.activity.db.avgPower,
powerZones: _powerZones,
),
),
DataCell(
Text(widget.activity.db.avgPower.toStringAsFixed(1)),
),
DataCell(
MyBarChart.visualizeDistributions(distributions: _heartRateDistributions),
),
DataCell(
MyBarChart(
value: widget.activity.db.avgHeartRate,
heartRateZones: _heartRateZones,
),
return SingleChildScrollView(scrollDirection: Axis.horizontal,
child: Container(width: 500,
child: ListView(padding: const EdgeInsets.all(20), children: <Widget>[
Table(columnWidths: const <int, TableColumnWidth>{
0: FixedColumnWidth(60),
1: FixedColumnWidth(160),
2: FixedColumnWidth(60),
3: FixedColumnWidth(160),
4: FixedColumnWidth(60),
}, children: <TableRow>[
const TableRow(children: <Widget>[
Text('Title\n'),
Text('Average Power'),
Text('Watts'),
Text('Average Heart Rate'),
Text('bpm'),
]),
TableRow(children: <Widget>[
const Text('Activity'),
MyBarChart(
width: 150,
value: widget.activity.db.avgPower,
powerZones: _powerZones,
),
Text(widget.activity.db.avgPower.toStringAsFixed(1)),
MyBarChart(
width: 150,
value: widget.activity.db.avgHeartRate,
heartRateZones: _heartRateZones,
),
Text(widget.activity.db.avgHeartRate.toString()),
]),
for (Lap lap in _laps)
TableRow(children: <Widget>[
Text('Lap ' + lap.index.toString()),
MyBarChart(
width: 150,
value: lap.db.avgPower,
powerZones: _powerZones,
),
DataCell(Text(
widget.activity.db.avgHeartRate.toString(),
)),
DataCell(
MyBarChart.visualizeDistributions(distributions: _powerDistributions),
Text(lap.db.avgPower.toStringAsFixed(1)),
MyBarChart(
width: 150,
value: lap.db.avgHeartRate,
heartRateZones: _heartRateZones,
),
DataCell(MyBarChart(
value: widget.activity.db.avgSpeed.toPaceDouble(),
maximum: 700,
)),
DataCell(Text(
widget.activity.db.avgSpeed.toPace(),
)),
Text(lap.db.avgHeartRate.toString()),
]),
for (Lap lap in _laps)
DataRow(cells: <DataCell>[
DataCell(Text('Lap ' + lap.index.toString())),
DataCell(
MyBarChart(
value: lap.db.avgPower,
powerZones: _powerZones,
),
),
DataCell(
Text(lap.db.avgPower.toStringAsFixed(1)),
),
DataCell(
MyBarChart.visualizeDistributions(distributions: lap.powerDistributions),
),
DataCell(
MyBarChart(
value: lap.db.avgHeartRate,
heartRateZones: _heartRateZones,
),
),
DataCell(
Text(lap.db.avgHeartRate.toString()),
),
DataCell(
MyBarChart.visualizeDistributions(distributions: lap.heartRateDistributions),
),
DataCell(MyBarChart(
value: lap.db.avgSpeed.toPaceDouble(),
maximum: 700,
)),
DataCell(Text(
lap.db.avgSpeed.toPace(),
)),
]),
]),
const SizedBox(height: 40),
Table(columnWidths: const <int, TableColumnWidth>{
0: FixedColumnWidth(60),
1: FixedColumnWidth(210),
2: FixedColumnWidth(210),
}, children: <TableRow>[
const TableRow(children: <Widget>[
Text('Title\n'),
Text('Power Zone Distribution'),
Text('Heart Rate Zone Distribution'),
]),
TableRow(children: <Widget>[
const Text('Activity'),
MyBarChart.visualizeDistributions(
distributions: _heartRateDistributions),
MyBarChart.visualizeDistributions(
distributions: _powerDistributions),
]),
for (Lap lap in _laps)
TableRow(children: <Widget>[
Text('Lap ' + lap.index.toString()),
MyBarChart.visualizeDistributions(
distributions: lap.powerDistributions),
MyBarChart.visualizeDistributions(
distributions: lap.heartRateDistributions),
]),
]),
const SizedBox(height: 40),
Table(columnWidths: const <int, TableColumnWidth>{
0: FixedColumnWidth(60),
1: FixedColumnWidth(210),
2: FixedColumnWidth(60),
}, children: <TableRow>[
const TableRow(children: <Widget>[
Text('Title\n'),
Text('Average Pace'),
Text('min/km'),
]),
TableRow(children: <Widget>[
const Text('Activity'),
MyBarChart(
value: widget.activity.db.avgSpeed.toPaceDouble(),
maximum: 700,
),
Text(widget.activity.db.avgSpeed.toPace()),
]),
for (Lap lap in _laps)
TableRow(children: <Widget>[
Text('Lap ' + lap.index.toString()),
MyBarChart(
value: lap.db.avgSpeed.toPaceDouble(),
maximum: 700,
),
Text(lap.db.avgSpeed.toPace()),
]),
]),
]),
),
);
} else {
return const Center(
child: Text('Loading'),
);
return const Center(child: Text('Loading'));
}
}
Future<void> getData() async {
final Activity activity = widget.activity;
_laps = await activity.laps;
for(final Lap _lap in _laps) {
for (final Lap _lap in _laps) {
_lap.powerDistributions = await _lap.powerZoneCounts();
_lap.heartRateDistributions = await _lap.heartRateZoneCounts();
}
......
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