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M4XSojKf4jxKROzi+eT7QIhKy2ValqIwsCSHljkd/2ugwGUT8v7HVvuM5aLazVrRo4NlWVrSgd63D69PUPMfhxsqBtXDSEIJHlpPObzwvvRkJs9AlbEB+MT3uum9bI7fcUqzUpt1ohSA2NB+eJUckF1huUwoJ5h0QP5bDwstAK20wm5Cr9wOAi/MoGJslqVjYkoX12uZHLCXtYvew9Y5DynQen9TfJxekwg2vpadJnhS99hJXuFpnVA6EvKhxO8IMOQfj8zzxLjLbS3jIznrFxU5sfQHb1uCVrvxU+PMyCACWmq3ag4t9kw5GPBwAKYpRmQOCIXt5ABrPRT85UGwo6qNmPbhehdaTcUM/pYI8b+BM3fRx+zOrxjIjxM67JACsmreouprJNgkG298hHtwF435cysSCPq4lzdzV04+hMYa9rfe0hnCQQ3k15xI9BcumlEBZFbvL545PWYN0Zg/GmRTJaVRxIynB3HAJw/ekR0QfZViIwr6/JWELNvO2coknEYjU5e4B/uw6Lut2qeh8BabQUDv5ZmsV8/c1u+IP4kd8GB1DGob6AzAbaFVctKzPRt3X+w6BuJ3fJfaE53BBWkWq3WVSegI7ZlkADjAFOWtQ7yW+ATf0IF/k9BhtpEGRPS5fPSfwh3Ptkf0/PcrtMQPqb1wgjzy+tl3o9CWfwvJW3hu8ac=","mac":"3aZYxqTeZujIHc58JnsVyg=="}
|
||||||
+566
-265
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,6 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
import 'dart:math';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
|
|
||||||
/// One saved target (a JSON file written by the preview screen).
|
/// One saved target (a JSON file written by the preview screen).
|
||||||
@@ -45,42 +46,74 @@ class Session {
|
|||||||
|
|
||||||
/// Aggregates over any set of sessions (trainings or tournaments of one format).
|
/// Aggregates over any set of sessions (trainings or tournaments of one format).
|
||||||
class ShooterStats {
|
class ShooterStats {
|
||||||
|
static const int trendWindow = 5;
|
||||||
|
|
||||||
final int sessions;
|
final int sessions;
|
||||||
final int targets;
|
final int targets;
|
||||||
final int shots;
|
final int shots;
|
||||||
final TargetRecord? best;
|
final Session? bestSession; // highest average per shot
|
||||||
final double? averageTarget;
|
final double? averageTarget;
|
||||||
final double? averagePerShot;
|
final double? averagePerShot;
|
||||||
|
final double? trend; // last sessions minus the ones before them, per shot
|
||||||
|
|
||||||
const ShooterStats._({
|
const ShooterStats._({
|
||||||
required this.sessions,
|
required this.sessions,
|
||||||
required this.targets,
|
required this.targets,
|
||||||
required this.shots,
|
required this.shots,
|
||||||
required this.best,
|
required this.bestSession,
|
||||||
required this.averageTarget,
|
required this.averageTarget,
|
||||||
required this.averagePerShot,
|
required this.averagePerShot,
|
||||||
|
required this.trend,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// [sessions] newest first, as [TargetRepository.loadSessions] returns them.
|
||||||
factory ShooterStats.of(List<Session> sessions) {
|
factory ShooterStats.of(List<Session> sessions) {
|
||||||
final all = [for (final s in sessions) ...s.targets];
|
final all = [for (final s in sessions) ...s.targets];
|
||||||
final shots = all.fold(0, (sum, t) => sum + t.shots);
|
final shots = all.fold(0, (sum, t) => sum + t.shots);
|
||||||
final total = all.fold(0, (sum, t) => sum + t.score);
|
final total = all.fold(0, (sum, t) => sum + t.score);
|
||||||
final ranked = [...all]..sort((a, b) => b.score.compareTo(a.score));
|
|
||||||
final mean = all.isEmpty ? null : total / all.length;
|
final mean = all.isEmpty ? null : total / all.length;
|
||||||
|
|
||||||
|
Session? bestSession;
|
||||||
|
for (final s in sessions) {
|
||||||
|
final avg = s.averagePerShot;
|
||||||
|
if (avg != null &&
|
||||||
|
(bestSession == null || avg > bestSession.averagePerShot!)) {
|
||||||
|
bestSession = s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ShooterStats._(
|
return ShooterStats._(
|
||||||
sessions: sessions.length,
|
sessions: sessions.length,
|
||||||
targets: all.length,
|
targets: all.length,
|
||||||
shots: shots,
|
shots: shots,
|
||||||
best: ranked.isEmpty ? null : ranked.first,
|
bestSession: bestSession,
|
||||||
averageTarget: mean,
|
averageTarget: mean,
|
||||||
averagePerShot: shots == 0 ? null : total / shots,
|
averagePerShot: shots == 0 ? null : total / shots,
|
||||||
|
trend: _trend(sessions),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Average per shot of the newest sessions minus the same number before them
|
||||||
|
static double? _trend(List<Session> newestFirst) {
|
||||||
|
final scored = newestFirst.where((s) => s.shots > 0).toList();
|
||||||
|
final n = min(trendWindow, scored.length ~/ 2);
|
||||||
|
if (n == 0) return null;
|
||||||
|
double avg(Iterable<Session> list) =>
|
||||||
|
list.fold(0, (a, s) => a + s.totalScore) /
|
||||||
|
list.fold(0, (a, s) => a + s.shots);
|
||||||
|
return avg(scored.take(n)) - avg(scored.skip(n).take(n));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reads and edits the saved targets under <documents>/saved_images/<session>/.
|
/// Reads and edits the saved targets under <documents>/saved_images/<session>/.
|
||||||
|
///
|
||||||
|
/// Score and shots of every target are cached in <documents>/target_index.json,
|
||||||
|
/// keyed by the file's path with its size and last change, so loading reads one
|
||||||
|
/// file instead of every target. A new, edited or renamed target no longer
|
||||||
|
/// matches its entry and is read again; entries of deleted files are dropped.
|
||||||
class TargetRepository {
|
class TargetRepository {
|
||||||
|
static Map<String, dynamic>? _index; // path in saved_images -> entry
|
||||||
|
|
||||||
static Future<Directory> _root() async {
|
static Future<Directory> _root() async {
|
||||||
final dir = Directory(
|
final dir = Directory(
|
||||||
'${(await getApplicationDocumentsDirectory()).path}/saved_images');
|
'${(await getApplicationDocumentsDirectory()).path}/saved_images');
|
||||||
@@ -88,15 +121,56 @@ class TargetRepository {
|
|||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sessions, newest first. With [year], only that year's target files are read.
|
static Future<File> _indexFile() async => File(
|
||||||
static Future<List<Session>> loadSessions({int? year}) async {
|
'${(await getApplicationDocumentsDirectory()).path}/target_index.json');
|
||||||
|
|
||||||
|
static Future<Map<String, dynamic>> _loadIndex() async {
|
||||||
|
if (_index != null) return _index!;
|
||||||
|
try {
|
||||||
|
final file = await _indexFile();
|
||||||
|
_index = await file.exists()
|
||||||
|
? jsonDecode(await file.readAsString()) as Map<String, dynamic>
|
||||||
|
: {};
|
||||||
|
} catch (_) {
|
||||||
|
_index = {}; // unreadable: rebuild it from the targets
|
||||||
|
}
|
||||||
|
return _index!;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Sessions, newest first.
|
||||||
|
static Future<List<Session>> loadSessions() async {
|
||||||
final sessions = <Session>[];
|
final sessions = <Session>[];
|
||||||
|
final index = await _loadIndex();
|
||||||
|
final seen = <String>{};
|
||||||
|
var changed = false;
|
||||||
|
|
||||||
for (final folder in await _folders()) {
|
for (final folder in await _folders()) {
|
||||||
if (year != null && folder.date.year != year) continue;
|
|
||||||
final targets = <TargetRecord>[];
|
final targets = <TargetRecord>[];
|
||||||
for (final file in folder.targetFiles) {
|
for (final file in folder.targetFiles) {
|
||||||
final record = await _readTarget(file);
|
final key = '${folder.name}/${file.uri.pathSegments.last}';
|
||||||
|
seen.add(key);
|
||||||
|
final stat = file.statSync();
|
||||||
|
final stamp = '${stat.size}:${stat.modified.millisecondsSinceEpoch}';
|
||||||
|
final cached = index[key];
|
||||||
|
TargetRecord? record;
|
||||||
|
if (cached is Map && cached['stamp'] == stamp) {
|
||||||
|
record = TargetRecord(
|
||||||
|
file: file,
|
||||||
|
shotAt: _timeFromFileName(file) ?? stat.modified,
|
||||||
|
score: cached['score'] as int,
|
||||||
|
shots: cached['shots'] as int,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
record = await _readTarget(file);
|
||||||
|
if (record != null) {
|
||||||
|
index[key] = {
|
||||||
|
'stamp': stamp,
|
||||||
|
'score': record.score,
|
||||||
|
'shots': record.shots
|
||||||
|
};
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (record != null) targets.add(record);
|
if (record != null) targets.add(record);
|
||||||
}
|
}
|
||||||
targets.sort((a, b) => a.shotAt.compareTo(b.shotAt));
|
targets.sort((a, b) => a.shotAt.compareTo(b.shotAt));
|
||||||
@@ -108,14 +182,18 @@ class TargetRepository {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
sessions.sort((a, b) => b.date.compareTo(a.date));
|
final before = index.length;
|
||||||
return sessions;
|
index.removeWhere((key, _) => !seen.contains(key));
|
||||||
|
if (changed || index.length != before) {
|
||||||
|
try {
|
||||||
|
await (await _indexFile()).writeAsString(jsonEncode(index));
|
||||||
|
} catch (_) {
|
||||||
|
// Only a cache: the next load reads the targets again
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Years that have at least one session, newest first. Reads only metadata.
|
sessions.sort((a, b) => b.date.compareTo(a.date));
|
||||||
static Future<List<int>> years() async {
|
return sessions;
|
||||||
final years = {for (final f in await _folders()) f.date.year}.toList();
|
|
||||||
return years..sort((a, b) => b.compareTo(a));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cheap pass over the folders: metadata + file names, no target files read
|
// Cheap pass over the folders: metadata + file names, no target files read
|
||||||
@@ -128,12 +206,15 @@ class TargetRepository {
|
|||||||
for (final f in folder.listSync().whereType<File>())
|
for (final f in folder.listSync().whereType<File>())
|
||||||
if (f.path.endsWith('.json') && !f.path.endsWith('metadata.json')) f,
|
if (f.path.endsWith('.json') && !f.path.endsWith('metadata.json')) f,
|
||||||
];
|
];
|
||||||
final fileTimes = files.map(_timeFromFileName).whereType<DateTime>().toList()..sort();
|
final fileTimes =
|
||||||
|
files.map(_timeFromFileName).whereType<DateTime>().toList()..sort();
|
||||||
result.add(_FolderInfo(
|
result.add(_FolderInfo(
|
||||||
name: folder.path.split('/').last,
|
name: folder.path.split('/').last,
|
||||||
isTournament: meta['isTournament'] == true,
|
isTournament: meta['isTournament'] == true,
|
||||||
date: DateTime.tryParse(meta['createdAt'] ?? '') ??
|
date: DateTime.tryParse(meta['createdAt'] ?? '') ??
|
||||||
(fileTimes.isNotEmpty ? fileTimes.first : folder.statSync().changed),
|
(fileTimes.isNotEmpty
|
||||||
|
? fileTimes.first
|
||||||
|
: folder.statSync().changed),
|
||||||
targetFiles: files,
|
targetFiles: files,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@@ -213,5 +294,9 @@ class _FolderInfo {
|
|||||||
final DateTime date;
|
final DateTime date;
|
||||||
final List<File> targetFiles;
|
final List<File> targetFiles;
|
||||||
|
|
||||||
const _FolderInfo({required this.name, required this.isTournament, required this.date, required this.targetFiles});
|
const _FolderInfo(
|
||||||
|
{required this.name,
|
||||||
|
required this.isTournament,
|
||||||
|
required this.date,
|
||||||
|
required this.targetFiles});
|
||||||
}
|
}
|
||||||
|
|||||||
+69
-12
@@ -1217,18 +1217,6 @@ class AppTranslations {
|
|||||||
'English': 'Shots 1–5: statistics only compare targets with the same number of shots. Grey numbers have no targets yet.',
|
'English': 'Shots 1–5: statistics only compare targets with the same number of shots. Grey numbers have no targets yet.',
|
||||||
'Slovenian': 'Streli 1–5: statistika primerja le tarče z enakim številom strelov. Sive številke še nimajo tarč.',
|
'Slovenian': 'Streli 1–5: statistika primerja le tarče z enakim številom strelov. Sive številke še nimajo tarč.',
|
||||||
},
|
},
|
||||||
'Year (top right): choose which year to show.': {
|
|
||||||
'English': 'Year (top right): choose which year to show.',
|
|
||||||
'Slovenian': 'Leto (desno zgoraj): izberi, katero leto se prikaže.',
|
|
||||||
},
|
|
||||||
'Graph: average per shot over time. Tap or drag on it to see each value.': {
|
|
||||||
'English': 'Graph: average per shot over time. Tap or drag on it to see each value.',
|
|
||||||
'Slovenian': 'Graf: povprečje na strel skozi čas. Tapni ali povleci po njem za posamezno vrednost.',
|
|
||||||
},
|
|
||||||
'By date / By score: sort the list by date or by best average per shot.': {
|
|
||||||
'English': 'By date / By score: sort the list by date or by best average per shot.',
|
|
||||||
'Slovenian': 'Po datumu / Po rezultatu: razvrsti seznam po datumu ali po najboljšem povprečju na strel.',
|
|
||||||
},
|
|
||||||
'Tap a session to see all its targets with the selected number of shots on one target.': {
|
'Tap a session to see all its targets with the selected number of shots on one target.': {
|
||||||
'English': 'Tap a session to see all its targets with the selected number of shots on one target.',
|
'English': 'Tap a session to see all its targets with the selected number of shots on one target.',
|
||||||
'Slovenian': 'Tapni sejo za prikaz vseh njenih tarč z izbranim številom strelov na eni tarči.',
|
'Slovenian': 'Tapni sejo za prikaz vseh njenih tarč z izbranim številom strelov na eni tarči.',
|
||||||
@@ -1237,6 +1225,75 @@ class AppTranslations {
|
|||||||
'English': 'Three dots on the right or long press: session details, single targets, rename and delete.',
|
'English': 'Three dots on the right or long press: session details, single targets, rename and delete.',
|
||||||
'Slovenian': 'Tri pike na desni ali dolg pritisk: podrobnosti seje, posamezne tarče, preimenovanje in brisanje.',
|
'Slovenian': 'Tri pike na desni ali dolg pritisk: podrobnosti seje, posamezne tarče, preimenovanje in brisanje.',
|
||||||
},
|
},
|
||||||
|
// Knjiga form sections
|
||||||
|
'Shot average': {
|
||||||
|
'English': 'Shot average',
|
||||||
|
'Slovenian': 'Povprečje strela',
|
||||||
|
},
|
||||||
|
'Number of points': {
|
||||||
|
'English': 'Number of points',
|
||||||
|
'Slovenian': 'Število točk',
|
||||||
|
},
|
||||||
|
'Graph: shot average (left axis) and number of points (right axis). Month shows each session of a month, Year one point per month; the arrows go back through earlier months or years. Tap or drag on it to see the values.': {
|
||||||
|
'English': 'Graph: shot average (left axis) and number of points (right axis). Month shows each session of a month, Year one point per month; the arrows go back through earlier months or years. Tap or drag on it to see the values.',
|
||||||
|
'Slovenian': 'Graf: povprečje strela (leva os) in število točk (desna os). Mesec prikaže vsako sejo meseca, Leto eno točko na mesec; s puščicami greš nazaj po mesecih ali letih. Tapni ali povleci po njem za vrednosti.',
|
||||||
|
},
|
||||||
|
'Period (next to History): this month, last 3 months, this year, all or your own dates. The top card and the list both use it.': {
|
||||||
|
'English': 'Period (next to History): this month, last 3 months, this year, all or your own dates. The top card and the list both use it.',
|
||||||
|
'Slovenian': 'Obdobje (zraven Zgodovine): ta mesec, zadnji 3 meseci, to leto, vse ali svoji datumi. Uporabljata ga zgornja kartica in seznam.',
|
||||||
|
},
|
||||||
|
'Period': {
|
||||||
|
'English': 'Period',
|
||||||
|
'Slovenian': 'Obdobje',
|
||||||
|
},
|
||||||
|
'This month': {
|
||||||
|
'English': 'This month',
|
||||||
|
'Slovenian': 'Ta mesec',
|
||||||
|
},
|
||||||
|
'Last 3 months': {
|
||||||
|
'English': 'Last 3 months',
|
||||||
|
'Slovenian': 'Zadnji 3 meseci',
|
||||||
|
},
|
||||||
|
'This year': {
|
||||||
|
'English': 'This year',
|
||||||
|
'Slovenian': 'To leto',
|
||||||
|
},
|
||||||
|
'Custom range': {
|
||||||
|
'English': 'Custom range',
|
||||||
|
'Slovenian': 'Po meri',
|
||||||
|
},
|
||||||
|
'No sessions in this period': {
|
||||||
|
'English': 'No sessions in this period',
|
||||||
|
'Slovenian': 'V tem obdobju ni sej',
|
||||||
|
},
|
||||||
|
'Month': {
|
||||||
|
'English': 'Month',
|
||||||
|
'Slovenian': 'Mesec',
|
||||||
|
},
|
||||||
|
'Best training / tournament in the top card: tap to open its targets.': {
|
||||||
|
'English': 'Best training / tournament in the top card: tap to open its targets.',
|
||||||
|
'Slovenian': 'Najboljši trening / tekmovanje v zgornji kartici: tapni za prikaz njegovih tarč.',
|
||||||
|
},
|
||||||
|
'vs earlier': {
|
||||||
|
'English': 'vs earlier',
|
||||||
|
'Slovenian': 'glede na prej',
|
||||||
|
},
|
||||||
|
'Best training': {
|
||||||
|
'English': 'Best training',
|
||||||
|
'Slovenian': 'Najboljši trening',
|
||||||
|
},
|
||||||
|
'Best tournament': {
|
||||||
|
'English': 'Best tournament',
|
||||||
|
'Slovenian': 'Najboljše tekmovanje',
|
||||||
|
},
|
||||||
|
'Arrow under the average: your last 5 sessions compared with the 5 before them.': {
|
||||||
|
'English': 'Arrow under the average: your last 5 sessions compared with the 5 before them.',
|
||||||
|
'Slovenian': 'Puščica pod povprečjem: tvojih zadnjih 5 sej v primerjavi s 5 pred njimi.',
|
||||||
|
},
|
||||||
|
'Sort icon: tap to switch between date order and best average per shot. The coloured number shows how far a session is from your average.': {
|
||||||
|
'English': 'Sort icon: tap to switch between date order and best average per shot. The coloured number shows how far a session is from your average.',
|
||||||
|
'Slovenian': 'Ikona razvrščanja: tapni za preklop med vrstnim redom po datumu in po najboljšem povprečju na strel. Barvna številka pokaže, koliko seja odstopa od tvojega povprečja.',
|
||||||
|
},
|
||||||
'Year': {
|
'Year': {
|
||||||
'English': 'Year',
|
'English': 'Year',
|
||||||
'Slovenian': 'Leto',
|
'Slovenian': 'Leto',
|
||||||
|
|||||||
+135
-67
@@ -1,24 +1,36 @@
|
|||||||
|
import 'dart:math';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class ChartPoint {
|
enum ChartAxis { left, right, none }
|
||||||
final String label; // shown in the tooltip and under the first/last point
|
|
||||||
final double value;
|
|
||||||
|
|
||||||
const ChartPoint(this.label, this.value);
|
/// One line on the chart. Each series has its own scale, so values of very
|
||||||
|
/// different size (average per shot vs. session total) can share the chart.
|
||||||
|
/// [axis] says which side labels its scale.
|
||||||
|
class ChartSeries {
|
||||||
|
final String name;
|
||||||
|
final Color color;
|
||||||
|
final List<double> values; // one per label
|
||||||
|
final int decimals;
|
||||||
|
final ChartAxis axis;
|
||||||
|
|
||||||
|
const ChartSeries(this.name, this.color, this.values,
|
||||||
|
{this.decimals = 2, this.axis = ChartAxis.none});
|
||||||
|
|
||||||
|
String format(double v) => v.toStringAsFixed(decimals);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Single-series line chart: 2px line, 8px points, three faint gridlines.
|
/// Line chart: 2px lines, 8px points, three faint gridlines, up to one labelled
|
||||||
/// Tap (or drag) to show the nearest point's label and value.
|
/// axis per side. Tap (or drag) to show every series' value at the nearest point.
|
||||||
class ProgressChart extends StatefulWidget {
|
class ProgressChart extends StatefulWidget {
|
||||||
final List<ChartPoint> points;
|
final List<String> labels; // shown in the tooltip and under the first/last point
|
||||||
final Color color;
|
final List<ChartSeries> series; // legend and tooltip order
|
||||||
final Color textColor;
|
final Color textColor;
|
||||||
final Color gridColor;
|
final Color gridColor;
|
||||||
|
|
||||||
const ProgressChart({
|
const ProgressChart({
|
||||||
super.key,
|
super.key,
|
||||||
required this.points,
|
required this.labels,
|
||||||
required this.color,
|
required this.series,
|
||||||
required this.textColor,
|
required this.textColor,
|
||||||
required this.gridColor,
|
required this.gridColor,
|
||||||
});
|
});
|
||||||
@@ -31,18 +43,21 @@ class _ProgressChartState extends State<ProgressChart> {
|
|||||||
int? _selected;
|
int? _selected;
|
||||||
|
|
||||||
void _select(Offset position, Size size) {
|
void _select(Offset position, Size size) {
|
||||||
final n = widget.points.length;
|
final n = widget.labels.length;
|
||||||
if (n == 0) return;
|
if (n == 0) return;
|
||||||
final plotWidth = size.width - _ChartPainter.leftAxis - _ChartPainter.pad * 2;
|
final plot = _ChartPainter.plotRect(size);
|
||||||
final x = (position.dx - _ChartPainter.leftAxis - _ChartPainter.pad) / plotWidth;
|
final x = (position.dx - plot.left) / plot.width;
|
||||||
setState(() => _selected = (x * (n - 1)).round().clamp(0, n - 1));
|
setState(() => _selected = (x * (n - 1)).round().clamp(0, n - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return LayoutBuilder(
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: [
|
||||||
|
LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
final size = Size(constraints.maxWidth, 170);
|
final size = Size(constraints.maxWidth, 190);
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
behavior: HitTestBehavior.opaque,
|
behavior: HitTestBehavior.opaque,
|
||||||
onTapDown: (d) => _select(d.localPosition, size),
|
onTapDown: (d) => _select(d.localPosition, size),
|
||||||
@@ -50,8 +65,8 @@ class _ProgressChartState extends State<ProgressChart> {
|
|||||||
child: CustomPaint(
|
child: CustomPaint(
|
||||||
size: size,
|
size: size,
|
||||||
painter: _ChartPainter(
|
painter: _ChartPainter(
|
||||||
points: widget.points,
|
labels: widget.labels,
|
||||||
color: widget.color,
|
series: widget.series,
|
||||||
textColor: widget.textColor,
|
textColor: widget.textColor,
|
||||||
gridColor: widget.gridColor,
|
gridColor: widget.gridColor,
|
||||||
selected: _selected,
|
selected: _selected,
|
||||||
@@ -59,92 +74,149 @@ class _ProgressChartState extends State<ProgressChart> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
// Legend, centred under the graph
|
||||||
|
Wrap(
|
||||||
|
alignment: WrapAlignment.center,
|
||||||
|
spacing: 16,
|
||||||
|
runSpacing: 4,
|
||||||
|
children: [
|
||||||
|
for (final s in widget.series)
|
||||||
|
Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: 14,
|
||||||
|
height: 3,
|
||||||
|
decoration: BoxDecoration(color: s.color, borderRadius: BorderRadius.circular(2)),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 6),
|
||||||
|
Text(s.name, style: TextStyle(fontSize: 12, color: widget.textColor)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ChartPainter extends CustomPainter {
|
class _ChartPainter extends CustomPainter {
|
||||||
static const double leftAxis = 32; // room for y labels
|
static const double axis = 34; // room for y labels on each side
|
||||||
static const double pad = 10; // keeps end points inside the plot
|
static const double pad = 10; // keeps end points inside the plot
|
||||||
static const double top = 34; // room for the tooltip
|
static const double top = 34; // room for the tooltip
|
||||||
static const double bottom = 20; // room for x labels
|
static const double bottom = 20; // room for x labels
|
||||||
|
|
||||||
final List<ChartPoint> points;
|
static Rect plotRect(Size size) =>
|
||||||
final Color color;
|
Rect.fromLTRB(axis + pad, top, size.width - axis - pad, size.height - bottom);
|
||||||
|
|
||||||
|
final List<String> labels;
|
||||||
|
final List<ChartSeries> series;
|
||||||
final Color textColor;
|
final Color textColor;
|
||||||
final Color gridColor;
|
final Color gridColor;
|
||||||
final int? selected;
|
final int? selected;
|
||||||
|
|
||||||
_ChartPainter({
|
_ChartPainter({
|
||||||
required this.points,
|
required this.labels,
|
||||||
required this.color,
|
required this.series,
|
||||||
required this.textColor,
|
required this.textColor,
|
||||||
required this.gridColor,
|
required this.gridColor,
|
||||||
required this.selected,
|
required this.selected,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Min and max of a series, widened so a flat line sits in the middle
|
||||||
|
static (double, double) _range(List<double> values, double minSpan) {
|
||||||
|
var lo = values.reduce(min);
|
||||||
|
var hi = values.reduce(max);
|
||||||
|
if (hi - lo < minSpan) {
|
||||||
|
final mid = (hi + lo) / 2;
|
||||||
|
lo = mid - minSpan / 2;
|
||||||
|
hi = mid + minSpan / 2;
|
||||||
|
}
|
||||||
|
return (lo, hi);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void paint(Canvas canvas, Size size) {
|
void paint(Canvas canvas, Size size) {
|
||||||
if (points.isEmpty) return;
|
if (labels.isEmpty || series.isEmpty) return;
|
||||||
final values = points.map((p) => p.value);
|
final plot = plotRect(size);
|
||||||
var minV = values.reduce((a, b) => a < b ? a : b);
|
final n = labels.length;
|
||||||
var maxV = values.reduce((a, b) => a > b ? a : b);
|
final ranges = [
|
||||||
if (maxV - minV < 1) {
|
for (final s in series) _range(s.values, s.values.reduce(max).abs() * 0.1 + 0.2),
|
||||||
minV -= 0.5;
|
];
|
||||||
maxV += 0.5;
|
|
||||||
}
|
|
||||||
final plot = Rect.fromLTRB(leftAxis + pad, top, size.width - pad, size.height - bottom);
|
|
||||||
|
|
||||||
Offset at(int i) => Offset(
|
double xAt(int i) => n == 1 ? plot.center.dx : plot.left + plot.width * i / (n - 1);
|
||||||
points.length == 1 ? plot.center.dx : plot.left + plot.width * i / (points.length - 1),
|
double yAt(double v, (double, double) r) => plot.bottom - plot.height * (v - r.$1) / (r.$2 - r.$1);
|
||||||
plot.bottom - plot.height * (points[i].value - minV) / (maxV - minV),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Gridlines + y labels (min, mid, max)
|
// Gridlines + y labels in each axis series' colour
|
||||||
final grid = Paint()
|
final grid = Paint()
|
||||||
..color = gridColor
|
..color = gridColor
|
||||||
..strokeWidth = 1;
|
..strokeWidth = 1;
|
||||||
for (final f in [0.0, 0.5, 1.0]) {
|
for (final f in [0.0, 0.5, 1.0]) {
|
||||||
final y = plot.bottom - plot.height * f;
|
final y = plot.bottom - plot.height * f;
|
||||||
canvas.drawLine(Offset(leftAxis, y), Offset(size.width, y), grid);
|
canvas.drawLine(Offset(axis, y), Offset(size.width - axis, y), grid);
|
||||||
_text(canvas, (minV + (maxV - minV) * f).toStringAsFixed(1), Offset(0, y - 7), 11, textColor);
|
for (int k = 0; k < series.length; k++) {
|
||||||
|
if (series[k].axis == ChartAxis.none) continue;
|
||||||
|
final right = series[k].axis == ChartAxis.right;
|
||||||
|
final r = ranges[k];
|
||||||
|
final v = r.$1 + (r.$2 - r.$1) * f;
|
||||||
|
final text = series[k].decimals == 0 ? v.round().toString() : v.toStringAsFixed(1);
|
||||||
|
_text(canvas, text, Offset(right ? size.width : 0, y - 7), 11, series[k].color, alignRight: right);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// x labels: first and last only
|
// x labels: first and last only
|
||||||
_text(canvas, points.first.label, Offset(plot.left - pad, plot.bottom + 5), 11, textColor);
|
_text(canvas, labels.first, Offset(plot.left - pad, plot.bottom + 5), 11, textColor);
|
||||||
if (points.length > 1) {
|
if (n > 1) {
|
||||||
_text(canvas, points.last.label, Offset(plot.right, plot.bottom + 5), 11, textColor, alignRight: true);
|
_text(canvas, labels.last, Offset(plot.right + pad, plot.bottom + 5), 11, textColor, alignRight: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Line
|
// Lines, last series first so the main one stays on top
|
||||||
final path = Path()..moveTo(at(0).dx, at(0).dy);
|
for (int k = series.length - 1; k >= 0; k--) {
|
||||||
for (int i = 1; i < points.length; i++) {
|
final s = series[k];
|
||||||
path.lineTo(at(i).dx, at(i).dy);
|
final r = ranges[k];
|
||||||
|
final path = Path()..moveTo(xAt(0), yAt(s.values[0], r));
|
||||||
|
for (int i = 1; i < n; i++) {
|
||||||
|
path.lineTo(xAt(i), yAt(s.values[i], r));
|
||||||
}
|
}
|
||||||
canvas.drawPath(
|
canvas.drawPath(
|
||||||
path,
|
path,
|
||||||
Paint()
|
Paint()
|
||||||
..color = color
|
..color = s.color
|
||||||
..strokeWidth = 2
|
..strokeWidth = 2
|
||||||
..style = PaintingStyle.stroke
|
..style = PaintingStyle.stroke
|
||||||
..strokeJoin = StrokeJoin.round,
|
..strokeJoin = StrokeJoin.round,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Points with a surface ring so they read on top of the line
|
// Points with a surface ring so they read on top of the line
|
||||||
for (int i = 0; i < points.length; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
final isSel = i == selected;
|
final isSel = i == selected;
|
||||||
canvas.drawCircle(at(i), isSel ? 7 : 5, Paint()..color = Colors.white);
|
final p = Offset(xAt(i), yAt(s.values[i], r));
|
||||||
canvas.drawCircle(at(i), isSel ? 5.5 : 4, Paint()..color = color);
|
canvas.drawCircle(p, isSel ? 6 : 4.5, Paint()..color = Colors.white);
|
||||||
|
canvas.drawCircle(p, isSel ? 4.5 : 3.5, Paint()..color = s.color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tooltip for the selected point
|
// Tooltip for the selected point: label, then each value in its colour
|
||||||
if (selected != null) {
|
if (selected != null) {
|
||||||
final p = at(selected!);
|
final i = selected!;
|
||||||
canvas.drawLine(Offset(p.dx, plot.top), Offset(p.dx, plot.bottom), grid);
|
canvas.drawLine(Offset(xAt(i), plot.top), Offset(xAt(i), plot.bottom), grid);
|
||||||
final label = '${points[selected!].label} ${points[selected!].value.toStringAsFixed(2)}';
|
final tp = TextPainter(
|
||||||
final tp = _layout(label, 12, Colors.white, bold: true);
|
text: TextSpan(
|
||||||
|
style: const TextStyle(fontSize: 12, fontWeight: FontWeight.w600, color: Colors.white),
|
||||||
|
children: [
|
||||||
|
TextSpan(text: labels[i]),
|
||||||
|
for (final s in series)
|
||||||
|
TextSpan(
|
||||||
|
text: ' ${s.format(s.values[i])}',
|
||||||
|
style: TextStyle(color: Color.lerp(s.color, Colors.white, 0.35)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
textDirection: TextDirection.ltr,
|
||||||
|
)..layout(maxWidth: size.width - 16);
|
||||||
final w = tp.width + 16;
|
final w = tp.width + 16;
|
||||||
final left = (p.dx - w / 2).clamp(0.0, size.width - w);
|
final left = (xAt(i) - w / 2).clamp(0.0, size.width - w);
|
||||||
canvas.drawRRect(
|
canvas.drawRRect(
|
||||||
RRect.fromRectAndRadius(Rect.fromLTWH(left, 2, w, 24), const Radius.circular(6)),
|
RRect.fromRectAndRadius(Rect.fromLTWH(left, 2, w, 24), const Radius.circular(6)),
|
||||||
Paint()..color = Colors.grey[900]!,
|
Paint()..color = Colors.grey[900]!,
|
||||||
@@ -153,22 +225,18 @@ class _ChartPainter extends CustomPainter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextPainter _layout(String text, double size, Color color, {bool bold = false}) {
|
void _text(Canvas canvas, String text, Offset at, double size, Color color, {bool alignRight = false}) {
|
||||||
return TextPainter(
|
final tp = TextPainter(
|
||||||
text: TextSpan(
|
text: TextSpan(text: text, style: TextStyle(fontSize: size, color: color)),
|
||||||
text: text,
|
|
||||||
style: TextStyle(fontSize: size, color: color, fontWeight: bold ? FontWeight.w600 : FontWeight.normal),
|
|
||||||
),
|
|
||||||
textDirection: TextDirection.ltr,
|
textDirection: TextDirection.ltr,
|
||||||
)..layout();
|
)..layout();
|
||||||
}
|
|
||||||
|
|
||||||
void _text(Canvas canvas, String text, Offset at, double size, Color color, {bool alignRight = false}) {
|
|
||||||
final tp = _layout(text, size, color);
|
|
||||||
tp.paint(canvas, alignRight ? at.translate(-tp.width, 0) : at);
|
tp.paint(canvas, alignRight ? at.translate(-tp.width, 0) : at);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool shouldRepaint(_ChartPainter old) =>
|
bool shouldRepaint(_ChartPainter old) =>
|
||||||
old.points != points || old.selected != selected || old.color != color || old.textColor != textColor;
|
old.labels != labels ||
|
||||||
|
old.series != series ||
|
||||||
|
old.selected != selected ||
|
||||||
|
old.textColor != textColor;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user