Graph objectification

This commit is contained in:
Felix 2019-07-18 16:38:12 +01:00
parent 9a09154332
commit d9abbbd0e7
No known key found for this signature in database
GPG key ID: 130EF6DC43E4DD07
4 changed files with 48 additions and 27 deletions

View file

@ -49,8 +49,8 @@ class GraphData {
List<TimeSeriesSpend> timeSeriesSpendList = new List<TimeSeriesSpend>();
for (int i = 0; i < labels.length; i++) {
print(DateTime(labels[i]));
timeSeriesSpendList.add(new TimeSeriesSpend(data[i], DateTime(labels[i])));
print(DateTime.parse(labels[i]));
timeSeriesSpendList.add(new TimeSeriesSpend(data[i], DateTime.parse(labels[i])));
}
return [

View file

@ -0,0 +1,19 @@
import 'package:flutter/material.dart';
import 'package:local_spend/common/widgets/charts/time_series_simple.dart';
class TimeSeries extends StatelessWidget {
final String chartDataName;
TimeSeries({
this.chartDataName,
});
@override
Widget build(BuildContext context) {
return new Container(
padding: EdgeInsets.symmetric(horizontal: 7.5, vertical: 7.5),
child: SimpleTimeSeriesChart.withSampleData(),
);
}
}

View file

@ -28,7 +28,7 @@ class ReceiptPageState extends State<ReceiptPage> {
final TextEditingController _amountController = TextEditingController();
final TextEditingController _essentialController = TextEditingController();
final TextEditingController _recurringController = TextEditingController();
final TextEditingController _categoryController = TextEditingController();
final TextEditingController _categoryController = TextEditingController(); // TODO: fix this
final TextEditingController _orgController = TextEditingController();
final OrganizationController _organizationController = OrganizationController();
List<String> _categoryDropDownItems = List<String>();
@ -542,23 +542,23 @@ class ReceiptPageState extends State<ReceiptPage> {
),
),
// Container(
// padding: const EdgeInsets.fromLTRB(29, 0, 0, 0),
// child: DropdownButton<String>(
// value: _categoryController.text,
// onChanged: (String newValue) {
// setState(() {
// _categoryController.text = newValue;
// });
// },
// items: _categoryDropDownItems.map<DropdownMenuItem<String>>((String value) {
// return DropdownMenuItem<String>(
// value: value,
// child: Text(value),
// );
// }).toList(), // fix errors here by [items] being an empty container while _categoryDropDownItems is null
// )
// ),
Container(
padding: const EdgeInsets.fromLTRB(29, 0, 0, 0),
child: DropdownButton<String>(
value: _categoryController.text,
onChanged: (String newValue) {
setState(() {
_categoryController.text = newValue;
});
},
items: _categoryDropDownItems.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(), // fix errors here by [items] being an empty container while _categoryDropDownItems is null
)
),
],
),

View file

@ -15,6 +15,7 @@ import 'package:local_spend/common/widgets/charts/series_legend_with_measures.da
import 'package:local_spend/common/widgets/charts/time_series_simple.dart';
import 'package:local_spend/common/apifunctions/get_graph_data.dart';
import 'package:charts_flutter/flutter.dart' as charts;
import 'package:local_spend/common/widgets/charts/chart_builder.dart';
const URL = "https://flutter.io/";
const demonstration = false;
@ -50,12 +51,12 @@ class StatsPageState extends State<StatsPage> {
@override
Widget build(BuildContext context) {
// if (graphData.data != null) {
graphData.getGraphData('total_last_week').then((val) {
totalLastWeek = val;
setState(() {
// update view
});
});
// graphData.getGraphData('total_last_week').then((val) {
// totalLastWeek = val;
// setState(() {
// // update view
// });
// });
// }
return PlatformScaffold(
@ -97,7 +98,8 @@ class StatsPageState extends State<StatsPage> {
height: 200,
// width: 250,
child: new SimpleTimeSeriesChart(totalLastWeek),//seriesList: List<charts.Series>
child: new TimeSeries(),
// child: new SimpleTimeSeriesChart(totalLastWeek),//seriesList: List<charts.Series>
),
],