Skip to content

Commit 2d9ba2f

Browse files
web/chart: fix sample (flutter#909)
1 parent 0fe216a commit 2d9ba2f

File tree

118 files changed

+3655
-3511
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+3655
-3511
lines changed

web/charts/analysis_options.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This file configures the analyzer, which statically analyzes Dart code to
2+
# check for errors, warnings, and lints.
3+
#
4+
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5+
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6+
# invoked from the command line by running `flutter analyze`.
7+
8+
# The following line activates a set of recommended lints for Flutter apps,
9+
# packages, and plugins designed to encourage good coding practices.
10+
include: package:flutter_lints/flutter.yaml
11+
12+
linter:
13+
# The lint rules applied to this project can be customized in the
14+
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15+
# included above or to enable additional rules. A list of all available lints
16+
# and their documentation is published at
17+
# https://dart-lang.github.io/linter/lints/index.html.
18+
#
19+
# Instead of disabling a lint rule for the entire project in the
20+
# section below, it can also be suppressed for a single line of code
21+
# or a specific dart file by using the `// ignore: name_of_lint` and
22+
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
23+
# producing the lint.
24+
rules:
25+
avoid_print: false
26+
prefer_single_quotes: true
27+
28+
# Additional information about this file can be found at
29+
# https://dart.dev/guides/language/analysis-options

web/charts/lib/a11y/a11y_gallery.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ import 'domain_a11y_explore_bar_chart.dart';
1818

1919
List<GalleryScaffold> buildGallery() {
2020
return [
21-
new GalleryScaffold(
22-
listTileIcon: new Icon(Icons.accessibility),
21+
GalleryScaffold(
22+
listTileIcon: const Icon(Icons.accessibility),
2323
title: 'Screen reader enabled bar chart',
2424
subtitle: 'Requires TalkBack or Voiceover turned on to work. '
2525
'Bar chart with domain selection explore mode behavior.',
26-
childBuilder: () => new DomainA11yExploreBarChart.withRandomData(),
26+
childBuilder: () => DomainA11yExploreBarChart.withRandomData(),
2727
),
2828
];
2929
}

web/charts/lib/a11y/domain_a11y_explore_bar_chart.dart

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ class DomainA11yExploreBarChart extends StatelessWidget {
4141
final List<charts.Series> seriesList;
4242
final bool animate;
4343

44-
DomainA11yExploreBarChart(this.seriesList, {this.animate});
44+
const DomainA11yExploreBarChart(this.seriesList, {this.animate, Key key})
45+
: super(key: key);
4546

4647
/// Creates a [BarChart] with sample data and no transition.
4748
factory DomainA11yExploreBarChart.withSampleData() {
48-
return new DomainA11yExploreBarChart(
49+
return DomainA11yExploreBarChart(
4950
_createSampleData(),
5051
// Disable animations for image tests.
5152
animate: false,
@@ -57,36 +58,36 @@ class DomainA11yExploreBarChart extends StatelessWidget {
5758
// It is used for creating random series data to demonstrate animation in
5859
// the example app only.
5960
factory DomainA11yExploreBarChart.withRandomData() {
60-
return new DomainA11yExploreBarChart(_createRandomData());
61+
return DomainA11yExploreBarChart(_createRandomData());
6162
}
6263

6364
/// Create random data.
6465
static List<charts.Series<OrdinalSales, String>> _createRandomData() {
65-
final random = new Random();
66+
final random = Random();
6667

6768
final mobileData = [
68-
new OrdinalSales('2014', random.nextInt(100)),
69-
new OrdinalSales('2015', random.nextInt(100)),
70-
new OrdinalSales('2016', random.nextInt(100)),
71-
new OrdinalSales('2017', random.nextInt(100)),
69+
OrdinalSales('2014', random.nextInt(100)),
70+
OrdinalSales('2015', random.nextInt(100)),
71+
OrdinalSales('2016', random.nextInt(100)),
72+
OrdinalSales('2017', random.nextInt(100)),
7273
];
7374

7475
final tabletData = [
7576
// Purposely missing data to show that only measures that are available
7677
// are vocalized.
77-
new OrdinalSales('2016', random.nextInt(100)),
78-
new OrdinalSales('2017', random.nextInt(100)),
78+
OrdinalSales('2016', random.nextInt(100)),
79+
OrdinalSales('2017', random.nextInt(100)),
7980
];
8081

8182
return [
82-
new charts.Series<OrdinalSales, String>(
83+
charts.Series<OrdinalSales, String>(
8384
id: 'Mobile Sales',
8485
colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault,
8586
domainFn: (OrdinalSales sales, _) => sales.year,
8687
measureFn: (OrdinalSales sales, _) => sales.sales,
8788
data: mobileData,
8889
),
89-
new charts.Series<OrdinalSales, String>(
90+
charts.Series<OrdinalSales, String>(
9091
id: 'Tablet Sales',
9192
colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault,
9293
domainFn: (OrdinalSales sales, _) => sales.year,
@@ -106,7 +107,7 @@ class DomainA11yExploreBarChart extends StatelessWidget {
106107
/// domain, it vocalizes the series display name and the measure and a
107108
/// description of that measure.
108109
String vocalizeDomainAndMeasures(List<charts.SeriesDatum> seriesDatums) {
109-
final buffer = new StringBuffer();
110+
final buffer = StringBuffer();
110111

111112
// The datum's type in this case is [OrdinalSales].
112113
// So we can access year and sales information here.
@@ -125,13 +126,13 @@ class DomainA11yExploreBarChart extends StatelessWidget {
125126

126127
@override
127128
Widget build(BuildContext context) {
128-
return new Semantics(
129+
return Semantics(
129130
// Describe your chart
130131
label: 'Yearly sales bar chart',
131132
// Optionally provide a hint for the user to know how to trigger
132133
// explore mode.
133134
hint: 'Press and hold to enable explore',
134-
child: new charts.BarChart(
135+
child: charts.BarChart(
135136
seriesList,
136137
animate: animate,
137138
// To prevent conflict with the select nearest behavior that uses the
@@ -140,7 +141,7 @@ class DomainA11yExploreBarChart extends StatelessWidget {
140141
// with the application.
141142
defaultInteractions: !MediaQuery.of(context).accessibleNavigation,
142143
behaviors: [
143-
new charts.DomainA11yExploreBehavior(
144+
charts.DomainA11yExploreBehavior(
144145
// Callback for generating the message that is vocalized.
145146
// An example of how to use is in [vocalizeDomainAndMeasures].
146147
// If none is set, the default only vocalizes the domain value.
@@ -166,36 +167,36 @@ class DomainA11yExploreBarChart extends StatelessWidget {
166167
// This behavior is included in this example to show that when an
167168
// a11y node has focus, the chart's internal selection model is
168169
// also updated.
169-
new charts.DomainHighlighter(charts.SelectionModelType.info),
170+
charts.DomainHighlighter(charts.SelectionModelType.info),
170171
],
171172
));
172173
}
173174

174175
/// Create one series with sample hard coded data.
175176
static List<charts.Series<OrdinalSales, String>> _createSampleData() {
176177
final mobileData = [
177-
new OrdinalSales('2014', 5),
178-
new OrdinalSales('2015', 25),
179-
new OrdinalSales('2016', 100),
180-
new OrdinalSales('2017', 75),
178+
OrdinalSales('2014', 5),
179+
OrdinalSales('2015', 25),
180+
OrdinalSales('2016', 100),
181+
OrdinalSales('2017', 75),
181182
];
182183

183184
final tabletData = [
184185
// Purposely missing data to show that only measures that are available
185186
// are vocalized.
186-
new OrdinalSales('2016', 25),
187-
new OrdinalSales('2017', 50),
187+
OrdinalSales('2016', 25),
188+
OrdinalSales('2017', 50),
188189
];
189190

190191
return [
191-
new charts.Series<OrdinalSales, String>(
192+
charts.Series<OrdinalSales, String>(
192193
id: 'Mobile Sales',
193194
colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault,
194195
domainFn: (OrdinalSales sales, _) => sales.year,
195196
measureFn: (OrdinalSales sales, _) => sales.sales,
196197
data: mobileData,
197198
),
198-
new charts.Series<OrdinalSales, String>(
199+
charts.Series<OrdinalSales, String>(
199200
id: 'Tablet Sales',
200201
colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault,
201202
domainFn: (OrdinalSales sales, _) => sales.year,

web/charts/lib/app_config.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ class AppConfig {
2828

2929
/// The default configuration of the app.
3030
AppConfig get defaultConfig {
31-
return new AppConfig(
31+
return AppConfig(
3232
appName: 'Charts Gallery',
3333
appLink: '',
34-
theme: new ThemeData(
34+
theme: ThemeData(
3535
brightness: Brightness.light,
3636
primarySwatch: Colors.lightBlue,
3737
),

web/charts/lib/axes/axes_gallery.dart

Lines changed: 49 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -34,104 +34,103 @@ import 'statically_provided_ticks.dart';
3434

3535
List<GalleryScaffold> buildGallery() {
3636
return [
37-
new GalleryScaffold(
38-
listTileIcon: new Icon(Icons.insert_chart),
37+
GalleryScaffold(
38+
listTileIcon: const Icon(Icons.insert_chart),
3939
title: 'Bar chart with Secondary Measure Axis',
4040
subtitle: 'Bar chart with a series using a secondary measure axis',
41-
childBuilder: () => new BarChartWithSecondaryAxis.withRandomData(),
41+
childBuilder: () => BarChartWithSecondaryAxis.withRandomData(),
4242
),
43-
new GalleryScaffold(
44-
listTileIcon: new Icon(Icons.insert_chart),
43+
GalleryScaffold(
44+
listTileIcon: const Icon(Icons.insert_chart),
4545
title: 'Bar chart with Secondary Measure Axis only',
4646
subtitle: 'Bar chart with both series using secondary measure axis',
47-
childBuilder: () => new BarChartWithSecondaryAxisOnly.withRandomData(),
47+
childBuilder: () => BarChartWithSecondaryAxisOnly.withRandomData(),
4848
),
49-
new GalleryScaffold(
50-
listTileIcon: new Transform.rotate(
51-
angle: 1.5708, child: new Icon(Icons.insert_chart)),
49+
GalleryScaffold(
50+
listTileIcon: Transform.rotate(
51+
angle: 1.5708, child: const Icon(Icons.insert_chart)),
5252
title: 'Horizontal bar chart with Secondary Measure Axis',
5353
subtitle:
5454
'Horizontal Bar chart with a series using secondary measure axis',
55-
childBuilder: () =>
56-
new HorizontalBarChartWithSecondaryAxis.withRandomData(),
55+
childBuilder: () => HorizontalBarChartWithSecondaryAxis.withRandomData(),
5756
),
58-
new GalleryScaffold(
59-
listTileIcon: new Icon(Icons.insert_chart),
57+
GalleryScaffold(
58+
listTileIcon: const Icon(Icons.insert_chart),
6059
title: 'Short Ticks Axis',
6160
subtitle: 'Bar chart with the primary measure axis having short ticks',
62-
childBuilder: () => new ShortTickLengthAxis.withRandomData(),
61+
childBuilder: () => ShortTickLengthAxis.withRandomData(),
6362
),
64-
new GalleryScaffold(
65-
listTileIcon: new Icon(Icons.insert_chart),
63+
GalleryScaffold(
64+
listTileIcon: const Icon(Icons.insert_chart),
6665
title: 'Custom Axis Fonts',
6766
subtitle: 'Bar chart with custom axis font size and color',
68-
childBuilder: () => new CustomFontSizeAndColor.withRandomData(),
67+
childBuilder: () => CustomFontSizeAndColor.withRandomData(),
6968
),
70-
new GalleryScaffold(
71-
listTileIcon: new Icon(Icons.insert_chart),
69+
GalleryScaffold(
70+
listTileIcon: const Icon(Icons.insert_chart),
7271
title: 'Label Alignment Axis',
7372
subtitle: 'Bar chart with custom measure axis label alignments',
74-
childBuilder: () => new MeasureAxisLabelAlignment.withRandomData(),
73+
childBuilder: () => MeasureAxisLabelAlignment.withRandomData(),
7574
),
76-
new GalleryScaffold(
77-
listTileIcon: new Icon(Icons.insert_chart),
75+
GalleryScaffold(
76+
listTileIcon: const Icon(Icons.insert_chart),
7877
title: 'No Axis',
7978
subtitle: 'Bar chart with only the axis line drawn',
80-
childBuilder: () => new HiddenTicksAndLabelsAxis.withRandomData(),
79+
childBuilder: () => HiddenTicksAndLabelsAxis.withRandomData(),
8180
),
82-
new GalleryScaffold(
83-
listTileIcon: new Icon(Icons.insert_chart),
81+
GalleryScaffold(
82+
listTileIcon: const Icon(Icons.insert_chart),
8483
title: 'Statically Provided Ticks',
8584
subtitle: 'Bar chart with statically provided ticks',
86-
childBuilder: () => new StaticallyProvidedTicks.withRandomData(),
85+
childBuilder: () => StaticallyProvidedTicks.withRandomData(),
8786
),
88-
new GalleryScaffold(
89-
listTileIcon: new Icon(Icons.show_chart),
87+
GalleryScaffold(
88+
listTileIcon: const Icon(Icons.show_chart),
9089
title: 'Custom Formatter',
9190
subtitle: 'Timeseries with custom domain and measure tick formatters',
92-
childBuilder: () => new CustomAxisTickFormatters.withRandomData(),
91+
childBuilder: () => CustomAxisTickFormatters.withRandomData(),
9392
),
94-
new GalleryScaffold(
95-
listTileIcon: new Icon(Icons.show_chart),
93+
GalleryScaffold(
94+
listTileIcon: const Icon(Icons.show_chart),
9695
title: 'Custom Tick Count',
9796
subtitle: 'Timeseries with custom measure axis tick count',
98-
childBuilder: () => new CustomMeasureTickCount.withRandomData(),
97+
childBuilder: () => CustomMeasureTickCount.withRandomData(),
9998
),
100-
new GalleryScaffold(
101-
listTileIcon: new Icon(Icons.show_chart),
99+
GalleryScaffold(
100+
listTileIcon: const Icon(Icons.show_chart),
102101
title: 'Integer Measure Ticks',
103102
subtitle: 'Timeseries with only whole number measure axis ticks',
104-
childBuilder: () => new IntegerOnlyMeasureAxis.withRandomData(),
103+
childBuilder: () => IntegerOnlyMeasureAxis.withRandomData(),
105104
),
106-
new GalleryScaffold(
107-
listTileIcon: new Icon(Icons.show_chart),
105+
GalleryScaffold(
106+
listTileIcon: const Icon(Icons.show_chart),
108107
title: 'Non-zero bound Axis',
109108
subtitle: 'Timeseries with measure axis that does not include zero',
110-
childBuilder: () => new NonzeroBoundMeasureAxis.withRandomData(),
109+
childBuilder: () => NonzeroBoundMeasureAxis.withRandomData(),
111110
),
112-
new GalleryScaffold(
113-
listTileIcon: new Icon(Icons.insert_chart),
111+
GalleryScaffold(
112+
listTileIcon: const Icon(Icons.insert_chart),
114113
title: 'Ordinal axis with initial viewport',
115114
subtitle: 'Single series with initial viewport',
116-
childBuilder: () => new OrdinalInitialViewport.withRandomData(),
115+
childBuilder: () => OrdinalInitialViewport.withRandomData(),
117116
),
118-
new GalleryScaffold(
119-
listTileIcon: new Icon(Icons.show_chart),
117+
GalleryScaffold(
118+
listTileIcon: const Icon(Icons.show_chart),
120119
title: 'Numeric axis with initial viewport',
121120
subtitle: 'Initial viewport is set to a subset of the data',
122-
childBuilder: () => new NumericInitialViewport.withRandomData(),
121+
childBuilder: () => NumericInitialViewport.withRandomData(),
123122
),
124-
new GalleryScaffold(
125-
listTileIcon: new Icon(Icons.show_chart),
123+
GalleryScaffold(
124+
listTileIcon: const Icon(Icons.show_chart),
126125
title: 'Gridline dash pattern',
127126
subtitle: 'Timeseries with measure gridlines that have a dash pattern',
128-
childBuilder: () => new GridlineDashPattern.withRandomData(),
127+
childBuilder: () => GridlineDashPattern.withRandomData(),
129128
),
130-
new GalleryScaffold(
131-
listTileIcon: new Icon(Icons.show_chart),
129+
GalleryScaffold(
130+
listTileIcon: const Icon(Icons.show_chart),
132131
title: 'Disjoint Measure Axes',
133132
subtitle: 'Line chart with disjoint measure axes',
134-
childBuilder: () => new DisjointMeasureAxisLineChart.withRandomData(),
133+
childBuilder: () => DisjointMeasureAxisLineChart.withRandomData(),
135134
),
136135
];
137136
}

0 commit comments

Comments
 (0)