-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1b7e7bf
commit f3d696b
Showing
3 changed files
with
66 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
mobile/lib/src/presentation/widgets/simple_line_chart.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters