debugging graphs...
it's hard!!
This commit is contained in:
parent
3060a6d1f9
commit
8bdc413eab
5 changed files with 28 additions and 18 deletions
|
@ -6,13 +6,13 @@ PODS:
|
||||||
- Flutter
|
- Flutter
|
||||||
|
|
||||||
DEPENDENCIES:
|
DEPENDENCIES:
|
||||||
- Flutter (from `.symlinks/flutter/ios-profile`)
|
- Flutter (from `.symlinks/flutter/ios`)
|
||||||
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
|
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
|
||||||
- url_launcher (from `.symlinks/plugins/url_launcher/ios`)
|
- url_launcher (from `.symlinks/plugins/url_launcher/ios`)
|
||||||
|
|
||||||
EXTERNAL SOURCES:
|
EXTERNAL SOURCES:
|
||||||
Flutter:
|
Flutter:
|
||||||
:path: ".symlinks/flutter/ios-profile"
|
:path: ".symlinks/flutter/ios"
|
||||||
shared_preferences:
|
shared_preferences:
|
||||||
:path: ".symlinks/plugins/shared_preferences/ios"
|
:path: ".symlinks/plugins/shared_preferences/ios"
|
||||||
url_launcher:
|
url_launcher:
|
||||||
|
|
|
@ -281,7 +281,7 @@
|
||||||
);
|
);
|
||||||
inputPaths = (
|
inputPaths = (
|
||||||
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
|
"${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";
|
name = "[CP] Embed Pods Frameworks";
|
||||||
outputPaths = (
|
outputPaths = (
|
||||||
|
|
|
@ -7,7 +7,8 @@ import 'package:charts_flutter/flutter.dart' as charts;
|
||||||
class GraphData {
|
class GraphData {
|
||||||
List<charts.Series> data = new List<charts.Series>();
|
List<charts.Series> data = new List<charts.Series>();
|
||||||
|
|
||||||
Future<List<charts.Series>> getGraphData(String graphType) async {
|
Future<List<charts.Series<dynamic, DateTime>>> getGraphData(String graphType) async {
|
||||||
|
// print("called");
|
||||||
/// Graph types:
|
/// Graph types:
|
||||||
/// - total_last_week
|
/// - total_last_week
|
||||||
/// - avg_spend_last_week
|
/// - avg_spend_last_week
|
||||||
|
@ -35,6 +36,10 @@ class GraphData {
|
||||||
final responseJson = jsonDecode(response.body);
|
final responseJson = jsonDecode(response.body);
|
||||||
final List<dynamic> labels = responseJson['graph']['labels'];
|
final List<dynamic> labels = responseJson['graph']['labels'];
|
||||||
final List<dynamic> data = responseJson['graph']['data'];
|
final List<dynamic> data = responseJson['graph']['data'];
|
||||||
|
|
||||||
|
for (int i = 0; i < data.length; i++) {
|
||||||
|
// print(labels[i].toString() + " : " + data[i].toString());
|
||||||
|
}
|
||||||
// final List<String> bounds = responseJson['graph']['bounds']; // why is this even returned?
|
// final List<String> bounds = responseJson['graph']['bounds']; // why is this even returned?
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -49,11 +54,13 @@ class GraphData {
|
||||||
List<TimeSeriesSpend> timeSeriesSpendList = new List<TimeSeriesSpend>();
|
List<TimeSeriesSpend> timeSeriesSpendList = new List<TimeSeriesSpend>();
|
||||||
|
|
||||||
for (int i = 0; i < labels.length; i++) {
|
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(i, DateTime(i)));
|
||||||
// timeSeriesSpendList.add(new TimeSeriesSpend(data[i], DateTime.parse(labels[i])));
|
// timeSeriesSpendList.add(new TimeSeriesSpend(data[i], DateTime.parse(labels[i])));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// print(timeSeriesSpendList);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
new charts.Series<TimeSeriesSpend, DateTime>(
|
new charts.Series<TimeSeriesSpend, DateTime>(
|
||||||
id: 'Spend',
|
id: 'Spend',
|
||||||
|
|
|
@ -50,12 +50,12 @@ Future<LoginModel> submitReceiptAPI(
|
||||||
body: json.encode(body),
|
body: json.encode(body),
|
||||||
);
|
);
|
||||||
|
|
||||||
debugPrint(response.body);
|
// debugPrint(response.body);
|
||||||
|
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
final responseJson = json.decode(response.body);
|
final responseJson = json.decode(response.body);
|
||||||
|
|
||||||
print(responseJson[0]);
|
// print(responseJson[0]);
|
||||||
|
|
||||||
showDialogSingleButton(
|
showDialogSingleButton(
|
||||||
context,
|
context,
|
||||||
|
|
|
@ -30,7 +30,7 @@ class StatsPage extends StatefulWidget {
|
||||||
class StatsPageState extends State<StatsPage> {
|
class StatsPageState extends State<StatsPage> {
|
||||||
|
|
||||||
GraphData graphData = new GraphData();
|
GraphData graphData = new GraphData();
|
||||||
List<charts.Series> totalLastWeek;
|
List<charts.Series<dynamic, DateTime>> displayedGraphData;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
@ -50,14 +50,15 @@ class StatsPageState extends State<StatsPage> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// if (graphData.data != null) {
|
if (graphData.data.length == 0) {
|
||||||
// graphData.getGraphData('total_last_week').then((val) {
|
graphData.getGraphData('total_last_week').then((fetchedData) {
|
||||||
// totalLastWeek = val;
|
displayedGraphData = (fetchedData);
|
||||||
// setState(() {
|
for (int i = 0; i < fetchedData[0].data.length; i++) {
|
||||||
// // update view
|
print(fetchedData[0].data[i].time); // this is getting very frustrating
|
||||||
// });
|
}
|
||||||
// });
|
setState(() {});
|
||||||
// }
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return PlatformScaffold(
|
return PlatformScaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
|
@ -98,8 +99,10 @@ class StatsPageState extends State<StatsPage> {
|
||||||
height: 200,
|
height: 200,
|
||||||
// width: 250,
|
// width: 250,
|
||||||
|
|
||||||
child: new TimeSeries(),
|
// child: new TimeSeries(),
|
||||||
// child: new SimpleTimeSeriesChart(totalLastWeek),//seriesList: List<charts.Series>
|
child: displayedGraphData != null ? new charts.TimeSeriesChart(displayedGraphData) : Container(), //List<Series<dynamic, DateTime>>
|
||||||
|
// child: new charts.TimeSeriesChart(displayedGraphData),
|
||||||
|
// child: new SimpleTimeSeriesChart(),//seriesList: List<charts.Series>
|
||||||
),
|
),
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
Reference in a new issue