From 8bdc413eabc4c41abcd3498eb2ca4a67517af925 Mon Sep 17 00:00:00 2001 From: Felix Date: Mon, 12 Aug 2019 16:03:00 +0100 Subject: [PATCH] debugging graphs... it's hard!! --- ios/Podfile.lock | 4 +-- ios/Runner.xcodeproj/project.pbxproj | 2 +- lib/common/apifunctions/get_graph_data.dart | 11 ++++++-- .../apifunctions/submit_receipt_api.dart | 4 +-- lib/pages/stats_page.dart | 25 +++++++++++-------- 5 files changed, 28 insertions(+), 18 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 8132310..a4e1203 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -6,13 +6,13 @@ PODS: - Flutter DEPENDENCIES: - - Flutter (from `.symlinks/flutter/ios-profile`) + - Flutter (from `.symlinks/flutter/ios`) - shared_preferences (from `.symlinks/plugins/shared_preferences/ios`) - url_launcher (from `.symlinks/plugins/url_launcher/ios`) EXTERNAL SOURCES: Flutter: - :path: ".symlinks/flutter/ios-profile" + :path: ".symlinks/flutter/ios" shared_preferences: :path: ".symlinks/plugins/shared_preferences/ios" url_launcher: diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index a0f8e33..5b4844c 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -281,7 +281,7 @@ ); inputPaths = ( "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", - "${PODS_ROOT}/../.symlinks/flutter/ios-profile/Flutter.framework", + "${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( diff --git a/lib/common/apifunctions/get_graph_data.dart b/lib/common/apifunctions/get_graph_data.dart index 6cabf2a..aea686c 100644 --- a/lib/common/apifunctions/get_graph_data.dart +++ b/lib/common/apifunctions/get_graph_data.dart @@ -7,7 +7,8 @@ import 'package:charts_flutter/flutter.dart' as charts; class GraphData { List data = new List(); - Future> getGraphData(String graphType) async { + Future>> getGraphData(String graphType) async { +// print("called"); /// Graph types: /// - total_last_week /// - avg_spend_last_week @@ -35,6 +36,10 @@ class GraphData { final responseJson = jsonDecode(response.body); final List labels = responseJson['graph']['labels']; final List data = responseJson['graph']['data']; + + for (int i = 0; i < data.length; i++) { +// print(labels[i].toString() + " : " + data[i].toString()); + } // final List bounds = responseJson['graph']['bounds']; // why is this even returned? /* @@ -49,11 +54,13 @@ class GraphData { List timeSeriesSpendList = new List(); for (int i = 0; i < labels.length; i++) { - print(DateTime.parse(labels[i])); +// print(DateTime.parse(labels[i])); timeSeriesSpendList.add(new TimeSeriesSpend(i, DateTime(i))); // timeSeriesSpendList.add(new TimeSeriesSpend(data[i], DateTime.parse(labels[i]))); } +// print(timeSeriesSpendList); + return [ new charts.Series( id: 'Spend', diff --git a/lib/common/apifunctions/submit_receipt_api.dart b/lib/common/apifunctions/submit_receipt_api.dart index 9dbb338..9ea7462 100644 --- a/lib/common/apifunctions/submit_receipt_api.dart +++ b/lib/common/apifunctions/submit_receipt_api.dart @@ -50,12 +50,12 @@ Future submitReceiptAPI( body: json.encode(body), ); - debugPrint(response.body); +// debugPrint(response.body); if (response.statusCode == 200) { final responseJson = json.decode(response.body); - print(responseJson[0]); +// print(responseJson[0]); showDialogSingleButton( context, diff --git a/lib/pages/stats_page.dart b/lib/pages/stats_page.dart index c5be96b..e8a470c 100644 --- a/lib/pages/stats_page.dart +++ b/lib/pages/stats_page.dart @@ -30,7 +30,7 @@ class StatsPage extends StatefulWidget { class StatsPageState extends State { GraphData graphData = new GraphData(); - List totalLastWeek; + List> displayedGraphData; @override void initState() { @@ -50,14 +50,15 @@ class StatsPageState extends State { @override Widget build(BuildContext context) { -// if (graphData.data != null) { -// graphData.getGraphData('total_last_week').then((val) { -// totalLastWeek = val; -// setState(() { -// // update view -// }); -// }); -// } + if (graphData.data.length == 0) { + graphData.getGraphData('total_last_week').then((fetchedData) { + displayedGraphData = (fetchedData); + for (int i = 0; i < fetchedData[0].data.length; i++) { + print(fetchedData[0].data[i].time); // this is getting very frustrating + } + setState(() {}); + }); + } return PlatformScaffold( appBar: AppBar( @@ -98,8 +99,10 @@ class StatsPageState extends State { height: 200, // width: 250, - child: new TimeSeries(), -// child: new SimpleTimeSeriesChart(totalLastWeek),//seriesList: List +// child: new TimeSeries(), + child: displayedGraphData != null ? new charts.TimeSeriesChart(displayedGraphData) : Container(), //List> +// child: new charts.TimeSeriesChart(displayedGraphData), +// child: new SimpleTimeSeriesChart(),//seriesList: List ), ],