Yaaaaay the graaaaaaph!!!
This commit is contained in:
parent
28f0d0ad7a
commit
a2a85ce151
|
@ -16,7 +16,7 @@ import 'package:sqflite_common_ffi/sqflite_ffi.dart';
|
|||
import 'package:sqflite_common_ffi_web/sqflite_ffi_web.dart';
|
||||
import 'package:tetra_stats/gen/strings.g.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:tetra_stats/views/main_view.dart';
|
||||
import 'package:tetra_stats/views/main_view_tiles.dart';
|
||||
import 'package:tetra_stats/views/settings_view.dart';
|
||||
import 'package:tetra_stats/views/tracked_players_view.dart';
|
||||
import 'package:tetra_stats/views/calc_view.dart';
|
||||
|
|
|
@ -554,20 +554,20 @@ class TetrioService extends DB {
|
|||
|
||||
switch (response.statusCode) {
|
||||
case 200:
|
||||
List<List<dynamic>> csv = const CsvToListConverter().convert(response.body)..removeAt(0);
|
||||
List<List<dynamic>> csv = const CsvToListConverter().convert(response.body, eol: "\n")..removeAt(0);
|
||||
List<Cutoffs> history = [];
|
||||
for (List<dynamic> entry in csv){
|
||||
Map<String, double> tr = {};
|
||||
Map<String, double> glicko = {};
|
||||
Map<String, double> gxe = {};
|
||||
for(int i = 0; i < ranks.length; i++){
|
||||
tr[ranks[ranks.length + i - ranks.length]] = entry[1 + i*3];
|
||||
glicko[ranks[ranks.length + i - ranks.length]] = entry[2 + i*3];
|
||||
glicko[ranks[ranks.length + i - ranks.length]] = entry[3 + i*3];
|
||||
tr[ranks[ranks.length - 1 - i]] = entry[1 + i*3];
|
||||
glicko[ranks[ranks.length - 1 - i]] = entry[2 + i*3];
|
||||
gxe[ranks[ranks.length - 1 - i]] = entry[3 + i*3];
|
||||
}
|
||||
history.add(
|
||||
Cutoffs(
|
||||
DateTime.fromMillisecondsSinceEpoch(entry[0]),
|
||||
DateTime.fromMillisecondsSinceEpoch(entry[0]*1000),
|
||||
tr,
|
||||
glicko,
|
||||
gxe
|
||||
|
|
|
@ -172,6 +172,7 @@ class _MainState extends State<MainView> with TickerProviderStateMixin {
|
|||
getDestinationButton(Icons.leaderboard, "Leaderboards"),
|
||||
getDestinationButton(Icons.compress, "Cutoffs"),
|
||||
getDestinationButton(Icons.calculate, "Calc"),
|
||||
getDestinationButton(Icons.info_outline, "Information"),
|
||||
getDestinationButton(Icons.storage, "Saved Data"),
|
||||
getDestinationButton(Icons.settings, "Settings"),
|
||||
],
|
||||
|
@ -293,6 +294,7 @@ class _DestinationGraphsState extends State<DestinationGraphs> {
|
|||
late ZoomPanBehavior _zoomPanBehavior;
|
||||
late TooltipBehavior _historyTooltipBehavior;
|
||||
late TooltipBehavior _tooltipBehavior;
|
||||
late TooltipBehavior _leagueTooltipBehavior;
|
||||
String yAxisTitle = "";
|
||||
bool _smooth = false;
|
||||
//final List _historyShortTitles = ["TR", "Glicko", "RD", "APM", "PPS", "VS", "APP", "DS/S", "DS/P", "APP + DS/P", "VS/APM", "Cheese", "GbE", "wAPP", "Area", "eTR", "±eTR", "Opener", "Plonk", "Inf. DS", "Stride"];
|
||||
|
@ -356,6 +358,32 @@ class _DestinationGraphsState extends State<DestinationGraphs> {
|
|||
);
|
||||
}
|
||||
);
|
||||
_leagueTooltipBehavior = TooltipBehavior(
|
||||
color: Colors.black,
|
||||
borderColor: Colors.white,
|
||||
enable: true,
|
||||
animationDuration: 0,
|
||||
builder: (dynamic data, dynamic point, dynamic series,
|
||||
int pointIndex, int seriesIndex) {
|
||||
print(point);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8.0),
|
||||
child: Text(
|
||||
"${f4.format(point.y)} $yAxisTitle",
|
||||
style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 20),
|
||||
),
|
||||
),
|
||||
Text(timestamp(data.ts))
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
);
|
||||
_zoomPanBehavior = ZoomPanBehavior(
|
||||
enablePinching: true,
|
||||
enableSelectionZooming: true,
|
||||
|
@ -538,7 +566,61 @@ class _DestinationGraphsState extends State<DestinationGraphs> {
|
|||
}
|
||||
|
||||
Widget getCutoffsHistory(){
|
||||
return Container(); // TODO
|
||||
return FutureBuilder<List<Cutoffs>>(
|
||||
future: teto.fetchCutoffsHistory(),
|
||||
builder: (context, snapshot) {
|
||||
switch (snapshot.connectionState){
|
||||
case ConnectionState.none:
|
||||
case ConnectionState.waiting:
|
||||
case ConnectionState.active:
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
case ConnectionState.done:
|
||||
if (snapshot.hasData){
|
||||
yAxisTitle = chartsShortTitles[_Ychart]!;
|
||||
return SfCartesianChart(
|
||||
tooltipBehavior: _leagueTooltipBehavior,
|
||||
zoomPanBehavior: _zoomPanBehavior,
|
||||
primaryXAxis: _gamesPlayedInsteadOfDateAndTime ? const NumericAxis() : const DateTimeAxis(),
|
||||
primaryYAxis: const NumericAxis(
|
||||
rangePadding: ChartRangePadding.additional,
|
||||
),
|
||||
margin: const EdgeInsets.all(0),
|
||||
series: <CartesianSeries>[
|
||||
for (String rank in ranks) StepLineSeries<Cutoffs, DateTime>(
|
||||
enableTooltip: true,
|
||||
dataSource: snapshot.data,
|
||||
animationDuration: 0,
|
||||
//opacity: _smooth ? 0 : 1,
|
||||
xValueMapper: (Cutoffs data, _) => data.ts,
|
||||
yValueMapper: (Cutoffs data, _) => data.tr[rank],
|
||||
color: rankColors[rank],
|
||||
// trendlines:<Trendline>[
|
||||
// Trendline(
|
||||
// isVisible: _smooth,
|
||||
// period: (selectedGraph.length/175).floor(),
|
||||
// type: TrendlineType.movingAverage,
|
||||
// color: Theme.of(context).colorScheme.primary)
|
||||
// ],
|
||||
)
|
||||
],
|
||||
);
|
||||
}else{
|
||||
return Center(child:
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(snapshot.error.toString(), style: const TextStyle(fontFamily: "Eurostile Round", fontSize: 42, fontWeight: FontWeight.bold), textAlign: TextAlign.center),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
child: Text(snapshot.stackTrace.toString(), textAlign: TextAlign.center),
|
||||
),
|
||||
],
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
Loading…
Reference in New Issue