1
0
mirror of https://github.com/flutter/samples.git synced 2026-06-08 07:18:49 +00:00

web/chart: fix sample (#909)

This commit is contained in:
Brett Morgan
2021-10-07 08:10:34 +11:00
committed by GitHub
parent 0fe216a1cf
commit 2d9ba2f9eb
118 changed files with 3655 additions and 3511 deletions

View File

@@ -28,11 +28,12 @@ class CustomMeasureTickCount extends StatelessWidget {
final List<charts.Series> seriesList;
final bool animate;
CustomMeasureTickCount(this.seriesList, {this.animate});
const CustomMeasureTickCount(this.seriesList, {this.animate, Key key})
: super(key: key);
/// Creates a [TimeSeriesChart] with sample data and no transition.
factory CustomMeasureTickCount.withSampleData() {
return new CustomMeasureTickCount(
return CustomMeasureTickCount(
_createSampleData(),
// Disable animations for image tests.
animate: false,
@@ -44,29 +45,29 @@ class CustomMeasureTickCount extends StatelessWidget {
// It is used for creating random series data to demonstrate animation in
// the example app only.
factory CustomMeasureTickCount.withRandomData() {
return new CustomMeasureTickCount(_createRandomData());
return CustomMeasureTickCount(_createRandomData());
}
/// Create random data.
static List<charts.Series<MyRow, DateTime>> _createRandomData() {
final random = new Random();
final random = Random();
final data = [
new MyRow(new DateTime(2017, 9, 25), random.nextInt(100)),
new MyRow(new DateTime(2017, 9, 26), random.nextInt(100)),
new MyRow(new DateTime(2017, 9, 27), random.nextInt(100)),
new MyRow(new DateTime(2017, 9, 28), random.nextInt(100)),
new MyRow(new DateTime(2017, 9, 29), random.nextInt(100)),
new MyRow(new DateTime(2017, 9, 30), random.nextInt(100)),
new MyRow(new DateTime(2017, 10, 01), random.nextInt(100)),
new MyRow(new DateTime(2017, 10, 02), random.nextInt(100)),
new MyRow(new DateTime(2017, 10, 03), random.nextInt(100)),
new MyRow(new DateTime(2017, 10, 04), random.nextInt(100)),
new MyRow(new DateTime(2017, 10, 05), random.nextInt(100)),
MyRow(DateTime(2017, 9, 25), random.nextInt(100)),
MyRow(DateTime(2017, 9, 26), random.nextInt(100)),
MyRow(DateTime(2017, 9, 27), random.nextInt(100)),
MyRow(DateTime(2017, 9, 28), random.nextInt(100)),
MyRow(DateTime(2017, 9, 29), random.nextInt(100)),
MyRow(DateTime(2017, 9, 30), random.nextInt(100)),
MyRow(DateTime(2017, 10, 01), random.nextInt(100)),
MyRow(DateTime(2017, 10, 02), random.nextInt(100)),
MyRow(DateTime(2017, 10, 03), random.nextInt(100)),
MyRow(DateTime(2017, 10, 04), random.nextInt(100)),
MyRow(DateTime(2017, 10, 05), random.nextInt(100)),
];
return [
new charts.Series<MyRow, DateTime>(
charts.Series<MyRow, DateTime>(
id: 'Cost',
domainFn: (MyRow row, _) => row.timeStamp,
measureFn: (MyRow row, _) => row.cost,
@@ -78,33 +79,33 @@ class CustomMeasureTickCount extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new charts.TimeSeriesChart(seriesList,
return charts.TimeSeriesChart(seriesList,
animate: animate,
/// Customize the measure axis to have 2 ticks,
primaryMeasureAxis: new charts.NumericAxisSpec(
primaryMeasureAxis: const charts.NumericAxisSpec(
tickProviderSpec:
new charts.BasicNumericTickProviderSpec(desiredTickCount: 2)));
charts.BasicNumericTickProviderSpec(desiredTickCount: 2)));
}
/// Create one series with sample hard coded data.
static List<charts.Series<MyRow, DateTime>> _createSampleData() {
final data = [
new MyRow(new DateTime(2017, 9, 25), 6),
new MyRow(new DateTime(2017, 9, 26), 8),
new MyRow(new DateTime(2017, 9, 27), 6),
new MyRow(new DateTime(2017, 9, 28), 9),
new MyRow(new DateTime(2017, 9, 29), 11),
new MyRow(new DateTime(2017, 9, 30), 15),
new MyRow(new DateTime(2017, 10, 01), 25),
new MyRow(new DateTime(2017, 10, 02), 33),
new MyRow(new DateTime(2017, 10, 03), 27),
new MyRow(new DateTime(2017, 10, 04), 31),
new MyRow(new DateTime(2017, 10, 05), 23),
MyRow(DateTime(2017, 9, 25), 6),
MyRow(DateTime(2017, 9, 26), 8),
MyRow(DateTime(2017, 9, 27), 6),
MyRow(DateTime(2017, 9, 28), 9),
MyRow(DateTime(2017, 9, 29), 11),
MyRow(DateTime(2017, 9, 30), 15),
MyRow(DateTime(2017, 10, 01), 25),
MyRow(DateTime(2017, 10, 02), 33),
MyRow(DateTime(2017, 10, 03), 27),
MyRow(DateTime(2017, 10, 04), 31),
MyRow(DateTime(2017, 10, 05), 23),
];
return [
new charts.Series<MyRow, DateTime>(
charts.Series<MyRow, DateTime>(
id: 'Cost',
domainFn: (MyRow row, _) => row.timeStamp,
measureFn: (MyRow row, _) => row.cost,