Skip to content

Commit

Permalink
adding mock chart
Browse files Browse the repository at this point in the history
  • Loading branch information
mateobelanger committed Oct 29, 2020
1 parent 1b7e7bf commit f3d696b
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,19 @@ class RecordSleepValidatePage extends StatelessWidget {
]),
);
else
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
RaisedButton(
child: Text("Stop"),
onPressed: () =>
BlocProvider.of<DataCubit>(context).stopStreaming(),
),
]),
return ListView(
children: [
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
RaisedButton(
child: Text("Stop"),
onPressed: () =>
BlocProvider.of<DataCubit>(context).stopStreaming(),
),
]),
SimpleLineChart.withSampleData(),
],
);
},
),
Expand Down
52 changes: 52 additions & 0 deletions mobile/lib/src/presentation/widgets/simple_line_chart.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/// Example of a simple line chart.
import 'package:charts_flutter/flutter.dart' as charts;
import 'package:flutter/material.dart';

class SimpleLineChart extends StatelessWidget {
final List<charts.Series> seriesList;
final bool animate;

SimpleLineChart(this.seriesList, {this.animate});

/// Creates a [LineChart] with sample data and no transition.
factory SimpleLineChart.withSampleData() {
return new SimpleLineChart(
_createSampleData(),
// Disable animations for image tests.
animate: false,
);
}

@override
Widget build(BuildContext context) {
return new charts.LineChart(seriesList, animate: animate);
}

/// Create one series with sample hard coded data.
static List<charts.Series<LinearSales, int>> _createSampleData() {
final data = [
new LinearSales(0, 5),
new LinearSales(1, 25),
new LinearSales(2, 100),
new LinearSales(3, 75),
];

return [
new charts.Series<LinearSales, int>(
id: 'Sales',
colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault,
domainFn: (LinearSales sales, _) => sales.year,
measureFn: (LinearSales sales, _) => sales.sales,
data: data,
)
];
}
}

/// Sample linear data type.
class LinearSales {
final int year;
final int sales;

LinearSales(this.year, this.sales);
}
1 change: 1 addition & 0 deletions mobile/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dependencies:
share: ^0.6.5
uuid: ^2.2.2
usb_serial: ^0.2.4
charts_flutter:

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit f3d696b

Please sign in to comment.