diff --git a/web/charts/analysis_options.yaml b/web/charts/analysis_options.yaml new file mode 100644 index 000000000..184fcbdd6 --- /dev/null +++ b/web/charts/analysis_options.yaml @@ -0,0 +1,29 @@ +# This file configures the analyzer, which statically analyzes Dart code to +# check for errors, warnings, and lints. +# +# The issues identified by the analyzer are surfaced in the UI of Dart-enabled +# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be +# invoked from the command line by running `flutter analyze`. + +# The following line activates a set of recommended lints for Flutter apps, +# packages, and plugins designed to encourage good coding practices. +include: package:flutter_lints/flutter.yaml + +linter: + # The lint rules applied to this project can be customized in the + # section below to disable rules from the `package:flutter_lints/flutter.yaml` + # included above or to enable additional rules. A list of all available lints + # and their documentation is published at + # https://dart-lang.github.io/linter/lints/index.html. + # + # Instead of disabling a lint rule for the entire project in the + # section below, it can also be suppressed for a single line of code + # or a specific dart file by using the `// ignore: name_of_lint` and + # `// ignore_for_file: name_of_lint` syntax on the line or in the file + # producing the lint. + rules: + avoid_print: false + prefer_single_quotes: true + +# Additional information about this file can be found at +# https://dart.dev/guides/language/analysis-options \ No newline at end of file diff --git a/web/charts/lib/a11y/a11y_gallery.dart b/web/charts/lib/a11y/a11y_gallery.dart index c5d4b5f71..d44299b4f 100644 --- a/web/charts/lib/a11y/a11y_gallery.dart +++ b/web/charts/lib/a11y/a11y_gallery.dart @@ -18,12 +18,12 @@ import 'domain_a11y_explore_bar_chart.dart'; List buildGallery() { return [ - new GalleryScaffold( - listTileIcon: new Icon(Icons.accessibility), + GalleryScaffold( + listTileIcon: const Icon(Icons.accessibility), title: 'Screen reader enabled bar chart', subtitle: 'Requires TalkBack or Voiceover turned on to work. ' 'Bar chart with domain selection explore mode behavior.', - childBuilder: () => new DomainA11yExploreBarChart.withRandomData(), + childBuilder: () => DomainA11yExploreBarChart.withRandomData(), ), ]; } diff --git a/web/charts/lib/a11y/domain_a11y_explore_bar_chart.dart b/web/charts/lib/a11y/domain_a11y_explore_bar_chart.dart index e4c03ca79..4eaca18f1 100644 --- a/web/charts/lib/a11y/domain_a11y_explore_bar_chart.dart +++ b/web/charts/lib/a11y/domain_a11y_explore_bar_chart.dart @@ -41,11 +41,12 @@ class DomainA11yExploreBarChart extends StatelessWidget { final List seriesList; final bool animate; - DomainA11yExploreBarChart(this.seriesList, {this.animate}); + const DomainA11yExploreBarChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [BarChart] with sample data and no transition. factory DomainA11yExploreBarChart.withSampleData() { - return new DomainA11yExploreBarChart( + return DomainA11yExploreBarChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -57,36 +58,36 @@ class DomainA11yExploreBarChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory DomainA11yExploreBarChart.withRandomData() { - return new DomainA11yExploreBarChart(_createRandomData()); + return DomainA11yExploreBarChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final mobileData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final tabletData = [ // Purposely missing data to show that only measures that are available // are vocalized. - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Mobile Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: mobileData, ), - new charts.Series( + charts.Series( id: 'Tablet Sales', colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault, domainFn: (OrdinalSales sales, _) => sales.year, @@ -106,7 +107,7 @@ class DomainA11yExploreBarChart extends StatelessWidget { /// domain, it vocalizes the series display name and the measure and a /// description of that measure. String vocalizeDomainAndMeasures(List seriesDatums) { - final buffer = new StringBuffer(); + final buffer = StringBuffer(); // The datum's type in this case is [OrdinalSales]. // So we can access year and sales information here. @@ -125,13 +126,13 @@ class DomainA11yExploreBarChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new Semantics( + return Semantics( // Describe your chart label: 'Yearly sales bar chart', // Optionally provide a hint for the user to know how to trigger // explore mode. hint: 'Press and hold to enable explore', - child: new charts.BarChart( + child: charts.BarChart( seriesList, animate: animate, // To prevent conflict with the select nearest behavior that uses the @@ -140,7 +141,7 @@ class DomainA11yExploreBarChart extends StatelessWidget { // with the application. defaultInteractions: !MediaQuery.of(context).accessibleNavigation, behaviors: [ - new charts.DomainA11yExploreBehavior( + charts.DomainA11yExploreBehavior( // Callback for generating the message that is vocalized. // An example of how to use is in [vocalizeDomainAndMeasures]. // If none is set, the default only vocalizes the domain value. @@ -166,7 +167,7 @@ class DomainA11yExploreBarChart extends StatelessWidget { // This behavior is included in this example to show that when an // a11y node has focus, the chart's internal selection model is // also updated. - new charts.DomainHighlighter(charts.SelectionModelType.info), + charts.DomainHighlighter(charts.SelectionModelType.info), ], )); } @@ -174,28 +175,28 @@ class DomainA11yExploreBarChart extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final mobileData = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tabletData = [ // Purposely missing data to show that only measures that are available // are vocalized. - new OrdinalSales('2016', 25), - new OrdinalSales('2017', 50), + OrdinalSales('2016', 25), + OrdinalSales('2017', 50), ]; return [ - new charts.Series( + charts.Series( id: 'Mobile Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: mobileData, ), - new charts.Series( + charts.Series( id: 'Tablet Sales', colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault, domainFn: (OrdinalSales sales, _) => sales.year, diff --git a/web/charts/lib/app_config.dart b/web/charts/lib/app_config.dart index 563c5c7c3..55fdca610 100644 --- a/web/charts/lib/app_config.dart +++ b/web/charts/lib/app_config.dart @@ -28,10 +28,10 @@ class AppConfig { /// The default configuration of the app. AppConfig get defaultConfig { - return new AppConfig( + return AppConfig( appName: 'Charts Gallery', appLink: '', - theme: new ThemeData( + theme: ThemeData( brightness: Brightness.light, primarySwatch: Colors.lightBlue, ), diff --git a/web/charts/lib/axes/axes_gallery.dart b/web/charts/lib/axes/axes_gallery.dart index f192e2c7e..f7b9cc5e2 100644 --- a/web/charts/lib/axes/axes_gallery.dart +++ b/web/charts/lib/axes/axes_gallery.dart @@ -34,104 +34,103 @@ import 'statically_provided_ticks.dart'; List buildGallery() { return [ - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Bar chart with Secondary Measure Axis', subtitle: 'Bar chart with a series using a secondary measure axis', - childBuilder: () => new BarChartWithSecondaryAxis.withRandomData(), + childBuilder: () => BarChartWithSecondaryAxis.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Bar chart with Secondary Measure Axis only', subtitle: 'Bar chart with both series using secondary measure axis', - childBuilder: () => new BarChartWithSecondaryAxisOnly.withRandomData(), + childBuilder: () => BarChartWithSecondaryAxisOnly.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Transform.rotate( - angle: 1.5708, child: new Icon(Icons.insert_chart)), + GalleryScaffold( + listTileIcon: Transform.rotate( + angle: 1.5708, child: const Icon(Icons.insert_chart)), title: 'Horizontal bar chart with Secondary Measure Axis', subtitle: 'Horizontal Bar chart with a series using secondary measure axis', - childBuilder: () => - new HorizontalBarChartWithSecondaryAxis.withRandomData(), + childBuilder: () => HorizontalBarChartWithSecondaryAxis.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Short Ticks Axis', subtitle: 'Bar chart with the primary measure axis having short ticks', - childBuilder: () => new ShortTickLengthAxis.withRandomData(), + childBuilder: () => ShortTickLengthAxis.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Custom Axis Fonts', subtitle: 'Bar chart with custom axis font size and color', - childBuilder: () => new CustomFontSizeAndColor.withRandomData(), + childBuilder: () => CustomFontSizeAndColor.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Label Alignment Axis', subtitle: 'Bar chart with custom measure axis label alignments', - childBuilder: () => new MeasureAxisLabelAlignment.withRandomData(), + childBuilder: () => MeasureAxisLabelAlignment.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'No Axis', subtitle: 'Bar chart with only the axis line drawn', - childBuilder: () => new HiddenTicksAndLabelsAxis.withRandomData(), + childBuilder: () => HiddenTicksAndLabelsAxis.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Statically Provided Ticks', subtitle: 'Bar chart with statically provided ticks', - childBuilder: () => new StaticallyProvidedTicks.withRandomData(), + childBuilder: () => StaticallyProvidedTicks.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Custom Formatter', subtitle: 'Timeseries with custom domain and measure tick formatters', - childBuilder: () => new CustomAxisTickFormatters.withRandomData(), + childBuilder: () => CustomAxisTickFormatters.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Custom Tick Count', subtitle: 'Timeseries with custom measure axis tick count', - childBuilder: () => new CustomMeasureTickCount.withRandomData(), + childBuilder: () => CustomMeasureTickCount.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Integer Measure Ticks', subtitle: 'Timeseries with only whole number measure axis ticks', - childBuilder: () => new IntegerOnlyMeasureAxis.withRandomData(), + childBuilder: () => IntegerOnlyMeasureAxis.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Non-zero bound Axis', subtitle: 'Timeseries with measure axis that does not include zero', - childBuilder: () => new NonzeroBoundMeasureAxis.withRandomData(), + childBuilder: () => NonzeroBoundMeasureAxis.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Ordinal axis with initial viewport', subtitle: 'Single series with initial viewport', - childBuilder: () => new OrdinalInitialViewport.withRandomData(), + childBuilder: () => OrdinalInitialViewport.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Numeric axis with initial viewport', subtitle: 'Initial viewport is set to a subset of the data', - childBuilder: () => new NumericInitialViewport.withRandomData(), + childBuilder: () => NumericInitialViewport.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Gridline dash pattern', subtitle: 'Timeseries with measure gridlines that have a dash pattern', - childBuilder: () => new GridlineDashPattern.withRandomData(), + childBuilder: () => GridlineDashPattern.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Disjoint Measure Axes', subtitle: 'Line chart with disjoint measure axes', - childBuilder: () => new DisjointMeasureAxisLineChart.withRandomData(), + childBuilder: () => DisjointMeasureAxisLineChart.withRandomData(), ), ]; } diff --git a/web/charts/lib/axes/bar_secondary_axis.dart b/web/charts/lib/axes/bar_secondary_axis.dart index 6fe676317..4e985af17 100644 --- a/web/charts/lib/axes/bar_secondary_axis.dart +++ b/web/charts/lib/axes/bar_secondary_axis.dart @@ -39,10 +39,11 @@ class BarChartWithSecondaryAxis extends StatelessWidget { final List seriesList; final bool animate; - BarChartWithSecondaryAxis(this.seriesList, {this.animate}); + const BarChartWithSecondaryAxis(this.seriesList, {this.animate, Key key}) + : super(key: key); factory BarChartWithSecondaryAxis.withSampleData() { - return new BarChartWithSecondaryAxis( + return BarChartWithSecondaryAxis( _createSampleData(), // Disable animations for image tests. animate: false, @@ -54,35 +55,35 @@ class BarChartWithSecondaryAxis extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory BarChartWithSecondaryAxis.withRandomData() { - return new BarChartWithSecondaryAxis(_createRandomData()); + return BarChartWithSecondaryAxis(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final globalSalesData = [ - new OrdinalSales('2014', random.nextInt(100) * 100), - new OrdinalSales('2015', random.nextInt(100) * 100), - new OrdinalSales('2016', random.nextInt(100) * 100), - new OrdinalSales('2017', random.nextInt(100) * 100), + OrdinalSales('2014', random.nextInt(100) * 100), + OrdinalSales('2015', random.nextInt(100) * 100), + OrdinalSales('2016', random.nextInt(100) * 100), + OrdinalSales('2017', random.nextInt(100) * 100), ]; final losAngelesSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Global Revenue', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: globalSalesData, ), - new charts.Series( + charts.Series( id: 'Los Angeles Revenue', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -97,46 +98,46 @@ class BarChartWithSecondaryAxis extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, barGroupingType: charts.BarGroupingType.grouped, // It is important when using both primary and secondary axes to choose // the same number of ticks for both sides to get the gridlines to line // up. - primaryMeasureAxis: new charts.NumericAxisSpec( + primaryMeasureAxis: const charts.NumericAxisSpec( tickProviderSpec: - new charts.BasicNumericTickProviderSpec(desiredTickCount: 3)), - secondaryMeasureAxis: new charts.NumericAxisSpec( + charts.BasicNumericTickProviderSpec(desiredTickCount: 3)), + secondaryMeasureAxis: const charts.NumericAxisSpec( tickProviderSpec: - new charts.BasicNumericTickProviderSpec(desiredTickCount: 3)), + charts.BasicNumericTickProviderSpec(desiredTickCount: 3)), ); } /// Create series list with multiple series static List> _createSampleData() { final globalSalesData = [ - new OrdinalSales('2014', 5000), - new OrdinalSales('2015', 25000), - new OrdinalSales('2016', 100000), - new OrdinalSales('2017', 750000), + OrdinalSales('2014', 5000), + OrdinalSales('2015', 25000), + OrdinalSales('2016', 100000), + OrdinalSales('2017', 750000), ]; final losAngelesSalesData = [ - new OrdinalSales('2014', 25), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 10), - new OrdinalSales('2017', 20), + OrdinalSales('2014', 25), + OrdinalSales('2015', 50), + OrdinalSales('2016', 10), + OrdinalSales('2017', 20), ]; return [ - new charts.Series( + charts.Series( id: 'Global Revenue', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: globalSalesData, ), - new charts.Series( + charts.Series( id: 'Los Angeles Revenue', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/axes/bar_secondary_axis_only.dart b/web/charts/lib/axes/bar_secondary_axis_only.dart index 3864028b8..dc949b8db 100644 --- a/web/charts/lib/axes/bar_secondary_axis_only.dart +++ b/web/charts/lib/axes/bar_secondary_axis_only.dart @@ -33,10 +33,11 @@ class BarChartWithSecondaryAxisOnly extends StatelessWidget { final List seriesList; final bool animate; - BarChartWithSecondaryAxisOnly(this.seriesList, {this.animate}); + const BarChartWithSecondaryAxisOnly(this.seriesList, {this.animate, Key key}) + : super(key: key); factory BarChartWithSecondaryAxisOnly.withSampleData() { - return new BarChartWithSecondaryAxisOnly( + return BarChartWithSecondaryAxisOnly( _createSampleData(), // Disable animations for image tests. animate: false, @@ -48,22 +49,22 @@ class BarChartWithSecondaryAxisOnly extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory BarChartWithSecondaryAxisOnly.withRandomData() { - return new BarChartWithSecondaryAxisOnly(_createRandomData()); + return BarChartWithSecondaryAxisOnly(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final globalSalesData = [ - new OrdinalSales('2014', random.nextInt(100) * 100), - new OrdinalSales('2015', random.nextInt(100) * 100), - new OrdinalSales('2016', random.nextInt(100) * 100), - new OrdinalSales('2017', random.nextInt(100) * 100), + OrdinalSales('2014', random.nextInt(100) * 100), + OrdinalSales('2015', random.nextInt(100) * 100), + OrdinalSales('2016', random.nextInt(100) * 100), + OrdinalSales('2017', random.nextInt(100) * 100), ]; return [ - new charts.Series( + charts.Series( id: 'Global Revenue', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -77,7 +78,7 @@ class BarChartWithSecondaryAxisOnly extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, ); @@ -86,14 +87,14 @@ class BarChartWithSecondaryAxisOnly extends StatelessWidget { /// Create series list with multiple series static List> _createSampleData() { final globalSalesData = [ - new OrdinalSales('2014', 500), - new OrdinalSales('2015', 2500), - new OrdinalSales('2016', 1000), - new OrdinalSales('2017', 7500), + OrdinalSales('2014', 500), + OrdinalSales('2015', 2500), + OrdinalSales('2016', 1000), + OrdinalSales('2017', 7500), ]; return [ - new charts.Series( + charts.Series( id: 'Global Revenue', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/axes/custom_axis_tick_formatters.dart b/web/charts/lib/axes/custom_axis_tick_formatters.dart index 527d8b4a5..4b3b4ec4e 100644 --- a/web/charts/lib/axes/custom_axis_tick_formatters.dart +++ b/web/charts/lib/axes/custom_axis_tick_formatters.dart @@ -25,11 +25,12 @@ class CustomAxisTickFormatters extends StatelessWidget { final List seriesList; final bool animate; - CustomAxisTickFormatters(this.seriesList, {this.animate}); + const CustomAxisTickFormatters(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [TimeSeriesChart] with sample data and no transition. factory CustomAxisTickFormatters.withSampleData() { - return new CustomAxisTickFormatters( + return CustomAxisTickFormatters( _createSampleData(), // Disable animations for image tests. animate: false, @@ -41,29 +42,29 @@ class CustomAxisTickFormatters extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory CustomAxisTickFormatters.withRandomData() { - return new CustomAxisTickFormatters(_createRandomData()); + return CustomAxisTickFormatters(_createRandomData()); } /// Create random data. static List> _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( + charts.Series( id: 'Cost', domainFn: (MyRow row, _) => row.timeStamp, measureFn: (MyRow row, _) => row.cost, @@ -79,8 +80,8 @@ class CustomAxisTickFormatters extends StatelessWidget { /// /// This is what is used in the [NumericAxisSpec] below. final simpleCurrencyFormatter = - new charts.BasicNumericTickFormatterSpec.fromNumberFormat( - new NumberFormat.compactSimpleCurrency()); + charts.BasicNumericTickFormatterSpec.fromNumberFormat( + NumberFormat.compactSimpleCurrency()); /// Formatter for numeric ticks that uses the callback provided. /// @@ -91,11 +92,11 @@ class CustomAxisTickFormatters extends StatelessWidget { // final customTickFormatter = // charts.BasicNumericTickFormatterSpec((num value) => 'MyValue: $value'); - return new charts.TimeSeriesChart(seriesList, + return charts.TimeSeriesChart(seriesList, animate: animate, // Sets up a currency formatter for the measure axis. - primaryMeasureAxis: new charts.NumericAxisSpec( - tickFormatterSpec: simpleCurrencyFormatter), + primaryMeasureAxis: + charts.NumericAxisSpec(tickFormatterSpec: simpleCurrencyFormatter), /// Customizes the date tick formatter. It will print the day of month /// as the default format, but include the month and year if it @@ -103,30 +104,30 @@ class CustomAxisTickFormatters extends StatelessWidget { /// /// minute, hour, day, month, and year are all provided by default and /// you can override them following this pattern. - domainAxis: new charts.DateTimeAxisSpec( - tickFormatterSpec: new charts.AutoDateTimeTickFormatterSpec( - day: new charts.TimeFormatterSpec( + domainAxis: const charts.DateTimeAxisSpec( + tickFormatterSpec: charts.AutoDateTimeTickFormatterSpec( + day: charts.TimeFormatterSpec( format: 'd', transitionFormat: 'MM/dd/yyyy')))); } /// Create one series with sample hard coded data. static List> _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( + charts.Series( id: 'Cost', domainFn: (MyRow row, _) => row.timeStamp, measureFn: (MyRow row, _) => row.cost, diff --git a/web/charts/lib/axes/custom_font_size_and_color.dart b/web/charts/lib/axes/custom_font_size_and_color.dart index 3dc8e63ea..c56a27f02 100644 --- a/web/charts/lib/axes/custom_font_size_and_color.dart +++ b/web/charts/lib/axes/custom_font_size_and_color.dart @@ -29,10 +29,11 @@ class CustomFontSizeAndColor extends StatelessWidget { final List seriesList; final bool animate; - CustomFontSizeAndColor(this.seriesList, {this.animate}); + const CustomFontSizeAndColor(this.seriesList, {this.animate, Key key}) + : super(key: key); factory CustomFontSizeAndColor.withSampleData() { - return new CustomFontSizeAndColor( + return CustomFontSizeAndColor( _createSampleData(), // Disable animations for image tests. animate: false, @@ -44,22 +45,22 @@ class CustomFontSizeAndColor extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory CustomFontSizeAndColor.withRandomData() { - return new CustomFontSizeAndColor(_createRandomData()); + return CustomFontSizeAndColor(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final globalSalesData = [ - new OrdinalSales('2014', random.nextInt(100) * 100), - new OrdinalSales('2015', random.nextInt(100) * 100), - new OrdinalSales('2016', random.nextInt(100) * 100), - new OrdinalSales('2017', random.nextInt(100) * 100), + OrdinalSales('2014', random.nextInt(100) * 100), + OrdinalSales('2015', random.nextInt(100) * 100), + OrdinalSales('2016', random.nextInt(100) * 100), + OrdinalSales('2017', random.nextInt(100) * 100), ]; return [ - new charts.Series( + charts.Series( id: 'Global Revenue', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -71,7 +72,7 @@ class CustomFontSizeAndColor extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, @@ -80,44 +81,44 @@ class CustomFontSizeAndColor extends StatelessWidget { /// This is an OrdinalAxisSpec to match up with BarChart's default /// ordinal domain axis (use NumericAxisSpec or DateTimeAxisSpec for /// other charts). - domainAxis: new charts.OrdinalAxisSpec( - renderSpec: new charts.SmallTickRendererSpec( + domainAxis: const charts.OrdinalAxisSpec( + renderSpec: charts.SmallTickRendererSpec( // Tick and Label styling here. - labelStyle: new charts.TextStyleSpec( + labelStyle: charts.TextStyleSpec( fontSize: 18, // size in Pts. color: charts.MaterialPalette.black), // Change the line colors to match text color. - lineStyle: new charts.LineStyleSpec( - color: charts.MaterialPalette.black))), + lineStyle: + charts.LineStyleSpec(color: charts.MaterialPalette.black))), /// Assign a custom style for the measure axis. - primaryMeasureAxis: new charts.NumericAxisSpec( - renderSpec: new charts.GridlineRendererSpec( + primaryMeasureAxis: const charts.NumericAxisSpec( + renderSpec: charts.GridlineRendererSpec( // Tick and Label styling here. - labelStyle: new charts.TextStyleSpec( + labelStyle: charts.TextStyleSpec( fontSize: 18, // size in Pts. color: charts.MaterialPalette.black), // Change the line colors to match text color. - lineStyle: new charts.LineStyleSpec( - color: charts.MaterialPalette.black))), + lineStyle: + charts.LineStyleSpec(color: charts.MaterialPalette.black))), ); } /// Create series list with single series static List> _createSampleData() { final globalSalesData = [ - new OrdinalSales('2014', 5000), - new OrdinalSales('2015', 25000), - new OrdinalSales('2016', 100000), - new OrdinalSales('2017', 750000), + OrdinalSales('2014', 5000), + OrdinalSales('2015', 25000), + OrdinalSales('2016', 100000), + OrdinalSales('2017', 750000), ]; return [ - new charts.Series( + charts.Series( id: 'Global Revenue', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/axes/custom_measure_tick_count.dart b/web/charts/lib/axes/custom_measure_tick_count.dart index 7a0efd36c..67b93c2db 100644 --- a/web/charts/lib/axes/custom_measure_tick_count.dart +++ b/web/charts/lib/axes/custom_measure_tick_count.dart @@ -28,11 +28,12 @@ class CustomMeasureTickCount extends StatelessWidget { final List 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> _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( + charts.Series( 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> _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( + charts.Series( id: 'Cost', domainFn: (MyRow row, _) => row.timeStamp, measureFn: (MyRow row, _) => row.cost, diff --git a/web/charts/lib/axes/flipped_vertical_axis.dart b/web/charts/lib/axes/flipped_vertical_axis.dart index d3fee92af..eaafaa2ed 100644 --- a/web/charts/lib/axes/flipped_vertical_axis.dart +++ b/web/charts/lib/axes/flipped_vertical_axis.dart @@ -32,10 +32,11 @@ class FlippedVerticalAxis extends StatelessWidget { final List seriesList; final bool animate; - FlippedVerticalAxis(this.seriesList, {this.animate}); + const FlippedVerticalAxis(this.seriesList, {this.animate, Key key}) + : super(key: key); factory FlippedVerticalAxis.withSampleData() { - return new FlippedVerticalAxis( + return FlippedVerticalAxis( _createSampleData(), // Disable animations for image tests. animate: false, @@ -47,25 +48,25 @@ class FlippedVerticalAxis extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory FlippedVerticalAxis.withRandomData() { - return new FlippedVerticalAxis(_createRandomData()); + return FlippedVerticalAxis(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); const runners = ['Smith', 'Jones', 'Brown', 'Doe']; // Randomly assign runners, but leave the order of the places. final raceData = [ - new RunnerRank(runners.removeAt(random.nextInt(runners.length)), 1), - new RunnerRank(runners.removeAt(random.nextInt(runners.length)), 2), - new RunnerRank(runners.removeAt(random.nextInt(runners.length)), 3), - new RunnerRank(runners.removeAt(random.nextInt(runners.length)), 4), + RunnerRank(runners.removeAt(random.nextInt(runners.length)), 1), + RunnerRank(runners.removeAt(random.nextInt(runners.length)), 2), + RunnerRank(runners.removeAt(random.nextInt(runners.length)), 3), + RunnerRank(runners.removeAt(random.nextInt(runners.length)), 4), ]; return [ - new charts.Series( + charts.Series( id: 'Race Results', domainFn: (RunnerRank row, _) => row.name, measureFn: (RunnerRank row, _) => row.place, @@ -80,7 +81,7 @@ class FlippedVerticalAxis extends StatelessWidget { // TODO: Remove this comment @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, flipVerticalAxis: true, @@ -90,14 +91,14 @@ class FlippedVerticalAxis extends StatelessWidget { /// Create series list with multiple series static List> _createSampleData() { final raceData = [ - new RunnerRank('Smith', 1), - new RunnerRank('Jones', 2), - new RunnerRank('Brown', 3), - new RunnerRank('Doe', 4), + RunnerRank('Smith', 1), + RunnerRank('Jones', 2), + RunnerRank('Brown', 3), + RunnerRank('Doe', 4), ]; return [ - new charts.Series( + charts.Series( id: 'Race Results', domainFn: (RunnerRank row, _) => row.name, measureFn: (RunnerRank row, _) => row.place, diff --git a/web/charts/lib/axes/gridline_dash_pattern.dart b/web/charts/lib/axes/gridline_dash_pattern.dart index 087dcc0aa..799240d78 100644 --- a/web/charts/lib/axes/gridline_dash_pattern.dart +++ b/web/charts/lib/axes/gridline_dash_pattern.dart @@ -24,11 +24,12 @@ class GridlineDashPattern extends StatelessWidget { final List seriesList; final bool animate; - GridlineDashPattern(this.seriesList, {this.animate}); + const GridlineDashPattern(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [TimeSeriesChart] with sample data and no transition. factory GridlineDashPattern.withSampleData() { - return new GridlineDashPattern( + return GridlineDashPattern( _createSampleData(), // Disable animations for image tests. animate: false, @@ -40,29 +41,29 @@ class GridlineDashPattern extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory GridlineDashPattern.withRandomData() { - return new GridlineDashPattern(_createRandomData()); + return GridlineDashPattern(_createRandomData()); } /// Create random data. static List> _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( + charts.Series( id: 'Cost', domainFn: (MyRow row, _) => row.timeStamp, measureFn: (MyRow row, _) => row.cost, @@ -74,11 +75,11 @@ class GridlineDashPattern extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.TimeSeriesChart(seriesList, + return charts.TimeSeriesChart(seriesList, animate: animate, /// Customize the gridlines to use a dash pattern. - primaryMeasureAxis: new charts.NumericAxisSpec( + primaryMeasureAxis: const charts.NumericAxisSpec( renderSpec: charts.GridlineRendererSpec( lineStyle: charts.LineStyleSpec( dashPattern: [4, 4], @@ -88,21 +89,21 @@ class GridlineDashPattern extends StatelessWidget { /// Create one series with sample hard coded data. static List> _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( + charts.Series( id: 'Cost', domainFn: (MyRow row, _) => row.timeStamp, measureFn: (MyRow row, _) => row.cost, diff --git a/web/charts/lib/axes/hidden_ticks_and_labels_axis.dart b/web/charts/lib/axes/hidden_ticks_and_labels_axis.dart index cc1204e49..895f4b3b2 100644 --- a/web/charts/lib/axes/hidden_ticks_and_labels_axis.dart +++ b/web/charts/lib/axes/hidden_ticks_and_labels_axis.dart @@ -25,10 +25,11 @@ class HiddenTicksAndLabelsAxis extends StatelessWidget { final List seriesList; final bool animate; - HiddenTicksAndLabelsAxis(this.seriesList, {this.animate}); + const HiddenTicksAndLabelsAxis(this.seriesList, {this.animate, Key key}) + : super(key: key); factory HiddenTicksAndLabelsAxis.withSampleData() { - return new HiddenTicksAndLabelsAxis( + return HiddenTicksAndLabelsAxis( _createSampleData(), // Disable animations for image tests. animate: false, @@ -40,22 +41,22 @@ class HiddenTicksAndLabelsAxis extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory HiddenTicksAndLabelsAxis.withRandomData() { - return new HiddenTicksAndLabelsAxis(_createRandomData()); + return HiddenTicksAndLabelsAxis(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final globalSalesData = [ - new OrdinalSales('2014', random.nextInt(100) * 100), - new OrdinalSales('2015', random.nextInt(100) * 100), - new OrdinalSales('2016', random.nextInt(100) * 100), - new OrdinalSales('2017', random.nextInt(100) * 100), + OrdinalSales('2014', random.nextInt(100) * 100), + OrdinalSales('2015', random.nextInt(100) * 100), + OrdinalSales('2016', random.nextInt(100) * 100), + OrdinalSales('2017', random.nextInt(100) * 100), ]; return [ - new charts.Series( + charts.Series( id: 'Global Revenue', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -67,7 +68,7 @@ class HiddenTicksAndLabelsAxis extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, @@ -76,30 +77,30 @@ class HiddenTicksAndLabelsAxis extends StatelessWidget { /// The NoneRenderSpec can still draw an axis line with /// showAxisLine=true. primaryMeasureAxis: - new charts.NumericAxisSpec(renderSpec: new charts.NoneRenderSpec()), + const charts.NumericAxisSpec(renderSpec: charts.NoneRenderSpec()), /// This is an OrdinalAxisSpec to match up with BarChart's default /// ordinal domain axis (use NumericAxisSpec or DateTimeAxisSpec for /// other charts). - domainAxis: new charts.OrdinalAxisSpec( + domainAxis: const charts.OrdinalAxisSpec( // Make sure that we draw the domain axis line. showAxisLine: true, // But don't draw anything else. - renderSpec: new charts.NoneRenderSpec()), + renderSpec: charts.NoneRenderSpec()), ); } /// Create series list with single series static List> _createSampleData() { final globalSalesData = [ - new OrdinalSales('2014', 5000), - new OrdinalSales('2015', 25000), - new OrdinalSales('2016', 100000), - new OrdinalSales('2017', 750000), + OrdinalSales('2014', 5000), + OrdinalSales('2015', 25000), + OrdinalSales('2016', 100000), + OrdinalSales('2017', 750000), ]; return [ - new charts.Series( + charts.Series( id: 'Global Revenue', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/axes/horizontal_bar_secondary_axis.dart b/web/charts/lib/axes/horizontal_bar_secondary_axis.dart index 51f207ba0..64a232e40 100644 --- a/web/charts/lib/axes/horizontal_bar_secondary_axis.dart +++ b/web/charts/lib/axes/horizontal_bar_secondary_axis.dart @@ -39,10 +39,12 @@ class HorizontalBarChartWithSecondaryAxis extends StatelessWidget { final List seriesList; final bool animate; - HorizontalBarChartWithSecondaryAxis(this.seriesList, {this.animate}); + const HorizontalBarChartWithSecondaryAxis(this.seriesList, + {this.animate, Key key}) + : super(key: key); factory HorizontalBarChartWithSecondaryAxis.withSampleData() { - return new HorizontalBarChartWithSecondaryAxis( + return HorizontalBarChartWithSecondaryAxis( _createSampleData(), // Disable animations for image tests. animate: false, @@ -54,35 +56,35 @@ class HorizontalBarChartWithSecondaryAxis extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory HorizontalBarChartWithSecondaryAxis.withRandomData() { - return new HorizontalBarChartWithSecondaryAxis(_createRandomData()); + return HorizontalBarChartWithSecondaryAxis(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final globalSalesData = [ - new OrdinalSales('2014', random.nextInt(100) * 100), - new OrdinalSales('2015', random.nextInt(100) * 100), - new OrdinalSales('2016', random.nextInt(100) * 100), - new OrdinalSales('2017', random.nextInt(100) * 100), + OrdinalSales('2014', random.nextInt(100) * 100), + OrdinalSales('2015', random.nextInt(100) * 100), + OrdinalSales('2016', random.nextInt(100) * 100), + OrdinalSales('2017', random.nextInt(100) * 100), ]; final losAngelesSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Global Revenue', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: globalSalesData, ), - new charts.Series( + charts.Series( id: 'Los Angeles Revenue', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -98,7 +100,7 @@ class HorizontalBarChartWithSecondaryAxis extends StatelessWidget { @override Widget build(BuildContext context) { // For horizontal bar charts, set the [vertical] flag to false. - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, barGroupingType: charts.BarGroupingType.grouped, @@ -106,39 +108,39 @@ class HorizontalBarChartWithSecondaryAxis extends StatelessWidget { // It is important when using both primary and secondary axes to choose // the same number of ticks for both sides to get the gridlines to line // up. - primaryMeasureAxis: new charts.NumericAxisSpec( + primaryMeasureAxis: const charts.NumericAxisSpec( tickProviderSpec: - new charts.BasicNumericTickProviderSpec(desiredTickCount: 3)), - secondaryMeasureAxis: new charts.NumericAxisSpec( + charts.BasicNumericTickProviderSpec(desiredTickCount: 3)), + secondaryMeasureAxis: const charts.NumericAxisSpec( tickProviderSpec: - new charts.BasicNumericTickProviderSpec(desiredTickCount: 3)), + charts.BasicNumericTickProviderSpec(desiredTickCount: 3)), ); } /// Create series list with multiple series static List> _createSampleData() { final globalSalesData = [ - new OrdinalSales('2014', 5000), - new OrdinalSales('2015', 25000), - new OrdinalSales('2016', 100000), - new OrdinalSales('2017', 750000), + OrdinalSales('2014', 5000), + OrdinalSales('2015', 25000), + OrdinalSales('2016', 100000), + OrdinalSales('2017', 750000), ]; final losAngelesSalesData = [ - new OrdinalSales('2014', 25), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 10), - new OrdinalSales('2017', 20), + OrdinalSales('2014', 25), + OrdinalSales('2015', 50), + OrdinalSales('2016', 10), + OrdinalSales('2017', 20), ]; return [ - new charts.Series( + charts.Series( id: 'Global Revenue', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: globalSalesData, ), - new charts.Series( + charts.Series( id: 'Los Angeles Revenue', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/axes/integer_only_measure_axis.dart b/web/charts/lib/axes/integer_only_measure_axis.dart index fbe445de4..0af1e73cf 100644 --- a/web/charts/lib/axes/integer_only_measure_axis.dart +++ b/web/charts/lib/axes/integer_only_measure_axis.dart @@ -29,11 +29,12 @@ class IntegerOnlyMeasureAxis extends StatelessWidget { final List seriesList; final bool animate; - IntegerOnlyMeasureAxis(this.seriesList, {this.animate}); + const IntegerOnlyMeasureAxis(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [TimeSeriesChart] with sample data and no transition. factory IntegerOnlyMeasureAxis.withSampleData() { - return new IntegerOnlyMeasureAxis( + return IntegerOnlyMeasureAxis( _createSampleData(), // Disable animations for image tests. animate: false, @@ -45,29 +46,29 @@ class IntegerOnlyMeasureAxis extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory IntegerOnlyMeasureAxis.withRandomData() { - return new IntegerOnlyMeasureAxis(_createRandomData()); + return IntegerOnlyMeasureAxis(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new MyRow(new DateTime(2017, 9, 25), random.nextDouble().round()), - new MyRow(new DateTime(2017, 9, 26), random.nextDouble().round()), - new MyRow(new DateTime(2017, 9, 27), random.nextDouble().round()), - new MyRow(new DateTime(2017, 9, 28), random.nextDouble().round()), - new MyRow(new DateTime(2017, 9, 29), random.nextDouble().round()), - new MyRow(new DateTime(2017, 9, 30), random.nextDouble().round()), - new MyRow(new DateTime(2017, 10, 01), random.nextDouble().round()), - new MyRow(new DateTime(2017, 10, 02), random.nextDouble().round()), - new MyRow(new DateTime(2017, 10, 03), random.nextDouble().round()), - new MyRow(new DateTime(2017, 10, 04), random.nextDouble().round()), - new MyRow(new DateTime(2017, 10, 05), random.nextDouble().round()), + MyRow(DateTime(2017, 9, 25), random.nextDouble().round()), + MyRow(DateTime(2017, 9, 26), random.nextDouble().round()), + MyRow(DateTime(2017, 9, 27), random.nextDouble().round()), + MyRow(DateTime(2017, 9, 28), random.nextDouble().round()), + MyRow(DateTime(2017, 9, 29), random.nextDouble().round()), + MyRow(DateTime(2017, 9, 30), random.nextDouble().round()), + MyRow(DateTime(2017, 10, 01), random.nextDouble().round()), + MyRow(DateTime(2017, 10, 02), random.nextDouble().round()), + MyRow(DateTime(2017, 10, 03), random.nextDouble().round()), + MyRow(DateTime(2017, 10, 04), random.nextDouble().round()), + MyRow(DateTime(2017, 10, 05), random.nextDouble().round()), ]; return [ - new charts.Series( + charts.Series( id: 'Headcount', domainFn: (MyRow row, _) => row.timeStamp, measureFn: (MyRow row, _) => row.headcount, @@ -79,12 +80,12 @@ class IntegerOnlyMeasureAxis extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.TimeSeriesChart( + return charts.TimeSeriesChart( seriesList, animate: animate, // Provides a custom axis ensuring that the ticks are in whole numbers. - primaryMeasureAxis: new charts.NumericAxisSpec( - tickProviderSpec: new charts.BasicNumericTickProviderSpec( + primaryMeasureAxis: const charts.NumericAxisSpec( + tickProviderSpec: charts.BasicNumericTickProviderSpec( // Make sure we don't have values less than 1 as ticks // (ie: counts). dataIsInWholeNumbers: true, @@ -97,21 +98,21 @@ class IntegerOnlyMeasureAxis extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new MyRow(new DateTime(2017, 9, 25), 0), - new MyRow(new DateTime(2017, 9, 26), 0), - new MyRow(new DateTime(2017, 9, 27), 0), - new MyRow(new DateTime(2017, 9, 28), 0), - new MyRow(new DateTime(2017, 9, 29), 0), - new MyRow(new DateTime(2017, 9, 30), 0), - new MyRow(new DateTime(2017, 10, 01), 1), - new MyRow(new DateTime(2017, 10, 02), 1), - new MyRow(new DateTime(2017, 10, 03), 1), - new MyRow(new DateTime(2017, 10, 04), 1), - new MyRow(new DateTime(2017, 10, 05), 1), + MyRow(DateTime(2017, 9, 25), 0), + MyRow(DateTime(2017, 9, 26), 0), + MyRow(DateTime(2017, 9, 27), 0), + MyRow(DateTime(2017, 9, 28), 0), + MyRow(DateTime(2017, 9, 29), 0), + MyRow(DateTime(2017, 9, 30), 0), + MyRow(DateTime(2017, 10, 01), 1), + MyRow(DateTime(2017, 10, 02), 1), + MyRow(DateTime(2017, 10, 03), 1), + MyRow(DateTime(2017, 10, 04), 1), + MyRow(DateTime(2017, 10, 05), 1), ]; return [ - new charts.Series( + charts.Series( id: 'Headcount', domainFn: (MyRow row, _) => row.timeStamp, measureFn: (MyRow row, _) => row.headcount, diff --git a/web/charts/lib/axes/line_disjoint_axis.dart b/web/charts/lib/axes/line_disjoint_axis.dart index 7809a1afd..beab2ce95 100644 --- a/web/charts/lib/axes/line_disjoint_axis.dart +++ b/web/charts/lib/axes/line_disjoint_axis.dart @@ -31,11 +31,12 @@ class DisjointMeasureAxisLineChart extends StatelessWidget { final List seriesList; final bool animate; - DisjointMeasureAxisLineChart(this.seriesList, {this.animate}); + const DisjointMeasureAxisLineChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [LineChart] with sample data and no transition. factory DisjointMeasureAxisLineChart.withSampleData() { - return new DisjointMeasureAxisLineChart( + return DisjointMeasureAxisLineChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -47,58 +48,58 @@ class DisjointMeasureAxisLineChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory DisjointMeasureAxisLineChart.withRandomData() { - return new DisjointMeasureAxisLineChart(_createRandomData()); + return DisjointMeasureAxisLineChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); // The first three series contain similar data with different magnitudes. // This demonstrates the ability to graph the trends in each series relative // to each other, without the largest magnitude series compressing the // smallest. final myFakeDesktopData = [ - new LinearClicks(0, clickCount: random.nextInt(100)), - new LinearClicks(1, clickCount: random.nextInt(100)), - new LinearClicks(2, clickCount: random.nextInt(100)), - new LinearClicks(3, clickCount: random.nextInt(100)), + LinearClicks(0, clickCount: random.nextInt(100)), + LinearClicks(1, clickCount: random.nextInt(100)), + LinearClicks(2, clickCount: random.nextInt(100)), + LinearClicks(3, clickCount: random.nextInt(100)), ]; final myFakeTabletData = [ - new LinearClicks(0, clickCount: random.nextInt(100) * 100), - new LinearClicks(1, clickCount: random.nextInt(100) * 100), - new LinearClicks(2, clickCount: random.nextInt(100) * 100), - new LinearClicks(3, clickCount: random.nextInt(100) * 100), + LinearClicks(0, clickCount: random.nextInt(100) * 100), + LinearClicks(1, clickCount: random.nextInt(100) * 100), + LinearClicks(2, clickCount: random.nextInt(100) * 100), + LinearClicks(3, clickCount: random.nextInt(100) * 100), ]; final myFakeMobileData = [ - new LinearClicks(0, clickCount: random.nextInt(100) * 1000), - new LinearClicks(1, clickCount: random.nextInt(100) * 1000), - new LinearClicks(2, clickCount: random.nextInt(100) * 1000), - new LinearClicks(3, clickCount: random.nextInt(100) * 1000), + LinearClicks(0, clickCount: random.nextInt(100) * 1000), + LinearClicks(1, clickCount: random.nextInt(100) * 1000), + LinearClicks(2, clickCount: random.nextInt(100) * 1000), + LinearClicks(3, clickCount: random.nextInt(100) * 1000), ]; // The fourth series renders with decimal values, representing a very // different sort ratio-based data. If this was on the same axis as any of // the other series, it would be squashed near zero. final myFakeClickRateData = [ - new LinearClicks(0, clickRate: .25), - new LinearClicks(1, clickRate: .65), - new LinearClicks(2, clickRate: .50), - new LinearClicks(3, clickRate: .30), + LinearClicks(0, clickRate: .25), + LinearClicks(1, clickRate: .65), + LinearClicks(2, clickRate: .50), + LinearClicks(3, clickRate: .30), ]; return [ // We render an empty series on the primary measure axis to ensure that // the axis itself gets rendered. This helps us draw the gridlines on the // chart. - new charts.Series( + charts.Series( id: 'Fake Series', domainFn: (LinearClicks clickCount, _) => clickCount.year, measureFn: (LinearClicks clickCount, _) => clickCount.clickCount, data: []), - new charts.Series( + charts.Series( id: 'Desktop', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (LinearClicks clickCount, _) => clickCount.year, @@ -107,7 +108,7 @@ class DisjointMeasureAxisLineChart extends StatelessWidget { ) // Set the 'Desktop' series to use a disjoint axis. ..setAttribute(charts.measureAxisIdKey, 'axis 1'), - new charts.Series( + charts.Series( id: 'Tablet', colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault, domainFn: (LinearClicks clickCount, _) => clickCount.year, @@ -116,7 +117,7 @@ class DisjointMeasureAxisLineChart extends StatelessWidget { ) // Set the 'Tablet' series to use a disjoint axis. ..setAttribute(charts.measureAxisIdKey, 'axis 2'), - new charts.Series( + charts.Series( id: 'Mobile', colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault, domainFn: (LinearClicks clickCount, _) => clickCount.year, @@ -125,7 +126,7 @@ class DisjointMeasureAxisLineChart extends StatelessWidget { ) // Set the 'Mobile' series to use a disjoint axis. ..setAttribute(charts.measureAxisIdKey, 'axis 3'), - new charts.Series( + charts.Series( id: 'Click Rate', colorFn: (_, __) => charts.MaterialPalette.purple.shadeDefault, domainFn: (LinearClicks clickCount, _) => clickCount.year, @@ -141,7 +142,7 @@ class DisjointMeasureAxisLineChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.LineChart(seriesList, + return charts.LineChart(seriesList, animate: animate, // Configure a primary measure axis that will render gridlines across // the chart. This axis uses fake ticks with no labels to ensure that we @@ -149,15 +150,15 @@ class DisjointMeasureAxisLineChart extends StatelessWidget { // // We do this because disjoint measure axes do not draw any tick // elements on the chart. - primaryMeasureAxis: new charts.NumericAxisSpec( - tickProviderSpec: new charts.StaticNumericTickProviderSpec( + primaryMeasureAxis: const charts.NumericAxisSpec( + tickProviderSpec: charts.StaticNumericTickProviderSpec( // Create the ticks to be used the domain axis. >[ - new charts.TickSpec(0, label: ''), - new charts.TickSpec(1, label: ''), - new charts.TickSpec(2, label: ''), - new charts.TickSpec(3, label: ''), - new charts.TickSpec(4, label: ''), + charts.TickSpec(0, label: ''), + charts.TickSpec(1, label: ''), + charts.TickSpec(2, label: ''), + charts.TickSpec(3, label: ''), + charts.TickSpec(4, label: ''), ], )), // Create one disjoint measure axis per series on the chart. @@ -165,11 +166,11 @@ class DisjointMeasureAxisLineChart extends StatelessWidget { // Disjoint measure axes will be used to scale the rendered data, // without drawing any tick elements on either side of the chart. disjointMeasureAxes: - new LinkedHashMap.from({ - 'axis 1': new charts.NumericAxisSpec(), - 'axis 2': new charts.NumericAxisSpec(), - 'axis 3': new charts.NumericAxisSpec(), - 'axis 4': new charts.NumericAxisSpec(), + LinkedHashMap.from({ + 'axis 1': const charts.NumericAxisSpec(), + 'axis 2': const charts.NumericAxisSpec(), + 'axis 3': const charts.NumericAxisSpec(), + 'axis 4': const charts.NumericAxisSpec(), })); } @@ -180,46 +181,46 @@ class DisjointMeasureAxisLineChart extends StatelessWidget { // to each other, without the largest magnitude series compressing the // smallest. final myFakeDesktopData = [ - new LinearClicks(0, clickCount: 25), - new LinearClicks(1, clickCount: 125), - new LinearClicks(2, clickCount: 920), - new LinearClicks(3, clickCount: 375), + LinearClicks(0, clickCount: 25), + LinearClicks(1, clickCount: 125), + LinearClicks(2, clickCount: 920), + LinearClicks(3, clickCount: 375), ]; final myFakeTabletData = [ - new LinearClicks(0, clickCount: 375), - new LinearClicks(1, clickCount: 1850), - new LinearClicks(2, clickCount: 9700), - new LinearClicks(3, clickCount: 5000), + LinearClicks(0, clickCount: 375), + LinearClicks(1, clickCount: 1850), + LinearClicks(2, clickCount: 9700), + LinearClicks(3, clickCount: 5000), ]; final myFakeMobileData = [ - new LinearClicks(0, clickCount: 5000), - new LinearClicks(1, clickCount: 25000), - new LinearClicks(2, clickCount: 100000), - new LinearClicks(3, clickCount: 75000), + LinearClicks(0, clickCount: 5000), + LinearClicks(1, clickCount: 25000), + LinearClicks(2, clickCount: 100000), + LinearClicks(3, clickCount: 75000), ]; // The fourth series renders with decimal values, representing a very // different sort ratio-based data. If this was on the same axis as any of // the other series, it would be squashed near zero. final myFakeClickRateData = [ - new LinearClicks(0, clickRate: .25), - new LinearClicks(1, clickRate: .65), - new LinearClicks(2, clickRate: .50), - new LinearClicks(3, clickRate: .30), + LinearClicks(0, clickRate: .25), + LinearClicks(1, clickRate: .65), + LinearClicks(2, clickRate: .50), + LinearClicks(3, clickRate: .30), ]; return [ // We render an empty series on the primary measure axis to ensure that // the axis itself gets rendered. This helps us draw the gridlines on the // chart. - new charts.Series( + charts.Series( id: 'Fake Series', domainFn: (LinearClicks clickCount, _) => clickCount.year, measureFn: (LinearClicks clickCount, _) => clickCount.clickCount, data: []), - new charts.Series( + charts.Series( id: 'Desktop', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (LinearClicks clickCount, _) => clickCount.year, @@ -228,7 +229,7 @@ class DisjointMeasureAxisLineChart extends StatelessWidget { ) // Set the 'Desktop' series to use a disjoint axis. ..setAttribute(charts.measureAxisIdKey, 'axis 1'), - new charts.Series( + charts.Series( id: 'Tablet', colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault, domainFn: (LinearClicks clickCount, _) => clickCount.year, @@ -237,7 +238,7 @@ class DisjointMeasureAxisLineChart extends StatelessWidget { ) // Set the 'Tablet' series to use a disjoint axis. ..setAttribute(charts.measureAxisIdKey, 'axis 2'), - new charts.Series( + charts.Series( id: 'Mobile', colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault, domainFn: (LinearClicks clickCount, _) => clickCount.year, @@ -246,7 +247,7 @@ class DisjointMeasureAxisLineChart extends StatelessWidget { ) // Set the 'Mobile' series to use a disjoint axis. ..setAttribute(charts.measureAxisIdKey, 'axis 3'), - new charts.Series( + charts.Series( id: 'Click Rate', colorFn: (_, __) => charts.MaterialPalette.purple.shadeDefault, domainFn: (LinearClicks clickCount, _) => clickCount.year, diff --git a/web/charts/lib/axes/measure_axis_label_alignment.dart b/web/charts/lib/axes/measure_axis_label_alignment.dart index ffcf590cd..e3e5895f1 100644 --- a/web/charts/lib/axes/measure_axis_label_alignment.dart +++ b/web/charts/lib/axes/measure_axis_label_alignment.dart @@ -26,10 +26,11 @@ class MeasureAxisLabelAlignment extends StatelessWidget { final List seriesList; final bool animate; - MeasureAxisLabelAlignment(this.seriesList, {this.animate}); + const MeasureAxisLabelAlignment(this.seriesList, {this.animate, Key key}) + : super(key: key); factory MeasureAxisLabelAlignment.withSampleData() { - return new MeasureAxisLabelAlignment( + return MeasureAxisLabelAlignment( _createSampleData(), // Disable animations for image tests. animate: false, @@ -41,22 +42,22 @@ class MeasureAxisLabelAlignment extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory MeasureAxisLabelAlignment.withRandomData() { - return new MeasureAxisLabelAlignment(_createRandomData()); + return MeasureAxisLabelAlignment(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final globalSalesData = [ - new OrdinalSales('2014', random.nextInt(100) * 100), - new OrdinalSales('2015', random.nextInt(100) * 100), - new OrdinalSales('2016', random.nextInt(100) * 100), - new OrdinalSales('2017', random.nextInt(100) * 100), + OrdinalSales('2014', random.nextInt(100) * 100), + OrdinalSales('2015', random.nextInt(100) * 100), + OrdinalSales('2016', random.nextInt(100) * 100), + OrdinalSales('2017', random.nextInt(100) * 100), ]; return [ - new charts.Series( + charts.Series( id: 'Global Revenue', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -68,15 +69,15 @@ class MeasureAxisLabelAlignment extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, /// Customize the primary measure axis using a small tick renderer. /// Use String instead of num for ordinal domain axis /// (typically bar charts). - primaryMeasureAxis: new charts.NumericAxisSpec( - renderSpec: new charts.GridlineRendererSpec( + primaryMeasureAxis: const charts.NumericAxisSpec( + renderSpec: charts.GridlineRendererSpec( // Display the measure axis labels below the gridline. // // 'Before' & 'after' follow the axis value direction. @@ -96,14 +97,14 @@ class MeasureAxisLabelAlignment extends StatelessWidget { /// Create series list with single series static List> _createSampleData() { final globalSalesData = [ - new OrdinalSales('2014', 5000), - new OrdinalSales('2015', 25000), - new OrdinalSales('2016', 100000), - new OrdinalSales('2017', 750000), + OrdinalSales('2014', 5000), + OrdinalSales('2015', 25000), + OrdinalSales('2016', 100000), + OrdinalSales('2017', 750000), ]; return [ - new charts.Series( + charts.Series( id: 'Global Revenue', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/axes/nonzero_bound_measure_axis.dart b/web/charts/lib/axes/nonzero_bound_measure_axis.dart index f1fe5c8aa..09e7f6a81 100644 --- a/web/charts/lib/axes/nonzero_bound_measure_axis.dart +++ b/web/charts/lib/axes/nonzero_bound_measure_axis.dart @@ -25,11 +25,12 @@ class NonzeroBoundMeasureAxis extends StatelessWidget { final List seriesList; final bool animate; - NonzeroBoundMeasureAxis(this.seriesList, {this.animate}); + const NonzeroBoundMeasureAxis(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [TimeSeriesChart] with sample data and no transition. factory NonzeroBoundMeasureAxis.withSampleData() { - return new NonzeroBoundMeasureAxis( + return NonzeroBoundMeasureAxis( _createSampleData(), // Disable animations for image tests. animate: false, @@ -41,29 +42,29 @@ class NonzeroBoundMeasureAxis extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory NonzeroBoundMeasureAxis.withRandomData() { - return new NonzeroBoundMeasureAxis(_createRandomData()); + return NonzeroBoundMeasureAxis(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new MyRow(new DateTime(2017, 9, 25), random.nextInt(100) + 100), - new MyRow(new DateTime(2017, 9, 26), random.nextInt(100) + 100), - new MyRow(new DateTime(2017, 9, 27), random.nextInt(100) + 100), - new MyRow(new DateTime(2017, 9, 28), random.nextInt(100) + 100), - new MyRow(new DateTime(2017, 9, 29), random.nextInt(100) + 100), - new MyRow(new DateTime(2017, 9, 30), random.nextInt(100) + 100), - new MyRow(new DateTime(2017, 10, 01), random.nextInt(100) + 100), - new MyRow(new DateTime(2017, 10, 02), random.nextInt(100) + 100), - new MyRow(new DateTime(2017, 10, 03), random.nextInt(100) + 100), - new MyRow(new DateTime(2017, 10, 04), random.nextInt(100) + 100), - new MyRow(new DateTime(2017, 10, 05), random.nextInt(100) + 100), + MyRow(DateTime(2017, 9, 25), random.nextInt(100) + 100), + MyRow(DateTime(2017, 9, 26), random.nextInt(100) + 100), + MyRow(DateTime(2017, 9, 27), random.nextInt(100) + 100), + MyRow(DateTime(2017, 9, 28), random.nextInt(100) + 100), + MyRow(DateTime(2017, 9, 29), random.nextInt(100) + 100), + MyRow(DateTime(2017, 9, 30), random.nextInt(100) + 100), + MyRow(DateTime(2017, 10, 01), random.nextInt(100) + 100), + MyRow(DateTime(2017, 10, 02), random.nextInt(100) + 100), + MyRow(DateTime(2017, 10, 03), random.nextInt(100) + 100), + MyRow(DateTime(2017, 10, 04), random.nextInt(100) + 100), + MyRow(DateTime(2017, 10, 05), random.nextInt(100) + 100), ]; return [ - new charts.Series( + charts.Series( id: 'Headcount', domainFn: (MyRow row, _) => row.timeStamp, measureFn: (MyRow row, _) => row.headcount, @@ -75,33 +76,33 @@ class NonzeroBoundMeasureAxis extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.TimeSeriesChart(seriesList, + return charts.TimeSeriesChart(seriesList, animate: animate, // Provide a tickProviderSpec which does NOT require that zero is // included. - primaryMeasureAxis: new charts.NumericAxisSpec( + primaryMeasureAxis: const charts.NumericAxisSpec( tickProviderSpec: - new charts.BasicNumericTickProviderSpec(zeroBound: false))); + charts.BasicNumericTickProviderSpec(zeroBound: false))); } /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new MyRow(new DateTime(2017, 9, 25), 106), - new MyRow(new DateTime(2017, 9, 26), 108), - new MyRow(new DateTime(2017, 9, 27), 106), - new MyRow(new DateTime(2017, 9, 28), 109), - new MyRow(new DateTime(2017, 9, 29), 111), - new MyRow(new DateTime(2017, 9, 30), 115), - new MyRow(new DateTime(2017, 10, 01), 125), - new MyRow(new DateTime(2017, 10, 02), 133), - new MyRow(new DateTime(2017, 10, 03), 127), - new MyRow(new DateTime(2017, 10, 04), 131), - new MyRow(new DateTime(2017, 10, 05), 123), + MyRow(DateTime(2017, 9, 25), 106), + MyRow(DateTime(2017, 9, 26), 108), + MyRow(DateTime(2017, 9, 27), 106), + MyRow(DateTime(2017, 9, 28), 109), + MyRow(DateTime(2017, 9, 29), 111), + MyRow(DateTime(2017, 9, 30), 115), + MyRow(DateTime(2017, 10, 01), 125), + MyRow(DateTime(2017, 10, 02), 133), + MyRow(DateTime(2017, 10, 03), 127), + MyRow(DateTime(2017, 10, 04), 131), + MyRow(DateTime(2017, 10, 05), 123), ]; return [ - new charts.Series( + charts.Series( id: 'Headcount', domainFn: (MyRow row, _) => row.timeStamp, measureFn: (MyRow row, _) => row.headcount, diff --git a/web/charts/lib/axes/numeric_initial_viewport.dart b/web/charts/lib/axes/numeric_initial_viewport.dart index 5f9144e81..75afcc3f3 100644 --- a/web/charts/lib/axes/numeric_initial_viewport.dart +++ b/web/charts/lib/axes/numeric_initial_viewport.dart @@ -32,11 +32,12 @@ class NumericInitialViewport extends StatelessWidget { final List seriesList; final bool animate; - NumericInitialViewport(this.seriesList, {this.animate}); + const NumericInitialViewport(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [LineChart] with sample data and no transition. factory NumericInitialViewport.withSampleData() { - return new NumericInitialViewport( + return NumericInitialViewport( _createSampleData(), // Disable animations for image tests. animate: false, @@ -48,29 +49,29 @@ class NumericInitialViewport extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory NumericInitialViewport.withRandomData() { - return new NumericInitialViewport(_createRandomData()); + return NumericInitialViewport(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), - new LinearSales(4, random.nextInt(100)), - new LinearSales(5, random.nextInt(100)), - new LinearSales(6, random.nextInt(100)), - new LinearSales(7, random.nextInt(100)), - new LinearSales(8, random.nextInt(100)), - new LinearSales(9, random.nextInt(100)), - new LinearSales(10, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), + LinearSales(4, random.nextInt(100)), + LinearSales(5, random.nextInt(100)), + LinearSales(6, random.nextInt(100)), + LinearSales(7, random.nextInt(100)), + LinearSales(8, random.nextInt(100)), + LinearSales(9, random.nextInt(100)), + LinearSales(10, random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, @@ -83,37 +84,37 @@ class NumericInitialViewport extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.LineChart( + return charts.LineChart( seriesList, animate: animate, - domainAxis: new charts.NumericAxisSpec( + domainAxis: const charts.NumericAxisSpec( // Set the initial viewport by providing a new AxisSpec with the // desired viewport, in NumericExtents. - viewport: new charts.NumericExtents(3.0, 7.0)), + viewport: charts.NumericExtents(3.0, 7.0)), // Optionally add a pan or pan and zoom behavior. // If pan/zoom is not added, the viewport specified remains the viewport. - behaviors: [new charts.PanAndZoomBehavior()], + behaviors: [charts.PanAndZoomBehavior()], ); } /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new LinearSales(0, 5), - new LinearSales(1, 25), - new LinearSales(2, 100), - new LinearSales(3, 75), - new LinearSales(4, 55), - new LinearSales(5, 66), - new LinearSales(6, 110), - new LinearSales(7, 70), - new LinearSales(8, 20), - new LinearSales(9, 25), - new LinearSales(10, 45), + LinearSales(0, 5), + LinearSales(1, 25), + LinearSales(2, 100), + LinearSales(3, 75), + LinearSales(4, 55), + LinearSales(5, 66), + LinearSales(6, 110), + LinearSales(7, 70), + LinearSales(8, 20), + LinearSales(9, 25), + LinearSales(10, 45), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, diff --git a/web/charts/lib/axes/ordinal_initial_viewport.dart b/web/charts/lib/axes/ordinal_initial_viewport.dart index 8dde13872..5547548d8 100644 --- a/web/charts/lib/axes/ordinal_initial_viewport.dart +++ b/web/charts/lib/axes/ordinal_initial_viewport.dart @@ -32,11 +32,12 @@ class OrdinalInitialViewport extends StatelessWidget { final List seriesList; final bool animate; - OrdinalInitialViewport(this.seriesList, {this.animate}); + const OrdinalInitialViewport(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [BarChart] with sample data and no transition. factory OrdinalInitialViewport.withSampleData() { - return new OrdinalInitialViewport( + return OrdinalInitialViewport( _createSampleData(), // Disable animations for image tests. animate: false, @@ -48,35 +49,35 @@ class OrdinalInitialViewport extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory OrdinalInitialViewport.withRandomData() { - return new OrdinalInitialViewport(_createRandomData()); + return OrdinalInitialViewport(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), - new OrdinalSales('2018', random.nextInt(100)), - new OrdinalSales('2019', random.nextInt(100)), - new OrdinalSales('2020', random.nextInt(100)), - new OrdinalSales('2021', random.nextInt(100)), - new OrdinalSales('2022', random.nextInt(100)), - new OrdinalSales('2023', random.nextInt(100)), - new OrdinalSales('2024', random.nextInt(100)), - new OrdinalSales('2025', random.nextInt(100)), - new OrdinalSales('2026', random.nextInt(100)), - new OrdinalSales('2027', random.nextInt(100)), - new OrdinalSales('2028', random.nextInt(100)), - new OrdinalSales('2029', random.nextInt(100)), - new OrdinalSales('2030', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2018', random.nextInt(100)), + OrdinalSales('2019', random.nextInt(100)), + OrdinalSales('2020', random.nextInt(100)), + OrdinalSales('2021', random.nextInt(100)), + OrdinalSales('2022', random.nextInt(100)), + OrdinalSales('2023', random.nextInt(100)), + OrdinalSales('2024', random.nextInt(100)), + OrdinalSales('2025', random.nextInt(100)), + OrdinalSales('2026', random.nextInt(100)), + OrdinalSales('2027', random.nextInt(100)), + OrdinalSales('2028', random.nextInt(100)), + OrdinalSales('2029', random.nextInt(100)), + OrdinalSales('2030', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (OrdinalSales sales, _) => sales.year, @@ -89,43 +90,43 @@ class OrdinalInitialViewport extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, // Set the initial viewport by providing a new AxisSpec with the // desired viewport: a starting domain and the data size. - domainAxis: new charts.OrdinalAxisSpec( - viewport: new charts.OrdinalViewport('2018', 4)), + domainAxis: + charts.OrdinalAxisSpec(viewport: charts.OrdinalViewport('2018', 4)), // Optionally add a pan or pan and zoom behavior. // If pan/zoom is not added, the viewport specified remains the viewport. - behaviors: [new charts.PanAndZoomBehavior()], + behaviors: [charts.PanAndZoomBehavior()], ); } /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), - new OrdinalSales('2018', 33), - new OrdinalSales('2019', 80), - new OrdinalSales('2020', 21), - new OrdinalSales('2021', 77), - new OrdinalSales('2022', 8), - new OrdinalSales('2023', 12), - new OrdinalSales('2024', 42), - new OrdinalSales('2025', 70), - new OrdinalSales('2026', 77), - new OrdinalSales('2027', 55), - new OrdinalSales('2028', 19), - new OrdinalSales('2029', 66), - new OrdinalSales('2030', 27), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), + OrdinalSales('2018', 33), + OrdinalSales('2019', 80), + OrdinalSales('2020', 21), + OrdinalSales('2021', 77), + OrdinalSales('2022', 8), + OrdinalSales('2023', 12), + OrdinalSales('2024', 42), + OrdinalSales('2025', 70), + OrdinalSales('2026', 77), + OrdinalSales('2027', 55), + OrdinalSales('2028', 19), + OrdinalSales('2029', 66), + OrdinalSales('2030', 27), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (OrdinalSales sales, _) => sales.year, diff --git a/web/charts/lib/axes/short_tick_length_axis.dart b/web/charts/lib/axes/short_tick_length_axis.dart index 365afa527..f7ead863f 100644 --- a/web/charts/lib/axes/short_tick_length_axis.dart +++ b/web/charts/lib/axes/short_tick_length_axis.dart @@ -30,10 +30,11 @@ class ShortTickLengthAxis extends StatelessWidget { final List seriesList; final bool animate; - ShortTickLengthAxis(this.seriesList, {this.animate}); + const ShortTickLengthAxis(this.seriesList, {this.animate, Key key}) + : super(key: key); factory ShortTickLengthAxis.withSampleData() { - return new ShortTickLengthAxis( + return ShortTickLengthAxis( _createSampleData(), // Disable animations for image tests. animate: false, @@ -45,22 +46,22 @@ class ShortTickLengthAxis extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory ShortTickLengthAxis.withRandomData() { - return new ShortTickLengthAxis(_createRandomData()); + return ShortTickLengthAxis(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final globalSalesData = [ - new OrdinalSales('2014', random.nextInt(100) * 100), - new OrdinalSales('2015', random.nextInt(100) * 100), - new OrdinalSales('2016', random.nextInt(100) * 100), - new OrdinalSales('2017', random.nextInt(100) * 100), + OrdinalSales('2014', random.nextInt(100) * 100), + OrdinalSales('2015', random.nextInt(100) * 100), + OrdinalSales('2016', random.nextInt(100) * 100), + OrdinalSales('2017', random.nextInt(100) * 100), ]; return [ - new charts.Series( + charts.Series( id: 'Global Revenue', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -72,15 +73,15 @@ class ShortTickLengthAxis extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, /// Customize the primary measure axis using a small tick renderer. /// Note: use String instead of num for ordinal domain axis /// (typically bar charts). - primaryMeasureAxis: new charts.NumericAxisSpec( - renderSpec: new charts.SmallTickRendererSpec( + primaryMeasureAxis: const charts.NumericAxisSpec( + renderSpec: charts.SmallTickRendererSpec( // Tick and Label styling here. )), ); @@ -89,14 +90,14 @@ class ShortTickLengthAxis extends StatelessWidget { /// Create series list with single series static List> _createSampleData() { final globalSalesData = [ - new OrdinalSales('2014', 5000), - new OrdinalSales('2015', 25000), - new OrdinalSales('2016', 100000), - new OrdinalSales('2017', 750000), + OrdinalSales('2014', 5000), + OrdinalSales('2015', 25000), + OrdinalSales('2016', 100000), + OrdinalSales('2017', 750000), ]; return [ - new charts.Series( + charts.Series( id: 'Global Revenue', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/axes/statically_provided_ticks.dart b/web/charts/lib/axes/statically_provided_ticks.dart index 6f09e98ce..6846f8152 100644 --- a/web/charts/lib/axes/statically_provided_ticks.dart +++ b/web/charts/lib/axes/statically_provided_ticks.dart @@ -37,10 +37,11 @@ class StaticallyProvidedTicks extends StatelessWidget { final List seriesList; final bool animate; - StaticallyProvidedTicks(this.seriesList, {this.animate}); + const StaticallyProvidedTicks(this.seriesList, {this.animate, Key key}) + : super(key: key); factory StaticallyProvidedTicks.withSampleData() { - return new StaticallyProvidedTicks( + return StaticallyProvidedTicks( _createSampleData(), // Disable animations for image tests. animate: false, @@ -52,22 +53,22 @@ class StaticallyProvidedTicks extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory StaticallyProvidedTicks.withRandomData() { - return new StaticallyProvidedTicks(_createRandomData()); + return StaticallyProvidedTicks(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final globalSalesData = [ - new OrdinalSales('2014', random.nextInt(100) * 100), - new OrdinalSales('2015', random.nextInt(100) * 100), - new OrdinalSales('2016', random.nextInt(100) * 100), - new OrdinalSales('2017', random.nextInt(100) * 100), + OrdinalSales('2014', random.nextInt(100) * 100), + OrdinalSales('2015', random.nextInt(100) * 100), + OrdinalSales('2016', random.nextInt(100) * 100), + OrdinalSales('2017', random.nextInt(100) * 100), ]; return [ - new charts.Series( + charts.Series( id: 'Global Revenue', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -81,41 +82,40 @@ class StaticallyProvidedTicks extends StatelessWidget { Widget build(BuildContext context) { // Create the ticks to be used the domain axis. final staticTicks = >[ - new charts.TickSpec( + const charts.TickSpec( // Value must match the domain value. '2014', // Optional label for this tick, defaults to domain value if not set. label: 'Year 2014', // The styling for this tick. - style: new charts.TextStyleSpec( - color: new charts.Color(r: 0x4C, g: 0xAF, b: 0x50))), + style: charts.TextStyleSpec( + color: charts.Color(r: 0x4C, g: 0xAF, b: 0x50))), // If no text style is specified - the style from renderSpec will be used // if one is specified. - new charts.TickSpec('2015'), - new charts.TickSpec('2016'), - new charts.TickSpec('2017'), + const charts.TickSpec('2015'), + const charts.TickSpec('2016'), + const charts.TickSpec('2017'), ]; - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, - domainAxis: new charts.OrdinalAxisSpec( - tickProviderSpec: - new charts.StaticOrdinalTickProviderSpec(staticTicks)), + domainAxis: charts.OrdinalAxisSpec( + tickProviderSpec: charts.StaticOrdinalTickProviderSpec(staticTicks)), ); } /// Create series list with single series static List> _createSampleData() { final globalSalesData = [ - new OrdinalSales('2014', 5000), - new OrdinalSales('2015', 25000), - new OrdinalSales('2016', 100000), - new OrdinalSales('2017', 750000), + OrdinalSales('2014', 5000), + OrdinalSales('2015', 25000), + OrdinalSales('2016', 100000), + OrdinalSales('2017', 750000), ]; return [ - new charts.Series( + charts.Series( id: 'Global Revenue', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/bar_chart/bar_gallery.dart b/web/charts/lib/bar_chart/bar_gallery.dart index 7b5a59b69..caf9b302b 100644 --- a/web/charts/lib/bar_chart/bar_gallery.dart +++ b/web/charts/lib/bar_chart/bar_gallery.dart @@ -36,121 +36,120 @@ import 'spark_bar.dart'; List buildGallery() { return [ - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Simple Bar Chart', subtitle: 'Simple bar chart with a single series', - childBuilder: () => new SimpleBarChart.withRandomData(), + childBuilder: () => SimpleBarChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Stacked Bar Chart', subtitle: 'Stacked bar chart with multiple series', - childBuilder: () => new StackedBarChart.withRandomData(), + childBuilder: () => StackedBarChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Grouped Bar Chart', subtitle: 'Grouped bar chart with multiple series', - childBuilder: () => new GroupedBarChart.withRandomData(), + childBuilder: () => GroupedBarChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Grouped Stacked Bar Chart', subtitle: 'Grouped and stacked bar chart with multiple series', - childBuilder: () => new GroupedStackedBarChart.withRandomData(), + childBuilder: () => GroupedStackedBarChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Grouped Bar Target Line Chart', subtitle: 'Grouped bar target line chart with multiple series', - childBuilder: () => new GroupedBarTargetLineChart.withRandomData(), + childBuilder: () => GroupedBarTargetLineChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Grouped Bar Single Target Line Chart', subtitle: 'Grouped bar target line chart with multiple series and a single target', - childBuilder: () => new GroupedBarSingleTargetLineChart.withRandomData(), + childBuilder: () => GroupedBarSingleTargetLineChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Stacked Bar Target Line Chart', subtitle: 'Stacked bar target line chart with multiple series', - childBuilder: () => new StackedBarTargetLineChart.withRandomData(), + childBuilder: () => StackedBarTargetLineChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Transform.rotate( - angle: 1.5708, child: new Icon(Icons.insert_chart)), + GalleryScaffold( + listTileIcon: Transform.rotate( + angle: 1.5708, child: const Icon(Icons.insert_chart)), title: 'Horizontal Bar Chart', subtitle: 'Horizontal bar chart with a single series', - childBuilder: () => new HorizontalBarChart.withRandomData(), + childBuilder: () => HorizontalBarChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Transform.rotate( - angle: 1.5708, child: new Icon(Icons.insert_chart)), + GalleryScaffold( + listTileIcon: Transform.rotate( + angle: 1.5708, child: const Icon(Icons.insert_chart)), title: 'Stacked Horizontal Bar Chart', subtitle: 'Stacked horizontal bar chart with multiple series', - childBuilder: () => new StackedHorizontalBarChart.withRandomData(), + childBuilder: () => StackedHorizontalBarChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Transform.rotate( - angle: 1.5708, child: new Icon(Icons.insert_chart)), + GalleryScaffold( + listTileIcon: Transform.rotate( + angle: 1.5708, child: const Icon(Icons.insert_chart)), title: 'Horizontal Bar Chart with Bar Labels', subtitle: 'Horizontal bar chart with a single series and bar labels', - childBuilder: () => new HorizontalBarLabelChart.withRandomData(), + childBuilder: () => HorizontalBarLabelChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Transform.rotate( - angle: 1.5708, child: new Icon(Icons.insert_chart)), + GalleryScaffold( + listTileIcon: Transform.rotate( + angle: 1.5708, child: const Icon(Icons.insert_chart)), title: 'Horizontal Bar Chart with Custom Bar Labels', subtitle: 'Bar labels with customized styling', - childBuilder: () => new HorizontalBarLabelCustomChart.withRandomData(), + childBuilder: () => HorizontalBarLabelCustomChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Spark Bar Chart', subtitle: 'Spark Bar Chart', - childBuilder: () => new SparkBar.withRandomData(), + childBuilder: () => SparkBar.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Grouped Fill Color Bar Chart', subtitle: 'Grouped bar chart with fill colors', - childBuilder: () => new GroupedFillColorBarChart.withRandomData(), + childBuilder: () => GroupedFillColorBarChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Stacked Fill Color Bar Chart', subtitle: 'Stacked bar chart with fill colors', - childBuilder: () => new StackedFillColorBarChart.withRandomData(), + childBuilder: () => StackedFillColorBarChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Pattern Forward Hatch Bar Chart', subtitle: 'Pattern Forward Hatch Bar Chart', - childBuilder: () => new PatternForwardHatchBarChart.withRandomData(), + childBuilder: () => PatternForwardHatchBarChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Transform.rotate( - angle: 1.5708, child: new Icon(Icons.insert_chart)), + GalleryScaffold( + listTileIcon: Transform.rotate( + angle: 1.5708, child: const Icon(Icons.insert_chart)), title: 'Horizontal Pattern Forward Hatch Bar Chart', subtitle: 'Horizontal Pattern Forward Hatch Bar Chart', childBuilder: () => - new HorizontalPatternForwardHatchBarChart.withRandomData(), + HorizontalPatternForwardHatchBarChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Weight Pattern Bar Chart', subtitle: 'Grouped and stacked bar chart with a weight pattern', - childBuilder: () => - new GroupedStackedWeightPatternBarChart.withRandomData(), + childBuilder: () => GroupedStackedWeightPatternBarChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Bar Chart with custom bar radius', subtitle: 'Custom rounded bar corners', - childBuilder: () => new CustomRoundedBars.withRandomData(), + childBuilder: () => CustomRoundedBars.withRandomData(), ), ]; } diff --git a/web/charts/lib/bar_chart/custom_rounded_bars.dart b/web/charts/lib/bar_chart/custom_rounded_bars.dart index 7de5587f0..a3fbd2d4d 100644 --- a/web/charts/lib/bar_chart/custom_rounded_bars.dart +++ b/web/charts/lib/bar_chart/custom_rounded_bars.dart @@ -24,11 +24,12 @@ class CustomRoundedBars extends StatelessWidget { final List seriesList; final bool animate; - CustomRoundedBars(this.seriesList, {this.animate}); + const CustomRoundedBars(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [BarChart] with custom rounded bars. factory CustomRoundedBars.withSampleData() { - return new CustomRoundedBars( + return CustomRoundedBars( _createSampleData(), // Disable animations for image tests. animate: false, @@ -40,22 +41,22 @@ class CustomRoundedBars extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory CustomRoundedBars.withRandomData() { - return new CustomRoundedBars(_createRandomData()); + return CustomRoundedBars(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (OrdinalSales sales, _) => sales.year, @@ -68,10 +69,10 @@ class CustomRoundedBars extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, - defaultRenderer: new charts.BarRendererConfig( + defaultRenderer: charts.BarRendererConfig( // By default, bar renderer will draw rounded bars with a constant // radius of 30. // To not have any rounded corners, use [NoCornerStrategy] @@ -83,14 +84,14 @@ class CustomRoundedBars extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (OrdinalSales sales, _) => sales.year, diff --git a/web/charts/lib/bar_chart/grouped.dart b/web/charts/lib/bar_chart/grouped.dart index f6e874aaf..dcfbd7b08 100644 --- a/web/charts/lib/bar_chart/grouped.dart +++ b/web/charts/lib/bar_chart/grouped.dart @@ -24,10 +24,11 @@ class GroupedBarChart extends StatelessWidget { final List seriesList; final bool animate; - GroupedBarChart(this.seriesList, {this.animate}); + const GroupedBarChart(this.seriesList, {this.animate, Key key}) + : super(key: key); factory GroupedBarChart.withSampleData() { - return new GroupedBarChart( + return GroupedBarChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -39,48 +40,48 @@ class GroupedBarChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory GroupedBarChart.withRandomData() { - return new GroupedBarChart(_createRandomData()); + return GroupedBarChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final desktopSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final tableSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final mobileSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -92,7 +93,7 @@ class GroupedBarChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, barGroupingType: charts.BarGroupingType.grouped, @@ -102,40 +103,40 @@ class GroupedBarChart extends StatelessWidget { /// Create series list with multiple series static List> _createSampleData() { final desktopSalesData = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tableSalesData = [ - new OrdinalSales('2014', 25), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 10), - new OrdinalSales('2017', 20), + OrdinalSales('2014', 25), + OrdinalSales('2015', 50), + OrdinalSales('2016', 10), + OrdinalSales('2017', 20), ]; final mobileSalesData = [ - new OrdinalSales('2014', 10), - new OrdinalSales('2015', 15), - new OrdinalSales('2016', 50), - new OrdinalSales('2017', 45), + OrdinalSales('2014', 10), + OrdinalSales('2015', 15), + OrdinalSales('2016', 50), + OrdinalSales('2017', 45), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/bar_chart/grouped_fill_color.dart b/web/charts/lib/bar_chart/grouped_fill_color.dart index fb34a3f73..a3f22d7f1 100644 --- a/web/charts/lib/bar_chart/grouped_fill_color.dart +++ b/web/charts/lib/bar_chart/grouped_fill_color.dart @@ -26,10 +26,11 @@ class GroupedFillColorBarChart extends StatelessWidget { final List seriesList; final bool animate; - GroupedFillColorBarChart(this.seriesList, {this.animate}); + const GroupedFillColorBarChart(this.seriesList, {this.animate, Key key}) + : super(key: key); factory GroupedFillColorBarChart.withSampleData() { - return new GroupedFillColorBarChart( + return GroupedFillColorBarChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -41,37 +42,37 @@ class GroupedFillColorBarChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory GroupedFillColorBarChart.withRandomData() { - return new GroupedFillColorBarChart(_createRandomData()); + return GroupedFillColorBarChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final desktopSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final tableSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final mobileSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ // Blue bars with a lighter center color. - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -82,7 +83,7 @@ class GroupedFillColorBarChart extends StatelessWidget { ), // Solid red bars. Fill color will default to the series color if no // fillColorFn is configured. - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -90,7 +91,7 @@ class GroupedFillColorBarChart extends StatelessWidget { colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault, ), // Hollow green bars. - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -104,11 +105,11 @@ class GroupedFillColorBarChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, // Configure a stroke width to enable borders on the bars. - defaultRenderer: new charts.BarRendererConfig( + defaultRenderer: charts.BarRendererConfig( groupingType: charts.BarGroupingType.grouped, strokeWidthPx: 2.0), ); } @@ -116,29 +117,29 @@ class GroupedFillColorBarChart extends StatelessWidget { /// Create series list with multiple series static List> _createSampleData() { final desktopSalesData = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tableSalesData = [ - new OrdinalSales('2014', 25), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 10), - new OrdinalSales('2017', 20), + OrdinalSales('2014', 25), + OrdinalSales('2015', 50), + OrdinalSales('2016', 10), + OrdinalSales('2017', 20), ]; final mobileSalesData = [ - new OrdinalSales('2014', 10), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 50), - new OrdinalSales('2017', 45), + OrdinalSales('2014', 10), + OrdinalSales('2015', 50), + OrdinalSales('2016', 50), + OrdinalSales('2017', 45), ]; return [ // Blue bars with a lighter center color. - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -149,7 +150,7 @@ class GroupedFillColorBarChart extends StatelessWidget { ), // Solid red bars. Fill color will default to the series color if no // fillColorFn is configured. - new charts.Series( + charts.Series( id: 'Tablet', measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesData, @@ -157,7 +158,7 @@ class GroupedFillColorBarChart extends StatelessWidget { domainFn: (OrdinalSales sales, _) => sales.year, ), // Hollow green bars. - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/bar_chart/grouped_single_target_line.dart b/web/charts/lib/bar_chart/grouped_single_target_line.dart index 3a18c0e23..efb464e05 100644 --- a/web/charts/lib/bar_chart/grouped_single_target_line.dart +++ b/web/charts/lib/bar_chart/grouped_single_target_line.dart @@ -24,10 +24,12 @@ class GroupedBarSingleTargetLineChart extends StatelessWidget { final List seriesList; final bool animate; - GroupedBarSingleTargetLineChart(this.seriesList, {this.animate}); + const GroupedBarSingleTargetLineChart(this.seriesList, + {this.animate, Key key}) + : super(key: key); factory GroupedBarSingleTargetLineChart.withSampleData() { - return new GroupedBarSingleTargetLineChart( + return GroupedBarSingleTargetLineChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -39,58 +41,58 @@ class GroupedBarSingleTargetLineChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory GroupedBarSingleTargetLineChart.withRandomData() { - return new GroupedBarSingleTargetLineChart(_createRandomData()); + return GroupedBarSingleTargetLineChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final desktopSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final tableSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final mobileSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final targetLineData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesData), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: mobileSalesData), - new charts.Series( + charts.Series( id: 'Desktop Target Line', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -103,11 +105,11 @@ class GroupedBarSingleTargetLineChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart(seriesList, + return charts.BarChart(seriesList, animate: animate, barGroupingType: charts.BarGroupingType.grouped, customSeriesRenderers: [ - new charts.BarTargetLineRendererConfig( + charts.BarTargetLineRendererConfig( // ID used to link series to this renderer. customRendererId: 'customTargetLine', groupingType: charts.BarGroupingType.grouped) @@ -117,50 +119,50 @@ class GroupedBarSingleTargetLineChart extends StatelessWidget { /// Create series list with multiple series static List> _createSampleData() { final desktopSalesData = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tableSalesData = [ - new OrdinalSales('2014', 25), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 10), - new OrdinalSales('2017', 20), + OrdinalSales('2014', 25), + OrdinalSales('2015', 50), + OrdinalSales('2016', 10), + OrdinalSales('2017', 20), ]; final mobileSalesData = [ - new OrdinalSales('2014', 10), - new OrdinalSales('2015', 15), - new OrdinalSales('2016', 50), - new OrdinalSales('2017', 45), + OrdinalSales('2014', 10), + OrdinalSales('2015', 15), + OrdinalSales('2016', 50), + OrdinalSales('2017', 45), ]; final targetLineData = [ - new OrdinalSales('2014', 30), - new OrdinalSales('2015', 55), - new OrdinalSales('2016', 15), - new OrdinalSales('2017', 25), + OrdinalSales('2014', 30), + OrdinalSales('2015', 55), + OrdinalSales('2016', 15), + OrdinalSales('2017', 25), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesData), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: mobileSalesData), - new charts.Series( + charts.Series( id: 'Desktop Target Line', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/bar_chart/grouped_stacked.dart b/web/charts/lib/bar_chart/grouped_stacked.dart index be224f2f1..968959347 100644 --- a/web/charts/lib/bar_chart/grouped_stacked.dart +++ b/web/charts/lib/bar_chart/grouped_stacked.dart @@ -24,10 +24,11 @@ class GroupedStackedBarChart extends StatelessWidget { final List seriesList; final bool animate; - GroupedStackedBarChart(this.seriesList, {this.animate}); + const GroupedStackedBarChart(this.seriesList, {this.animate, Key key}) + : super(key: key); factory GroupedStackedBarChart.withSampleData() { - return new GroupedStackedBarChart( + return GroupedStackedBarChart( createSampleData(), // Disable animations for image tests. animate: false, @@ -39,92 +40,92 @@ class GroupedStackedBarChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory GroupedStackedBarChart.withRandomData() { - return new GroupedStackedBarChart(_createRandomData()); + return GroupedStackedBarChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final desktopSalesDataA = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final tableSalesDataA = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final mobileSalesDataA = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final desktopSalesDataB = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final tableSalesDataB = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final mobileSalesDataB = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop A', seriesCategory: 'A', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesDataA, ), - new charts.Series( + charts.Series( id: 'Tablet A', seriesCategory: 'A', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesDataA, ), - new charts.Series( + charts.Series( id: 'Mobile A', seriesCategory: 'A', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: mobileSalesDataA, ), - new charts.Series( + charts.Series( id: 'Desktop B', seriesCategory: 'B', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesDataB, ), - new charts.Series( + charts.Series( id: 'Tablet B', seriesCategory: 'B', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesDataB, ), - new charts.Series( + charts.Series( id: 'Mobile B', seriesCategory: 'B', domainFn: (OrdinalSales sales, _) => sales.year, @@ -137,7 +138,7 @@ class GroupedStackedBarChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, barGroupingType: charts.BarGroupingType.groupedStacked, @@ -147,84 +148,84 @@ class GroupedStackedBarChart extends StatelessWidget { /// Create series list with multiple series static List> createSampleData() { final desktopSalesDataA = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tableSalesDataA = [ - new OrdinalSales('2014', 25), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 10), - new OrdinalSales('2017', 20), + OrdinalSales('2014', 25), + OrdinalSales('2015', 50), + OrdinalSales('2016', 10), + OrdinalSales('2017', 20), ]; final mobileSalesDataA = [ - new OrdinalSales('2014', 10), - new OrdinalSales('2015', 15), - new OrdinalSales('2016', 50), - new OrdinalSales('2017', 45), + OrdinalSales('2014', 10), + OrdinalSales('2015', 15), + OrdinalSales('2016', 50), + OrdinalSales('2017', 45), ]; final desktopSalesDataB = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tableSalesDataB = [ - new OrdinalSales('2014', 25), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 10), - new OrdinalSales('2017', 20), + OrdinalSales('2014', 25), + OrdinalSales('2015', 50), + OrdinalSales('2016', 10), + OrdinalSales('2017', 20), ]; final mobileSalesDataB = [ - new OrdinalSales('2014', 10), - new OrdinalSales('2015', 15), - new OrdinalSales('2016', 50), - new OrdinalSales('2017', 45), + OrdinalSales('2014', 10), + OrdinalSales('2015', 15), + OrdinalSales('2016', 50), + OrdinalSales('2017', 45), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop A', seriesCategory: 'A', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesDataA, ), - new charts.Series( + charts.Series( id: 'Tablet A', seriesCategory: 'A', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesDataA, ), - new charts.Series( + charts.Series( id: 'Mobile A', seriesCategory: 'A', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: mobileSalesDataA, ), - new charts.Series( + charts.Series( id: 'Desktop B', seriesCategory: 'B', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesDataB, ), - new charts.Series( + charts.Series( id: 'Tablet B', seriesCategory: 'B', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesDataB, ), - new charts.Series( + charts.Series( id: 'Mobile B', seriesCategory: 'B', domainFn: (OrdinalSales sales, _) => sales.year, diff --git a/web/charts/lib/bar_chart/grouped_stacked_weight_pattern.dart b/web/charts/lib/bar_chart/grouped_stacked_weight_pattern.dart index 5f3ebf51f..367024507 100644 --- a/web/charts/lib/bar_chart/grouped_stacked_weight_pattern.dart +++ b/web/charts/lib/bar_chart/grouped_stacked_weight_pattern.dart @@ -28,10 +28,12 @@ class GroupedStackedWeightPatternBarChart extends StatelessWidget { final List seriesList; final bool animate; - GroupedStackedWeightPatternBarChart(this.seriesList, {this.animate}); + const GroupedStackedWeightPatternBarChart(this.seriesList, + {this.animate, Key key}) + : super(key: key); factory GroupedStackedWeightPatternBarChart.withSampleData() { - return new GroupedStackedWeightPatternBarChart( + return GroupedStackedWeightPatternBarChart( createSampleData(), // Disable animations for image tests. animate: false, @@ -43,92 +45,92 @@ class GroupedStackedWeightPatternBarChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory GroupedStackedWeightPatternBarChart.withRandomData() { - return new GroupedStackedWeightPatternBarChart(_createRandomData()); + return GroupedStackedWeightPatternBarChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final desktopSalesDataA = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final tableSalesDataA = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final mobileSalesDataA = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final desktopSalesDataB = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final tableSalesDataB = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final mobileSalesDataB = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop A', seriesCategory: 'A', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesDataA, ), - new charts.Series( + charts.Series( id: 'Tablet A', seriesCategory: 'A', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesDataA, ), - new charts.Series( + charts.Series( id: 'Mobile A', seriesCategory: 'A', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: mobileSalesDataA, ), - new charts.Series( + charts.Series( id: 'Desktop B', seriesCategory: 'B', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesDataB, ), - new charts.Series( + charts.Series( id: 'Tablet B', seriesCategory: 'B', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesDataB, ), - new charts.Series( + charts.Series( id: 'Mobile B', seriesCategory: 'B', domainFn: (OrdinalSales sales, _) => sales.year, @@ -141,7 +143,7 @@ class GroupedStackedWeightPatternBarChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, // Configure the bar renderer in grouped stacked rendering mode with a @@ -149,7 +151,7 @@ class GroupedStackedWeightPatternBarChart extends StatelessWidget { // // The first stack of bars in each group is configured to be twice as wide // as the second stack of bars in each group. - defaultRenderer: new charts.BarRendererConfig( + defaultRenderer: charts.BarRendererConfig( groupingType: charts.BarGroupingType.groupedStacked, weightPattern: [2, 1], ), @@ -159,84 +161,84 @@ class GroupedStackedWeightPatternBarChart extends StatelessWidget { /// Create series list with multiple series static List> createSampleData() { final desktopSalesDataA = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tableSalesDataA = [ - new OrdinalSales('2014', 25), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 10), - new OrdinalSales('2017', 20), + OrdinalSales('2014', 25), + OrdinalSales('2015', 50), + OrdinalSales('2016', 10), + OrdinalSales('2017', 20), ]; final mobileSalesDataA = [ - new OrdinalSales('2014', 10), - new OrdinalSales('2015', 15), - new OrdinalSales('2016', 50), - new OrdinalSales('2017', 45), + OrdinalSales('2014', 10), + OrdinalSales('2015', 15), + OrdinalSales('2016', 50), + OrdinalSales('2017', 45), ]; final desktopSalesDataB = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tableSalesDataB = [ - new OrdinalSales('2014', 25), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 10), - new OrdinalSales('2017', 20), + OrdinalSales('2014', 25), + OrdinalSales('2015', 50), + OrdinalSales('2016', 10), + OrdinalSales('2017', 20), ]; final mobileSalesDataB = [ - new OrdinalSales('2014', 10), - new OrdinalSales('2015', 15), - new OrdinalSales('2016', 50), - new OrdinalSales('2017', 45), + OrdinalSales('2014', 10), + OrdinalSales('2015', 15), + OrdinalSales('2016', 50), + OrdinalSales('2017', 45), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop A', seriesCategory: 'A', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesDataA, ), - new charts.Series( + charts.Series( id: 'Tablet A', seriesCategory: 'A', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesDataA, ), - new charts.Series( + charts.Series( id: 'Mobile A', seriesCategory: 'A', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: mobileSalesDataA, ), - new charts.Series( + charts.Series( id: 'Desktop B', seriesCategory: 'B', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesDataB, ), - new charts.Series( + charts.Series( id: 'Tablet B', seriesCategory: 'B', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesDataB, ), - new charts.Series( + charts.Series( id: 'Mobile B', seriesCategory: 'B', domainFn: (OrdinalSales sales, _) => sales.year, diff --git a/web/charts/lib/bar_chart/grouped_target_line.dart b/web/charts/lib/bar_chart/grouped_target_line.dart index bdbec34ff..776e336b7 100644 --- a/web/charts/lib/bar_chart/grouped_target_line.dart +++ b/web/charts/lib/bar_chart/grouped_target_line.dart @@ -24,10 +24,11 @@ class GroupedBarTargetLineChart extends StatelessWidget { final List seriesList; final bool animate; - GroupedBarTargetLineChart(this.seriesList, {this.animate}); + const GroupedBarTargetLineChart(this.seriesList, {this.animate, Key key}) + : super(key: key); factory GroupedBarTargetLineChart.withSampleData() { - return new GroupedBarTargetLineChart( + return GroupedBarTargetLineChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -39,75 +40,75 @@ class GroupedBarTargetLineChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory GroupedBarTargetLineChart.withRandomData() { - return new GroupedBarTargetLineChart(_createRandomData()); + return GroupedBarTargetLineChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final desktopSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final tableSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final mobileSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final desktopTargetLineData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final tableTargetLineData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final mobileTargetLineData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: mobileSalesData, ), - new charts.Series( + charts.Series( id: 'Desktop Target Line', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -115,7 +116,7 @@ class GroupedBarTargetLineChart extends StatelessWidget { ) // Configure our custom bar target renderer for this series. ..setAttribute(charts.rendererIdKey, 'customTargetLine'), - new charts.Series( + charts.Series( id: 'Tablet Target Line', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -123,7 +124,7 @@ class GroupedBarTargetLineChart extends StatelessWidget { ) // Configure our custom bar target renderer for this series. ..setAttribute(charts.rendererIdKey, 'customTargetLine'), - new charts.Series( + charts.Series( id: 'Mobile Target Line', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -137,11 +138,11 @@ class GroupedBarTargetLineChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart(seriesList, + return charts.BarChart(seriesList, animate: animate, barGroupingType: charts.BarGroupingType.grouped, customSeriesRenderers: [ - new charts.BarTargetLineRendererConfig( + charts.BarTargetLineRendererConfig( // ID used to link series to this renderer. customRendererId: 'customTargetLine', groupingType: charts.BarGroupingType.grouped) @@ -151,67 +152,67 @@ class GroupedBarTargetLineChart extends StatelessWidget { /// Create series list with multiple series static List> _createSampleData() { final desktopSalesData = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tableSalesData = [ - new OrdinalSales('2014', 25), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 10), - new OrdinalSales('2017', 20), + OrdinalSales('2014', 25), + OrdinalSales('2015', 50), + OrdinalSales('2016', 10), + OrdinalSales('2017', 20), ]; final mobileSalesData = [ - new OrdinalSales('2014', 10), - new OrdinalSales('2015', 15), - new OrdinalSales('2016', 50), - new OrdinalSales('2017', 45), + OrdinalSales('2014', 10), + OrdinalSales('2015', 15), + OrdinalSales('2016', 50), + OrdinalSales('2017', 45), ]; final desktopTargetLineData = [ - new OrdinalSales('2014', 4), - new OrdinalSales('2015', 20), - new OrdinalSales('2016', 80), - new OrdinalSales('2017', 65), + OrdinalSales('2014', 4), + OrdinalSales('2015', 20), + OrdinalSales('2016', 80), + OrdinalSales('2017', 65), ]; final tableTargetLineData = [ - new OrdinalSales('2014', 30), - new OrdinalSales('2015', 55), - new OrdinalSales('2016', 15), - new OrdinalSales('2017', 25), + OrdinalSales('2014', 30), + OrdinalSales('2015', 55), + OrdinalSales('2016', 15), + OrdinalSales('2017', 25), ]; final mobileTargetLineData = [ - new OrdinalSales('2014', 10), - new OrdinalSales('2015', 5), - new OrdinalSales('2016', 45), - new OrdinalSales('2017', 35), + OrdinalSales('2014', 10), + OrdinalSales('2015', 5), + OrdinalSales('2016', 45), + OrdinalSales('2017', 35), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: mobileSalesData, ), - new charts.Series( + charts.Series( id: 'Desktop Target Line', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -219,7 +220,7 @@ class GroupedBarTargetLineChart extends StatelessWidget { ) // Configure our custom bar target renderer for this series. ..setAttribute(charts.rendererIdKey, 'customTargetLine'), - new charts.Series( + charts.Series( id: 'Tablet Target Line', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -227,7 +228,7 @@ class GroupedBarTargetLineChart extends StatelessWidget { ) // Configure our custom bar target renderer for this series. ..setAttribute(charts.rendererIdKey, 'customTargetLine'), - new charts.Series( + charts.Series( id: 'Mobile Target Line', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/bar_chart/horizontal.dart b/web/charts/lib/bar_chart/horizontal.dart index b12bd8159..3241919e3 100644 --- a/web/charts/lib/bar_chart/horizontal.dart +++ b/web/charts/lib/bar_chart/horizontal.dart @@ -24,11 +24,12 @@ class HorizontalBarChart extends StatelessWidget { final List seriesList; final bool animate; - HorizontalBarChart(this.seriesList, {this.animate}); + const HorizontalBarChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [BarChart] with sample data and no transition. factory HorizontalBarChart.withSampleData() { - return new HorizontalBarChart( + return HorizontalBarChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -40,22 +41,22 @@ class HorizontalBarChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory HorizontalBarChart.withRandomData() { - return new HorizontalBarChart(_createRandomData()); + return HorizontalBarChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -68,7 +69,7 @@ class HorizontalBarChart extends StatelessWidget { @override Widget build(BuildContext context) { // For horizontal bar charts, set the [vertical] flag to false. - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, vertical: false, @@ -78,14 +79,14 @@ class HorizontalBarChart extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/bar_chart/horizontal_bar_label.dart b/web/charts/lib/bar_chart/horizontal_bar_label.dart index 98b14ecc0..f0dc4ed63 100644 --- a/web/charts/lib/bar_chart/horizontal_bar_label.dart +++ b/web/charts/lib/bar_chart/horizontal_bar_label.dart @@ -24,11 +24,12 @@ class HorizontalBarLabelChart extends StatelessWidget { final List seriesList; final bool animate; - HorizontalBarLabelChart(this.seriesList, {this.animate}); + const HorizontalBarLabelChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [BarChart] with sample data and no transition. factory HorizontalBarLabelChart.withSampleData() { - return new HorizontalBarLabelChart( + return HorizontalBarLabelChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -40,22 +41,22 @@ class HorizontalBarLabelChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory HorizontalBarLabelChart.withRandomData() { - return new HorizontalBarLabelChart(_createRandomData()); + return HorizontalBarLabelChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -76,7 +77,7 @@ class HorizontalBarLabelChart extends StatelessWidget { // [insideLabelStyleSpec] and [outsideLabelStyleSpec]. @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, vertical: false, @@ -85,24 +86,24 @@ class HorizontalBarLabelChart extends StatelessWidget { // barRendererDecorator: new charts.BarLabelDecorator( // insideLabelStyleSpec: new charts.TextStyleSpec(...), // outsideLabelStyleSpec: new charts.TextStyleSpec(...)), - barRendererDecorator: new charts.BarLabelDecorator(), + barRendererDecorator: charts.BarLabelDecorator(), // Hide domain axis. domainAxis: - new charts.OrdinalAxisSpec(renderSpec: new charts.NoneRenderSpec()), + const charts.OrdinalAxisSpec(renderSpec: charts.NoneRenderSpec()), ); } /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/bar_chart/horizontal_bar_label_custom.dart b/web/charts/lib/bar_chart/horizontal_bar_label_custom.dart index 7dd34d524..a43a088d5 100644 --- a/web/charts/lib/bar_chart/horizontal_bar_label_custom.dart +++ b/web/charts/lib/bar_chart/horizontal_bar_label_custom.dart @@ -24,11 +24,12 @@ class HorizontalBarLabelCustomChart extends StatelessWidget { final List seriesList; final bool animate; - HorizontalBarLabelCustomChart(this.seriesList, {this.animate}); + const HorizontalBarLabelCustomChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [BarChart] with sample data and no transition. static HorizontalBarLabelCustomChart createWithSampleData() { - return new HorizontalBarLabelCustomChart( + return HorizontalBarLabelCustomChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -40,22 +41,22 @@ class HorizontalBarLabelCustomChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory HorizontalBarLabelCustomChart.withRandomData() { - return new HorizontalBarLabelCustomChart(_createRandomData()); + return HorizontalBarLabelCustomChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -67,13 +68,13 @@ class HorizontalBarLabelCustomChart extends StatelessWidget { final color = (sales.year == '2014') ? charts.MaterialPalette.red.shadeDefault : charts.MaterialPalette.yellow.shadeDefault.darker; - return new charts.TextStyleSpec(color: color); + return charts.TextStyleSpec(color: color); }, outsideLabelStyleAccessorFn: (OrdinalSales sales, _) { final color = (sales.year == '2014') ? charts.MaterialPalette.red.shadeDefault : charts.MaterialPalette.yellow.shadeDefault.darker; - return new charts.TextStyleSpec(color: color); + return charts.TextStyleSpec(color: color); }, ), ]; @@ -85,28 +86,28 @@ class HorizontalBarLabelCustomChart extends StatelessWidget { // style, set the style accessor functions on the series. @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, vertical: false, - barRendererDecorator: new charts.BarLabelDecorator(), + barRendererDecorator: charts.BarLabelDecorator(), // Hide domain axis. domainAxis: - new charts.OrdinalAxisSpec(renderSpec: new charts.NoneRenderSpec()), + const charts.OrdinalAxisSpec(renderSpec: charts.NoneRenderSpec()), ); } /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -118,13 +119,13 @@ class HorizontalBarLabelCustomChart extends StatelessWidget { final color = (sales.year == '2014') ? charts.MaterialPalette.red.shadeDefault : charts.MaterialPalette.yellow.shadeDefault.darker; - return new charts.TextStyleSpec(color: color); + return charts.TextStyleSpec(color: color); }, outsideLabelStyleAccessorFn: (OrdinalSales sales, _) { final color = (sales.year == '2014') ? charts.MaterialPalette.red.shadeDefault : charts.MaterialPalette.yellow.shadeDefault.darker; - return new charts.TextStyleSpec(color: color); + return charts.TextStyleSpec(color: color); }, ), ]; diff --git a/web/charts/lib/bar_chart/horizontal_pattern_forward_hatch.dart b/web/charts/lib/bar_chart/horizontal_pattern_forward_hatch.dart index e89c510d9..ef45de2b4 100644 --- a/web/charts/lib/bar_chart/horizontal_pattern_forward_hatch.dart +++ b/web/charts/lib/bar_chart/horizontal_pattern_forward_hatch.dart @@ -28,10 +28,12 @@ class HorizontalPatternForwardHatchBarChart extends StatelessWidget { final List seriesList; final bool animate; - HorizontalPatternForwardHatchBarChart(this.seriesList, {this.animate}); + const HorizontalPatternForwardHatchBarChart(this.seriesList, + {this.animate, Key key}) + : super(key: key); factory HorizontalPatternForwardHatchBarChart.withSampleData() { - return new HorizontalPatternForwardHatchBarChart( + return HorizontalPatternForwardHatchBarChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -43,42 +45,42 @@ class HorizontalPatternForwardHatchBarChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory HorizontalPatternForwardHatchBarChart.withRandomData() { - return new HorizontalPatternForwardHatchBarChart(_createRandomData()); + return HorizontalPatternForwardHatchBarChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final desktopSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final tableSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final mobileSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -86,7 +88,7 @@ class HorizontalPatternForwardHatchBarChart extends StatelessWidget { fillPatternFn: (OrdinalSales sales, _) => charts.FillPatternType.forwardHatch, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -98,7 +100,7 @@ class HorizontalPatternForwardHatchBarChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, barGroupingType: charts.BarGroupingType.grouped, @@ -109,34 +111,34 @@ class HorizontalPatternForwardHatchBarChart extends StatelessWidget { /// Create series list with multiple series static List> _createSampleData() { final desktopSalesData = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tableSalesData = [ - new OrdinalSales('2014', 25), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 10), - new OrdinalSales('2017', 20), + OrdinalSales('2014', 25), + OrdinalSales('2015', 50), + OrdinalSales('2016', 10), + OrdinalSales('2017', 20), ]; final mobileSalesData = [ - new OrdinalSales('2014', 10), - new OrdinalSales('2015', 15), - new OrdinalSales('2016', 50), - new OrdinalSales('2017', 45), + OrdinalSales('2014', 10), + OrdinalSales('2015', 15), + OrdinalSales('2016', 50), + OrdinalSales('2017', 45), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -144,7 +146,7 @@ class HorizontalPatternForwardHatchBarChart extends StatelessWidget { fillPatternFn: (OrdinalSales sales, _) => charts.FillPatternType.forwardHatch, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/bar_chart/pattern_forward_hatch.dart b/web/charts/lib/bar_chart/pattern_forward_hatch.dart index 14e3bd4e6..8a251d7cf 100644 --- a/web/charts/lib/bar_chart/pattern_forward_hatch.dart +++ b/web/charts/lib/bar_chart/pattern_forward_hatch.dart @@ -27,10 +27,11 @@ class PatternForwardHatchBarChart extends StatelessWidget { final List seriesList; final bool animate; - PatternForwardHatchBarChart(this.seriesList, {this.animate}); + const PatternForwardHatchBarChart(this.seriesList, {this.animate, Key key}) + : super(key: key); factory PatternForwardHatchBarChart.withSampleData() { - return new PatternForwardHatchBarChart( + return PatternForwardHatchBarChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -42,42 +43,42 @@ class PatternForwardHatchBarChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory PatternForwardHatchBarChart.withRandomData() { - return new PatternForwardHatchBarChart(_createRandomData()); + return PatternForwardHatchBarChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final desktopSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final tableSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final mobileSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -85,7 +86,7 @@ class PatternForwardHatchBarChart extends StatelessWidget { fillPatternFn: (OrdinalSales sales, _) => charts.FillPatternType.forwardHatch, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -97,7 +98,7 @@ class PatternForwardHatchBarChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, barGroupingType: charts.BarGroupingType.grouped, @@ -107,34 +108,34 @@ class PatternForwardHatchBarChart extends StatelessWidget { /// Create series list with multiple series static List> _createSampleData() { final desktopSalesData = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tableSalesData = [ - new OrdinalSales('2014', 25), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 10), - new OrdinalSales('2017', 20), + OrdinalSales('2014', 25), + OrdinalSales('2015', 50), + OrdinalSales('2016', 10), + OrdinalSales('2017', 20), ]; final mobileSalesData = [ - new OrdinalSales('2014', 10), - new OrdinalSales('2015', 15), - new OrdinalSales('2016', 50), - new OrdinalSales('2017', 45), + OrdinalSales('2014', 10), + OrdinalSales('2015', 15), + OrdinalSales('2016', 50), + OrdinalSales('2017', 45), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -142,7 +143,7 @@ class PatternForwardHatchBarChart extends StatelessWidget { fillPatternFn: (OrdinalSales sales, _) => charts.FillPatternType.forwardHatch, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/bar_chart/simple.dart b/web/charts/lib/bar_chart/simple.dart index b1d13bf14..8fc3f64ab 100644 --- a/web/charts/lib/bar_chart/simple.dart +++ b/web/charts/lib/bar_chart/simple.dart @@ -24,11 +24,12 @@ class SimpleBarChart extends StatelessWidget { final List seriesList; final bool animate; - SimpleBarChart(this.seriesList, {this.animate}); + const SimpleBarChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [BarChart] with sample data and no transition. factory SimpleBarChart.withSampleData() { - return new SimpleBarChart( + return SimpleBarChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -40,22 +41,22 @@ class SimpleBarChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory SimpleBarChart.withRandomData() { - return new SimpleBarChart(_createRandomData()); + return SimpleBarChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (OrdinalSales sales, _) => sales.year, @@ -68,7 +69,7 @@ class SimpleBarChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, ); @@ -77,14 +78,14 @@ class SimpleBarChart extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (OrdinalSales sales, _) => sales.year, diff --git a/web/charts/lib/bar_chart/spark_bar.dart b/web/charts/lib/bar_chart/spark_bar.dart index aadb35f1f..e388bfda0 100644 --- a/web/charts/lib/bar_chart/spark_bar.dart +++ b/web/charts/lib/bar_chart/spark_bar.dart @@ -25,10 +25,10 @@ class SparkBar extends StatelessWidget { final List seriesList; final bool animate; - SparkBar(this.seriesList, {this.animate}); + const SparkBar(this.seriesList, {this.animate, Key key}) : super(key: key); factory SparkBar.withSampleData() { - return new SparkBar( + return SparkBar( _createSampleData(), // Disable animations for image tests. animate: false, @@ -40,29 +40,29 @@ class SparkBar extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory SparkBar.withRandomData() { - return new SparkBar(_createRandomData()); + return SparkBar(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final globalSalesData = [ - new OrdinalSales('2007', random.nextInt(100)), - new OrdinalSales('2008', random.nextInt(100)), - new OrdinalSales('2009', random.nextInt(100)), - new OrdinalSales('2010', random.nextInt(100)), - new OrdinalSales('2011', random.nextInt(100)), - new OrdinalSales('2012', random.nextInt(100)), - new OrdinalSales('2013', random.nextInt(100)), - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2007', random.nextInt(100)), + OrdinalSales('2008', random.nextInt(100)), + OrdinalSales('2009', random.nextInt(100)), + OrdinalSales('2010', random.nextInt(100)), + OrdinalSales('2011', random.nextInt(100)), + OrdinalSales('2012', random.nextInt(100)), + OrdinalSales('2013', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Global Revenue', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -74,7 +74,7 @@ class SparkBar extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, @@ -83,45 +83,45 @@ class SparkBar extends StatelessWidget { /// The NoneRenderSpec only draws an axis line (and even that can be hidden /// with showAxisLine=false). primaryMeasureAxis: - new charts.NumericAxisSpec(renderSpec: new charts.NoneRenderSpec()), + const charts.NumericAxisSpec(renderSpec: charts.NoneRenderSpec()), /// This is an OrdinalAxisSpec to match up with BarChart's default /// ordinal domain axis (use NumericAxisSpec or DateTimeAxisSpec for /// other charts). - domainAxis: new charts.OrdinalAxisSpec( + domainAxis: const charts.OrdinalAxisSpec( // Make sure that we draw the domain axis line. showAxisLine: true, // But don't draw anything else. - renderSpec: new charts.NoneRenderSpec()), + renderSpec: charts.NoneRenderSpec()), // With a spark chart we likely don't want large chart margins. // 1px is the smallest we can make each margin. - layoutConfig: new charts.LayoutConfig( - leftMarginSpec: new charts.MarginSpec.fixedPixel(0), - topMarginSpec: new charts.MarginSpec.fixedPixel(0), - rightMarginSpec: new charts.MarginSpec.fixedPixel(0), - bottomMarginSpec: new charts.MarginSpec.fixedPixel(0)), + layoutConfig: charts.LayoutConfig( + leftMarginSpec: charts.MarginSpec.fixedPixel(0), + topMarginSpec: charts.MarginSpec.fixedPixel(0), + rightMarginSpec: charts.MarginSpec.fixedPixel(0), + bottomMarginSpec: charts.MarginSpec.fixedPixel(0)), ); } /// Create series list with single series static List> _createSampleData() { final globalSalesData = [ - new OrdinalSales('2007', 3100), - new OrdinalSales('2008', 3500), - new OrdinalSales('2009', 5000), - new OrdinalSales('2010', 2500), - new OrdinalSales('2011', 3200), - new OrdinalSales('2012', 4500), - new OrdinalSales('2013', 4400), - new OrdinalSales('2014', 5000), - new OrdinalSales('2015', 5000), - new OrdinalSales('2016', 4500), - new OrdinalSales('2017', 4300), + OrdinalSales('2007', 3100), + OrdinalSales('2008', 3500), + OrdinalSales('2009', 5000), + OrdinalSales('2010', 2500), + OrdinalSales('2011', 3200), + OrdinalSales('2012', 4500), + OrdinalSales('2013', 4400), + OrdinalSales('2014', 5000), + OrdinalSales('2015', 5000), + OrdinalSales('2016', 4500), + OrdinalSales('2017', 4300), ]; return [ - new charts.Series( + charts.Series( id: 'Global Revenue', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/bar_chart/stacked.dart b/web/charts/lib/bar_chart/stacked.dart index b3303fa22..f6a0aeba6 100644 --- a/web/charts/lib/bar_chart/stacked.dart +++ b/web/charts/lib/bar_chart/stacked.dart @@ -24,11 +24,12 @@ class StackedBarChart extends StatelessWidget { final List seriesList; final bool animate; - StackedBarChart(this.seriesList, {this.animate}); + const StackedBarChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a stacked [BarChart] with sample data and no transition. factory StackedBarChart.withSampleData() { - return new StackedBarChart( + return StackedBarChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -40,48 +41,48 @@ class StackedBarChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory StackedBarChart.withRandomData() { - return new StackedBarChart(_createRandomData()); + return StackedBarChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final desktopSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final tableSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final mobileSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -93,7 +94,7 @@ class StackedBarChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, barGroupingType: charts.BarGroupingType.stacked, @@ -103,40 +104,40 @@ class StackedBarChart extends StatelessWidget { /// Create series list with multiple series static List> _createSampleData() { final desktopSalesData = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tableSalesData = [ - new OrdinalSales('2014', 25), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 10), - new OrdinalSales('2017', 20), + OrdinalSales('2014', 25), + OrdinalSales('2015', 50), + OrdinalSales('2016', 10), + OrdinalSales('2017', 20), ]; final mobileSalesData = [ - new OrdinalSales('2014', 10), - new OrdinalSales('2015', 15), - new OrdinalSales('2016', 50), - new OrdinalSales('2017', 45), + OrdinalSales('2014', 10), + OrdinalSales('2015', 15), + OrdinalSales('2016', 50), + OrdinalSales('2017', 45), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/bar_chart/stacked_fill_color.dart b/web/charts/lib/bar_chart/stacked_fill_color.dart index 029b09640..e50d35b27 100644 --- a/web/charts/lib/bar_chart/stacked_fill_color.dart +++ b/web/charts/lib/bar_chart/stacked_fill_color.dart @@ -26,10 +26,11 @@ class StackedFillColorBarChart extends StatelessWidget { final List seriesList; final bool animate; - StackedFillColorBarChart(this.seriesList, {this.animate}); + const StackedFillColorBarChart(this.seriesList, {this.animate, Key key}) + : super(key: key); factory StackedFillColorBarChart.withSampleData() { - return new StackedFillColorBarChart( + return StackedFillColorBarChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -41,37 +42,37 @@ class StackedFillColorBarChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory StackedFillColorBarChart.withRandomData() { - return new StackedFillColorBarChart(_createRandomData()); + return StackedFillColorBarChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final desktopSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final tableSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final mobileSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ // Blue bars with a lighter center color. - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -82,7 +83,7 @@ class StackedFillColorBarChart extends StatelessWidget { ), // Solid red bars. Fill color will default to the series color if no // fillColorFn is configured. - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -90,7 +91,7 @@ class StackedFillColorBarChart extends StatelessWidget { colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault, ), // Hollow green bars. - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -104,11 +105,11 @@ class StackedFillColorBarChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, // Configure a stroke width to enable borders on the bars. - defaultRenderer: new charts.BarRendererConfig( + defaultRenderer: charts.BarRendererConfig( groupingType: charts.BarGroupingType.stacked, strokeWidthPx: 2.0), ); } @@ -116,29 +117,29 @@ class StackedFillColorBarChart extends StatelessWidget { /// Create series list with multiple series static List> _createSampleData() { final desktopSalesData = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tableSalesData = [ - new OrdinalSales('2014', 25), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 10), - new OrdinalSales('2017', 20), + OrdinalSales('2014', 25), + OrdinalSales('2015', 50), + OrdinalSales('2016', 10), + OrdinalSales('2017', 20), ]; final mobileSalesData = [ - new OrdinalSales('2014', 10), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 50), - new OrdinalSales('2017', 45), + OrdinalSales('2014', 10), + OrdinalSales('2015', 50), + OrdinalSales('2016', 50), + OrdinalSales('2017', 45), ]; return [ // Blue bars with a lighter center color. - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -149,7 +150,7 @@ class StackedFillColorBarChart extends StatelessWidget { ), // Solid red bars. Fill color will default to the series color if no // fillColorFn is configured. - new charts.Series( + charts.Series( id: 'Tablet', measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesData, @@ -157,7 +158,7 @@ class StackedFillColorBarChart extends StatelessWidget { domainFn: (OrdinalSales sales, _) => sales.year, ), // Hollow green bars. - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/bar_chart/stacked_horizontal.dart b/web/charts/lib/bar_chart/stacked_horizontal.dart index 8b7c66935..d43c9fd95 100644 --- a/web/charts/lib/bar_chart/stacked_horizontal.dart +++ b/web/charts/lib/bar_chart/stacked_horizontal.dart @@ -24,11 +24,12 @@ class StackedHorizontalBarChart extends StatelessWidget { final List seriesList; final bool animate; - StackedHorizontalBarChart(this.seriesList, {this.animate}); + const StackedHorizontalBarChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a stacked [BarChart] with sample data and no transition. factory StackedHorizontalBarChart.withSampleData() { - return new StackedHorizontalBarChart( + return StackedHorizontalBarChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -40,48 +41,48 @@ class StackedHorizontalBarChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory StackedHorizontalBarChart.withRandomData() { - return new StackedHorizontalBarChart(_createRandomData()); + return StackedHorizontalBarChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final desktopSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final tableSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final mobileSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -94,7 +95,7 @@ class StackedHorizontalBarChart extends StatelessWidget { @override Widget build(BuildContext context) { // For horizontal bar charts, set the [vertical] flag to false. - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, barGroupingType: charts.BarGroupingType.stacked, @@ -105,40 +106,40 @@ class StackedHorizontalBarChart extends StatelessWidget { /// Create series list with multiple series static List> _createSampleData() { final desktopSalesData = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tableSalesData = [ - new OrdinalSales('2014', 25), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 10), - new OrdinalSales('2017', 20), + OrdinalSales('2014', 25), + OrdinalSales('2015', 50), + OrdinalSales('2016', 10), + OrdinalSales('2017', 20), ]; final mobileSalesData = [ - new OrdinalSales('2014', 10), - new OrdinalSales('2015', 15), - new OrdinalSales('2016', 50), - new OrdinalSales('2017', 45), + OrdinalSales('2014', 10), + OrdinalSales('2015', 15), + OrdinalSales('2016', 50), + OrdinalSales('2017', 45), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/bar_chart/stacked_target_line.dart b/web/charts/lib/bar_chart/stacked_target_line.dart index 4a1252072..fac56a405 100644 --- a/web/charts/lib/bar_chart/stacked_target_line.dart +++ b/web/charts/lib/bar_chart/stacked_target_line.dart @@ -24,11 +24,12 @@ class StackedBarTargetLineChart extends StatelessWidget { final List seriesList; final bool animate; - StackedBarTargetLineChart(this.seriesList, {this.animate}); + const StackedBarTargetLineChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a stacked [BarChart] with sample data and no transition. factory StackedBarTargetLineChart.withSampleData() { - return new StackedBarTargetLineChart( + return StackedBarTargetLineChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -40,75 +41,75 @@ class StackedBarTargetLineChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory StackedBarTargetLineChart.withRandomData() { - return new StackedBarTargetLineChart(_createRandomData()); + return StackedBarTargetLineChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final desktopSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final tableSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final mobileSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final desktopTargetLineData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final tableTargetLineData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final mobileTargetLineData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: mobileSalesData, ), - new charts.Series( + charts.Series( id: 'Desktop Target Line', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -116,7 +117,7 @@ class StackedBarTargetLineChart extends StatelessWidget { ) // Configure our custom bar target renderer for this series. ..setAttribute(charts.rendererIdKey, 'customTargetLine'), - new charts.Series( + charts.Series( id: 'Tablet Target Line', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -124,7 +125,7 @@ class StackedBarTargetLineChart extends StatelessWidget { ) // Configure our custom bar target renderer for this series. ..setAttribute(charts.rendererIdKey, 'customTargetLine'), - new charts.Series( + charts.Series( id: 'Mobile Target Line', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -138,11 +139,11 @@ class StackedBarTargetLineChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart(seriesList, + return charts.BarChart(seriesList, animate: animate, barGroupingType: charts.BarGroupingType.stacked, customSeriesRenderers: [ - new charts.BarTargetLineRendererConfig( + charts.BarTargetLineRendererConfig( // ID used to link series to this renderer. customRendererId: 'customTargetLine', groupingType: charts.BarGroupingType.stacked) @@ -152,67 +153,67 @@ class StackedBarTargetLineChart extends StatelessWidget { /// Create series list with multiple series static List> _createSampleData() { final desktopSalesData = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tableSalesData = [ - new OrdinalSales('2014', 25), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 10), - new OrdinalSales('2017', 20), + OrdinalSales('2014', 25), + OrdinalSales('2015', 50), + OrdinalSales('2016', 10), + OrdinalSales('2017', 20), ]; final mobileSalesData = [ - new OrdinalSales('2014', 10), - new OrdinalSales('2015', 15), - new OrdinalSales('2016', 50), - new OrdinalSales('2017', 45), + OrdinalSales('2014', 10), + OrdinalSales('2015', 15), + OrdinalSales('2016', 50), + OrdinalSales('2017', 45), ]; final desktopTargetLineData = [ - new OrdinalSales('2014', 4), - new OrdinalSales('2015', 20), - new OrdinalSales('2016', 80), - new OrdinalSales('2017', 65), + OrdinalSales('2014', 4), + OrdinalSales('2015', 20), + OrdinalSales('2016', 80), + OrdinalSales('2017', 65), ]; final tableTargetLineData = [ - new OrdinalSales('2014', 30), - new OrdinalSales('2015', 55), - new OrdinalSales('2016', 15), - new OrdinalSales('2017', 25), + OrdinalSales('2014', 30), + OrdinalSales('2015', 55), + OrdinalSales('2016', 15), + OrdinalSales('2017', 25), ]; final mobileTargetLineData = [ - new OrdinalSales('2014', 10), - new OrdinalSales('2015', 5), - new OrdinalSales('2016', 45), - new OrdinalSales('2017', 35), + OrdinalSales('2014', 10), + OrdinalSales('2015', 5), + OrdinalSales('2016', 45), + OrdinalSales('2017', 35), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: mobileSalesData, ), - new charts.Series( + charts.Series( id: 'Desktop Target Line', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -220,7 +221,7 @@ class StackedBarTargetLineChart extends StatelessWidget { ) // Configure our custom bar target renderer for this series. ..setAttribute(charts.rendererIdKey, 'customTargetLine'), - new charts.Series( + charts.Series( id: 'Tablet Target Line', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -228,7 +229,7 @@ class StackedBarTargetLineChart extends StatelessWidget { ) // Configure our custom bar target renderer for this series. ..setAttribute(charts.rendererIdKey, 'customTargetLine'), - new charts.Series( + charts.Series( id: 'Mobile Target Line', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/behaviors/behaviors_gallery.dart b/web/charts/lib/behaviors/behaviors_gallery.dart index 36d25e995..94e3fc615 100644 --- a/web/charts/lib/behaviors/behaviors_gallery.dart +++ b/web/charts/lib/behaviors/behaviors_gallery.dart @@ -32,95 +32,93 @@ import 'sliding_viewport_on_selection.dart'; List buildGallery() { return [ - new GalleryScaffold( - listTileIcon: new Icon(Icons.flag), + GalleryScaffold( + listTileIcon: const Icon(Icons.flag), title: 'Selection Bar Highlight', subtitle: 'Simple bar chart with tap activation', - childBuilder: () => new SelectionBarHighlight.withRandomData(), + childBuilder: () => SelectionBarHighlight.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.flag), + GalleryScaffold( + listTileIcon: const Icon(Icons.flag), title: 'Selection Line Highlight', subtitle: 'Line chart with tap and drag activation', - childBuilder: () => new SelectionLineHighlight.withRandomData(), + childBuilder: () => SelectionLineHighlight.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.flag), + GalleryScaffold( + listTileIcon: const Icon(Icons.flag), title: 'Selection Line Highlight Custom Shape', subtitle: 'Line chart with tap and drag activation and a custom shape', - childBuilder: () => - new SelectionLineHighlightCustomShape.withRandomData(), + childBuilder: () => SelectionLineHighlightCustomShape.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.flag), + GalleryScaffold( + listTileIcon: const Icon(Icons.flag), title: 'Selection Scatter Plot Highlight', subtitle: 'Scatter plot chart with tap and drag activation', - childBuilder: () => new SelectionScatterPlotHighlight.withRandomData(), + childBuilder: () => SelectionScatterPlotHighlight.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.flag), + GalleryScaffold( + listTileIcon: const Icon(Icons.flag), title: 'Selection Callback Example', subtitle: 'Timeseries that updates external components on selection', - childBuilder: () => new SelectionCallbackExample.withRandomData(), + childBuilder: () => SelectionCallbackExample.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.flag), + GalleryScaffold( + listTileIcon: const Icon(Icons.flag), title: 'User managed selection', subtitle: 'Example where selection can be set and cleared programmatically', - childBuilder: () => new SelectionUserManaged.withRandomData(), + childBuilder: () => SelectionUserManaged.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Bar Chart with initial selection', subtitle: 'Single series with initial selection', - childBuilder: () => new InitialSelection.withRandomData(), + childBuilder: () => InitialSelection.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.flag), + GalleryScaffold( + listTileIcon: const Icon(Icons.flag), title: 'Line Chart with Chart Titles', subtitle: 'Line chart with four chart titles', - childBuilder: () => new ChartTitleLine.withRandomData(), + childBuilder: () => ChartTitleLine.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.flag), + GalleryScaffold( + listTileIcon: const Icon(Icons.flag), title: 'Line Chart with Slider', subtitle: 'Line chart with a slider behavior', - childBuilder: () => new SliderLine.withRandomData(), + childBuilder: () => SliderLine.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Percent of Domain', - subtitle: 'Stacked bar chart with measures calculated as percent of ' + - 'domain', - childBuilder: () => new PercentOfDomainBarChart.withRandomData(), + subtitle: + 'Stacked bar chart with measures calculated as percent of ' 'domain', + childBuilder: () => PercentOfDomainBarChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Percent of Domain by Category', subtitle: 'Grouped stacked bar chart with measures calculated as ' 'percent of domain and series category', - childBuilder: () => - new PercentOfDomainByCategoryBarChart.withRandomData(), + childBuilder: () => PercentOfDomainByCategoryBarChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Percent of Series', - subtitle: 'Grouped bar chart with measures calculated as percent of ' + - 'series', - childBuilder: () => new PercentOfSeriesBarChart.withRandomData(), + subtitle: + 'Grouped bar chart with measures calculated as percent of ' 'series', + childBuilder: () => PercentOfSeriesBarChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Sliding viewport on domain selection', subtitle: 'Center viewport on selected domain', - childBuilder: () => new SlidingViewportOnSelection.withRandomData(), + childBuilder: () => SlidingViewportOnSelection.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Initial hint animation ', subtitle: 'Animate into final viewport', - childBuilder: () => new InitialHintAnimation.withRandomData(), + childBuilder: () => InitialHintAnimation.withRandomData(), ), ]; } diff --git a/web/charts/lib/behaviors/chart_title.dart b/web/charts/lib/behaviors/chart_title.dart index 14ab8ae43..23fb96c67 100644 --- a/web/charts/lib/behaviors/chart_title.dart +++ b/web/charts/lib/behaviors/chart_title.dart @@ -26,11 +26,12 @@ class ChartTitleLine extends StatelessWidget { final List seriesList; final bool animate; - ChartTitleLine(this.seriesList, {this.animate}); + const ChartTitleLine(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [LineChart] with sample data and no transition. factory ChartTitleLine.withSampleData() { - return new ChartTitleLine( + return ChartTitleLine( _createSampleData(), // Disable animations for image tests. animate: false, @@ -42,22 +43,22 @@ class ChartTitleLine extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory ChartTitleLine.withRandomData() { - return new ChartTitleLine(_createRandomData()); + return ChartTitleLine(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, @@ -69,7 +70,7 @@ class ChartTitleLine extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.LineChart( + return charts.LineChart( seriesList, animate: animate, // Configures four [ChartTitle] behaviors to render titles in each chart @@ -77,7 +78,7 @@ class ChartTitleLine extends StatelessWidget { // of the chart. The other titles are aligned with the middle of the draw // area. behaviors: [ - new charts.ChartTitle('Top title text', + charts.ChartTitle('Top title text', subTitle: 'Top sub-title text', behaviorPosition: charts.BehaviorPosition.top, titleOutsideJustification: charts.OutsideJustification.start, @@ -86,15 +87,15 @@ class ChartTitleLine extends StatelessWidget { // The top tick label may extend upwards into the top margin region // if it is located at the top of the draw area. innerPadding: 18), - new charts.ChartTitle('Bottom title text', + charts.ChartTitle('Bottom title text', behaviorPosition: charts.BehaviorPosition.bottom, titleOutsideJustification: charts.OutsideJustification.middleDrawArea), - new charts.ChartTitle('Start title', + charts.ChartTitle('Start title', behaviorPosition: charts.BehaviorPosition.start, titleOutsideJustification: charts.OutsideJustification.middleDrawArea), - new charts.ChartTitle('End title', + charts.ChartTitle('End title', behaviorPosition: charts.BehaviorPosition.end, titleOutsideJustification: charts.OutsideJustification.middleDrawArea), @@ -105,14 +106,14 @@ class ChartTitleLine extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new LinearSales(0, 5), - new LinearSales(1, 25), - new LinearSales(2, 100), - new LinearSales(3, 75), + LinearSales(0, 5), + LinearSales(1, 25), + LinearSales(2, 100), + LinearSales(3, 75), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, diff --git a/web/charts/lib/behaviors/initial_hint_animation.dart b/web/charts/lib/behaviors/initial_hint_animation.dart index f6ea5b14a..af550db0e 100644 --- a/web/charts/lib/behaviors/initial_hint_animation.dart +++ b/web/charts/lib/behaviors/initial_hint_animation.dart @@ -51,11 +51,12 @@ class InitialHintAnimation extends StatelessWidget { final List seriesList; final bool animate; - InitialHintAnimation(this.seriesList, {this.animate}); + const InitialHintAnimation(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [BarChart] with sample data and no transition. factory InitialHintAnimation.withSampleData() { - return new InitialHintAnimation( + return InitialHintAnimation( _createSampleData(), // Disable animations for image tests. animate: false, @@ -67,35 +68,35 @@ class InitialHintAnimation extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory InitialHintAnimation.withRandomData() { - return new InitialHintAnimation(_createRandomData()); + return InitialHintAnimation(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), - new OrdinalSales('2018', random.nextInt(100)), - new OrdinalSales('2019', random.nextInt(100)), - new OrdinalSales('2020', random.nextInt(100)), - new OrdinalSales('2021', random.nextInt(100)), - new OrdinalSales('2022', random.nextInt(100)), - new OrdinalSales('2023', random.nextInt(100)), - new OrdinalSales('2024', random.nextInt(100)), - new OrdinalSales('2025', random.nextInt(100)), - new OrdinalSales('2026', random.nextInt(100)), - new OrdinalSales('2027', random.nextInt(100)), - new OrdinalSales('2028', random.nextInt(100)), - new OrdinalSales('2029', random.nextInt(100)), - new OrdinalSales('2030', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2018', random.nextInt(100)), + OrdinalSales('2019', random.nextInt(100)), + OrdinalSales('2020', random.nextInt(100)), + OrdinalSales('2021', random.nextInt(100)), + OrdinalSales('2022', random.nextInt(100)), + OrdinalSales('2023', random.nextInt(100)), + OrdinalSales('2024', random.nextInt(100)), + OrdinalSales('2025', random.nextInt(100)), + OrdinalSales('2026', random.nextInt(100)), + OrdinalSales('2027', random.nextInt(100)), + OrdinalSales('2028', random.nextInt(100)), + OrdinalSales('2029', random.nextInt(100)), + OrdinalSales('2030', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (OrdinalSales sales, _) => sales.year, @@ -108,7 +109,7 @@ class InitialHintAnimation extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, // Optionally turn off the animation that animates values up from the @@ -117,17 +118,17 @@ class InitialHintAnimation extends StatelessWidget { animationDuration: Duration.zero, // Set the initial viewport by providing a new AxisSpec with the // desired viewport: a starting domain and the data size. - domainAxis: new charts.OrdinalAxisSpec( - viewport: new charts.OrdinalViewport('2018', 4)), + domainAxis: + charts.OrdinalAxisSpec(viewport: charts.OrdinalViewport('2018', 4)), behaviors: [ // Add this behavior to show initial hint animation that will pan to the // final desired viewport. // The duration of the animation can be adjusted by pass in // [hintDuration]. By default this is 3000ms. - new charts.InitialHintBehavior(maxHintTranslate: 4.0), + charts.InitialHintBehavior(maxHintTranslate: 4.0), // Optionally add a pan or pan and zoom behavior. // If pan/zoom is not added, the viewport specified remains the viewport - new charts.PanAndZoomBehavior(), + charts.PanAndZoomBehavior(), ], ); } @@ -135,27 +136,27 @@ class InitialHintAnimation extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), - new OrdinalSales('2018', 33), - new OrdinalSales('2019', 80), - new OrdinalSales('2020', 21), - new OrdinalSales('2021', 77), - new OrdinalSales('2022', 8), - new OrdinalSales('2023', 12), - new OrdinalSales('2024', 42), - new OrdinalSales('2025', 70), - new OrdinalSales('2026', 77), - new OrdinalSales('2027', 55), - new OrdinalSales('2028', 19), - new OrdinalSales('2029', 66), - new OrdinalSales('2030', 27), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), + OrdinalSales('2018', 33), + OrdinalSales('2019', 80), + OrdinalSales('2020', 21), + OrdinalSales('2021', 77), + OrdinalSales('2022', 8), + OrdinalSales('2023', 12), + OrdinalSales('2024', 42), + OrdinalSales('2025', 70), + OrdinalSales('2026', 77), + OrdinalSales('2027', 55), + OrdinalSales('2028', 19), + OrdinalSales('2029', 66), + OrdinalSales('2030', 27), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (OrdinalSales sales, _) => sales.year, diff --git a/web/charts/lib/behaviors/initial_selection.dart b/web/charts/lib/behaviors/initial_selection.dart index 44d5f5828..b49e345ff 100644 --- a/web/charts/lib/behaviors/initial_selection.dart +++ b/web/charts/lib/behaviors/initial_selection.dart @@ -34,11 +34,12 @@ class InitialSelection extends StatelessWidget { final List seriesList; final bool animate; - InitialSelection(this.seriesList, {this.animate}); + const InitialSelection(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [BarChart] with initial selection behavior. factory InitialSelection.withSampleData() { - return new InitialSelection( + return InitialSelection( _createSampleData(), // Disable animations for image tests. animate: false, @@ -50,22 +51,22 @@ class InitialSelection extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory InitialSelection.withRandomData() { - return new InitialSelection(_createRandomData()); + return InitialSelection(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (OrdinalSales sales, _) => sales.year, @@ -78,7 +79,7 @@ class InitialSelection extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, behaviors: [ @@ -92,8 +93,8 @@ class InitialSelection extends StatelessWidget { // [BarChart] by default includes behaviors [SelectNearest] and // [DomainHighlighter]. So this behavior shows the initial selection // highlighted and when another datum is tapped, the selection changes. - new charts.InitialSelection(selectedDataConfig: [ - new charts.SeriesDatumConfig('Sales', '2016') + charts.InitialSelection(selectedDataConfig: [ + charts.SeriesDatumConfig('Sales', '2016') ]) ], ); @@ -102,14 +103,14 @@ class InitialSelection extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (OrdinalSales sales, _) => sales.year, diff --git a/web/charts/lib/behaviors/percent_of_domain.dart b/web/charts/lib/behaviors/percent_of_domain.dart index 3f74d7695..243a99e7c 100644 --- a/web/charts/lib/behaviors/percent_of_domain.dart +++ b/web/charts/lib/behaviors/percent_of_domain.dart @@ -27,11 +27,12 @@ class PercentOfDomainBarChart extends StatelessWidget { final List seriesList; final bool animate; - PercentOfDomainBarChart(this.seriesList, {this.animate}); + const PercentOfDomainBarChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a stacked [BarChart] with sample data and no transition. factory PercentOfDomainBarChart.withSampleData() { - return new PercentOfDomainBarChart( + return PercentOfDomainBarChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -43,48 +44,48 @@ class PercentOfDomainBarChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory PercentOfDomainBarChart.withRandomData() { - return new PercentOfDomainBarChart(_createRandomData()); + return PercentOfDomainBarChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final desktopSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final tableSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final mobileSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -96,7 +97,7 @@ class PercentOfDomainBarChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, barGroupingType: charts.BarGroupingType.stacked, @@ -104,51 +105,51 @@ class PercentOfDomainBarChart extends StatelessWidget { // values as the percentage of the total of all data that shares a // domain value. behaviors: [ - new charts.PercentInjector( + charts.PercentInjector( totalType: charts.PercentInjectorTotalType.domain) ], // Configure the axis spec to show percentage values. - primaryMeasureAxis: new charts.PercentAxisSpec(), + primaryMeasureAxis: charts.PercentAxisSpec(), ); } /// Create series list with multiple series static List> _createSampleData() { final desktopSalesData = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tableSalesData = [ - new OrdinalSales('2014', 25), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 10), - new OrdinalSales('2017', 20), + OrdinalSales('2014', 25), + OrdinalSales('2015', 50), + OrdinalSales('2016', 10), + OrdinalSales('2017', 20), ]; final mobileSalesData = [ - new OrdinalSales('2014', 10), - new OrdinalSales('2015', 15), - new OrdinalSales('2016', 50), - new OrdinalSales('2017', 45), + OrdinalSales('2014', 10), + OrdinalSales('2015', 15), + OrdinalSales('2016', 50), + OrdinalSales('2017', 45), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/behaviors/percent_of_domain_by_category.dart b/web/charts/lib/behaviors/percent_of_domain_by_category.dart index fe252a18c..f89de500a 100644 --- a/web/charts/lib/behaviors/percent_of_domain_by_category.dart +++ b/web/charts/lib/behaviors/percent_of_domain_by_category.dart @@ -28,10 +28,12 @@ class PercentOfDomainByCategoryBarChart extends StatelessWidget { final List seriesList; final bool animate; - PercentOfDomainByCategoryBarChart(this.seriesList, {this.animate}); + const PercentOfDomainByCategoryBarChart(this.seriesList, + {this.animate, Key key}) + : super(key: key); factory PercentOfDomainByCategoryBarChart.withSampleData() { - return new PercentOfDomainByCategoryBarChart( + return PercentOfDomainByCategoryBarChart( createSampleData(), // Disable animations for image tests. animate: false, @@ -43,92 +45,92 @@ class PercentOfDomainByCategoryBarChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory PercentOfDomainByCategoryBarChart.withRandomData() { - return new PercentOfDomainByCategoryBarChart(_createRandomData()); + return PercentOfDomainByCategoryBarChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final desktopSalesDataA = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final tableSalesDataA = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final mobileSalesDataA = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final desktopSalesDataB = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final tableSalesDataB = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final mobileSalesDataB = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop A', seriesCategory: 'A', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesDataA, ), - new charts.Series( + charts.Series( id: 'Tablet A', seriesCategory: 'A', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesDataA, ), - new charts.Series( + charts.Series( id: 'Mobile A', seriesCategory: 'A', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: mobileSalesDataA, ), - new charts.Series( + charts.Series( id: 'Desktop B', seriesCategory: 'B', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesDataB, ), - new charts.Series( + charts.Series( id: 'Tablet B', seriesCategory: 'B', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesDataB, ), - new charts.Series( + charts.Series( id: 'Mobile B', seriesCategory: 'B', domainFn: (OrdinalSales sales, _) => sales.year, @@ -141,7 +143,7 @@ class PercentOfDomainByCategoryBarChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, barGroupingType: charts.BarGroupingType.groupedStacked, @@ -153,95 +155,95 @@ class PercentOfDomainByCategoryBarChart extends StatelessWidget { // total value for each bar stack is 100%. A stacked bar chart that does // not group by series category would use the "domain" option. behaviors: [ - new charts.PercentInjector( + charts.PercentInjector( totalType: charts.PercentInjectorTotalType.domainBySeriesCategory) ], // Configure the axis spec to show percentage values. - primaryMeasureAxis: new charts.PercentAxisSpec(), + primaryMeasureAxis: charts.PercentAxisSpec(), ); } /// Create series list with multiple series static List> createSampleData() { final desktopSalesDataA = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tableSalesDataA = [ - new OrdinalSales('2014', 25), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 10), - new OrdinalSales('2017', 20), + OrdinalSales('2014', 25), + OrdinalSales('2015', 50), + OrdinalSales('2016', 10), + OrdinalSales('2017', 20), ]; final mobileSalesDataA = [ - new OrdinalSales('2014', 10), - new OrdinalSales('2015', 15), - new OrdinalSales('2016', 50), - new OrdinalSales('2017', 45), + OrdinalSales('2014', 10), + OrdinalSales('2015', 15), + OrdinalSales('2016', 50), + OrdinalSales('2017', 45), ]; final desktopSalesDataB = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tableSalesDataB = [ - new OrdinalSales('2014', 25), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 10), - new OrdinalSales('2017', 20), + OrdinalSales('2014', 25), + OrdinalSales('2015', 50), + OrdinalSales('2016', 10), + OrdinalSales('2017', 20), ]; final mobileSalesDataB = [ - new OrdinalSales('2014', 10), - new OrdinalSales('2015', 15), - new OrdinalSales('2016', 50), - new OrdinalSales('2017', 45), + OrdinalSales('2014', 10), + OrdinalSales('2015', 15), + OrdinalSales('2016', 50), + OrdinalSales('2017', 45), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop A', seriesCategory: 'A', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesDataA, ), - new charts.Series( + charts.Series( id: 'Tablet A', seriesCategory: 'A', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesDataA, ), - new charts.Series( + charts.Series( id: 'Mobile A', seriesCategory: 'A', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: mobileSalesDataA, ), - new charts.Series( + charts.Series( id: 'Desktop B', seriesCategory: 'B', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesDataB, ), - new charts.Series( + charts.Series( id: 'Tablet B', seriesCategory: 'B', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesDataB, ), - new charts.Series( + charts.Series( id: 'Mobile B', seriesCategory: 'B', domainFn: (OrdinalSales sales, _) => sales.year, diff --git a/web/charts/lib/behaviors/percent_of_series.dart b/web/charts/lib/behaviors/percent_of_series.dart index 279e8cd91..8fe8410da 100644 --- a/web/charts/lib/behaviors/percent_of_series.dart +++ b/web/charts/lib/behaviors/percent_of_series.dart @@ -25,11 +25,12 @@ class PercentOfSeriesBarChart extends StatelessWidget { final List seriesList; final bool animate; - PercentOfSeriesBarChart(this.seriesList, {this.animate}); + const PercentOfSeriesBarChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a stacked [BarChart] with sample data and no transition. factory PercentOfSeriesBarChart.withSampleData() { - return new PercentOfSeriesBarChart( + return PercentOfSeriesBarChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -41,26 +42,26 @@ class PercentOfSeriesBarChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory PercentOfSeriesBarChart.withRandomData() { - return new PercentOfSeriesBarChart(_createRandomData()); + return PercentOfSeriesBarChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final desktopSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -72,36 +73,36 @@ class PercentOfSeriesBarChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, barGroupingType: charts.BarGroupingType.grouped, // Configures a [PercentInjector] behavior that will calculate measure // values as the percentage of the total of all data in its series. behaviors: [ - new charts.PercentInjector( + charts.PercentInjector( totalType: charts.PercentInjectorTotalType.series) ], // Configure the axis spec to show percentage values. - primaryMeasureAxis: new charts.PercentAxisSpec(), + primaryMeasureAxis: charts.PercentAxisSpec(), ); } /// Create series list with multiple series static List> _createSampleData() { final desktopSalesData = [ - new OrdinalSales('2011', 5), - new OrdinalSales('2012', 25), - new OrdinalSales('2013', 50), - new OrdinalSales('2014', 75), - new OrdinalSales('2015', 100), - new OrdinalSales('2016', 125), - new OrdinalSales('2017', 200), - new OrdinalSales('2018', 150), + OrdinalSales('2011', 5), + OrdinalSales('2012', 25), + OrdinalSales('2013', 50), + OrdinalSales('2014', 75), + OrdinalSales('2015', 100), + OrdinalSales('2016', 125), + OrdinalSales('2017', 200), + OrdinalSales('2018', 150), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/behaviors/selection_bar_highlight.dart b/web/charts/lib/behaviors/selection_bar_highlight.dart index 6ebb12c18..091cd1e80 100644 --- a/web/charts/lib/behaviors/selection_bar_highlight.dart +++ b/web/charts/lib/behaviors/selection_bar_highlight.dart @@ -22,11 +22,12 @@ class SelectionBarHighlight extends StatelessWidget { final List seriesList; final bool animate; - SelectionBarHighlight(this.seriesList, {this.animate}); + const SelectionBarHighlight(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [BarChart] with sample data and no transition. factory SelectionBarHighlight.withSampleData() { - return new SelectionBarHighlight( + return SelectionBarHighlight( _createSampleData(), // Disable animations for image tests. animate: false, @@ -38,22 +39,22 @@ class SelectionBarHighlight extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory SelectionBarHighlight.withRandomData() { - return new SelectionBarHighlight(_createRandomData()); + return SelectionBarHighlight(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -74,7 +75,7 @@ class SelectionBarHighlight extends StatelessWidget { // // [defaultInteractions] can be set to false to avoid the default // interactions. - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, defaultInteractions: true, @@ -84,14 +85,14 @@ class SelectionBarHighlight extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/behaviors/selection_callback_example.dart b/web/charts/lib/behaviors/selection_callback_example.dart index ba4bde9b3..48f612b42 100644 --- a/web/charts/lib/behaviors/selection_callback_example.dart +++ b/web/charts/lib/behaviors/selection_callback_example.dart @@ -36,11 +36,12 @@ class SelectionCallbackExample extends StatefulWidget { final List seriesList; final bool animate; - SelectionCallbackExample(this.seriesList, {this.animate}); + const SelectionCallbackExample(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [charts.TimeSeriesChart] with sample data and no transition. factory SelectionCallbackExample.withSampleData() { - return new SelectionCallbackExample( + return SelectionCallbackExample( _createSampleData(), // Disable animations for image tests. animate: false, @@ -52,35 +53,35 @@ class SelectionCallbackExample extends StatefulWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory SelectionCallbackExample.withRandomData() { - return new SelectionCallbackExample(_createRandomData()); + return SelectionCallbackExample(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final usData = [ - new TimeSeriesSales(new DateTime(2017, 9, 19), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 26), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 10, 3), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 10, 10), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 19), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 26), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 10, 3), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 10, 10), random.nextInt(100)), ]; final ukData = [ - new TimeSeriesSales(new DateTime(2017, 9, 19), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 26), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 10, 3), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 10, 10), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 19), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 26), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 10, 3), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 10, 10), random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'US Sales', domainFn: (TimeSeriesSales sales, _) => sales.time, measureFn: (TimeSeriesSales sales, _) => sales.sales, data: usData, ), - new charts.Series( + charts.Series( id: 'UK Sales', domainFn: (TimeSeriesSales sales, _) => sales.time, measureFn: (TimeSeriesSales sales, _) => sales.sales, @@ -93,32 +94,32 @@ class SelectionCallbackExample extends StatefulWidget { // We need a Stateful widget to build the selection details with the current // selection as the state. @override - State createState() => new _SelectionCallbackState(); + State createState() => _SelectionCallbackState(); /// Create one series with sample hard coded data. static List> _createSampleData() { final usData = [ - new TimeSeriesSales(new DateTime(2017, 9, 19), 5), - new TimeSeriesSales(new DateTime(2017, 9, 26), 25), - new TimeSeriesSales(new DateTime(2017, 10, 3), 78), - new TimeSeriesSales(new DateTime(2017, 10, 10), 54), + TimeSeriesSales(DateTime(2017, 9, 19), 5), + TimeSeriesSales(DateTime(2017, 9, 26), 25), + TimeSeriesSales(DateTime(2017, 10, 3), 78), + TimeSeriesSales(DateTime(2017, 10, 10), 54), ]; final ukData = [ - new TimeSeriesSales(new DateTime(2017, 9, 19), 15), - new TimeSeriesSales(new DateTime(2017, 9, 26), 33), - new TimeSeriesSales(new DateTime(2017, 10, 3), 68), - new TimeSeriesSales(new DateTime(2017, 10, 10), 48), + TimeSeriesSales(DateTime(2017, 9, 19), 15), + TimeSeriesSales(DateTime(2017, 9, 26), 33), + TimeSeriesSales(DateTime(2017, 10, 3), 68), + TimeSeriesSales(DateTime(2017, 10, 10), 48), ]; return [ - new charts.Series( + charts.Series( id: 'US Sales', domainFn: (TimeSeriesSales sales, _) => sales.time, measureFn: (TimeSeriesSales sales, _) => sales.sales, data: usData, ), - new charts.Series( + charts.Series( id: 'UK Sales', domainFn: (TimeSeriesSales sales, _) => sales.time, measureFn: (TimeSeriesSales sales, _) => sales.sales, @@ -148,9 +149,9 @@ class _SelectionCallbackState extends State { // series name for each selection point. if (selectedDatum.isNotEmpty) { time = selectedDatum.first.datum.time; - selectedDatum.forEach((charts.SeriesDatum datumPair) { + for (var datumPair in selectedDatum) { measures[datumPair.series.displayName] = datumPair.datum.sales; - }); + } } // Request a build. @@ -164,13 +165,13 @@ class _SelectionCallbackState extends State { Widget build(BuildContext context) { // The children consist of a Chart and Text widgets below to hold the info. final children = [ - new SizedBox( + SizedBox( height: 150.0, - child: new charts.TimeSeriesChart( + child: charts.TimeSeriesChart( widget.seriesList, animate: widget.animate, selectionModels: [ - new charts.SelectionModelConfig( + charts.SelectionModelConfig( type: charts.SelectionModelType.info, changedListener: _onSelectionChanged, ) @@ -180,15 +181,15 @@ class _SelectionCallbackState extends State { // If there is a selection, then include the details. if (_time != null) { - children.add(new Padding( - padding: new EdgeInsets.only(top: 5.0), - child: new Text(_time.toString()))); + children.add(Padding( + padding: const EdgeInsets.only(top: 5.0), + child: Text(_time.toString()))); } _measures?.forEach((String series, num value) { - children.add(new Text('$series: $value')); + children.add(Text('$series: $value')); }); - return new Column(children: children); + return Column(children: children); } } diff --git a/web/charts/lib/behaviors/selection_line_highlight.dart b/web/charts/lib/behaviors/selection_line_highlight.dart index e5307d562..cc34e37cc 100644 --- a/web/charts/lib/behaviors/selection_line_highlight.dart +++ b/web/charts/lib/behaviors/selection_line_highlight.dart @@ -22,11 +22,12 @@ class SelectionLineHighlight extends StatelessWidget { final List seriesList; final bool animate; - SelectionLineHighlight(this.seriesList, {this.animate}); + const SelectionLineHighlight(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [LineChart] with sample data and no transition. factory SelectionLineHighlight.withSampleData() { - return new SelectionLineHighlight( + return SelectionLineHighlight( _createSampleData(), // Disable animations for image tests. animate: false, @@ -38,22 +39,22 @@ class SelectionLineHighlight extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory SelectionLineHighlight.withRandomData() { - return new SelectionLineHighlight(_createRandomData()); + return SelectionLineHighlight(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, @@ -75,7 +76,7 @@ class SelectionLineHighlight extends StatelessWidget { // // As an alternative, [defaultInteractions] can be set to true to include // the default chart interactions, including a LinePointHighlighter. - return new charts.LineChart(seriesList, animate: animate, behaviors: [ + return charts.LineChart(seriesList, animate: animate, behaviors: [ // Optional - Configures a [LinePointHighlighter] behavior with a // vertical follow line. A vertical follow line is included by // default, but is shown here as an example configuration. @@ -84,7 +85,7 @@ class SelectionLineHighlight extends StatelessWidget { // set by providing a [dashPattern] or it can be turned off by passing in // an empty list. An empty list is necessary because passing in a null // value will be treated the same as not passing in a value at all. - new charts.LinePointHighlighter( + charts.LinePointHighlighter( showHorizontalFollowLine: charts.LinePointHighlighterFollowLineType.none, showVerticalFollowLine: @@ -94,21 +95,21 @@ class SelectionLineHighlight extends StatelessWidget { // highlighter. Changing the trigger to tap and drag allows the // highlighter to follow the dragging gesture but it is not // recommended to be used when pan/zoom behavior is enabled. - new charts.SelectNearest(eventTrigger: charts.SelectionTrigger.tapAndDrag) + charts.SelectNearest(eventTrigger: charts.SelectionTrigger.tapAndDrag) ]); } /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new LinearSales(0, 5), - new LinearSales(1, 25), - new LinearSales(2, 100), - new LinearSales(3, 75), + LinearSales(0, 5), + LinearSales(1, 25), + LinearSales(2, 100), + LinearSales(3, 75), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, diff --git a/web/charts/lib/behaviors/selection_line_highlight_custom_shape.dart b/web/charts/lib/behaviors/selection_line_highlight_custom_shape.dart index fada01940..c974a8d52 100644 --- a/web/charts/lib/behaviors/selection_line_highlight_custom_shape.dart +++ b/web/charts/lib/behaviors/selection_line_highlight_custom_shape.dart @@ -22,11 +22,13 @@ class SelectionLineHighlightCustomShape extends StatelessWidget { final List seriesList; final bool animate; - SelectionLineHighlightCustomShape(this.seriesList, {this.animate}); + const SelectionLineHighlightCustomShape(this.seriesList, + {this.animate, Key key}) + : super(key: key); /// Creates a [LineChart] with sample data and no transition. factory SelectionLineHighlightCustomShape.withSampleData() { - return new SelectionLineHighlightCustomShape( + return SelectionLineHighlightCustomShape( _createSampleData(), // Disable animations for image tests. animate: false, @@ -38,22 +40,22 @@ class SelectionLineHighlightCustomShape extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory SelectionLineHighlightCustomShape.withRandomData() { - return new SelectionLineHighlightCustomShape(_createRandomData()); + return SelectionLineHighlightCustomShape(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, @@ -74,7 +76,7 @@ class SelectionLineHighlightCustomShape extends StatelessWidget { // // As an alternative, [defaultInteractions] can be set to true to include // the default chart interactions, including a LinePointHighlighter. - return new charts.LineChart(seriesList, animate: animate, behaviors: [ + return charts.LineChart(seriesList, animate: animate, behaviors: [ // Optional - Configures a [LinePointHighlighter] behavior with a // vertical follow line. A vertical follow line is included by // default, but is shown here as an example configuration. @@ -86,32 +88,32 @@ class SelectionLineHighlightCustomShape extends StatelessWidget { // // The symbol renderer is configured to render a hollow shape, for // demonstration. - new charts.LinePointHighlighter( + charts.LinePointHighlighter( showHorizontalFollowLine: charts.LinePointHighlighterFollowLineType.none, showVerticalFollowLine: charts.LinePointHighlighterFollowLineType.nearest, - symbolRenderer: new charts.RectSymbolRenderer(isSolid: false)), + symbolRenderer: charts.RectSymbolRenderer(isSolid: false)), // Optional - By default, select nearest is configured to trigger // with tap so that a user can have pan/zoom behavior and line point // highlighter. Changing the trigger to tap and drag allows the // highlighter to follow the dragging gesture but it is not // recommended to be used when pan/zoom behavior is enabled. - new charts.SelectNearest(eventTrigger: charts.SelectionTrigger.tapAndDrag) + charts.SelectNearest(eventTrigger: charts.SelectionTrigger.tapAndDrag) ]); } /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new LinearSales(0, 5), - new LinearSales(1, 25), - new LinearSales(2, 100), - new LinearSales(3, 75), + LinearSales(0, 5), + LinearSales(1, 25), + LinearSales(2, 100), + LinearSales(3, 75), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, diff --git a/web/charts/lib/behaviors/selection_scatter_plot_highlight.dart b/web/charts/lib/behaviors/selection_scatter_plot_highlight.dart index 087b105a6..200ef70f0 100644 --- a/web/charts/lib/behaviors/selection_scatter_plot_highlight.dart +++ b/web/charts/lib/behaviors/selection_scatter_plot_highlight.dart @@ -41,11 +41,12 @@ class SelectionScatterPlotHighlight extends StatelessWidget { final List seriesList; final bool animate; - SelectionScatterPlotHighlight(this.seriesList, {this.animate}); + const SelectionScatterPlotHighlight(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [ScatterPlotChart] with sample data and no transition. factory SelectionScatterPlotHighlight.withSampleData() { - return new SelectionScatterPlotHighlight( + return SelectionScatterPlotHighlight( _createSampleData(), // Disable animations for image tests. animate: false, @@ -57,49 +58,49 @@ class SelectionScatterPlotHighlight extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory SelectionScatterPlotHighlight.withRandomData() { - return new SelectionScatterPlotHighlight(_createRandomData()); + return SelectionScatterPlotHighlight(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); - final makeRadius = (int value) => (random.nextInt(value) + 2).toDouble(); + makeRadius(int value) => (random.nextInt(value) + 2).toDouble(); final data = [ - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), 'circle', null, null), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), - null, null, null), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), - null, null, null), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), null, + null, null), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), null, + null, null), // Render a hollow circle, filled in with white. - new LinearSales(random.nextInt(100), random.nextInt(100), - makeRadius(4) + 4, 'circle', charts.MaterialPalette.white, 2.0), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), - null, null, null), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), - null, null, null), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(4) + 4, + 'circle', charts.MaterialPalette.white, 2.0), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), null, + null, null), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), null, + null, null), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), 'circle', null, null), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), - null, null, null), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), - null, null, null), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), null, + null, null), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), null, + null, null), // Render a hollow circle, filled in with white. - new LinearSales(random.nextInt(100), random.nextInt(100), - makeRadius(4) + 4, 'circle', charts.MaterialPalette.white, 2.0), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), - null, null, null), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(4) + 4, + 'circle', charts.MaterialPalette.white, 2.0), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), null, + null, null), // Render a hollow square, filled in with white. - new LinearSales(random.nextInt(100), random.nextInt(100), - makeRadius(4) + 4, null, charts.MaterialPalette.white, 2.0), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(4) + 4, + null, charts.MaterialPalette.white, 2.0), ]; - final maxMeasure = 100; + const maxMeasure = 100; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (LinearSales sales, _) { // Color bucket the measure column value into 3 distinct colors. @@ -131,7 +132,7 @@ class SelectionScatterPlotHighlight extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.ScatterPlotChart(seriesList, + return charts.ScatterPlotChart(seriesList, animate: animate, behaviors: [ // Optional - Configures a [LinePointHighlighter] behavior with @@ -143,7 +144,7 @@ class SelectionScatterPlotHighlight extends StatelessWidget { // in an empty list. An empty list is necessary because passing in a // null value will be treated the same as not passing in a value at // all. - new charts.LinePointHighlighter( + charts.LinePointHighlighter( showHorizontalFollowLine: charts.LinePointHighlighterFollowLineType.nearest, showVerticalFollowLine: @@ -153,44 +154,42 @@ class SelectionScatterPlotHighlight extends StatelessWidget { // highlighter. Changing the trigger to tap and drag allows the // highlighter to follow the dragging gesture but it is not // recommended to be used when pan/zoom behavior is enabled. - new charts.SelectNearest( + charts.SelectNearest( eventTrigger: charts.SelectionTrigger.tapAndDrag), ], // Configure the point renderer to have a map of custom symbol // renderers. defaultRenderer: - new charts.PointRendererConfig(customSymbolRenderers: { - 'circle': new charts.CircleSymbolRenderer(), - 'rect': new charts.RectSymbolRenderer(), + charts.PointRendererConfig(customSymbolRenderers: { + 'circle': charts.CircleSymbolRenderer(), + 'rect': charts.RectSymbolRenderer(), })); } /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new LinearSales(0, 5, 3.0, 'circle', null, null), - new LinearSales(10, 25, 5.0, null, null, null), - new LinearSales(12, 75, 4.0, null, null, null), + LinearSales(0, 5, 3.0, 'circle', null, null), + LinearSales(10, 25, 5.0, null, null, null), + LinearSales(12, 75, 4.0, null, null, null), // Render a hollow circle, filled in with white. - new LinearSales( - 13, 225, 5.0, 'circle', charts.MaterialPalette.white, 2.0), - new LinearSales(16, 50, 4.0, null, null, null), - new LinearSales(24, 75, 3.0, null, null, null), - new LinearSales(25, 100, 3.0, 'circle', null, null), - new LinearSales(34, 150, 5.0, null, null, null), - new LinearSales(37, 10, 4.5, null, null, null), + LinearSales(13, 225, 5.0, 'circle', charts.MaterialPalette.white, 2.0), + LinearSales(16, 50, 4.0, null, null, null), + LinearSales(24, 75, 3.0, null, null, null), + LinearSales(25, 100, 3.0, 'circle', null, null), + LinearSales(34, 150, 5.0, null, null, null), + LinearSales(37, 10, 4.5, null, null, null), // Render a hollow circle, filled in with white. - new LinearSales( - 45, 300, 8.0, 'circle', charts.MaterialPalette.white, 2.0), - new LinearSales(52, 15, 4.0, null, null, null), + LinearSales(45, 300, 8.0, 'circle', charts.MaterialPalette.white, 2.0), + LinearSales(52, 15, 4.0, null, null, null), // Render a hollow square, filled in with white. - new LinearSales(56, 200, 7.0, null, charts.MaterialPalette.white, 2.0), + LinearSales(56, 200, 7.0, null, charts.MaterialPalette.white, 2.0), ]; - final maxMeasure = 300; + const maxMeasure = 300; return [ - new charts.Series( + charts.Series( id: 'Sales', // Providing a color function is optional. colorFn: (LinearSales sales, _) { diff --git a/web/charts/lib/behaviors/selection_user_managed.dart b/web/charts/lib/behaviors/selection_user_managed.dart index 2378e1d2f..80bab816e 100644 --- a/web/charts/lib/behaviors/selection_user_managed.dart +++ b/web/charts/lib/behaviors/selection_user_managed.dart @@ -32,11 +32,12 @@ class SelectionUserManaged extends StatefulWidget { final List seriesList; final bool animate; - SelectionUserManaged(this.seriesList, {this.animate}); + const SelectionUserManaged(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [BarChart] with sample data and no transition. factory SelectionUserManaged.withSampleData() { - return new SelectionUserManaged( + return SelectionUserManaged( _createSampleData(), // Disable animations for image tests. animate: false, @@ -48,22 +49,22 @@ class SelectionUserManaged extends StatefulWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory SelectionUserManaged.withRandomData() { - return new SelectionUserManaged(_createRandomData()); + return SelectionUserManaged(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (OrdinalSales sales, _) => sales.year, @@ -77,14 +78,14 @@ class SelectionUserManaged extends StatefulWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (OrdinalSales sales, _) => sales.year, @@ -96,20 +97,20 @@ class SelectionUserManaged extends StatefulWidget { @override SelectionUserManagedState createState() { - return new SelectionUserManagedState(); + return SelectionUserManagedState(); } } class SelectionUserManagedState extends State { - final _myState = new charts.UserManagedState(); + final _myState = charts.UserManagedState(); @override Widget build(BuildContext context) { - final chart = new charts.BarChart( + final chart = charts.BarChart( widget.seriesList, animate: false, //widget.animate, selectionModels: [ - new charts.SelectionModelConfig( + charts.SelectionModelConfig( type: charts.SelectionModelType.info, updatedListener: _infoSelectionModelUpdated) ], @@ -119,17 +120,17 @@ class SelectionUserManagedState extends State { // The initial selection can still be optionally added by adding the // initial selection behavior. behaviors: [ - new charts.InitialSelection(selectedDataConfig: [ - new charts.SeriesDatumConfig('Sales', '2016') + charts.InitialSelection(selectedDataConfig: [ + charts.SeriesDatumConfig('Sales', '2016') ]) ], ); - final clearSelection = new MaterialButton( - onPressed: _handleClearSelection, child: new Text('Clear Selection')); + final clearSelection = MaterialButton( + onPressed: _handleClearSelection, child: const Text('Clear Selection')); - return new Column( - children: [new SizedBox(child: chart, height: 150.0), clearSelection]); + return Column( + children: [SizedBox(child: chart, height: 150.0), clearSelection]); } void _infoSelectionModelUpdated(charts.SelectionModel model) { @@ -141,7 +142,7 @@ class SelectionUserManagedState extends State { // This also allows you to listen to the selection model update events and // alter the selection. _myState.selectionModels[charts.SelectionModelType.info] = - new charts.UserManagedSelectionModel(model: model); + charts.UserManagedSelectionModel(model: model); } void _handleClearSelection() { @@ -150,7 +151,7 @@ class SelectionUserManagedState extends State { // no selection model to clear all selection when rebuilt. setState(() { _myState.selectionModels[charts.SelectionModelType.info] = - new charts.UserManagedSelectionModel(); + charts.UserManagedSelectionModel(); }); } } diff --git a/web/charts/lib/behaviors/slider.dart b/web/charts/lib/behaviors/slider.dart index a08b3fe00..6dce65d8c 100644 --- a/web/charts/lib/behaviors/slider.dart +++ b/web/charts/lib/behaviors/slider.dart @@ -36,11 +36,11 @@ class SliderLine extends StatefulWidget { final List seriesList; final bool animate; - SliderLine(this.seriesList, {this.animate}); + const SliderLine(this.seriesList, {this.animate, Key key}) : super(key: key); /// Creates a [LineChart] with sample data and no transition. factory SliderLine.withSampleData() { - return new SliderLine( + return SliderLine( _createSampleData(), // Disable animations for image tests. animate: false, @@ -52,22 +52,22 @@ class SliderLine extends StatefulWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory SliderLine.withRandomData() { - return new SliderLine(_createRandomData()); + return SliderLine(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, @@ -80,19 +80,19 @@ class SliderLine extends StatefulWidget { // We need a Stateful widget to build the selection details with the current // selection as the state. @override - State createState() => new _SliderCallbackState(); + State createState() => _SliderCallbackState(); /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new LinearSales(0, 5), - new LinearSales(1, 25), - new LinearSales(2, 100), - new LinearSales(3, 75), + LinearSales(0, 5), + LinearSales(1, 25), + LinearSales(2, 100), + LinearSales(3, 75), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, @@ -126,9 +126,9 @@ class _SliderCallbackState extends State { Widget build(BuildContext context) { // The children consist of a Chart and Text widgets below to hold the info. final children = [ - new SizedBox( + SizedBox( height: 150.0, - child: new charts.LineChart( + child: charts.LineChart( widget.seriesList, animate: widget.animate, // Configures a [Slider] behavior. @@ -159,7 +159,7 @@ class _SliderCallbackState extends State { // [style] takes in a [SliderStyle] configuration object, and // configures the color and sizing of the slider line and handle. behaviors: [ - new charts.Slider( + charts.Slider( initialDomainValue: 1.0, onChangeCallback: _onSliderChange), ], )), @@ -167,23 +167,23 @@ class _SliderCallbackState extends State { // If there is a slider change event, then include the details. if (_sliderDomainValue != null) { - children.add(new Padding( - padding: new EdgeInsets.only(top: 5.0), - child: new Text('Slider domain value: $_sliderDomainValue'))); + children.add(Padding( + padding: const EdgeInsets.only(top: 5.0), + child: Text('Slider domain value: $_sliderDomainValue'))); } if (_sliderPosition != null) { - children.add(new Padding( - padding: new EdgeInsets.only(top: 5.0), - child: new Text( + children.add(Padding( + padding: const EdgeInsets.only(top: 5.0), + child: Text( 'Slider position: ${_sliderPosition.x}, ${_sliderPosition.y}'))); } if (_sliderDragState != null) { - children.add(new Padding( - padding: new EdgeInsets.only(top: 5.0), - child: new Text('Slider drag state: $_sliderDragState'))); + children.add(Padding( + padding: const EdgeInsets.only(top: 5.0), + child: Text('Slider drag state: $_sliderDragState'))); } - return new Column(children: children); + return Column(children: children); } } diff --git a/web/charts/lib/behaviors/sliding_viewport_on_selection.dart b/web/charts/lib/behaviors/sliding_viewport_on_selection.dart index 52208ce67..700210a8c 100644 --- a/web/charts/lib/behaviors/sliding_viewport_on_selection.dart +++ b/web/charts/lib/behaviors/sliding_viewport_on_selection.dart @@ -25,11 +25,12 @@ class SlidingViewportOnSelection extends StatelessWidget { final List seriesList; final bool animate; - SlidingViewportOnSelection(this.seriesList, {this.animate}); + const SlidingViewportOnSelection(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [BarChart] with sample data and no transition. factory SlidingViewportOnSelection.withSampleData() { - return new SlidingViewportOnSelection( + return SlidingViewportOnSelection( _createSampleData(), // Disable animations for image tests. animate: false, @@ -41,35 +42,35 @@ class SlidingViewportOnSelection extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory SlidingViewportOnSelection.withRandomData() { - return new SlidingViewportOnSelection(_createRandomData()); + return SlidingViewportOnSelection(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), - new OrdinalSales('2018', random.nextInt(100)), - new OrdinalSales('2019', random.nextInt(100)), - new OrdinalSales('2020', random.nextInt(100)), - new OrdinalSales('2021', random.nextInt(100)), - new OrdinalSales('2022', random.nextInt(100)), - new OrdinalSales('2023', random.nextInt(100)), - new OrdinalSales('2024', random.nextInt(100)), - new OrdinalSales('2025', random.nextInt(100)), - new OrdinalSales('2026', random.nextInt(100)), - new OrdinalSales('2027', random.nextInt(100)), - new OrdinalSales('2028', random.nextInt(100)), - new OrdinalSales('2029', random.nextInt(100)), - new OrdinalSales('2030', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2018', random.nextInt(100)), + OrdinalSales('2019', random.nextInt(100)), + OrdinalSales('2020', random.nextInt(100)), + OrdinalSales('2021', random.nextInt(100)), + OrdinalSales('2022', random.nextInt(100)), + OrdinalSales('2023', random.nextInt(100)), + OrdinalSales('2024', random.nextInt(100)), + OrdinalSales('2025', random.nextInt(100)), + OrdinalSales('2026', random.nextInt(100)), + OrdinalSales('2027', random.nextInt(100)), + OrdinalSales('2028', random.nextInt(100)), + OrdinalSales('2029', random.nextInt(100)), + OrdinalSales('2030', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (OrdinalSales sales, _) => sales.year, @@ -82,49 +83,49 @@ class SlidingViewportOnSelection extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, behaviors: [ // Add the sliding viewport behavior to have the viewport center on the // domain that is currently selected. - new charts.SlidingViewport(), + charts.SlidingViewport(), // A pan and zoom behavior helps demonstrate the sliding viewport // behavior by allowing the data visible in the viewport to be adjusted // dynamically. - new charts.PanAndZoomBehavior(), + charts.PanAndZoomBehavior(), ], // Set an initial viewport to demonstrate the sliding viewport behavior on // initial chart load. - domainAxis: new charts.OrdinalAxisSpec( - viewport: new charts.OrdinalViewport('2018', 4)), + domainAxis: + charts.OrdinalAxisSpec(viewport: charts.OrdinalViewport('2018', 4)), ); } /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), - new OrdinalSales('2018', 33), - new OrdinalSales('2019', 80), - new OrdinalSales('2020', 21), - new OrdinalSales('2021', 77), - new OrdinalSales('2022', 8), - new OrdinalSales('2023', 12), - new OrdinalSales('2024', 42), - new OrdinalSales('2025', 70), - new OrdinalSales('2026', 77), - new OrdinalSales('2027', 55), - new OrdinalSales('2028', 19), - new OrdinalSales('2029', 66), - new OrdinalSales('2030', 27), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), + OrdinalSales('2018', 33), + OrdinalSales('2019', 80), + OrdinalSales('2020', 21), + OrdinalSales('2021', 77), + OrdinalSales('2022', 8), + OrdinalSales('2023', 12), + OrdinalSales('2024', 42), + OrdinalSales('2025', 70), + OrdinalSales('2026', 77), + OrdinalSales('2027', 55), + OrdinalSales('2028', 19), + OrdinalSales('2029', 66), + OrdinalSales('2030', 27), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (OrdinalSales sales, _) => sales.year, diff --git a/web/charts/lib/combo_chart/combo_gallery.dart b/web/charts/lib/combo_chart/combo_gallery.dart index e56655102..d5348dc94 100644 --- a/web/charts/lib/combo_chart/combo_gallery.dart +++ b/web/charts/lib/combo_chart/combo_gallery.dart @@ -23,35 +23,35 @@ import 'scatter_plot_line.dart'; List buildGallery() { return [ - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Ordinal Combo Chart', subtitle: 'Ordinal combo chart with bars and lines', - childBuilder: () => new OrdinalComboBarLineChart.withRandomData(), + childBuilder: () => OrdinalComboBarLineChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Numeric Line Bar Combo Chart', subtitle: 'Numeric combo chart with lines and bars', - childBuilder: () => new NumericComboLineBarChart.withRandomData(), + childBuilder: () => NumericComboLineBarChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Numeric Line Points Combo Chart', subtitle: 'Numeric combo chart with lines and points', - childBuilder: () => new NumericComboLinePointChart.withRandomData(), + childBuilder: () => NumericComboLinePointChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Time Series Combo Chart', subtitle: 'Time series combo chart with lines and points', - childBuilder: () => new DateTimeComboLinePointChart.withRandomData(), + childBuilder: () => DateTimeComboLinePointChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.scatter_plot), + GalleryScaffold( + listTileIcon: const Icon(Icons.scatter_plot), title: 'Scatter Plot Combo Chart', subtitle: 'Scatter plot combo chart with a line', - childBuilder: () => new ScatterPlotComboLineChart.withRandomData(), + childBuilder: () => ScatterPlotComboLineChart.withRandomData(), ), ]; } diff --git a/web/charts/lib/combo_chart/date_time_line_point.dart b/web/charts/lib/combo_chart/date_time_line_point.dart index cf2ffd11b..646adecf5 100644 --- a/web/charts/lib/combo_chart/date_time_line_point.dart +++ b/web/charts/lib/combo_chart/date_time_line_point.dart @@ -30,11 +30,12 @@ class DateTimeComboLinePointChart extends StatelessWidget { final List seriesList; final bool animate; - DateTimeComboLinePointChart(this.seriesList, {this.animate}); + const DateTimeComboLinePointChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [TimeSeriesChart] with sample data and no transition. factory DateTimeComboLinePointChart.withSampleData() { - return new DateTimeComboLinePointChart( + return DateTimeComboLinePointChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -46,50 +47,50 @@ class DateTimeComboLinePointChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory DateTimeComboLinePointChart.withRandomData() { - return new DateTimeComboLinePointChart(_createRandomData()); + return DateTimeComboLinePointChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final desktopSalesData = [ - new TimeSeriesSales(new DateTime(2017, 9, 19), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 26), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 10, 3), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 10, 10), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 19), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 26), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 10, 3), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 10, 10), random.nextInt(100)), ]; final tableSalesData = [ - new TimeSeriesSales(new DateTime(2017, 9, 19), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 26), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 10, 3), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 10, 10), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 19), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 26), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 10, 3), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 10, 10), random.nextInt(100)), ]; final mobileSalesData = [ - new TimeSeriesSales(new DateTime(2017, 9, 19), tableSalesData[0].sales), - new TimeSeriesSales(new DateTime(2017, 9, 26), tableSalesData[1].sales), - new TimeSeriesSales(new DateTime(2017, 10, 3), tableSalesData[2].sales), - new TimeSeriesSales(new DateTime(2017, 10, 10), tableSalesData[3].sales), + TimeSeriesSales(DateTime(2017, 9, 19), tableSalesData[0].sales), + TimeSeriesSales(DateTime(2017, 9, 26), tableSalesData[1].sales), + TimeSeriesSales(DateTime(2017, 10, 3), tableSalesData[2].sales), + TimeSeriesSales(DateTime(2017, 10, 10), tableSalesData[3].sales), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (TimeSeriesSales sales, _) => sales.time, measureFn: (TimeSeriesSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault, domainFn: (TimeSeriesSales sales, _) => sales.time, measureFn: (TimeSeriesSales sales, _) => sales.sales, data: tableSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault, domainFn: (TimeSeriesSales sales, _) => sales.time, @@ -103,17 +104,17 @@ class DateTimeComboLinePointChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.TimeSeriesChart( + return charts.TimeSeriesChart( seriesList, animate: animate, // Configure the default renderer as a line renderer. This will be used // for any series that does not define a rendererIdKey. // // This is the default configuration, but is shown here for illustration. - defaultRenderer: new charts.LineRendererConfig(), + defaultRenderer: charts.LineRendererConfig(), // Custom renderer configuration for the point series. customSeriesRenderers: [ - new charts.PointRendererConfig( + charts.PointRendererConfig( // ID used to link series to this renderer. customRendererId: 'customPoint') ], @@ -127,42 +128,42 @@ class DateTimeComboLinePointChart extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final desktopSalesData = [ - new TimeSeriesSales(new DateTime(2017, 9, 19), 5), - new TimeSeriesSales(new DateTime(2017, 9, 26), 25), - new TimeSeriesSales(new DateTime(2017, 10, 3), 100), - new TimeSeriesSales(new DateTime(2017, 10, 10), 75), + TimeSeriesSales(DateTime(2017, 9, 19), 5), + TimeSeriesSales(DateTime(2017, 9, 26), 25), + TimeSeriesSales(DateTime(2017, 10, 3), 100), + TimeSeriesSales(DateTime(2017, 10, 10), 75), ]; final tableSalesData = [ - new TimeSeriesSales(new DateTime(2017, 9, 19), 10), - new TimeSeriesSales(new DateTime(2017, 9, 26), 50), - new TimeSeriesSales(new DateTime(2017, 10, 3), 200), - new TimeSeriesSales(new DateTime(2017, 10, 10), 150), + TimeSeriesSales(DateTime(2017, 9, 19), 10), + TimeSeriesSales(DateTime(2017, 9, 26), 50), + TimeSeriesSales(DateTime(2017, 10, 3), 200), + TimeSeriesSales(DateTime(2017, 10, 10), 150), ]; final mobileSalesData = [ - new TimeSeriesSales(new DateTime(2017, 9, 19), 10), - new TimeSeriesSales(new DateTime(2017, 9, 26), 50), - new TimeSeriesSales(new DateTime(2017, 10, 3), 200), - new TimeSeriesSales(new DateTime(2017, 10, 10), 150), + TimeSeriesSales(DateTime(2017, 9, 19), 10), + TimeSeriesSales(DateTime(2017, 9, 26), 50), + TimeSeriesSales(DateTime(2017, 10, 3), 200), + TimeSeriesSales(DateTime(2017, 10, 10), 150), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (TimeSeriesSales sales, _) => sales.time, measureFn: (TimeSeriesSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault, domainFn: (TimeSeriesSales sales, _) => sales.time, measureFn: (TimeSeriesSales sales, _) => sales.sales, data: tableSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault, domainFn: (TimeSeriesSales sales, _) => sales.time, diff --git a/web/charts/lib/combo_chart/numeric_line_bar.dart b/web/charts/lib/combo_chart/numeric_line_bar.dart index 1f9ef516f..c3053a6de 100644 --- a/web/charts/lib/combo_chart/numeric_line_bar.dart +++ b/web/charts/lib/combo_chart/numeric_line_bar.dart @@ -25,11 +25,12 @@ class NumericComboLineBarChart extends StatelessWidget { final List seriesList; final bool animate; - NumericComboLineBarChart(this.seriesList, {this.animate}); + const NumericComboLineBarChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [LineChart] with sample data and no transition. factory NumericComboLineBarChart.withSampleData() { - return new NumericComboLineBarChart( + return NumericComboLineBarChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -41,36 +42,36 @@ class NumericComboLineBarChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory NumericComboLineBarChart.withRandomData() { - return new NumericComboLineBarChart(_createRandomData()); + return NumericComboLineBarChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final desktopSalesData = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; final tableSalesData = [ - new LinearSales(0, desktopSalesData[0].sales), - new LinearSales(1, desktopSalesData[1].sales), - new LinearSales(2, desktopSalesData[2].sales), - new LinearSales(3, desktopSalesData[3].sales), + LinearSales(0, desktopSalesData[0].sales), + LinearSales(1, desktopSalesData[1].sales), + LinearSales(2, desktopSalesData[2].sales), + LinearSales(3, desktopSalesData[3].sales), ]; final mobileSalesData = [ - new LinearSales(0, tableSalesData[0].sales * 2), - new LinearSales(1, tableSalesData[1].sales * 2), - new LinearSales(2, tableSalesData[2].sales * 2), - new LinearSales(3, tableSalesData[3].sales * 2), + LinearSales(0, tableSalesData[0].sales * 2), + LinearSales(1, tableSalesData[1].sales * 2), + LinearSales(2, tableSalesData[2].sales * 2), + LinearSales(3, tableSalesData[3].sales * 2), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, @@ -79,7 +80,7 @@ class NumericComboLineBarChart extends StatelessWidget { ) // Configure our custom bar renderer for this series. ..setAttribute(charts.rendererIdKey, 'customBar'), - new charts.Series( + charts.Series( id: 'Tablet', colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, @@ -88,7 +89,7 @@ class NumericComboLineBarChart extends StatelessWidget { ) // Configure our custom bar renderer for this series. ..setAttribute(charts.rendererIdKey, 'customBar'), - new charts.Series( + charts.Series( id: 'Mobile', colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, @@ -100,14 +101,14 @@ class NumericComboLineBarChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.NumericComboChart(seriesList, + return charts.NumericComboChart(seriesList, animate: animate, // Configure the default renderer as a line renderer. This will be used // for any series that does not define a rendererIdKey. - defaultRenderer: new charts.LineRendererConfig(), + defaultRenderer: charts.LineRendererConfig(), // Custom renderer configuration for the bar series. customSeriesRenderers: [ - new charts.BarRendererConfig( + charts.BarRendererConfig( // ID used to link series to this renderer. customRendererId: 'customBar') ]); @@ -116,28 +117,28 @@ class NumericComboLineBarChart extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final desktopSalesData = [ - new LinearSales(0, 5), - new LinearSales(1, 25), - new LinearSales(2, 100), - new LinearSales(3, 75), + LinearSales(0, 5), + LinearSales(1, 25), + LinearSales(2, 100), + LinearSales(3, 75), ]; final tableSalesData = [ - new LinearSales(0, 5), - new LinearSales(1, 25), - new LinearSales(2, 100), - new LinearSales(3, 75), + LinearSales(0, 5), + LinearSales(1, 25), + LinearSales(2, 100), + LinearSales(3, 75), ]; final mobileSalesData = [ - new LinearSales(0, 10), - new LinearSales(1, 50), - new LinearSales(2, 200), - new LinearSales(3, 150), + LinearSales(0, 10), + LinearSales(1, 50), + LinearSales(2, 200), + LinearSales(3, 150), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, @@ -146,7 +147,7 @@ class NumericComboLineBarChart extends StatelessWidget { ) // Configure our custom bar renderer for this series. ..setAttribute(charts.rendererIdKey, 'customBar'), - new charts.Series( + charts.Series( id: 'Tablet', colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, @@ -155,7 +156,7 @@ class NumericComboLineBarChart extends StatelessWidget { ) // Configure our custom bar renderer for this series. ..setAttribute(charts.rendererIdKey, 'customBar'), - new charts.Series( + charts.Series( id: 'Mobile', colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, diff --git a/web/charts/lib/combo_chart/numeric_line_point.dart b/web/charts/lib/combo_chart/numeric_line_point.dart index 0b371345d..059586810 100644 --- a/web/charts/lib/combo_chart/numeric_line_point.dart +++ b/web/charts/lib/combo_chart/numeric_line_point.dart @@ -30,11 +30,12 @@ class NumericComboLinePointChart extends StatelessWidget { final List seriesList; final bool animate; - NumericComboLinePointChart(this.seriesList, {this.animate}); + const NumericComboLinePointChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [LineChart] with sample data and no transition. factory NumericComboLinePointChart.withSampleData() { - return new NumericComboLinePointChart( + return NumericComboLinePointChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -46,50 +47,50 @@ class NumericComboLinePointChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory NumericComboLinePointChart.withRandomData() { - return new NumericComboLinePointChart(_createRandomData()); + return NumericComboLinePointChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final desktopSalesData = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; final tableSalesData = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; final mobileSalesData = [ - new LinearSales(0, tableSalesData[0].sales), - new LinearSales(1, tableSalesData[1].sales), - new LinearSales(2, tableSalesData[2].sales), - new LinearSales(3, tableSalesData[3].sales), + LinearSales(0, tableSalesData[0].sales), + LinearSales(1, tableSalesData[1].sales), + LinearSales(2, tableSalesData[2].sales), + LinearSales(3, tableSalesData[3].sales), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, data: tableSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, @@ -103,14 +104,14 @@ class NumericComboLinePointChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.NumericComboChart(seriesList, + return charts.NumericComboChart(seriesList, animate: animate, // Configure the default renderer as a line renderer. This will be used // for any series that does not define a rendererIdKey. - defaultRenderer: new charts.LineRendererConfig(), + defaultRenderer: charts.LineRendererConfig(), // Custom renderer configuration for the point series. customSeriesRenderers: [ - new charts.PointRendererConfig( + charts.PointRendererConfig( // ID used to link series to this renderer. customRendererId: 'customPoint') ]); @@ -119,42 +120,42 @@ class NumericComboLinePointChart extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final desktopSalesData = [ - new LinearSales(0, 5), - new LinearSales(1, 25), - new LinearSales(2, 100), - new LinearSales(3, 75), + LinearSales(0, 5), + LinearSales(1, 25), + LinearSales(2, 100), + LinearSales(3, 75), ]; final tableSalesData = [ - new LinearSales(0, 10), - new LinearSales(1, 50), - new LinearSales(2, 200), - new LinearSales(3, 150), + LinearSales(0, 10), + LinearSales(1, 50), + LinearSales(2, 200), + LinearSales(3, 150), ]; final mobileSalesData = [ - new LinearSales(0, 10), - new LinearSales(1, 50), - new LinearSales(2, 200), - new LinearSales(3, 150), + LinearSales(0, 10), + LinearSales(1, 50), + LinearSales(2, 200), + LinearSales(3, 150), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, data: tableSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, diff --git a/web/charts/lib/combo_chart/ordinal_bar_line.dart b/web/charts/lib/combo_chart/ordinal_bar_line.dart index ae2086001..4d65dc8d7 100644 --- a/web/charts/lib/combo_chart/ordinal_bar_line.dart +++ b/web/charts/lib/combo_chart/ordinal_bar_line.dart @@ -25,10 +25,11 @@ class OrdinalComboBarLineChart extends StatelessWidget { final List seriesList; final bool animate; - OrdinalComboBarLineChart(this.seriesList, {this.animate}); + const OrdinalComboBarLineChart(this.seriesList, {this.animate, Key key}) + : super(key: key); factory OrdinalComboBarLineChart.withSampleData() { - return new OrdinalComboBarLineChart( + return OrdinalComboBarLineChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -40,48 +41,48 @@ class OrdinalComboBarLineChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory OrdinalComboBarLineChart.withRandomData() { - return new OrdinalComboBarLineChart(_createRandomData()); + return OrdinalComboBarLineChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final desktopSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final tableSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final mobileSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData), - new charts.Series( + charts.Series( id: 'Tablet', colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault, domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesData), - new charts.Series( + charts.Series( id: 'Mobile', colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault, domainFn: (OrdinalSales sales, _) => sales.year, @@ -95,15 +96,15 @@ class OrdinalComboBarLineChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.OrdinalComboChart(seriesList, + return charts.OrdinalComboChart(seriesList, animate: animate, // Configure the default renderer as a bar renderer. - defaultRenderer: new charts.BarRendererConfig( + defaultRenderer: charts.BarRendererConfig( groupingType: charts.BarGroupingType.grouped), // Custom renderer configuration for the line series. This will be used for // any series that does not define a rendererIdKey. customSeriesRenderers: [ - new charts.LineRendererConfig( + charts.LineRendererConfig( // ID used to link series to this renderer. customRendererId: 'customLine') ]); @@ -112,40 +113,40 @@ class OrdinalComboBarLineChart extends StatelessWidget { /// Create series list with multiple series static List> _createSampleData() { final desktopSalesData = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tableSalesData = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final mobileSalesData = [ - new OrdinalSales('2014', 10), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 200), - new OrdinalSales('2017', 150), + OrdinalSales('2014', 10), + OrdinalSales('2015', 50), + OrdinalSales('2016', 200), + OrdinalSales('2017', 150), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData), - new charts.Series( + charts.Series( id: 'Tablet', colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault, domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tableSalesData), - new charts.Series( + charts.Series( id: 'Mobile ', colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault, domainFn: (OrdinalSales sales, _) => sales.year, diff --git a/web/charts/lib/combo_chart/scatter_plot_line.dart b/web/charts/lib/combo_chart/scatter_plot_line.dart index e2d6df9f3..0912df585 100644 --- a/web/charts/lib/combo_chart/scatter_plot_line.dart +++ b/web/charts/lib/combo_chart/scatter_plot_line.dart @@ -25,11 +25,12 @@ class ScatterPlotComboLineChart extends StatelessWidget { final List seriesList; final bool animate; - ScatterPlotComboLineChart(this.seriesList, {this.animate}); + const ScatterPlotComboLineChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [ScatterPlotChart] with sample data and no transition. factory ScatterPlotComboLineChart.withSampleData() { - return new ScatterPlotComboLineChart( + return ScatterPlotComboLineChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -41,40 +42,40 @@ class ScatterPlotComboLineChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory ScatterPlotComboLineChart.withRandomData() { - return new ScatterPlotComboLineChart(_createRandomData()); + return ScatterPlotComboLineChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); - final makeRadius = (int value) => (random.nextInt(value) + 2).toDouble(); + makeRadius(int value) => (random.nextInt(value) + 2).toDouble(); final desktopSalesData = [ - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), ]; var myRegressionData = [ - new LinearSales(0, desktopSalesData[0].sales, 3.5), - new LinearSales( + LinearSales(0, desktopSalesData[0].sales, 3.5), + LinearSales( 100, desktopSalesData[desktopSalesData.length - 1].sales, 7.5), ]; - final maxMeasure = 100; + const maxMeasure = 100; return [ - new charts.Series( + charts.Series( id: 'Sales', // Providing a color function is optional. colorFn: (LinearSales sales, _) { @@ -95,7 +96,7 @@ class ScatterPlotComboLineChart extends StatelessWidget { radiusPxFn: (LinearSales sales, _) => sales.radius, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', colorFn: (_, __) => charts.MaterialPalette.purple.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, @@ -109,17 +110,17 @@ class ScatterPlotComboLineChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.ScatterPlotChart(seriesList, + return charts.ScatterPlotChart(seriesList, animate: animate, // Configure the default renderer as a point renderer. This will be used // for any series that does not define a rendererIdKey. // // This is the default configuration, but is shown here for // illustration. - defaultRenderer: new charts.PointRendererConfig(), + defaultRenderer: charts.PointRendererConfig(), // Custom renderer configuration for the line series. customSeriesRenderers: [ - new charts.LineRendererConfig( + charts.LineRendererConfig( // ID used to link series to this renderer. customRendererId: 'customLine', // Configure the regression line to be painted above the points. @@ -133,29 +134,29 @@ class ScatterPlotComboLineChart extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final desktopSalesData = [ - new LinearSales(0, 5, 3.0), - new LinearSales(10, 25, 5.0), - new LinearSales(12, 75, 4.0), - new LinearSales(13, 225, 5.0), - new LinearSales(16, 50, 4.0), - new LinearSales(24, 75, 3.0), - new LinearSales(25, 100, 3.0), - new LinearSales(34, 150, 5.0), - new LinearSales(37, 10, 4.5), - new LinearSales(45, 300, 8.0), - new LinearSales(52, 15, 4.0), - new LinearSales(56, 200, 7.0), + LinearSales(0, 5, 3.0), + LinearSales(10, 25, 5.0), + LinearSales(12, 75, 4.0), + LinearSales(13, 225, 5.0), + LinearSales(16, 50, 4.0), + LinearSales(24, 75, 3.0), + LinearSales(25, 100, 3.0), + LinearSales(34, 150, 5.0), + LinearSales(37, 10, 4.5), + LinearSales(45, 300, 8.0), + LinearSales(52, 15, 4.0), + LinearSales(56, 200, 7.0), ]; var myRegressionData = [ - new LinearSales(0, 5, 3.5), - new LinearSales(56, 240, 3.5), + LinearSales(0, 5, 3.5), + LinearSales(56, 240, 3.5), ]; - final maxMeasure = 300; + const maxMeasure = 300; return [ - new charts.Series( + charts.Series( id: 'Sales', // Providing a color function is optional. colorFn: (LinearSales sales, _) { @@ -176,7 +177,7 @@ class ScatterPlotComboLineChart extends StatelessWidget { radiusPxFn: (LinearSales sales, _) => sales.radius, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', colorFn: (_, __) => charts.MaterialPalette.purple.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, diff --git a/web/charts/lib/drawer.dart b/web/charts/lib/drawer.dart index ad2f68ac1..d0647afa5 100644 --- a/web/charts/lib/drawer.dart +++ b/web/charts/lib/drawer.dart @@ -20,7 +20,7 @@ class GalleryDrawer extends StatelessWidget { final bool showPerformanceOverlay; final ValueChanged onShowPerformanceOverlayChanged; - GalleryDrawer( + const GalleryDrawer( {Key key, this.showPerformanceOverlay, this.onShowPerformanceOverlayChanged}) @@ -28,17 +28,17 @@ class GalleryDrawer extends StatelessWidget { @override Widget build(BuildContext context) { - return new Drawer( - child: new ListView(children: [ + return Drawer( + child: ListView(children: [ // Performance overlay toggle. - new ListTile( - leading: new Icon(Icons.assessment), - title: new Text('Performance Overlay'), + ListTile( + leading: const Icon(Icons.assessment), + title: const Text('Performance Overlay'), onTap: () { onShowPerformanceOverlayChanged(!showPerformanceOverlay); }, selected: showPerformanceOverlay, - trailing: new Checkbox( + trailing: Checkbox( value: showPerformanceOverlay, onChanged: (bool value) { onShowPerformanceOverlayChanged(!showPerformanceOverlay); diff --git a/web/charts/lib/gallery_scaffold.dart b/web/charts/lib/gallery_scaffold.dart index 9278ce6fd..332ad47ef 100644 --- a/web/charts/lib/gallery_scaffold.dart +++ b/web/charts/lib/gallery_scaffold.dart @@ -15,7 +15,7 @@ import 'package:flutter/material.dart'; -typedef Widget GalleryWidgetBuilder(); +typedef GalleryWidgetBuilder = Widget Function(); /// Helper to build gallery. class GalleryScaffold extends StatefulWidget { @@ -25,20 +25,25 @@ class GalleryScaffold extends StatefulWidget { final String subtitle; final GalleryWidgetBuilder childBuilder; - GalleryScaffold( - {this.listTileIcon, this.title, this.subtitle, this.childBuilder}); + const GalleryScaffold( + {this.listTileIcon, + this.title, + this.subtitle, + this.childBuilder, + Key key}) + : super(key: key); /// Gets the gallery - Widget buildGalleryListTile(BuildContext context) => new ListTile( + Widget buildGalleryListTile(BuildContext context) => ListTile( leading: listTileIcon, - title: new Text(title), - subtitle: new Text(subtitle), + title: Text(title), + subtitle: Text(subtitle), onTap: () { - Navigator.push(context, new MaterialPageRoute(builder: (_) => this)); + Navigator.push(context, MaterialPageRoute(builder: (_) => this)); }); @override - _GalleryScaffoldState createState() => new _GalleryScaffoldState(); + _GalleryScaffoldState createState() => _GalleryScaffoldState(); } class _GalleryScaffoldState extends State { @@ -48,15 +53,15 @@ class _GalleryScaffoldState extends State { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar(title: new Text(widget.title)), - body: new Padding( + return Scaffold( + appBar: AppBar(title: Text(widget.title)), + body: Padding( padding: const EdgeInsets.all(8.0), - child: new Column(children: [ - new SizedBox(height: 250.0, child: widget.childBuilder()), + child: Column(children: [ + SizedBox(height: 250.0, child: widget.childBuilder()), ])), - floatingActionButton: new FloatingActionButton( - child: new Icon(Icons.refresh), onPressed: _handleButtonPress), + floatingActionButton: FloatingActionButton( + child: const Icon(Icons.refresh), onPressed: _handleButtonPress), ); } } diff --git a/web/charts/lib/home.dart b/web/charts/lib/home.dart index c51904f89..b40833965 100644 --- a/web/charts/lib/home.dart +++ b/web/charts/lib/home.dart @@ -53,7 +53,7 @@ class Home extends StatelessWidget { Home( {Key key, this.showPerformanceOverlay, - this.onShowPerformanceOverlayChanged}) + @required this.onShowPerformanceOverlayChanged}) : super(key: key) { assert(onShowPerformanceOverlayChanged != null); } @@ -106,12 +106,12 @@ class Home extends StatelessWidget { _setupPerformance(); - return new Scaffold( - drawer: new GalleryDrawer( + return Scaffold( + drawer: GalleryDrawer( showPerformanceOverlay: showPerformanceOverlay, onShowPerformanceOverlayChanged: onShowPerformanceOverlayChanged), - appBar: new AppBar(title: new Text(defaultConfig.appName)), - body: new ListView(padding: kMaterialListPadding, children: galleries), + appBar: AppBar(title: Text(defaultConfig.appName)), + body: ListView(padding: kMaterialListPadding, children: galleries), ); } diff --git a/web/charts/lib/i18n/i18n_gallery.dart b/web/charts/lib/i18n/i18n_gallery.dart index cab90664d..e63a4d1ce 100644 --- a/web/charts/lib/i18n/i18n_gallery.dart +++ b/web/charts/lib/i18n/i18n_gallery.dart @@ -22,29 +22,29 @@ import 'rtl_series_legend.dart'; List buildGallery() { return [ - new GalleryScaffold( - listTileIcon: new Icon(Icons.flag), + GalleryScaffold( + listTileIcon: const Icon(Icons.flag), title: 'RTL Bar Chart', subtitle: 'Simple bar chart in RTL', - childBuilder: () => new RTLBarChart.withRandomData(), + childBuilder: () => RTLBarChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.flag), + GalleryScaffold( + listTileIcon: const Icon(Icons.flag), title: 'RTL Line Chart', subtitle: 'Simple line chart in RTL', - childBuilder: () => new RTLLineChart.withRandomData(), + childBuilder: () => RTLLineChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.flag), + GalleryScaffold( + listTileIcon: const Icon(Icons.flag), title: 'RTL Line Segments', subtitle: 'Stacked area chart with style segments in RTL', - childBuilder: () => new RTLLineSegments.withRandomData(), + childBuilder: () => RTLLineSegments.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.flag), + GalleryScaffold( + listTileIcon: const Icon(Icons.flag), title: 'RTL Series Legend', subtitle: 'Series legend in RTL', - childBuilder: () => new RTLSeriesLegend.withRandomData(), + childBuilder: () => RTLSeriesLegend.withRandomData(), ), ]; } diff --git a/web/charts/lib/i18n/rtl_bar_chart.dart b/web/charts/lib/i18n/rtl_bar_chart.dart index d4916561b..b88ed26e2 100644 --- a/web/charts/lib/i18n/rtl_bar_chart.dart +++ b/web/charts/lib/i18n/rtl_bar_chart.dart @@ -24,11 +24,11 @@ class RTLBarChart extends StatelessWidget { final List seriesList; final bool animate; - RTLBarChart(this.seriesList, {this.animate}); + const RTLBarChart(this.seriesList, {this.animate, Key key}) : super(key: key); /// Creates a [BarChart] with sample data and no transition. factory RTLBarChart.withSampleData() { - return new RTLBarChart( + return RTLBarChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -40,22 +40,22 @@ class RTLBarChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory RTLBarChart.withRandomData() { - return new RTLBarChart(_createRandomData()); + return RTLBarChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -81,9 +81,9 @@ class RTLBarChart extends StatelessWidget { // // Optionally, [RTLSpec] can be passed in when creating the chart to specify // chart display settings in RTL mode. - return new Directionality( + return Directionality( textDirection: TextDirection.rtl, - child: new charts.BarChart( + child: charts.BarChart( seriesList, animate: animate, vertical: false, @@ -93,14 +93,14 @@ class RTLBarChart extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/i18n/rtl_line_chart.dart b/web/charts/lib/i18n/rtl_line_chart.dart index 01b5d6130..d43d51c44 100644 --- a/web/charts/lib/i18n/rtl_line_chart.dart +++ b/web/charts/lib/i18n/rtl_line_chart.dart @@ -24,11 +24,12 @@ class RTLLineChart extends StatelessWidget { final List seriesList; final bool animate; - RTLLineChart(this.seriesList, {this.animate}); + const RTLLineChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [LineChart] with sample data and no transition. factory RTLLineChart.withSampleData() { - return new RTLLineChart( + return RTLLineChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -40,22 +41,22 @@ class RTLLineChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory RTLLineChart.withRandomData() { - return new RTLLineChart(_createRandomData()); + return RTLLineChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, @@ -78,9 +79,9 @@ class RTLLineChart extends StatelessWidget { // Measure axis positions are flipped. Primary measure axis is on the right // and the secondary measure axis is on the left (when used). // Domain axis' first domain starts on the right and grows left. - return new Directionality( + return Directionality( textDirection: TextDirection.rtl, - child: new charts.LineChart( + child: charts.LineChart( seriesList, animate: animate, )); @@ -89,14 +90,14 @@ class RTLLineChart extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new LinearSales(0, 5), - new LinearSales(1, 25), - new LinearSales(2, 100), - new LinearSales(3, 75), + LinearSales(0, 5), + LinearSales(1, 25), + LinearSales(2, 100), + LinearSales(3, 75), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, diff --git a/web/charts/lib/i18n/rtl_line_segments.dart b/web/charts/lib/i18n/rtl_line_segments.dart index 9560d35d5..c981438b3 100644 --- a/web/charts/lib/i18n/rtl_line_segments.dart +++ b/web/charts/lib/i18n/rtl_line_segments.dart @@ -35,11 +35,12 @@ class RTLLineSegments extends StatelessWidget { final List seriesList; final bool animate; - RTLLineSegments(this.seriesList, {this.animate}); + const RTLLineSegments(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [LineChart] with sample data and no transition. factory RTLLineSegments.withSampleData() { - return new RTLLineSegments( + return RTLLineSegments( _createSampleData(), // Disable animations for image tests. animate: false, @@ -51,45 +52,45 @@ class RTLLineSegments extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory RTLLineSegments.withRandomData() { - return new RTLLineSegments(_createRandomData()); + return RTLLineSegments(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); // Series of data with static dash pattern and stroke width. The colorFn // accessor will colorize each datum (for all three series). final colorChangeData = [ - new LinearSales(0, random.nextInt(100), null, 2.0), - new LinearSales(1, random.nextInt(100), null, 2.0), - new LinearSales(2, random.nextInt(100), null, 2.0), - new LinearSales(3, random.nextInt(100), null, 2.0), - new LinearSales(4, random.nextInt(100), null, 2.0), - new LinearSales(5, random.nextInt(100), null, 2.0), - new LinearSales(6, random.nextInt(100), null, 2.0), + LinearSales(0, random.nextInt(100), null, 2.0), + LinearSales(1, random.nextInt(100), null, 2.0), + LinearSales(2, random.nextInt(100), null, 2.0), + LinearSales(3, random.nextInt(100), null, 2.0), + LinearSales(4, random.nextInt(100), null, 2.0), + LinearSales(5, random.nextInt(100), null, 2.0), + LinearSales(6, random.nextInt(100), null, 2.0), ]; // Series of data with changing color and dash pattern. final dashPatternChangeData = [ - new LinearSales(0, random.nextInt(100), [2, 2], 2.0), - new LinearSales(1, random.nextInt(100), [2, 2], 2.0), - new LinearSales(2, random.nextInt(100), [4, 4], 2.0), - new LinearSales(3, random.nextInt(100), [4, 4], 2.0), - new LinearSales(4, random.nextInt(100), [4, 4], 2.0), - new LinearSales(5, random.nextInt(100), [8, 3, 2, 3], 2.0), - new LinearSales(6, random.nextInt(100), [8, 3, 2, 3], 2.0), + LinearSales(0, random.nextInt(100), [2, 2], 2.0), + LinearSales(1, random.nextInt(100), [2, 2], 2.0), + LinearSales(2, random.nextInt(100), [4, 4], 2.0), + LinearSales(3, random.nextInt(100), [4, 4], 2.0), + LinearSales(4, random.nextInt(100), [4, 4], 2.0), + LinearSales(5, random.nextInt(100), [8, 3, 2, 3], 2.0), + LinearSales(6, random.nextInt(100), [8, 3, 2, 3], 2.0), ]; // Series of data with changing color and stroke width. final strokeWidthChangeData = [ - new LinearSales(0, random.nextInt(100), null, 2.0), - new LinearSales(1, random.nextInt(100), null, 2.0), - new LinearSales(2, random.nextInt(100), null, 4.0), - new LinearSales(3, random.nextInt(100), null, 4.0), - new LinearSales(4, random.nextInt(100), null, 4.0), - new LinearSales(5, random.nextInt(100), null, 6.0), - new LinearSales(6, random.nextInt(100), null, 6.0), + LinearSales(0, random.nextInt(100), null, 2.0), + LinearSales(1, random.nextInt(100), null, 2.0), + LinearSales(2, random.nextInt(100), null, 4.0), + LinearSales(3, random.nextInt(100), null, 4.0), + LinearSales(4, random.nextInt(100), null, 4.0), + LinearSales(5, random.nextInt(100), null, 6.0), + LinearSales(6, random.nextInt(100), null, 6.0), ]; // Generate 2 shades of each color so that we can style the line segments. @@ -98,7 +99,7 @@ class RTLLineSegments extends StatelessWidget { final green = charts.MaterialPalette.green.makeShades(2); return [ - new charts.Series( + charts.Series( id: 'Color Change', // Light shade for even years, dark shade for odd. colorFn: (LinearSales sales, _) => @@ -109,7 +110,7 @@ class RTLLineSegments extends StatelessWidget { measureFn: (LinearSales sales, _) => sales.sales, data: colorChangeData, ), - new charts.Series( + charts.Series( id: 'Dash Pattern Change', // Light shade for even years, dark shade for odd. colorFn: (LinearSales sales, _) => @@ -120,7 +121,7 @@ class RTLLineSegments extends StatelessWidget { measureFn: (LinearSales sales, _) => sales.sales, data: dashPatternChangeData, ), - new charts.Series( + charts.Series( id: 'Stroke Width Change', // Light shade for even years, dark shade for odd. colorFn: (LinearSales sales, _) => @@ -148,12 +149,12 @@ class RTLLineSegments extends StatelessWidget { // Measure axis positions are flipped. Primary measure axis is on the right // and the secondary measure axis is on the left (when used). // Domain axis' first domain starts on the right and grows left. - return new Directionality( + return Directionality( textDirection: TextDirection.rtl, - child: new charts.LineChart( + child: charts.LineChart( seriesList, defaultRenderer: - new charts.LineRendererConfig(includeArea: true, stacked: true), + charts.LineRendererConfig(includeArea: true, stacked: true), animate: animate, )); } @@ -163,35 +164,35 @@ class RTLLineSegments extends StatelessWidget { // Series of data with static dash pattern and stroke width. The colorFn // accessor will colorize each datum (for all three series). final colorChangeData = [ - new LinearSales(0, 5, null, 2.0), - new LinearSales(1, 15, null, 2.0), - new LinearSales(2, 25, null, 2.0), - new LinearSales(3, 75, null, 2.0), - new LinearSales(4, 100, null, 2.0), - new LinearSales(5, 90, null, 2.0), - new LinearSales(6, 75, null, 2.0), + LinearSales(0, 5, null, 2.0), + LinearSales(1, 15, null, 2.0), + LinearSales(2, 25, null, 2.0), + LinearSales(3, 75, null, 2.0), + LinearSales(4, 100, null, 2.0), + LinearSales(5, 90, null, 2.0), + LinearSales(6, 75, null, 2.0), ]; // Series of data with changing color and dash pattern. final dashPatternChangeData = [ - new LinearSales(0, 5, [2, 2], 2.0), - new LinearSales(1, 15, [2, 2], 2.0), - new LinearSales(2, 25, [4, 4], 2.0), - new LinearSales(3, 75, [4, 4], 2.0), - new LinearSales(4, 100, [4, 4], 2.0), - new LinearSales(5, 90, [8, 3, 2, 3], 2.0), - new LinearSales(6, 75, [8, 3, 2, 3], 2.0), + LinearSales(0, 5, [2, 2], 2.0), + LinearSales(1, 15, [2, 2], 2.0), + LinearSales(2, 25, [4, 4], 2.0), + LinearSales(3, 75, [4, 4], 2.0), + LinearSales(4, 100, [4, 4], 2.0), + LinearSales(5, 90, [8, 3, 2, 3], 2.0), + LinearSales(6, 75, [8, 3, 2, 3], 2.0), ]; // Series of data with changing color and stroke width. final strokeWidthChangeData = [ - new LinearSales(0, 5, null, 2.0), - new LinearSales(1, 15, null, 2.0), - new LinearSales(2, 25, null, 4.0), - new LinearSales(3, 75, null, 4.0), - new LinearSales(4, 100, null, 4.0), - new LinearSales(5, 90, null, 6.0), - new LinearSales(6, 75, null, 6.0), + LinearSales(0, 5, null, 2.0), + LinearSales(1, 15, null, 2.0), + LinearSales(2, 25, null, 4.0), + LinearSales(3, 75, null, 4.0), + LinearSales(4, 100, null, 4.0), + LinearSales(5, 90, null, 6.0), + LinearSales(6, 75, null, 6.0), ]; // Generate 2 shades of each color so that we can style the line segments. @@ -200,7 +201,7 @@ class RTLLineSegments extends StatelessWidget { final green = charts.MaterialPalette.green.makeShades(2); return [ - new charts.Series( + charts.Series( id: 'Color Change', // Light shade for even years, dark shade for odd. colorFn: (LinearSales sales, _) => @@ -211,7 +212,7 @@ class RTLLineSegments extends StatelessWidget { measureFn: (LinearSales sales, _) => sales.sales, data: colorChangeData, ), - new charts.Series( + charts.Series( id: 'Dash Pattern Change', // Light shade for even years, dark shade for odd. colorFn: (LinearSales sales, _) => @@ -222,7 +223,7 @@ class RTLLineSegments extends StatelessWidget { measureFn: (LinearSales sales, _) => sales.sales, data: dashPatternChangeData, ), - new charts.Series( + charts.Series( id: 'Stroke Width Change', // Light shade for even years, dark shade for odd. colorFn: (LinearSales sales, _) => diff --git a/web/charts/lib/i18n/rtl_series_legend.dart b/web/charts/lib/i18n/rtl_series_legend.dart index 06763382c..e46b167ec 100644 --- a/web/charts/lib/i18n/rtl_series_legend.dart +++ b/web/charts/lib/i18n/rtl_series_legend.dart @@ -24,11 +24,12 @@ class RTLSeriesLegend extends StatelessWidget { final List seriesList; final bool animate; - RTLSeriesLegend(this.seriesList, {this.animate}); + const RTLSeriesLegend(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [BarChart] with sample data and no transition. factory RTLSeriesLegend.withSampleData() { - return new RTLSeriesLegend( + return RTLSeriesLegend( _createSampleData(), // Disable animations for image tests. animate: false, @@ -40,61 +41,61 @@ class RTLSeriesLegend extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory RTLSeriesLegend.withRandomData() { - return new RTLSeriesLegend(_createRandomData()); + return RTLSeriesLegend(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final desktopSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final tabletSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final mobileSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final otherSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tabletSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: mobileSalesData, ), - new charts.Series( + charts.Series( id: 'Other', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -126,13 +127,13 @@ class RTLSeriesLegend extends StatelessWidget { // The below example changes the position to 'start' and max rows of 2 in // order to show these effects, but are not required for SeriesLegend to // work with the correct directionality. - return new Directionality( + return Directionality( textDirection: TextDirection.rtl, - child: new charts.BarChart( + child: charts.BarChart( seriesList, animate: animate, behaviors: [ - new charts.SeriesLegend( + charts.SeriesLegend( position: charts.BehaviorPosition.end, desiredMaxRows: 2) ], )); @@ -141,53 +142,53 @@ class RTLSeriesLegend extends StatelessWidget { /// Create series list with multiple series static List> _createSampleData() { final desktopSalesData = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tabletSalesData = [ - new OrdinalSales('2014', 25), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 10), - new OrdinalSales('2017', 20), + OrdinalSales('2014', 25), + OrdinalSales('2015', 50), + OrdinalSales('2016', 10), + OrdinalSales('2017', 20), ]; final mobileSalesData = [ - new OrdinalSales('2014', 10), - new OrdinalSales('2015', 15), - new OrdinalSales('2016', 50), - new OrdinalSales('2017', 45), + OrdinalSales('2014', 10), + OrdinalSales('2015', 15), + OrdinalSales('2016', 50), + OrdinalSales('2017', 45), ]; final otherSalesData = [ - new OrdinalSales('2014', 20), - new OrdinalSales('2015', 35), - new OrdinalSales('2016', 15), - new OrdinalSales('2017', 10), + OrdinalSales('2014', 20), + OrdinalSales('2015', 35), + OrdinalSales('2016', 15), + OrdinalSales('2017', 10), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tabletSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: mobileSalesData, ), - new charts.Series( + charts.Series( id: 'Other', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/legends/datum_legend_options.dart b/web/charts/lib/legends/datum_legend_options.dart index 6ab6da204..f052b7e53 100644 --- a/web/charts/lib/legends/datum_legend_options.dart +++ b/web/charts/lib/legends/datum_legend_options.dart @@ -28,10 +28,11 @@ class DatumLegendOptions extends StatelessWidget { final List seriesList; final bool animate; - DatumLegendOptions(this.seriesList, {this.animate}); + const DatumLegendOptions(this.seriesList, {this.animate, Key key}) + : super(key: key); factory DatumLegendOptions.withSampleData() { - return new DatumLegendOptions( + return DatumLegendOptions( _createSampleData(), // Disable animations for image tests. animate: false, @@ -43,22 +44,22 @@ class DatumLegendOptions extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory DatumLegendOptions.withRandomData() { - return new DatumLegendOptions(_createRandomData()); + return DatumLegendOptions(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, @@ -70,14 +71,14 @@ class DatumLegendOptions extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.PieChart( + return charts.PieChart( seriesList, animate: animate, // Add the legend behavior to the chart to turn on legends. // This example shows how to change the position and justification of // the legend, in addition to altering the max rows and padding. behaviors: [ - new charts.DatumLegend( + charts.DatumLegend( // Positions for "start" and "end" will be left and right respectively // for widgets with a build context that has directionality ltr. // For rtl, "start" and "end" will be right and left respectively. @@ -96,7 +97,7 @@ class DatumLegendOptions extends StatelessWidget { // rows before adding a new column. desiredMaxRows: 2, // This defines the padding around each legend entry. - cellPadding: new EdgeInsets.only(right: 4.0, bottom: 4.0), + cellPadding: const EdgeInsets.only(right: 4.0, bottom: 4.0), // Render the legend entry text with custom styles. entryTextStyle: charts.TextStyleSpec( color: charts.MaterialPalette.purple.shadeDefault, @@ -110,14 +111,14 @@ class DatumLegendOptions extends StatelessWidget { /// Create series list with one series static List> _createSampleData() { final data = [ - new LinearSales(0, 100), - new LinearSales(1, 75), - new LinearSales(2, 25), - new LinearSales(3, 5), + LinearSales(0, 100), + LinearSales(1, 75), + LinearSales(2, 25), + LinearSales(3, 5), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, diff --git a/web/charts/lib/legends/datum_legend_with_measures.dart b/web/charts/lib/legends/datum_legend_with_measures.dart index 0d9dbd962..625b25a42 100644 --- a/web/charts/lib/legends/datum_legend_with_measures.dart +++ b/web/charts/lib/legends/datum_legend_with_measures.dart @@ -28,13 +28,14 @@ import 'package:charts_flutter/flutter.dart' as charts; /// /// Also shows the option to provide a custom measure formatter. class DatumLegendWithMeasures extends StatelessWidget { - final List seriesList; + final List> seriesList; final bool animate; - DatumLegendWithMeasures(this.seriesList, {this.animate}); + const DatumLegendWithMeasures(this.seriesList, {this.animate, Key key}) + : super(key: key); factory DatumLegendWithMeasures.withSampleData() { - return new DatumLegendWithMeasures( + return DatumLegendWithMeasures( _createSampleData(), // Disable animations for image tests. animate: false, @@ -46,22 +47,22 @@ class DatumLegendWithMeasures extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory DatumLegendWithMeasures.withRandomData() { - return new DatumLegendWithMeasures(_createRandomData()); + return DatumLegendWithMeasures(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new LinearSales(2014, random.nextInt(100)), - new LinearSales(2015, random.nextInt(100)), - new LinearSales(2016, random.nextInt(100)), - new LinearSales(2017, random.nextInt(100)), + LinearSales(2014, random.nextInt(100)), + LinearSales(2015, random.nextInt(100)), + LinearSales(2016, random.nextInt(100)), + LinearSales(2017, random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, @@ -73,7 +74,7 @@ class DatumLegendWithMeasures extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.PieChart( + return charts.PieChart( seriesList, animate: animate, // Add the legend behavior to the chart to turn on legends. @@ -84,13 +85,13 @@ class DatumLegendWithMeasures extends StatelessWidget { // This section is excluded from being copied to the gallery. // This is added in order to generate the image for the gallery to show // an initial selection so that measure values are shown in the gallery. - new charts.InitialSelection( + charts.InitialSelection( selectedDataConfig: [ - new charts.SeriesDatumConfig('Sales', 0), + charts.SeriesDatumConfig('Sales', 0), ], ), // EXCLUDE_FROM_GALLERY_DOCS_END - new charts.DatumLegend( + charts.DatumLegend( // Positions for "start" and "end" will be left and right respectively // for widgets with a build context that has directionality ltr. // For rtl, "start" and "end" will be right and left respectively. @@ -102,7 +103,7 @@ class DatumLegendWithMeasures extends StatelessWidget { // legend entries will grow as new rows first instead of a new column. horizontalFirst: false, // This defines the padding around each legend entry. - cellPadding: new EdgeInsets.only(right: 4.0, bottom: 4.0), + cellPadding: const EdgeInsets.only(right: 4.0, bottom: 4.0), // Set [showMeasures] to true to display measures in series legend. showMeasures: true, // Configure the measure value to be shown by default in the legend. @@ -120,14 +121,14 @@ class DatumLegendWithMeasures extends StatelessWidget { /// Create series list with one series static List> _createSampleData() { final data = [ - new LinearSales(2014, 100), - new LinearSales(2015, 75), - new LinearSales(2016, 25), - new LinearSales(2017, 5), + LinearSales(2014, 100), + LinearSales(2015, 75), + LinearSales(2016, 25), + LinearSales(2017, 5), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, diff --git a/web/charts/lib/legends/default_hidden_series_legend.dart b/web/charts/lib/legends/default_hidden_series_legend.dart index d1cc48275..60026a2d0 100644 --- a/web/charts/lib/legends/default_hidden_series_legend.dart +++ b/web/charts/lib/legends/default_hidden_series_legend.dart @@ -24,10 +24,11 @@ class DefaultHiddenSeriesLegend extends StatelessWidget { final List seriesList; final bool animate; - DefaultHiddenSeriesLegend(this.seriesList, {this.animate}); + const DefaultHiddenSeriesLegend(this.seriesList, {this.animate, Key key}) + : super(key: key); factory DefaultHiddenSeriesLegend.withSampleData() { - return new DefaultHiddenSeriesLegend( + return DefaultHiddenSeriesLegend( _createSampleData(), // Disable animations for image tests. animate: false, @@ -39,61 +40,61 @@ class DefaultHiddenSeriesLegend extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory DefaultHiddenSeriesLegend.withRandomData() { - return new DefaultHiddenSeriesLegend(_createRandomData()); + return DefaultHiddenSeriesLegend(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final desktopSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final tabletSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final mobileSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final otherSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tabletSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: mobileSalesData, ), - new charts.Series( + charts.Series( id: 'Other', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -105,16 +106,16 @@ class DefaultHiddenSeriesLegend extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, barGroupingType: charts.BarGroupingType.grouped, // Add the series legend behavior to the chart to turn on series legends. // By default the legend will display above the chart. behaviors: [ - new charts.SeriesLegend( + charts.SeriesLegend( // Configures the "Other" series to be hidden on first chart draw. - defaultHiddenSeries: ['Other'], + defaultHiddenSeries: const ['Other'], ) ], ); @@ -123,53 +124,53 @@ class DefaultHiddenSeriesLegend extends StatelessWidget { /// Create series list with multiple series static List> _createSampleData() { final desktopSalesData = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tabletSalesData = [ - new OrdinalSales('2014', 25), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 10), - new OrdinalSales('2017', 20), + OrdinalSales('2014', 25), + OrdinalSales('2015', 50), + OrdinalSales('2016', 10), + OrdinalSales('2017', 20), ]; final mobileSalesData = [ - new OrdinalSales('2014', 10), - new OrdinalSales('2015', 15), - new OrdinalSales('2016', 50), - new OrdinalSales('2017', 45), + OrdinalSales('2014', 10), + OrdinalSales('2015', 15), + OrdinalSales('2016', 50), + OrdinalSales('2017', 45), ]; final otherSalesData = [ - new OrdinalSales('2014', 20), - new OrdinalSales('2015', 35), - new OrdinalSales('2016', 15), - new OrdinalSales('2017', 10), + OrdinalSales('2014', 20), + OrdinalSales('2015', 35), + OrdinalSales('2016', 15), + OrdinalSales('2017', 10), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tabletSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: mobileSalesData, ), - new charts.Series( + charts.Series( id: 'Other', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/legends/legend_custom_symbol.dart b/web/charts/lib/legends/legend_custom_symbol.dart index 4bf4b1450..8c8dc7eb0 100644 --- a/web/charts/lib/legends/legend_custom_symbol.dart +++ b/web/charts/lib/legends/legend_custom_symbol.dart @@ -29,15 +29,16 @@ class IconRenderer extends charts.CustomSymbolRenderer { IconRenderer(this.iconData); @override - Widget build(BuildContext context, {Size size, Color color, bool enabled}) { + Widget build(BuildContext context, + {Size size, Color color, bool enabled = true}) { // Lighten the color if the symbol is not enabled // Example: If user has tapped on a Series deselecting it. if (!enabled) { color = color.withOpacity(0.26); } - return new SizedBox.fromSize( - size: size, child: new Icon(iconData, color: color, size: 12.0)); + return SizedBox.fromSize( + size: size, child: Icon(iconData, color: color, size: 12.0)); } } @@ -45,10 +46,11 @@ class LegendWithCustomSymbol extends StatelessWidget { final List seriesList; final bool animate; - LegendWithCustomSymbol(this.seriesList, {this.animate}); + const LegendWithCustomSymbol(this.seriesList, {this.animate, Key key}) + : super(key: key); factory LegendWithCustomSymbol.withSampleData() { - return new LegendWithCustomSymbol( + return LegendWithCustomSymbol( _createSampleData(), // Disable animations for image tests. animate: false, @@ -60,61 +62,61 @@ class LegendWithCustomSymbol extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory LegendWithCustomSymbol.withRandomData() { - return new LegendWithCustomSymbol(_createRandomData()); + return LegendWithCustomSymbol(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final desktopSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final tabletSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final mobileSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final otherSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tabletSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: mobileSalesData, ), - new charts.Series( + charts.Series( id: 'Other', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -126,7 +128,7 @@ class LegendWithCustomSymbol extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, barGroupingType: charts.BarGroupingType.grouped, @@ -135,62 +137,62 @@ class LegendWithCustomSymbol extends StatelessWidget { // // To change the symbol used in the legend, set the renderer attribute of // symbolRendererKey to a SymbolRenderer. - behaviors: [new charts.SeriesLegend()], - defaultRenderer: new charts.BarRendererConfig( - symbolRenderer: new IconRenderer(Icons.cloud)), + behaviors: [charts.SeriesLegend()], + defaultRenderer: + charts.BarRendererConfig(symbolRenderer: IconRenderer(Icons.cloud)), ); } /// Create series list with multiple series static List> _createSampleData() { final desktopSalesData = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tabletSalesData = [ - new OrdinalSales('2014', 25), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 10), - new OrdinalSales('2017', 20), + OrdinalSales('2014', 25), + OrdinalSales('2015', 50), + OrdinalSales('2016', 10), + OrdinalSales('2017', 20), ]; final mobileSalesData = [ - new OrdinalSales('2014', 10), - new OrdinalSales('2015', 15), - new OrdinalSales('2016', 50), - new OrdinalSales('2017', 45), + OrdinalSales('2014', 10), + OrdinalSales('2015', 15), + OrdinalSales('2016', 50), + OrdinalSales('2017', 45), ]; final otherSalesData = [ - new OrdinalSales('2014', 20), - new OrdinalSales('2015', 35), - new OrdinalSales('2016', 15), - new OrdinalSales('2017', 10), + OrdinalSales('2014', 20), + OrdinalSales('2015', 35), + OrdinalSales('2016', 15), + OrdinalSales('2017', 10), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tabletSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: mobileSalesData, ), - new charts.Series( + charts.Series( id: 'Other', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/legends/legends_gallery.dart b/web/charts/lib/legends/legends_gallery.dart index 82be62865..7b87716eb 100644 --- a/web/charts/lib/legends/legends_gallery.dart +++ b/web/charts/lib/legends/legends_gallery.dart @@ -26,55 +26,55 @@ import 'simple_series_legend.dart'; List buildGallery() { return [ - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Series Legend', subtitle: 'A series legend for a bar chart with default settings', - childBuilder: () => new SimpleSeriesLegend.withRandomData(), + childBuilder: () => SimpleSeriesLegend.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Series Legend Options', subtitle: 'A series legend with custom positioning and spacing for a bar chart', - childBuilder: () => new LegendOptions.withRandomData(), + childBuilder: () => LegendOptions.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Series Legend Custom Symbol', subtitle: 'A series legend using a custom symbol renderer', - childBuilder: () => new LegendWithCustomSymbol.withRandomData(), + childBuilder: () => LegendWithCustomSymbol.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Default Hidden Series Legend', subtitle: 'A series legend showing a series hidden by default', - childBuilder: () => new DefaultHiddenSeriesLegend.withRandomData(), + childBuilder: () => DefaultHiddenSeriesLegend.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.insert_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.insert_chart), title: 'Series legend with measures', subtitle: 'Series legend with measures and measure formatting', - childBuilder: () => new LegendWithMeasures.withRandomData(), + childBuilder: () => LegendWithMeasures.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.pie_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.pie_chart), title: 'Datum Legend', subtitle: 'A datum legend for a pie chart with default settings', - childBuilder: () => new SimpleDatumLegend.withRandomData(), + childBuilder: () => SimpleDatumLegend.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.pie_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.pie_chart), title: 'Datum Legend Options', subtitle: 'A datum legend with custom positioning and spacing for a pie chart', - childBuilder: () => new DatumLegendOptions.withRandomData(), + childBuilder: () => DatumLegendOptions.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.pie_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.pie_chart), title: 'Datum legend with measures', subtitle: 'Datum legend with measures and measure formatting', - childBuilder: () => new DatumLegendWithMeasures.withRandomData(), + childBuilder: () => DatumLegendWithMeasures.withRandomData(), ), ]; } diff --git a/web/charts/lib/legends/series_legend_options.dart b/web/charts/lib/legends/series_legend_options.dart index 1ac3a7a56..6c9db191c 100644 --- a/web/charts/lib/legends/series_legend_options.dart +++ b/web/charts/lib/legends/series_legend_options.dart @@ -28,10 +28,11 @@ class LegendOptions extends StatelessWidget { final List seriesList; final bool animate; - LegendOptions(this.seriesList, {this.animate}); + const LegendOptions(this.seriesList, {this.animate, Key key}) + : super(key: key); factory LegendOptions.withSampleData() { - return new LegendOptions( + return LegendOptions( _createSampleData(), // Disable animations for image tests. animate: false, @@ -43,61 +44,61 @@ class LegendOptions extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory LegendOptions.withRandomData() { - return new LegendOptions(_createRandomData()); + return LegendOptions(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final desktopSalesData = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tabletSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final mobileSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final otherSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tabletSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: mobileSalesData, ), - new charts.Series( + charts.Series( id: 'Other', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -109,7 +110,7 @@ class LegendOptions extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, barGroupingType: charts.BarGroupingType.grouped, @@ -117,7 +118,7 @@ class LegendOptions extends StatelessWidget { // This example shows how to change the position and justification of // the legend, in addition to altering the max rows and padding. behaviors: [ - new charts.SeriesLegend( + charts.SeriesLegend( // Positions for "start" and "end" will be left and right respectively // for widgets with a build context that has directionality ltr. // For rtl, "start" and "end" will be right and left respectively. @@ -136,7 +137,7 @@ class LegendOptions extends StatelessWidget { // rows before adding a new column. desiredMaxRows: 2, // This defines the padding around each legend entry. - cellPadding: new EdgeInsets.only(right: 4.0, bottom: 4.0), + cellPadding: const EdgeInsets.only(right: 4.0, bottom: 4.0), // Render the legend entry text with custom styles. entryTextStyle: charts.TextStyleSpec( color: charts.MaterialPalette.purple.shadeDefault, @@ -150,53 +151,53 @@ class LegendOptions extends StatelessWidget { /// Create series list with multiple series static List> _createSampleData() { final desktopSalesData = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tabletSalesData = [ - new OrdinalSales('2014', 25), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 10), - new OrdinalSales('2017', 20), + OrdinalSales('2014', 25), + OrdinalSales('2015', 50), + OrdinalSales('2016', 10), + OrdinalSales('2017', 20), ]; final mobileSalesData = [ - new OrdinalSales('2014', 10), - new OrdinalSales('2015', 15), - new OrdinalSales('2016', 50), - new OrdinalSales('2017', 45), + OrdinalSales('2014', 10), + OrdinalSales('2015', 15), + OrdinalSales('2016', 50), + OrdinalSales('2017', 45), ]; final otherSalesData = [ - new OrdinalSales('2014', 20), - new OrdinalSales('2015', 35), - new OrdinalSales('2016', 15), - new OrdinalSales('2017', 10), + OrdinalSales('2014', 20), + OrdinalSales('2015', 35), + OrdinalSales('2016', 15), + OrdinalSales('2017', 10), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tabletSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: mobileSalesData, ), - new charts.Series( + charts.Series( id: 'Other', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/legends/series_legend_with_measures.dart b/web/charts/lib/legends/series_legend_with_measures.dart index 35ed13241..464e46eef 100644 --- a/web/charts/lib/legends/series_legend_with_measures.dart +++ b/web/charts/lib/legends/series_legend_with_measures.dart @@ -32,10 +32,11 @@ class LegendWithMeasures extends StatelessWidget { final List seriesList; final bool animate; - LegendWithMeasures(this.seriesList, {this.animate}); + const LegendWithMeasures(this.seriesList, {this.animate, Key key}) + : super(key: key); factory LegendWithMeasures.withSampleData() { - return new LegendWithMeasures( + return LegendWithMeasures( _createSampleData(), // Disable animations for image tests. animate: false, @@ -47,61 +48,61 @@ class LegendWithMeasures extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory LegendWithMeasures.withRandomData() { - return new LegendWithMeasures(_createRandomData()); + return LegendWithMeasures(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final desktopSalesData = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tabletSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final mobileSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final otherSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tabletSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: mobileSalesData, ), - new charts.Series( + charts.Series( id: 'Other', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -113,7 +114,7 @@ class LegendWithMeasures extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, barGroupingType: charts.BarGroupingType.grouped, @@ -125,16 +126,16 @@ class LegendWithMeasures extends StatelessWidget { // This section is excluded from being copied to the gallery. // This is added in order to generate the image for the gallery to show // an initial selection so that measure values are shown in the gallery. - new charts.InitialSelection( + charts.InitialSelection( selectedDataConfig: [ - new charts.SeriesDatumConfig('Desktop', '2016'), - new charts.SeriesDatumConfig('Tablet', '2016'), - new charts.SeriesDatumConfig('Mobile', '2016'), - new charts.SeriesDatumConfig('Other', '2016'), + charts.SeriesDatumConfig('Desktop', '2016'), + charts.SeriesDatumConfig('Tablet', '2016'), + charts.SeriesDatumConfig('Mobile', '2016'), + charts.SeriesDatumConfig('Other', '2016'), ], ), // EXCLUDE_FROM_GALLERY_DOCS_END - new charts.SeriesLegend( + charts.SeriesLegend( // Positions for "start" and "end" will be left and right respectively // for widgets with a build context that has directionality ltr. // For rtl, "start" and "end" will be right and left respectively. @@ -146,7 +147,7 @@ class LegendWithMeasures extends StatelessWidget { // legend entries will grow as new rows first instead of a new column. horizontalFirst: false, // This defines the padding around each legend entry. - cellPadding: new EdgeInsets.only(right: 4.0, bottom: 4.0), + cellPadding: const EdgeInsets.only(right: 4.0, bottom: 4.0), // Set show measures to true to display measures in series legend, // when the datum is selected. showMeasures: true, @@ -163,53 +164,53 @@ class LegendWithMeasures extends StatelessWidget { /// Create series list with multiple series static List> _createSampleData() { final desktopSalesData = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tabletSalesData = [ - new OrdinalSales('2014', 25), - new OrdinalSales('2015', 50), + OrdinalSales('2014', 25), + OrdinalSales('2015', 50), // Purposely have a missing datum for 2016 to show the null measure format - new OrdinalSales('2017', 20), + OrdinalSales('2017', 20), ]; final mobileSalesData = [ - new OrdinalSales('2014', 10), - new OrdinalSales('2015', 15), - new OrdinalSales('2016', 50), - new OrdinalSales('2017', 45), + OrdinalSales('2014', 10), + OrdinalSales('2015', 15), + OrdinalSales('2016', 50), + OrdinalSales('2017', 45), ]; final otherSalesData = [ - new OrdinalSales('2014', 20), - new OrdinalSales('2015', 35), - new OrdinalSales('2016', 15), - new OrdinalSales('2017', 10), + OrdinalSales('2014', 20), + OrdinalSales('2015', 35), + OrdinalSales('2016', 15), + OrdinalSales('2017', 10), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tabletSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: mobileSalesData, ), - new charts.Series( + charts.Series( id: 'Other', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/legends/simple_datum_legend.dart b/web/charts/lib/legends/simple_datum_legend.dart index b37378223..ce41b4d8e 100644 --- a/web/charts/lib/legends/simple_datum_legend.dart +++ b/web/charts/lib/legends/simple_datum_legend.dart @@ -24,10 +24,11 @@ class SimpleDatumLegend extends StatelessWidget { final List seriesList; final bool animate; - SimpleDatumLegend(this.seriesList, {this.animate}); + const SimpleDatumLegend(this.seriesList, {this.animate, Key key}) + : super(key: key); factory SimpleDatumLegend.withSampleData() { - return new SimpleDatumLegend( + return SimpleDatumLegend( _createSampleData(), // Disable animations for image tests. animate: false, @@ -39,22 +40,22 @@ class SimpleDatumLegend extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory SimpleDatumLegend.withRandomData() { - return new SimpleDatumLegend(_createRandomData()); + return SimpleDatumLegend(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, @@ -66,26 +67,26 @@ class SimpleDatumLegend extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.PieChart( + return charts.PieChart( seriesList, animate: animate, // Add the series legend behavior to the chart to turn on series legends. // By default the legend will display above the chart. - behaviors: [new charts.DatumLegend()], + behaviors: [charts.DatumLegend()], ); } /// Create series list with one series static List> _createSampleData() { final data = [ - new LinearSales(0, 100), - new LinearSales(1, 75), - new LinearSales(2, 25), - new LinearSales(3, 5), + LinearSales(0, 100), + LinearSales(1, 75), + LinearSales(2, 25), + LinearSales(3, 5), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, diff --git a/web/charts/lib/legends/simple_series_legend.dart b/web/charts/lib/legends/simple_series_legend.dart index a665b410c..c363f80fd 100644 --- a/web/charts/lib/legends/simple_series_legend.dart +++ b/web/charts/lib/legends/simple_series_legend.dart @@ -24,10 +24,11 @@ class SimpleSeriesLegend extends StatelessWidget { final List seriesList; final bool animate; - SimpleSeriesLegend(this.seriesList, {this.animate}); + const SimpleSeriesLegend(this.seriesList, {this.animate, Key key}) + : super(key: key); factory SimpleSeriesLegend.withSampleData() { - return new SimpleSeriesLegend( + return SimpleSeriesLegend( _createSampleData(), // Disable animations for image tests. animate: false, @@ -39,61 +40,61 @@ class SimpleSeriesLegend extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory SimpleSeriesLegend.withRandomData() { - return new SimpleSeriesLegend(_createRandomData()); + return SimpleSeriesLegend(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final desktopSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final tabletSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final mobileSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; final otherSalesData = [ - new OrdinalSales('2014', random.nextInt(100)), - new OrdinalSales('2015', random.nextInt(100)), - new OrdinalSales('2016', random.nextInt(100)), - new OrdinalSales('2017', random.nextInt(100)), + OrdinalSales('2014', random.nextInt(100)), + OrdinalSales('2015', random.nextInt(100)), + OrdinalSales('2016', random.nextInt(100)), + OrdinalSales('2017', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tabletSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: mobileSalesData, ), - new charts.Series( + charts.Series( id: 'Other', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, @@ -105,66 +106,66 @@ class SimpleSeriesLegend extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.BarChart( + return charts.BarChart( seriesList, animate: animate, barGroupingType: charts.BarGroupingType.grouped, // Add the series legend behavior to the chart to turn on series legends. // By default the legend will display above the chart. - behaviors: [new charts.SeriesLegend()], + behaviors: [charts.SeriesLegend()], ); } /// Create series list with multiple series static List> _createSampleData() { final desktopSalesData = [ - new OrdinalSales('2014', 5), - new OrdinalSales('2015', 25), - new OrdinalSales('2016', 100), - new OrdinalSales('2017', 75), + OrdinalSales('2014', 5), + OrdinalSales('2015', 25), + OrdinalSales('2016', 100), + OrdinalSales('2017', 75), ]; final tabletSalesData = [ - new OrdinalSales('2014', 25), - new OrdinalSales('2015', 50), - new OrdinalSales('2016', 10), - new OrdinalSales('2017', 20), + OrdinalSales('2014', 25), + OrdinalSales('2015', 50), + OrdinalSales('2016', 10), + OrdinalSales('2017', 20), ]; final mobileSalesData = [ - new OrdinalSales('2014', 10), - new OrdinalSales('2015', 15), - new OrdinalSales('2016', 50), - new OrdinalSales('2017', 45), + OrdinalSales('2014', 10), + OrdinalSales('2015', 15), + OrdinalSales('2016', 50), + OrdinalSales('2017', 45), ]; final otherSalesData = [ - new OrdinalSales('2014', 20), - new OrdinalSales('2015', 35), - new OrdinalSales('2016', 15), - new OrdinalSales('2017', 10), + OrdinalSales('2014', 20), + OrdinalSales('2015', 35), + OrdinalSales('2016', 15), + OrdinalSales('2017', 10), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: desktopSalesData, ), - new charts.Series( + charts.Series( id: 'Tablet', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: tabletSalesData, ), - new charts.Series( + charts.Series( id: 'Mobile', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, data: mobileSalesData, ), - new charts.Series( + charts.Series( id: 'Other', domainFn: (OrdinalSales sales, _) => sales.year, measureFn: (OrdinalSales sales, _) => sales.sales, diff --git a/web/charts/lib/line_chart/animation_zoom.dart b/web/charts/lib/line_chart/animation_zoom.dart index 7f52ed128..aa2d611c2 100644 --- a/web/charts/lib/line_chart/animation_zoom.dart +++ b/web/charts/lib/line_chart/animation_zoom.dart @@ -25,11 +25,12 @@ class LineAnimationZoomChart extends StatelessWidget { final List seriesList; final bool animate; - LineAnimationZoomChart(this.seriesList, {this.animate}); + const LineAnimationZoomChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [LineChart] with sample data and no transition. factory LineAnimationZoomChart.withSampleData() { - return new LineAnimationZoomChart( + return LineAnimationZoomChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -41,21 +42,21 @@ class LineAnimationZoomChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory LineAnimationZoomChart.withRandomData() { - return new LineAnimationZoomChart(_createRandomData()); + return LineAnimationZoomChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = []; for (var i = 0; i < 100; i++) { - data.add(new LinearSales(i, random.nextInt(100))); + data.add(LinearSales(i, random.nextInt(100))); } return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, @@ -67,22 +68,22 @@ class LineAnimationZoomChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.LineChart(seriesList, animate: animate, behaviors: [ - new charts.PanAndZoomBehavior(), + return charts.LineChart(seriesList, animate: animate, behaviors: [ + charts.PanAndZoomBehavior(), ]); } /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new LinearSales(0, 5), - new LinearSales(1, 25), - new LinearSales(2, 100), - new LinearSales(3, 75), + LinearSales(0, 5), + LinearSales(1, 25), + LinearSales(2, 100), + LinearSales(3, 75), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, diff --git a/web/charts/lib/line_chart/area_and_line.dart b/web/charts/lib/line_chart/area_and_line.dart index d2005168b..987096135 100644 --- a/web/charts/lib/line_chart/area_and_line.dart +++ b/web/charts/lib/line_chart/area_and_line.dart @@ -24,11 +24,12 @@ class AreaAndLineChart extends StatelessWidget { final List seriesList; final bool animate; - AreaAndLineChart(this.seriesList, {this.animate}); + const AreaAndLineChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [LineChart] with sample data and no transition. factory AreaAndLineChart.withSampleData() { - return new AreaAndLineChart( + return AreaAndLineChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -40,36 +41,36 @@ class AreaAndLineChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory AreaAndLineChart.withRandomData() { - return new AreaAndLineChart(_createRandomData()); + return AreaAndLineChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final myFakeDesktopData = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; var myFakeTabletData = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, data: myFakeDesktopData, ), - new charts.Series( + charts.Series( id: 'Tablet', colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, @@ -84,10 +85,10 @@ class AreaAndLineChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.LineChart(seriesList, + return charts.LineChart(seriesList, animate: animate, customSeriesRenderers: [ - new charts.LineRendererConfig( + charts.LineRendererConfig( // ID used to link series to this renderer. customRendererId: 'customArea', includeArea: true, @@ -98,21 +99,21 @@ class AreaAndLineChart extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final myFakeDesktopData = [ - new LinearSales(0, 5), - new LinearSales(1, 25), - new LinearSales(2, 100), - new LinearSales(3, 75), + LinearSales(0, 5), + LinearSales(1, 25), + LinearSales(2, 100), + LinearSales(3, 75), ]; var myFakeTabletData = [ - new LinearSales(0, 10), - new LinearSales(1, 50), - new LinearSales(2, 200), - new LinearSales(3, 150), + LinearSales(0, 10), + LinearSales(1, 50), + LinearSales(2, 200), + LinearSales(3, 150), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, @@ -121,7 +122,7 @@ class AreaAndLineChart extends StatelessWidget { ) // Configure our custom bar target renderer for this series. ..setAttribute(charts.rendererIdKey, 'customArea'), - new charts.Series( + charts.Series( id: 'Tablet', colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, diff --git a/web/charts/lib/line_chart/dash_pattern.dart b/web/charts/lib/line_chart/dash_pattern.dart index af4ff4767..29a656977 100644 --- a/web/charts/lib/line_chart/dash_pattern.dart +++ b/web/charts/lib/line_chart/dash_pattern.dart @@ -25,11 +25,12 @@ class DashPatternLineChart extends StatelessWidget { final List seriesList; final bool animate; - DashPatternLineChart(this.seriesList, {this.animate}); + const DashPatternLineChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [LineChart] with sample data and no transition. factory DashPatternLineChart.withSampleData() { - return new DashPatternLineChart( + return DashPatternLineChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -41,43 +42,43 @@ class DashPatternLineChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory DashPatternLineChart.withRandomData() { - return new DashPatternLineChart(_createRandomData()); + return DashPatternLineChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final myFakeDesktopData = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; var myFakeTabletData = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; var myFakeMobileData = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, data: myFakeDesktopData, ), - new charts.Series( + charts.Series( id: 'Tablet', colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault, dashPatternFn: (_, __) => [2, 2], @@ -85,7 +86,7 @@ class DashPatternLineChart extends StatelessWidget { measureFn: (LinearSales sales, _) => sales.sales, data: myFakeTabletData, ), - new charts.Series( + charts.Series( id: 'Mobile', colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault, dashPatternFn: (_, __) => [8, 3, 2, 3], @@ -99,41 +100,41 @@ class DashPatternLineChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.LineChart(seriesList, animate: animate); + return charts.LineChart(seriesList, animate: animate); } /// Create three series with sample hard coded data. static List> _createSampleData() { final myFakeDesktopData = [ - new LinearSales(0, 5), - new LinearSales(1, 25), - new LinearSales(2, 100), - new LinearSales(3, 75), + LinearSales(0, 5), + LinearSales(1, 25), + LinearSales(2, 100), + LinearSales(3, 75), ]; var myFakeTabletData = [ - new LinearSales(0, 10), - new LinearSales(1, 50), - new LinearSales(2, 200), - new LinearSales(3, 150), + LinearSales(0, 10), + LinearSales(1, 50), + LinearSales(2, 200), + LinearSales(3, 150), ]; var myFakeMobileData = [ - new LinearSales(0, 15), - new LinearSales(1, 75), - new LinearSales(2, 300), - new LinearSales(3, 225), + LinearSales(0, 15), + LinearSales(1, 75), + LinearSales(2, 300), + LinearSales(3, 225), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, data: myFakeDesktopData, ), - new charts.Series( + charts.Series( id: 'Tablet', colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault, dashPatternFn: (_, __) => [2, 2], @@ -141,7 +142,7 @@ class DashPatternLineChart extends StatelessWidget { measureFn: (LinearSales sales, _) => sales.sales, data: myFakeTabletData, ), - new charts.Series( + charts.Series( id: 'Mobile', colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault, dashPatternFn: (_, __) => [8, 3, 2, 3], diff --git a/web/charts/lib/line_chart/line_annotation.dart b/web/charts/lib/line_chart/line_annotation.dart index 657ac380b..dcdc42a0d 100644 --- a/web/charts/lib/line_chart/line_annotation.dart +++ b/web/charts/lib/line_chart/line_annotation.dart @@ -24,7 +24,8 @@ class LineLineAnnotationChart extends StatelessWidget { final List seriesList; final bool animate; - LineLineAnnotationChart(this.seriesList, {this.animate}); + const LineLineAnnotationChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [LineChart] with sample data and line annotations. /// @@ -32,7 +33,7 @@ class LineLineAnnotationChart extends StatelessWidget { /// demonstrating the effect of the [Charts.RangeAnnotation.extendAxis] flag. /// This can be set to false to disable range extension. factory LineLineAnnotationChart.withSampleData() { - return new LineLineAnnotationChart( + return LineLineAnnotationChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -44,24 +45,24 @@ class LineLineAnnotationChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory LineLineAnnotationChart.withRandomData() { - return new LineLineAnnotationChart(_createRandomData()); + return LineLineAnnotationChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), // Fix one of the points to 100 so that the annotations are consistently // placed. - new LinearSales(3, 100), + LinearSales(3, 100), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, @@ -73,21 +74,17 @@ class LineLineAnnotationChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.LineChart(seriesList, animate: animate, behaviors: [ - new charts.RangeAnnotation([ - new charts.LineAnnotationSegment( - 1.0, charts.RangeAnnotationAxisType.domain, + return charts.LineChart(seriesList, animate: animate, behaviors: [ + charts.RangeAnnotation([ + charts.LineAnnotationSegment(1.0, charts.RangeAnnotationAxisType.domain, startLabel: 'Domain 1'), - new charts.LineAnnotationSegment( - 4, charts.RangeAnnotationAxisType.domain, + charts.LineAnnotationSegment(4, charts.RangeAnnotationAxisType.domain, endLabel: 'Domain 2', color: charts.MaterialPalette.gray.shade200), - new charts.LineAnnotationSegment( - 20, charts.RangeAnnotationAxisType.measure, + charts.LineAnnotationSegment(20, charts.RangeAnnotationAxisType.measure, startLabel: 'Measure 1 Start', endLabel: 'Measure 1 End', color: charts.MaterialPalette.gray.shade300), - new charts.LineAnnotationSegment( - 65, charts.RangeAnnotationAxisType.measure, + charts.LineAnnotationSegment(65, charts.RangeAnnotationAxisType.measure, startLabel: 'Measure 2 Start', endLabel: 'Measure 2 End', color: charts.MaterialPalette.gray.shade400), @@ -98,14 +95,14 @@ class LineLineAnnotationChart extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new LinearSales(0, 5), - new LinearSales(1, 25), - new LinearSales(2, 100), - new LinearSales(3, 75), + LinearSales(0, 5), + LinearSales(1, 25), + LinearSales(2, 100), + LinearSales(3, 75), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, diff --git a/web/charts/lib/line_chart/line_gallery.dart b/web/charts/lib/line_chart/line_gallery.dart index edd29a411..bcd9c9771 100644 --- a/web/charts/lib/line_chart/line_gallery.dart +++ b/web/charts/lib/line_chart/line_gallery.dart @@ -31,83 +31,83 @@ import 'stacked_area_nulls.dart'; List buildGallery() { return [ - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Simple Line Chart', subtitle: 'With a single series and default line point highlighter', - childBuilder: () => new SimpleLineChart.withRandomData(), + childBuilder: () => SimpleLineChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Stacked Area Chart', subtitle: 'Stacked area chart with three series', - childBuilder: () => new StackedAreaLineChart.withRandomData(), + childBuilder: () => StackedAreaLineChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Stacked Area Custom Color Chart', subtitle: 'Stacked area chart with custom area skirt color', - childBuilder: () => new StackedAreaCustomColorLineChart.withRandomData(), + childBuilder: () => StackedAreaCustomColorLineChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Area and Line Combo Chart', subtitle: 'Combo chart with one line series and one area series', - childBuilder: () => new AreaAndLineChart.withRandomData(), + childBuilder: () => AreaAndLineChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Points Line Chart', subtitle: 'Line chart with points on a single series', - childBuilder: () => new PointsLineChart.withRandomData(), + childBuilder: () => PointsLineChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Null Data Line Chart', subtitle: 'With a single series and null measure values', - childBuilder: () => new SimpleNullsLineChart.withRandomData(), + childBuilder: () => SimpleNullsLineChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Stacked Area with Nulls Chart', subtitle: 'Stacked area chart with three series and null measure values', - childBuilder: () => new StackedAreaNullsLineChart.withRandomData(), + childBuilder: () => StackedAreaNullsLineChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Dash Pattern Line Chart', subtitle: 'Line chart with dash patterns', - childBuilder: () => new DashPatternLineChart.withRandomData(), + childBuilder: () => DashPatternLineChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Segments Line Chart', subtitle: 'Line chart with changes of style for each line', - childBuilder: () => new SegmentsLineChart.withRandomData(), + childBuilder: () => SegmentsLineChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Line Annotation Line Chart', subtitle: 'Line chart with line annotations', - childBuilder: () => new LineLineAnnotationChart.withRandomData(), + childBuilder: () => LineLineAnnotationChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Range Annotation Line Chart', subtitle: 'Line chart with range annotations', - childBuilder: () => new LineRangeAnnotationChart.withRandomData(), + childBuilder: () => LineRangeAnnotationChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Range Annotation Margin Labels Line Chart', subtitle: 'Line chart with range annotations with labels in margins', - childBuilder: () => new LineRangeAnnotationMarginChart.withRandomData(), + childBuilder: () => LineRangeAnnotationMarginChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Pan and Zoom Line Chart', subtitle: 'Simple line chart pan and zoom behaviors enabled', - childBuilder: () => new LineAnimationZoomChart.withRandomData(), + childBuilder: () => LineAnimationZoomChart.withRandomData(), ), ]; } diff --git a/web/charts/lib/line_chart/points.dart b/web/charts/lib/line_chart/points.dart index 76f08d55a..2b9034de8 100644 --- a/web/charts/lib/line_chart/points.dart +++ b/web/charts/lib/line_chart/points.dart @@ -24,11 +24,12 @@ class PointsLineChart extends StatelessWidget { final List seriesList; final bool animate; - PointsLineChart(this.seriesList, {this.animate}); + const PointsLineChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [LineChart] with sample data and no transition. factory PointsLineChart.withSampleData() { - return new PointsLineChart( + return PointsLineChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -40,22 +41,22 @@ class PointsLineChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory PointsLineChart.withRandomData() { - return new PointsLineChart(_createRandomData()); + return PointsLineChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, @@ -68,22 +69,22 @@ class PointsLineChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.LineChart(seriesList, + return charts.LineChart(seriesList, animate: animate, - defaultRenderer: new charts.LineRendererConfig(includePoints: true)); + defaultRenderer: charts.LineRendererConfig(includePoints: true)); } /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new LinearSales(0, 5), - new LinearSales(1, 25), - new LinearSales(2, 100), - new LinearSales(3, 75), + LinearSales(0, 5), + LinearSales(1, 25), + LinearSales(2, 100), + LinearSales(3, 75), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, diff --git a/web/charts/lib/line_chart/range_annotation.dart b/web/charts/lib/line_chart/range_annotation.dart index 59a56e816..4283e44f8 100644 --- a/web/charts/lib/line_chart/range_annotation.dart +++ b/web/charts/lib/line_chart/range_annotation.dart @@ -24,7 +24,8 @@ class LineRangeAnnotationChart extends StatelessWidget { final List seriesList; final bool animate; - LineRangeAnnotationChart(this.seriesList, {this.animate}); + const LineRangeAnnotationChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [LineChart] with sample data and range annotations. /// @@ -32,7 +33,7 @@ class LineRangeAnnotationChart extends StatelessWidget { /// demonstrating the effect of the [Charts.RangeAnnotation.extendAxis] flag. /// This can be set to false to disable range extension. factory LineRangeAnnotationChart.withSampleData() { - return new LineRangeAnnotationChart( + return LineRangeAnnotationChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -44,24 +45,24 @@ class LineRangeAnnotationChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory LineRangeAnnotationChart.withRandomData() { - return new LineRangeAnnotationChart(_createRandomData()); + return LineRangeAnnotationChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), // Fix one of the points to 100 so that the annotations are consistently // placed. - new LinearSales(3, 100), + LinearSales(3, 100), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, @@ -73,20 +74,20 @@ class LineRangeAnnotationChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.LineChart(seriesList, animate: animate, behaviors: [ - new charts.RangeAnnotation([ - new charts.RangeAnnotationSegment( + return charts.LineChart(seriesList, animate: animate, behaviors: [ + charts.RangeAnnotation([ + charts.RangeAnnotationSegment( 0.5, 1.0, charts.RangeAnnotationAxisType.domain, startLabel: 'Domain 1'), - new charts.RangeAnnotationSegment( + charts.RangeAnnotationSegment( 2, 4, charts.RangeAnnotationAxisType.domain, endLabel: 'Domain 2', color: charts.MaterialPalette.gray.shade200), - new charts.RangeAnnotationSegment( + charts.RangeAnnotationSegment( 15, 20, charts.RangeAnnotationAxisType.measure, startLabel: 'Measure 1 Start', endLabel: 'Measure 1 End', color: charts.MaterialPalette.gray.shade300), - new charts.RangeAnnotationSegment( + charts.RangeAnnotationSegment( 35, 65, charts.RangeAnnotationAxisType.measure, startLabel: 'Measure 2 Start', endLabel: 'Measure 2 End', @@ -98,14 +99,14 @@ class LineRangeAnnotationChart extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new LinearSales(0, 5), - new LinearSales(1, 25), - new LinearSales(2, 100), - new LinearSales(3, 75), + LinearSales(0, 5), + LinearSales(1, 25), + LinearSales(2, 100), + LinearSales(3, 75), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, diff --git a/web/charts/lib/line_chart/range_annotation_margin.dart b/web/charts/lib/line_chart/range_annotation_margin.dart index 3edcb0aa4..c44343fcd 100644 --- a/web/charts/lib/line_chart/range_annotation_margin.dart +++ b/web/charts/lib/line_chart/range_annotation_margin.dart @@ -25,7 +25,8 @@ class LineRangeAnnotationMarginChart extends StatelessWidget { final List seriesList; final bool animate; - LineRangeAnnotationMarginChart(this.seriesList, {this.animate}); + const LineRangeAnnotationMarginChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [LineChart] with sample data and range annotations. /// @@ -33,7 +34,7 @@ class LineRangeAnnotationMarginChart extends StatelessWidget { /// demonstrating the effect of the [Charts.RangeAnnotation.extendAxis] flag. /// This can be set to false to disable range extension. factory LineRangeAnnotationMarginChart.withSampleData() { - return new LineRangeAnnotationMarginChart( + return LineRangeAnnotationMarginChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -45,24 +46,24 @@ class LineRangeAnnotationMarginChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory LineRangeAnnotationMarginChart.withRandomData() { - return new LineRangeAnnotationMarginChart(_createRandomData()); + return LineRangeAnnotationMarginChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), // Fix one of the points to 100 so that the annotations are consistently // placed. - new LinearSales(3, 100), + LinearSales(3, 100), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, @@ -74,21 +75,21 @@ class LineRangeAnnotationMarginChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.LineChart(seriesList, + return charts.LineChart(seriesList, animate: animate, // Allow enough space in the left and right chart margins for the // annotations. - layoutConfig: new charts.LayoutConfig( - leftMarginSpec: new charts.MarginSpec.fixedPixel(60), - topMarginSpec: new charts.MarginSpec.fixedPixel(20), - rightMarginSpec: new charts.MarginSpec.fixedPixel(60), - bottomMarginSpec: new charts.MarginSpec.fixedPixel(20)), + layoutConfig: charts.LayoutConfig( + leftMarginSpec: charts.MarginSpec.fixedPixel(60), + topMarginSpec: charts.MarginSpec.fixedPixel(20), + rightMarginSpec: charts.MarginSpec.fixedPixel(60), + bottomMarginSpec: charts.MarginSpec.fixedPixel(20)), behaviors: [ // Define one domain and two measure annotations configured to render // labels in the chart margins. - new charts.RangeAnnotation([ - new charts.RangeAnnotationSegment( + charts.RangeAnnotation([ + charts.RangeAnnotationSegment( 0.5, 1.0, charts.RangeAnnotationAxisType.domain, startLabel: 'D1 Start', endLabel: 'D1 End', @@ -96,13 +97,13 @@ class LineRangeAnnotationMarginChart extends StatelessWidget { color: charts.MaterialPalette.gray.shade200, // Override the default vertical direction for domain labels. labelDirection: charts.AnnotationLabelDirection.horizontal), - new charts.RangeAnnotationSegment( + charts.RangeAnnotationSegment( 15, 20, charts.RangeAnnotationAxisType.measure, startLabel: 'M1 Start', endLabel: 'M1 End', labelAnchor: charts.AnnotationLabelAnchor.end, color: charts.MaterialPalette.gray.shade300), - new charts.RangeAnnotationSegment( + charts.RangeAnnotationSegment( 35, 65, charts.RangeAnnotationAxisType.measure, startLabel: 'M2 Start', endLabel: 'M2 End', @@ -115,14 +116,14 @@ class LineRangeAnnotationMarginChart extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new LinearSales(0, 5), - new LinearSales(1, 25), - new LinearSales(2, 100), - new LinearSales(3, 75), + LinearSales(0, 5), + LinearSales(1, 25), + LinearSales(2, 100), + LinearSales(3, 75), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, diff --git a/web/charts/lib/line_chart/segments.dart b/web/charts/lib/line_chart/segments.dart index 1ef629e90..dfdb6f40e 100644 --- a/web/charts/lib/line_chart/segments.dart +++ b/web/charts/lib/line_chart/segments.dart @@ -35,11 +35,12 @@ class SegmentsLineChart extends StatelessWidget { final List seriesList; final bool animate; - SegmentsLineChart(this.seriesList, {this.animate}); + const SegmentsLineChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [LineChart] with sample data and no transition. factory SegmentsLineChart.withSampleData() { - return new SegmentsLineChart( + return SegmentsLineChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -51,45 +52,45 @@ class SegmentsLineChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory SegmentsLineChart.withRandomData() { - return new SegmentsLineChart(_createRandomData()); + return SegmentsLineChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); // Series of data with static dash pattern and stroke width. The colorFn // accessor will colorize each datum (for all three series). final colorChangeData = [ - new LinearSales(0, random.nextInt(100), null, 2.0), - new LinearSales(1, random.nextInt(100), null, 2.0), - new LinearSales(2, random.nextInt(100), null, 2.0), - new LinearSales(3, random.nextInt(100), null, 2.0), - new LinearSales(4, random.nextInt(100), null, 2.0), - new LinearSales(5, random.nextInt(100), null, 2.0), - new LinearSales(6, random.nextInt(100), null, 2.0), + LinearSales(0, random.nextInt(100), null, 2.0), + LinearSales(1, random.nextInt(100), null, 2.0), + LinearSales(2, random.nextInt(100), null, 2.0), + LinearSales(3, random.nextInt(100), null, 2.0), + LinearSales(4, random.nextInt(100), null, 2.0), + LinearSales(5, random.nextInt(100), null, 2.0), + LinearSales(6, random.nextInt(100), null, 2.0), ]; // Series of data with changing color and dash pattern. final dashPatternChangeData = [ - new LinearSales(0, random.nextInt(100), [2, 2], 2.0), - new LinearSales(1, random.nextInt(100), [2, 2], 2.0), - new LinearSales(2, random.nextInt(100), [4, 4], 2.0), - new LinearSales(3, random.nextInt(100), [4, 4], 2.0), - new LinearSales(4, random.nextInt(100), [4, 4], 2.0), - new LinearSales(5, random.nextInt(100), [8, 3, 2, 3], 2.0), - new LinearSales(6, random.nextInt(100), [8, 3, 2, 3], 2.0), + LinearSales(0, random.nextInt(100), [2, 2], 2.0), + LinearSales(1, random.nextInt(100), [2, 2], 2.0), + LinearSales(2, random.nextInt(100), [4, 4], 2.0), + LinearSales(3, random.nextInt(100), [4, 4], 2.0), + LinearSales(4, random.nextInt(100), [4, 4], 2.0), + LinearSales(5, random.nextInt(100), [8, 3, 2, 3], 2.0), + LinearSales(6, random.nextInt(100), [8, 3, 2, 3], 2.0), ]; // Series of data with changing color and stroke width. final strokeWidthChangeData = [ - new LinearSales(0, random.nextInt(100), null, 2.0), - new LinearSales(1, random.nextInt(100), null, 2.0), - new LinearSales(2, random.nextInt(100), null, 4.0), - new LinearSales(3, random.nextInt(100), null, 4.0), - new LinearSales(4, random.nextInt(100), null, 4.0), - new LinearSales(5, random.nextInt(100), null, 6.0), - new LinearSales(6, random.nextInt(100), null, 6.0), + LinearSales(0, random.nextInt(100), null, 2.0), + LinearSales(1, random.nextInt(100), null, 2.0), + LinearSales(2, random.nextInt(100), null, 4.0), + LinearSales(3, random.nextInt(100), null, 4.0), + LinearSales(4, random.nextInt(100), null, 4.0), + LinearSales(5, random.nextInt(100), null, 6.0), + LinearSales(6, random.nextInt(100), null, 6.0), ]; // Generate 2 shades of each color so that we can style the line segments. @@ -98,7 +99,7 @@ class SegmentsLineChart extends StatelessWidget { final green = charts.MaterialPalette.green.makeShades(2); return [ - new charts.Series( + charts.Series( id: 'Color Change', // Light shade for even years, dark shade for odd. colorFn: (LinearSales sales, _) => @@ -109,7 +110,7 @@ class SegmentsLineChart extends StatelessWidget { measureFn: (LinearSales sales, _) => sales.sales, data: colorChangeData, ), - new charts.Series( + charts.Series( id: 'Dash Pattern Change', // Light shade for even years, dark shade for odd. colorFn: (LinearSales sales, _) => @@ -120,7 +121,7 @@ class SegmentsLineChart extends StatelessWidget { measureFn: (LinearSales sales, _) => sales.sales, data: dashPatternChangeData, ), - new charts.Series( + charts.Series( id: 'Stroke Width Change', // Light shade for even years, dark shade for odd. colorFn: (LinearSales sales, _) => @@ -137,9 +138,9 @@ class SegmentsLineChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.LineChart(seriesList, + return charts.LineChart(seriesList, defaultRenderer: - new charts.LineRendererConfig(includeArea: true, stacked: true), + charts.LineRendererConfig(includeArea: true, stacked: true), animate: animate); } @@ -148,35 +149,35 @@ class SegmentsLineChart extends StatelessWidget { // Series of data with static dash pattern and stroke width. The colorFn // accessor will colorize each datum (for all three series). final colorChangeData = [ - new LinearSales(0, 5, null, 2.0), - new LinearSales(1, 15, null, 2.0), - new LinearSales(2, 25, null, 2.0), - new LinearSales(3, 75, null, 2.0), - new LinearSales(4, 100, null, 2.0), - new LinearSales(5, 90, null, 2.0), - new LinearSales(6, 75, null, 2.0), + LinearSales(0, 5, null, 2.0), + LinearSales(1, 15, null, 2.0), + LinearSales(2, 25, null, 2.0), + LinearSales(3, 75, null, 2.0), + LinearSales(4, 100, null, 2.0), + LinearSales(5, 90, null, 2.0), + LinearSales(6, 75, null, 2.0), ]; // Series of data with changing color and dash pattern. final dashPatternChangeData = [ - new LinearSales(0, 5, [2, 2], 2.0), - new LinearSales(1, 15, [2, 2], 2.0), - new LinearSales(2, 25, [4, 4], 2.0), - new LinearSales(3, 75, [4, 4], 2.0), - new LinearSales(4, 100, [4, 4], 2.0), - new LinearSales(5, 90, [8, 3, 2, 3], 2.0), - new LinearSales(6, 75, [8, 3, 2, 3], 2.0), + LinearSales(0, 5, [2, 2], 2.0), + LinearSales(1, 15, [2, 2], 2.0), + LinearSales(2, 25, [4, 4], 2.0), + LinearSales(3, 75, [4, 4], 2.0), + LinearSales(4, 100, [4, 4], 2.0), + LinearSales(5, 90, [8, 3, 2, 3], 2.0), + LinearSales(6, 75, [8, 3, 2, 3], 2.0), ]; // Series of data with changing color and stroke width. final strokeWidthChangeData = [ - new LinearSales(0, 5, null, 2.0), - new LinearSales(1, 15, null, 2.0), - new LinearSales(2, 25, null, 4.0), - new LinearSales(3, 75, null, 4.0), - new LinearSales(4, 100, null, 4.0), - new LinearSales(5, 90, null, 6.0), - new LinearSales(6, 75, null, 6.0), + LinearSales(0, 5, null, 2.0), + LinearSales(1, 15, null, 2.0), + LinearSales(2, 25, null, 4.0), + LinearSales(3, 75, null, 4.0), + LinearSales(4, 100, null, 4.0), + LinearSales(5, 90, null, 6.0), + LinearSales(6, 75, null, 6.0), ]; // Generate 2 shades of each color so that we can style the line segments. @@ -185,7 +186,7 @@ class SegmentsLineChart extends StatelessWidget { final green = charts.MaterialPalette.green.makeShades(2); return [ - new charts.Series( + charts.Series( id: 'Color Change', // Light shade for even years, dark shade for odd. colorFn: (LinearSales sales, _) => @@ -196,7 +197,7 @@ class SegmentsLineChart extends StatelessWidget { measureFn: (LinearSales sales, _) => sales.sales, data: colorChangeData, ), - new charts.Series( + charts.Series( id: 'Dash Pattern Change', // Light shade for even years, dark shade for odd. colorFn: (LinearSales sales, _) => @@ -207,7 +208,7 @@ class SegmentsLineChart extends StatelessWidget { measureFn: (LinearSales sales, _) => sales.sales, data: dashPatternChangeData, ), - new charts.Series( + charts.Series( id: 'Stroke Width Change', // Light shade for even years, dark shade for odd. colorFn: (LinearSales sales, _) => diff --git a/web/charts/lib/line_chart/simple.dart b/web/charts/lib/line_chart/simple.dart index 1975162ef..99462f1c9 100644 --- a/web/charts/lib/line_chart/simple.dart +++ b/web/charts/lib/line_chart/simple.dart @@ -24,11 +24,12 @@ class SimpleLineChart extends StatelessWidget { final List seriesList; final bool animate; - SimpleLineChart(this.seriesList, {this.animate}); + const SimpleLineChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [LineChart] with sample data and no transition. factory SimpleLineChart.withSampleData() { - return new SimpleLineChart( + return SimpleLineChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -40,22 +41,22 @@ class SimpleLineChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory SimpleLineChart.withRandomData() { - return new SimpleLineChart(_createRandomData()); + return SimpleLineChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, @@ -68,20 +69,20 @@ class SimpleLineChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.LineChart(seriesList, animate: animate); + return charts.LineChart(seriesList, animate: animate); } /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new LinearSales(0, 5), - new LinearSales(1, 25), - new LinearSales(2, 100), - new LinearSales(3, 75), + LinearSales(0, 5), + LinearSales(1, 25), + LinearSales(2, 100), + LinearSales(3, 75), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, diff --git a/web/charts/lib/line_chart/simple_nulls.dart b/web/charts/lib/line_chart/simple_nulls.dart index 91ad7f575..633f11c21 100644 --- a/web/charts/lib/line_chart/simple_nulls.dart +++ b/web/charts/lib/line_chart/simple_nulls.dart @@ -28,11 +28,12 @@ class SimpleNullsLineChart extends StatelessWidget { final List seriesList; final bool animate; - SimpleNullsLineChart(this.seriesList, {this.animate}); + const SimpleNullsLineChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [LineChart] with sample data and no transition. factory SimpleNullsLineChart.withSampleData() { - return new SimpleNullsLineChart( + return SimpleNullsLineChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -44,59 +45,59 @@ class SimpleNullsLineChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory SimpleNullsLineChart.withRandomData() { - return new SimpleNullsLineChart(_createRandomData()); + return SimpleNullsLineChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final myFakeDesktopData = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, null), - new LinearSales(3, random.nextInt(100)), - new LinearSales(4, random.nextInt(100)), - new LinearSales(5, random.nextInt(100)), - new LinearSales(6, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, null), + LinearSales(3, random.nextInt(100)), + LinearSales(4, random.nextInt(100)), + LinearSales(5, random.nextInt(100)), + LinearSales(6, random.nextInt(100)), ]; var myFakeTabletData = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), - new LinearSales(4, random.nextInt(100)), - new LinearSales(5, random.nextInt(100)), - new LinearSales(6, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), + LinearSales(4, random.nextInt(100)), + LinearSales(5, random.nextInt(100)), + LinearSales(6, random.nextInt(100)), ]; var myFakeMobileData = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, null), - new LinearSales(3, random.nextInt(100)), - new LinearSales(4, null), - new LinearSales(5, random.nextInt(100)), - new LinearSales(6, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, null), + LinearSales(3, random.nextInt(100)), + LinearSales(4, null), + LinearSales(5, random.nextInt(100)), + LinearSales(6, random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, data: myFakeDesktopData, ), - new charts.Series( + charts.Series( id: 'Tablet', colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, data: myFakeTabletData, ), - new charts.Series( + charts.Series( id: 'Mobile', colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, @@ -109,57 +110,57 @@ class SimpleNullsLineChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.LineChart(seriesList, animate: animate); + return charts.LineChart(seriesList, animate: animate); } /// Create one series with sample hard coded data. static List> _createSampleData() { final myFakeDesktopData = [ - new LinearSales(0, 5), - new LinearSales(1, 15), - new LinearSales(2, null), - new LinearSales(3, 75), - new LinearSales(4, 100), - new LinearSales(5, 90), - new LinearSales(6, 75), + LinearSales(0, 5), + LinearSales(1, 15), + LinearSales(2, null), + LinearSales(3, 75), + LinearSales(4, 100), + LinearSales(5, 90), + LinearSales(6, 75), ]; final myFakeTabletData = [ - new LinearSales(0, 10), - new LinearSales(1, 30), - new LinearSales(2, 50), - new LinearSales(3, 150), - new LinearSales(4, 200), - new LinearSales(5, 180), - new LinearSales(6, 150), + LinearSales(0, 10), + LinearSales(1, 30), + LinearSales(2, 50), + LinearSales(3, 150), + LinearSales(4, 200), + LinearSales(5, 180), + LinearSales(6, 150), ]; final myFakeMobileData = [ - new LinearSales(0, 15), - new LinearSales(1, 45), - new LinearSales(2, null), - new LinearSales(3, 225), - new LinearSales(4, null), - new LinearSales(5, 270), - new LinearSales(6, 225), + LinearSales(0, 15), + LinearSales(1, 45), + LinearSales(2, null), + LinearSales(3, 225), + LinearSales(4, null), + LinearSales(5, 270), + LinearSales(6, 225), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, data: myFakeDesktopData, ), - new charts.Series( + charts.Series( id: 'Tablet', colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, data: myFakeTabletData, ), - new charts.Series( + charts.Series( id: 'Mobile', colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, diff --git a/web/charts/lib/line_chart/stacked_area.dart b/web/charts/lib/line_chart/stacked_area.dart index 989dfecee..cb1b7aa72 100644 --- a/web/charts/lib/line_chart/stacked_area.dart +++ b/web/charts/lib/line_chart/stacked_area.dart @@ -24,11 +24,12 @@ class StackedAreaLineChart extends StatelessWidget { final List seriesList; final bool animate; - StackedAreaLineChart(this.seriesList, {this.animate}); + const StackedAreaLineChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [LineChart] with sample data and no transition. factory StackedAreaLineChart.withSampleData() { - return new StackedAreaLineChart( + return StackedAreaLineChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -40,50 +41,50 @@ class StackedAreaLineChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory StackedAreaLineChart.withRandomData() { - return new StackedAreaLineChart(_createRandomData()); + return StackedAreaLineChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final myFakeDesktopData = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; var myFakeTabletData = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; var myFakeMobileData = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, data: myFakeDesktopData, ), - new charts.Series( + charts.Series( id: 'Tablet', colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, data: myFakeTabletData, ), - new charts.Series( + charts.Series( id: 'Mobile', colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, @@ -96,51 +97,51 @@ class StackedAreaLineChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.LineChart(seriesList, + return charts.LineChart(seriesList, defaultRenderer: - new charts.LineRendererConfig(includeArea: true, stacked: true), + charts.LineRendererConfig(includeArea: true, stacked: true), animate: animate); } /// Create one series with sample hard coded data. static List> _createSampleData() { final myFakeDesktopData = [ - new LinearSales(0, 5), - new LinearSales(1, 25), - new LinearSales(2, 100), - new LinearSales(3, 75), + LinearSales(0, 5), + LinearSales(1, 25), + LinearSales(2, 100), + LinearSales(3, 75), ]; var myFakeTabletData = [ - new LinearSales(0, 10), - new LinearSales(1, 50), - new LinearSales(2, 200), - new LinearSales(3, 150), + LinearSales(0, 10), + LinearSales(1, 50), + LinearSales(2, 200), + LinearSales(3, 150), ]; var myFakeMobileData = [ - new LinearSales(0, 15), - new LinearSales(1, 75), - new LinearSales(2, 300), - new LinearSales(3, 225), + LinearSales(0, 15), + LinearSales(1, 75), + LinearSales(2, 300), + LinearSales(3, 225), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, data: myFakeDesktopData, ), - new charts.Series( + charts.Series( id: 'Tablet', colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, data: myFakeTabletData, ), - new charts.Series( + charts.Series( id: 'Mobile', colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, diff --git a/web/charts/lib/line_chart/stacked_area_custom_color.dart b/web/charts/lib/line_chart/stacked_area_custom_color.dart index 1f218e8c1..6e2c92dd8 100644 --- a/web/charts/lib/line_chart/stacked_area_custom_color.dart +++ b/web/charts/lib/line_chart/stacked_area_custom_color.dart @@ -28,11 +28,13 @@ class StackedAreaCustomColorLineChart extends StatelessWidget { final List seriesList; final bool animate; - StackedAreaCustomColorLineChart(this.seriesList, {this.animate}); + const StackedAreaCustomColorLineChart(this.seriesList, + {this.animate, Key key}) + : super(key: key); /// Creates a [LineChart] with sample data and no transition. factory StackedAreaCustomColorLineChart.withSampleData() { - return new StackedAreaCustomColorLineChart( + return StackedAreaCustomColorLineChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -44,50 +46,50 @@ class StackedAreaCustomColorLineChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory StackedAreaCustomColorLineChart.withRandomData() { - return new StackedAreaCustomColorLineChart(_createRandomData()); + return StackedAreaCustomColorLineChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final myFakeDesktopData = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; var myFakeTabletData = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; var myFakeMobileData = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, data: myFakeDesktopData, ), - new charts.Series( + charts.Series( id: 'Tablet', colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, data: myFakeTabletData, ), - new charts.Series( + charts.Series( id: 'Mobile', colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, @@ -100,37 +102,37 @@ class StackedAreaCustomColorLineChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.LineChart(seriesList, + return charts.LineChart(seriesList, defaultRenderer: - new charts.LineRendererConfig(includeArea: true, stacked: true), + charts.LineRendererConfig(includeArea: true, stacked: true), animate: animate); } /// Create one series with sample hard coded data. static List> _createSampleData() { final myFakeDesktopData = [ - new LinearSales(0, 5), - new LinearSales(1, 25), - new LinearSales(2, 100), - new LinearSales(3, 75), + LinearSales(0, 5), + LinearSales(1, 25), + LinearSales(2, 100), + LinearSales(3, 75), ]; var myFakeTabletData = [ - new LinearSales(0, 10), - new LinearSales(1, 50), - new LinearSales(2, 200), - new LinearSales(3, 150), + LinearSales(0, 10), + LinearSales(1, 50), + LinearSales(2, 200), + LinearSales(3, 150), ]; var myFakeMobileData = [ - new LinearSales(0, 15), - new LinearSales(1, 75), - new LinearSales(2, 300), - new LinearSales(3, 225), + LinearSales(0, 15), + LinearSales(1, 75), + LinearSales(2, 300), + LinearSales(3, 225), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', // colorFn specifies that the line will be blue. colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, @@ -141,7 +143,7 @@ class StackedAreaCustomColorLineChart extends StatelessWidget { measureFn: (LinearSales sales, _) => sales.sales, data: myFakeDesktopData, ), - new charts.Series( + charts.Series( id: 'Tablet', // colorFn specifies that the line will be red. colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault, @@ -151,7 +153,7 @@ class StackedAreaCustomColorLineChart extends StatelessWidget { measureFn: (LinearSales sales, _) => sales.sales, data: myFakeTabletData, ), - new charts.Series( + charts.Series( id: 'Mobile', // colorFn specifies that the line will be green. colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault, diff --git a/web/charts/lib/line_chart/stacked_area_nulls.dart b/web/charts/lib/line_chart/stacked_area_nulls.dart index 90d0b4177..115e1b54c 100644 --- a/web/charts/lib/line_chart/stacked_area_nulls.dart +++ b/web/charts/lib/line_chart/stacked_area_nulls.dart @@ -37,11 +37,12 @@ class StackedAreaNullsLineChart extends StatelessWidget { final List seriesList; final bool animate; - StackedAreaNullsLineChart(this.seriesList, {this.animate}); + const StackedAreaNullsLineChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [LineChart] with sample data and no transition. factory StackedAreaNullsLineChart.withSampleData() { - return new StackedAreaNullsLineChart( + return StackedAreaNullsLineChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -53,59 +54,59 @@ class StackedAreaNullsLineChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory StackedAreaNullsLineChart.withRandomData() { - return new StackedAreaNullsLineChart(_createRandomData()); + return StackedAreaNullsLineChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final myFakeDesktopData = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, null), - new LinearSales(3, random.nextInt(100)), - new LinearSales(4, random.nextInt(100)), - new LinearSales(5, random.nextInt(100)), - new LinearSales(6, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, null), + LinearSales(3, random.nextInt(100)), + LinearSales(4, random.nextInt(100)), + LinearSales(5, random.nextInt(100)), + LinearSales(6, random.nextInt(100)), ]; var myFakeTabletData = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), - new LinearSales(4, random.nextInt(100)), - new LinearSales(5, random.nextInt(100)), - new LinearSales(6, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), + LinearSales(4, random.nextInt(100)), + LinearSales(5, random.nextInt(100)), + LinearSales(6, random.nextInt(100)), ]; var myFakeMobileData = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), - new LinearSales(4, null), - new LinearSales(5, random.nextInt(100)), - new LinearSales(6, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), + LinearSales(4, null), + LinearSales(5, random.nextInt(100)), + LinearSales(6, random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, data: myFakeDesktopData, ), - new charts.Series( + charts.Series( id: 'Tablet', colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, data: myFakeTabletData, ), - new charts.Series( + charts.Series( id: 'Mobile', colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, @@ -118,60 +119,60 @@ class StackedAreaNullsLineChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.LineChart(seriesList, + return charts.LineChart(seriesList, defaultRenderer: - new charts.LineRendererConfig(includeArea: true, stacked: true), + charts.LineRendererConfig(includeArea: true, stacked: true), animate: animate); } /// Create one series with sample hard coded data. static List> _createSampleData() { final myFakeDesktopData = [ - new LinearSales(0, 5), - new LinearSales(1, 15), - new LinearSales(2, null), - new LinearSales(3, 75), - new LinearSales(4, 100), - new LinearSales(5, 90), - new LinearSales(6, 75), + LinearSales(0, 5), + LinearSales(1, 15), + LinearSales(2, null), + LinearSales(3, 75), + LinearSales(4, 100), + LinearSales(5, 90), + LinearSales(6, 75), ]; final myFakeTabletData = [ - new LinearSales(0, 5), - new LinearSales(1, 15), - new LinearSales(2, 25), - new LinearSales(3, 75), - new LinearSales(4, 100), - new LinearSales(5, 90), - new LinearSales(6, 75), + LinearSales(0, 5), + LinearSales(1, 15), + LinearSales(2, 25), + LinearSales(3, 75), + LinearSales(4, 100), + LinearSales(5, 90), + LinearSales(6, 75), ]; final myFakeMobileData = [ - new LinearSales(0, 5), - new LinearSales(1, 15), - new LinearSales(2, 25), - new LinearSales(3, 75), - new LinearSales(4, null), - new LinearSales(5, 90), - new LinearSales(6, 75), + LinearSales(0, 5), + LinearSales(1, 15), + LinearSales(2, 25), + LinearSales(3, 75), + LinearSales(4, null), + LinearSales(5, 90), + LinearSales(6, 75), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, data: myFakeDesktopData, ), - new charts.Series( + charts.Series( id: 'Tablet', colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, data: myFakeTabletData, ), - new charts.Series( + charts.Series( id: 'Mobile', colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault, domainFn: (LinearSales sales, _) => sales.year, diff --git a/web/charts/lib/main.dart b/web/charts/lib/main.dart index add19300d..5dcfe1c20 100644 --- a/web/charts/lib/main.dart +++ b/web/charts/lib/main.dart @@ -19,10 +19,10 @@ import 'home.dart'; /// The main gallery app widget. class GalleryApp extends StatefulWidget { - GalleryApp({Key key}) : super(key: key); + const GalleryApp({Key key}) : super(key: key); @override - GalleryAppState createState() => new GalleryAppState(); + GalleryAppState createState() => GalleryAppState(); } /// The main gallery app state. @@ -34,11 +34,11 @@ class GalleryAppState extends State { @override Widget build(BuildContext context) { - return new MaterialApp( + return MaterialApp( title: defaultConfig.appName, theme: defaultConfig.theme, showPerformanceOverlay: _showPerformanceOverlay, - home: new Home( + home: Home( showPerformanceOverlay: _showPerformanceOverlay, onShowPerformanceOverlayChanged: (bool value) { setState(() { @@ -50,5 +50,5 @@ class GalleryAppState extends State { } void main() { - runApp(new GalleryApp()); + runApp(const GalleryApp()); } diff --git a/web/charts/lib/pie_chart/auto_label.dart b/web/charts/lib/pie_chart/auto_label.dart index af719d776..0002d562d 100644 --- a/web/charts/lib/pie_chart/auto_label.dart +++ b/web/charts/lib/pie_chart/auto_label.dart @@ -25,11 +25,12 @@ class DonutAutoLabelChart extends StatelessWidget { final List seriesList; final bool animate; - DonutAutoLabelChart(this.seriesList, {this.animate}); + const DonutAutoLabelChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [PieChart] with sample data and no transition. factory DonutAutoLabelChart.withSampleData() { - return new DonutAutoLabelChart( + return DonutAutoLabelChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -41,22 +42,22 @@ class DonutAutoLabelChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory DonutAutoLabelChart.withRandomData() { - return new DonutAutoLabelChart(_createRandomData()); + return DonutAutoLabelChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, @@ -70,7 +71,7 @@ class DonutAutoLabelChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.PieChart(seriesList, + return charts.PieChart(seriesList, animate: animate, // Configure the width of the pie slices to 60px. The remaining space in // the chart will be left as a hole in the center. @@ -87,22 +88,21 @@ class DonutAutoLabelChart extends StatelessWidget { // new charts.ArcLabelDecorator( // insideLabelStyleSpec: new charts.TextStyleSpec(...), // outsideLabelStyleSpec: new charts.TextStyleSpec(...)), - defaultRenderer: new charts.ArcRendererConfig( - arcWidth: 60, - arcRendererDecorators: [new charts.ArcLabelDecorator()])); + defaultRenderer: charts.ArcRendererConfig( + arcWidth: 60, arcRendererDecorators: [charts.ArcLabelDecorator()])); } /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new LinearSales(0, 100), - new LinearSales(1, 75), - new LinearSales(2, 25), - new LinearSales(3, 5), + LinearSales(0, 100), + LinearSales(1, 75), + LinearSales(2, 25), + LinearSales(3, 5), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, diff --git a/web/charts/lib/pie_chart/donut.dart b/web/charts/lib/pie_chart/donut.dart index 59c02aa2b..3ecbc1b56 100644 --- a/web/charts/lib/pie_chart/donut.dart +++ b/web/charts/lib/pie_chart/donut.dart @@ -24,11 +24,12 @@ class DonutPieChart extends StatelessWidget { final List seriesList; final bool animate; - DonutPieChart(this.seriesList, {this.animate}); + const DonutPieChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [PieChart] with sample data and no transition. factory DonutPieChart.withSampleData() { - return new DonutPieChart( + return DonutPieChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -40,22 +41,22 @@ class DonutPieChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory DonutPieChart.withRandomData() { - return new DonutPieChart(_createRandomData()); + return DonutPieChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, @@ -67,24 +68,24 @@ class DonutPieChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.PieChart(seriesList, + return charts.PieChart(seriesList, animate: animate, // Configure the width of the pie slices to 60px. The remaining space in // the chart will be left as a hole in the center. - defaultRenderer: new charts.ArcRendererConfig(arcWidth: 60)); + defaultRenderer: charts.ArcRendererConfig(arcWidth: 60)); } /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new LinearSales(0, 100), - new LinearSales(1, 75), - new LinearSales(2, 25), - new LinearSales(3, 5), + LinearSales(0, 100), + LinearSales(1, 75), + LinearSales(2, 25), + LinearSales(3, 5), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, diff --git a/web/charts/lib/pie_chart/gauge.dart b/web/charts/lib/pie_chart/gauge.dart index ae1fae77f..9f3f7ff8a 100644 --- a/web/charts/lib/pie_chart/gauge.dart +++ b/web/charts/lib/pie_chart/gauge.dart @@ -25,11 +25,11 @@ class GaugeChart extends StatelessWidget { final List seriesList; final bool animate; - GaugeChart(this.seriesList, {this.animate}); + const GaugeChart(this.seriesList, {this.animate, Key key}) : super(key: key); /// Creates a [PieChart] with sample data and no transition. factory GaugeChart.withSampleData() { - return new GaugeChart( + return GaugeChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -41,22 +41,22 @@ class GaugeChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory GaugeChart.withRandomData() { - return new GaugeChart(_createRandomData()); + return GaugeChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new GaugeSegment('Low', random.nextInt(100)), - new GaugeSegment('Acceptable', random.nextInt(100)), - new GaugeSegment('High', random.nextInt(100)), - new GaugeSegment('Highly Unusual', random.nextInt(100)), + GaugeSegment('Low', random.nextInt(100)), + GaugeSegment('Acceptable', random.nextInt(100)), + GaugeSegment('High', random.nextInt(100)), + GaugeSegment('Highly Unusual', random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Segments', domainFn: (GaugeSegment segment, _) => segment.segment, measureFn: (GaugeSegment segment, _) => segment.size, @@ -68,26 +68,26 @@ class GaugeChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.PieChart(seriesList, + return charts.PieChart(seriesList, animate: animate, // Configure the width of the pie slices to 30px. The remaining space in // the chart will be left as a hole in the center. Adjust the start // angle and the arc length of the pie so it resembles a gauge. - defaultRenderer: new charts.ArcRendererConfig( + defaultRenderer: charts.ArcRendererConfig( arcWidth: 30, startAngle: 4 / 5 * pi, arcLength: 7 / 5 * pi)); } /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new GaugeSegment('Low', 75), - new GaugeSegment('Acceptable', 100), - new GaugeSegment('High', 50), - new GaugeSegment('Highly Unusual', 5), + GaugeSegment('Low', 75), + GaugeSegment('Acceptable', 100), + GaugeSegment('High', 50), + GaugeSegment('Highly Unusual', 5), ]; return [ - new charts.Series( + charts.Series( id: 'Segments', domainFn: (GaugeSegment segment, _) => segment.segment, measureFn: (GaugeSegment segment, _) => segment.size, diff --git a/web/charts/lib/pie_chart/outside_label.dart b/web/charts/lib/pie_chart/outside_label.dart index bf87677d6..9862c546b 100644 --- a/web/charts/lib/pie_chart/outside_label.dart +++ b/web/charts/lib/pie_chart/outside_label.dart @@ -24,11 +24,12 @@ class PieOutsideLabelChart extends StatelessWidget { final List seriesList; final bool animate; - PieOutsideLabelChart(this.seriesList, {this.animate}); + const PieOutsideLabelChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [PieChart] with sample data and no transition. factory PieOutsideLabelChart.withSampleData() { - return new PieOutsideLabelChart( + return PieOutsideLabelChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -40,22 +41,22 @@ class PieOutsideLabelChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory PieOutsideLabelChart.withRandomData() { - return new PieOutsideLabelChart(_createRandomData()); + return PieOutsideLabelChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, @@ -69,7 +70,7 @@ class PieOutsideLabelChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.PieChart(seriesList, + return charts.PieChart(seriesList, animate: animate, // Add an [ArcLabelDecorator] configured to render labels outside of the // arc with a leader line. @@ -81,8 +82,8 @@ class PieOutsideLabelChart extends StatelessWidget { // new charts.ArcLabelDecorator( // insideLabelStyleSpec: new charts.TextStyleSpec(...), // outsideLabelStyleSpec: new charts.TextStyleSpec(...)), - defaultRenderer: new charts.ArcRendererConfig(arcRendererDecorators: [ - new charts.ArcLabelDecorator( + defaultRenderer: charts.ArcRendererConfig(arcRendererDecorators: [ + charts.ArcLabelDecorator( labelPosition: charts.ArcLabelPosition.outside) ])); } @@ -90,14 +91,14 @@ class PieOutsideLabelChart extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new LinearSales(0, 100), - new LinearSales(1, 75), - new LinearSales(2, 25), - new LinearSales(3, 5), + LinearSales(0, 100), + LinearSales(1, 75), + LinearSales(2, 25), + LinearSales(3, 5), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, diff --git a/web/charts/lib/pie_chart/partial_pie.dart b/web/charts/lib/pie_chart/partial_pie.dart index 1d6bf1f05..ea0dd1f69 100644 --- a/web/charts/lib/pie_chart/partial_pie.dart +++ b/web/charts/lib/pie_chart/partial_pie.dart @@ -25,11 +25,12 @@ class PartialPieChart extends StatelessWidget { final List seriesList; final bool animate; - PartialPieChart(this.seriesList, {this.animate}); + const PartialPieChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [PieChart] with sample data and no transition. factory PartialPieChart.withSampleData() { - return new PartialPieChart( + return PartialPieChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -41,22 +42,22 @@ class PartialPieChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory PartialPieChart.withRandomData() { - return new PartialPieChart(_createRandomData()); + return PartialPieChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, @@ -70,22 +71,22 @@ class PartialPieChart extends StatelessWidget { Widget build(BuildContext context) { // Configure the pie to display the data across only 3/4 instead of the full // revolution. - return new charts.PieChart(seriesList, + return charts.PieChart(seriesList, animate: animate, - defaultRenderer: new charts.ArcRendererConfig(arcLength: 3 / 2 * pi)); + defaultRenderer: charts.ArcRendererConfig(arcLength: 3 / 2 * pi)); } /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new LinearSales(0, 100), - new LinearSales(1, 75), - new LinearSales(2, 25), - new LinearSales(3, 5), + LinearSales(0, 100), + LinearSales(1, 75), + LinearSales(2, 25), + LinearSales(3, 5), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, diff --git a/web/charts/lib/pie_chart/pie_gallery.dart b/web/charts/lib/pie_chart/pie_gallery.dart index 56c917803..f43a9ee0e 100644 --- a/web/charts/lib/pie_chart/pie_gallery.dart +++ b/web/charts/lib/pie_chart/pie_gallery.dart @@ -24,42 +24,42 @@ import 'partial_pie.dart'; List buildGallery() { return [ - new GalleryScaffold( - listTileIcon: new Icon(Icons.pie_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.pie_chart), title: 'Simple Pie Chart', subtitle: 'With a single series', - childBuilder: () => new SimplePieChart.withRandomData(), + childBuilder: () => SimplePieChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.pie_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.pie_chart), title: 'Outside Label Pie Chart', subtitle: 'With a single series and labels outside the arcs', - childBuilder: () => new PieOutsideLabelChart.withRandomData(), + childBuilder: () => PieOutsideLabelChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.pie_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.pie_chart), title: 'Partial Pie Chart', subtitle: 'That doesn\'t cover a full revolution', - childBuilder: () => new PartialPieChart.withRandomData(), + childBuilder: () => PartialPieChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.pie_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.pie_chart), title: 'Simple Donut Chart', subtitle: 'With a single series and a hole in the middle', - childBuilder: () => new DonutPieChart.withRandomData(), + childBuilder: () => DonutPieChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.pie_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.pie_chart), title: 'Auto Label Donut Chart', subtitle: 'With a single series, a hole in the middle, and auto-positioned labels', - childBuilder: () => new DonutAutoLabelChart.withRandomData(), + childBuilder: () => DonutAutoLabelChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.pie_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.pie_chart), title: 'Gauge Chart', subtitle: 'That doesn\'t cover a full revolution', - childBuilder: () => new GaugeChart.withRandomData(), + childBuilder: () => GaugeChart.withRandomData(), ), ]; } diff --git a/web/charts/lib/pie_chart/simple.dart b/web/charts/lib/pie_chart/simple.dart index 667ddc121..cdf80772f 100644 --- a/web/charts/lib/pie_chart/simple.dart +++ b/web/charts/lib/pie_chart/simple.dart @@ -24,11 +24,12 @@ class SimplePieChart extends StatelessWidget { final List seriesList; final bool animate; - SimplePieChart(this.seriesList, {this.animate}); + const SimplePieChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [PieChart] with sample data and no transition. factory SimplePieChart.withSampleData() { - return new SimplePieChart( + return SimplePieChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -40,22 +41,22 @@ class SimplePieChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory SimplePieChart.withRandomData() { - return new SimplePieChart(_createRandomData()); + return SimplePieChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new LinearSales(0, random.nextInt(100)), - new LinearSales(1, random.nextInt(100)), - new LinearSales(2, random.nextInt(100)), - new LinearSales(3, random.nextInt(100)), + LinearSales(0, random.nextInt(100)), + LinearSales(1, random.nextInt(100)), + LinearSales(2, random.nextInt(100)), + LinearSales(3, random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, @@ -67,20 +68,20 @@ class SimplePieChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.PieChart(seriesList, animate: animate); + return charts.PieChart(seriesList, animate: animate); } /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new LinearSales(0, 100), - new LinearSales(1, 75), - new LinearSales(2, 25), - new LinearSales(3, 5), + LinearSales(0, 100), + LinearSales(1, 75), + LinearSales(2, 25), + LinearSales(3, 5), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (LinearSales sales, _) => sales.year, measureFn: (LinearSales sales, _) => sales.sales, diff --git a/web/charts/lib/scatter_plot_chart/animation_zoom.dart b/web/charts/lib/scatter_plot_chart/animation_zoom.dart index bd4c683f4..2f8b472c8 100644 --- a/web/charts/lib/scatter_plot_chart/animation_zoom.dart +++ b/web/charts/lib/scatter_plot_chart/animation_zoom.dart @@ -25,11 +25,12 @@ class ScatterPlotAnimationZoomChart extends StatelessWidget { final List seriesList; final bool animate; - ScatterPlotAnimationZoomChart(this.seriesList, {this.animate}); + const ScatterPlotAnimationZoomChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [ScatterPlotChart] with sample data and no transition. factory ScatterPlotAnimationZoomChart.withSampleData() { - return new ScatterPlotAnimationZoomChart( + return ScatterPlotAnimationZoomChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -41,25 +42,25 @@ class ScatterPlotAnimationZoomChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory ScatterPlotAnimationZoomChart.withRandomData() { - return new ScatterPlotAnimationZoomChart(_createRandomData()); + return ScatterPlotAnimationZoomChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = []; - final makeRadius = (int value) => (random.nextInt(value) + 2).toDouble(); + makeRadius(int value) => (random.nextInt(value) + 2).toDouble(); for (var i = 0; i < 100; i++) { - data.add(new LinearSales(i, random.nextInt(100), makeRadius(4))); + data.add(LinearSales(i, random.nextInt(100), makeRadius(4))); } - final maxMeasure = 100; + const maxMeasure = 100; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (LinearSales sales, _) { // Color bucket the measure column value into 3 distinct colors. @@ -84,34 +85,32 @@ class ScatterPlotAnimationZoomChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.ScatterPlotChart(seriesList, - animate: animate, - behaviors: [ - new charts.PanAndZoomBehavior(), - ]); + return charts.ScatterPlotChart(seriesList, animate: animate, behaviors: [ + charts.PanAndZoomBehavior(), + ]); } /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new LinearSales(0, 5, 3.0), - new LinearSales(10, 25, 5.0), - new LinearSales(12, 75, 4.0), - new LinearSales(13, 225, 5.0), - new LinearSales(16, 50, 4.0), - new LinearSales(24, 75, 3.0), - new LinearSales(25, 100, 3.0), - new LinearSales(34, 150, 5.0), - new LinearSales(37, 10, 4.5), - new LinearSales(45, 300, 8.0), - new LinearSales(52, 15, 4.0), - new LinearSales(56, 200, 7.0), + LinearSales(0, 5, 3.0), + LinearSales(10, 25, 5.0), + LinearSales(12, 75, 4.0), + LinearSales(13, 225, 5.0), + LinearSales(16, 50, 4.0), + LinearSales(24, 75, 3.0), + LinearSales(25, 100, 3.0), + LinearSales(34, 150, 5.0), + LinearSales(37, 10, 4.5), + LinearSales(45, 300, 8.0), + LinearSales(52, 15, 4.0), + LinearSales(56, 200, 7.0), ]; - final maxMeasure = 300; + const maxMeasure = 300; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (LinearSales sales, _) { // Color bucket the measure column value into 3 distinct colors. diff --git a/web/charts/lib/scatter_plot_chart/bucketing_axis.dart b/web/charts/lib/scatter_plot_chart/bucketing_axis.dart index 1488841c0..c8f1e3a31 100644 --- a/web/charts/lib/scatter_plot_chart/bucketing_axis.dart +++ b/web/charts/lib/scatter_plot_chart/bucketing_axis.dart @@ -29,11 +29,12 @@ class BucketingAxisScatterPlotChart extends StatelessWidget { final List seriesList; final bool animate; - BucketingAxisScatterPlotChart(this.seriesList, {this.animate}); + const BucketingAxisScatterPlotChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [ScatterPlotChart] with sample data and no transition. factory BucketingAxisScatterPlotChart.withSampleData() { - return new BucketingAxisScatterPlotChart( + return BucketingAxisScatterPlotChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -45,61 +46,55 @@ class BucketingAxisScatterPlotChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory BucketingAxisScatterPlotChart.withRandomData() { - return new BucketingAxisScatterPlotChart(_createRandomData()); + return BucketingAxisScatterPlotChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); - final makeRadius = (int value) => (random.nextInt(value) + 6).toDouble(); + makeRadius(int value) => (random.nextInt(value) + 6).toDouble(); // Make sure that the measure values for the first five series are well // above the threshold. This simulates the grouping of the small values into // the "Other" series. final myFakeDesktopData = [ - new LinearSales( + LinearSales( random.nextInt(100), (random.nextInt(50) + 50) / 100, makeRadius(6)), ]; final myFakeTabletData = [ - new LinearSales( + LinearSales( random.nextInt(100), (random.nextInt(50) + 50) / 100, makeRadius(6)), ]; final myFakeMobileData = [ - new LinearSales( + LinearSales( random.nextInt(100), (random.nextInt(50) + 50) / 100, makeRadius(6)), ]; final myFakeChromebookData = [ - new LinearSales( + LinearSales( random.nextInt(100), (random.nextInt(50) + 50) / 100, makeRadius(6)), ]; final myFakeHomeData = [ - new LinearSales( + LinearSales( random.nextInt(100), (random.nextInt(50) + 50) / 100, makeRadius(6)), ]; // Make sure that the "Other" series values are smaller. final myFakeOtherData = [ - new LinearSales( - random.nextInt(100), random.nextInt(50) / 100, makeRadius(6)), - new LinearSales( - random.nextInt(100), random.nextInt(50) / 100, makeRadius(6)), - new LinearSales( - random.nextInt(100), random.nextInt(50) / 100, makeRadius(6)), - new LinearSales( - random.nextInt(100), random.nextInt(50) / 100, makeRadius(6)), - new LinearSales( - random.nextInt(100), random.nextInt(50) / 100, makeRadius(6)), - new LinearSales( - random.nextInt(100), random.nextInt(50) / 100, makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(50) / 100, makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(50) / 100, makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(50) / 100, makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(50) / 100, makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(50) / 100, makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(50) / 100, makeRadius(6)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', colorFn: (LinearSales sales, _) => charts.MaterialPalette.blue.shadeDefault, @@ -107,7 +102,7 @@ class BucketingAxisScatterPlotChart extends StatelessWidget { measureFn: (LinearSales sales, _) => sales.revenueShare, radiusPxFn: (LinearSales sales, _) => sales.radius, data: myFakeDesktopData), - new charts.Series( + charts.Series( id: 'Tablet', colorFn: (LinearSales sales, _) => charts.MaterialPalette.red.shadeDefault, @@ -115,7 +110,7 @@ class BucketingAxisScatterPlotChart extends StatelessWidget { measureFn: (LinearSales sales, _) => sales.revenueShare, radiusPxFn: (LinearSales sales, _) => sales.radius, data: myFakeTabletData), - new charts.Series( + charts.Series( id: 'Mobile', colorFn: (LinearSales sales, _) => charts.MaterialPalette.green.shadeDefault, @@ -123,7 +118,7 @@ class BucketingAxisScatterPlotChart extends StatelessWidget { measureFn: (LinearSales sales, _) => sales.revenueShare, radiusPxFn: (LinearSales sales, _) => sales.radius, data: myFakeMobileData), - new charts.Series( + charts.Series( id: 'Chromebook', colorFn: (LinearSales sales, _) => charts.MaterialPalette.purple.shadeDefault, @@ -131,7 +126,7 @@ class BucketingAxisScatterPlotChart extends StatelessWidget { measureFn: (LinearSales sales, _) => sales.revenueShare, radiusPxFn: (LinearSales sales, _) => sales.radius, data: myFakeChromebookData), - new charts.Series( + charts.Series( id: 'Home', colorFn: (LinearSales sales, _) => charts.MaterialPalette.indigo.shadeDefault, @@ -139,7 +134,7 @@ class BucketingAxisScatterPlotChart extends StatelessWidget { measureFn: (LinearSales sales, _) => sales.revenueShare, radiusPxFn: (LinearSales sales, _) => sales.radius, data: myFakeHomeData), - new charts.Series( + charts.Series( id: 'Other', colorFn: (LinearSales sales, _) => charts.MaterialPalette.gray.shadeDefault, @@ -153,19 +148,19 @@ class BucketingAxisScatterPlotChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.ScatterPlotChart(seriesList, + return charts.ScatterPlotChart(seriesList, // Set up a bucketing axis that will place all values below 0.1 (10%) // into a bucket at the bottom of the chart. // // Configure a tick count of 3 so that we get 100%, 50%, and the // threshold. - primaryMeasureAxis: new charts.BucketingAxisSpec( + primaryMeasureAxis: charts.BucketingAxisSpec( threshold: 0.1, - tickProviderSpec: new charts.BucketingNumericTickProviderSpec( + tickProviderSpec: const charts.BucketingNumericTickProviderSpec( desiredTickCount: 3)), // Add a series legend to display the series names. behaviors: [ - new charts.SeriesLegend(position: charts.BehaviorPosition.end), + charts.SeriesLegend(position: charts.BehaviorPosition.end), ], animate: animate); } @@ -173,36 +168,36 @@ class BucketingAxisScatterPlotChart extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final myFakeDesktopData = [ - new LinearSales(52, 0.75, 14.0), + LinearSales(52, 0.75, 14.0), ]; final myFakeTabletData = [ - new LinearSales(45, 0.3, 18.0), + LinearSales(45, 0.3, 18.0), ]; final myFakeMobileData = [ - new LinearSales(56, 0.8, 17.0), + LinearSales(56, 0.8, 17.0), ]; final myFakeChromebookData = [ - new LinearSales(25, 0.6, 13.0), + LinearSales(25, 0.6, 13.0), ]; final myFakeHomeData = [ - new LinearSales(34, 0.5, 15.0), + LinearSales(34, 0.5, 15.0), ]; final myFakeOtherData = [ - new LinearSales(10, 0.25, 15.0), - new LinearSales(12, 0.075, 14.0), - new LinearSales(13, 0.225, 15.0), - new LinearSales(16, 0.03, 14.0), - new LinearSales(24, 0.04, 13.0), - new LinearSales(37, 0.1, 14.5), + LinearSales(10, 0.25, 15.0), + LinearSales(12, 0.075, 14.0), + LinearSales(13, 0.225, 15.0), + LinearSales(16, 0.03, 14.0), + LinearSales(24, 0.04, 13.0), + LinearSales(37, 0.1, 14.5), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', colorFn: (LinearSales sales, _) => charts.MaterialPalette.blue.shadeDefault, @@ -210,7 +205,7 @@ class BucketingAxisScatterPlotChart extends StatelessWidget { measureFn: (LinearSales sales, _) => sales.revenueShare, radiusPxFn: (LinearSales sales, _) => sales.radius, data: myFakeDesktopData), - new charts.Series( + charts.Series( id: 'Tablet', colorFn: (LinearSales sales, _) => charts.MaterialPalette.red.shadeDefault, @@ -218,7 +213,7 @@ class BucketingAxisScatterPlotChart extends StatelessWidget { measureFn: (LinearSales sales, _) => sales.revenueShare, radiusPxFn: (LinearSales sales, _) => sales.radius, data: myFakeTabletData), - new charts.Series( + charts.Series( id: 'Mobile', colorFn: (LinearSales sales, _) => charts.MaterialPalette.green.shadeDefault, @@ -226,7 +221,7 @@ class BucketingAxisScatterPlotChart extends StatelessWidget { measureFn: (LinearSales sales, _) => sales.revenueShare, radiusPxFn: (LinearSales sales, _) => sales.radius, data: myFakeMobileData), - new charts.Series( + charts.Series( id: 'Chromebook', colorFn: (LinearSales sales, _) => charts.MaterialPalette.purple.shadeDefault, @@ -234,7 +229,7 @@ class BucketingAxisScatterPlotChart extends StatelessWidget { measureFn: (LinearSales sales, _) => sales.revenueShare, radiusPxFn: (LinearSales sales, _) => sales.radius, data: myFakeChromebookData), - new charts.Series( + charts.Series( id: 'Home', colorFn: (LinearSales sales, _) => charts.MaterialPalette.indigo.shadeDefault, @@ -242,7 +237,7 @@ class BucketingAxisScatterPlotChart extends StatelessWidget { measureFn: (LinearSales sales, _) => sales.revenueShare, radiusPxFn: (LinearSales sales, _) => sales.radius, data: myFakeHomeData), - new charts.Series( + charts.Series( id: 'Other', colorFn: (LinearSales sales, _) => charts.MaterialPalette.gray.shadeDefault, diff --git a/web/charts/lib/scatter_plot_chart/comparison_points.dart b/web/charts/lib/scatter_plot_chart/comparison_points.dart index 000c4ebbf..7dc628d4d 100644 --- a/web/charts/lib/scatter_plot_chart/comparison_points.dart +++ b/web/charts/lib/scatter_plot_chart/comparison_points.dart @@ -24,11 +24,13 @@ class ComparisonPointsScatterPlotChart extends StatelessWidget { final List seriesList; final bool animate; - ComparisonPointsScatterPlotChart(this.seriesList, {this.animate}); + const ComparisonPointsScatterPlotChart(this.seriesList, + {this.animate, Key key}) + : super(key: key); /// Creates a [ScatterPlotChart] with sample data and no transition. factory ComparisonPointsScatterPlotChart.withSampleData() { - return new ComparisonPointsScatterPlotChart( + return ComparisonPointsScatterPlotChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -40,14 +42,14 @@ class ComparisonPointsScatterPlotChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory ComparisonPointsScatterPlotChart.withRandomData() { - return new ComparisonPointsScatterPlotChart(_createRandomData()); + return ComparisonPointsScatterPlotChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); - final maxMeasure = 100; + const maxMeasure = 100; final data = [ _makeRandomDatum(maxMeasure, random), @@ -59,7 +61,7 @@ class ComparisonPointsScatterPlotChart extends StatelessWidget { ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (LinearSales sales, _) { // Color bucket the measure column value into 3 distinct colors. @@ -86,7 +88,7 @@ class ComparisonPointsScatterPlotChart extends StatelessWidget { } static LinearSales _makeRandomDatum(int max, Random random) { - final makeRadius = (int value) => (random.nextInt(value) + 6).toDouble(); + makeRadius(int value) => (random.nextInt(value) + 6).toDouble(); final year = random.nextInt(max); final yearLower = (year * 0.8).round(); @@ -95,37 +97,36 @@ class ComparisonPointsScatterPlotChart extends StatelessWidget { final salesLower = (sales * 0.8).round(); final salesUpper = sales; - return new LinearSales(year, yearLower, yearUpper, sales, salesLower, + return LinearSales(year, yearLower, yearUpper, sales, salesLower, salesUpper, makeRadius(4)); } // EXCLUDE_FROM_GALLERY_DOCS_END @override Widget build(BuildContext context) { - return new charts.ScatterPlotChart(seriesList, + return charts.ScatterPlotChart(seriesList, animate: animate, - defaultRenderer: - new charts.PointRendererConfig(pointRendererDecorators: [ - new charts.ComparisonPointsDecorator( - symbolRenderer: new charts.CylinderSymbolRenderer()) + defaultRenderer: charts.PointRendererConfig(pointRendererDecorators: [ + charts.ComparisonPointsDecorator( + symbolRenderer: charts.CylinderSymbolRenderer()) ])); } /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new LinearSales(10, 7, 10, 25, 20, 25, 5.0), - new LinearSales(13, 11, 13, 225, 205, 225, 5.0), - new LinearSales(34, 34, 24, 150, 150, 130, 5.0), - new LinearSales(37, 37, 57, 10, 10, 12, 6.5), - new LinearSales(45, 35, 45, 260, 300, 260, 8.0), - new LinearSales(56, 46, 56, 200, 170, 200, 7.0), + LinearSales(10, 7, 10, 25, 20, 25, 5.0), + LinearSales(13, 11, 13, 225, 205, 225, 5.0), + LinearSales(34, 34, 24, 150, 150, 130, 5.0), + LinearSales(37, 37, 57, 10, 10, 12, 6.5), + LinearSales(45, 35, 45, 260, 300, 260, 8.0), + LinearSales(56, 46, 56, 200, 170, 200, 7.0), ]; - final maxMeasure = 300; + const maxMeasure = 300; return [ - new charts.Series( + charts.Series( id: 'Sales', // Providing a color function is optional. colorFn: (LinearSales sales, _) { diff --git a/web/charts/lib/scatter_plot_chart/scatter_plot_gallery.dart b/web/charts/lib/scatter_plot_chart/scatter_plot_gallery.dart index 3c1b3f7a2..432812e6c 100644 --- a/web/charts/lib/scatter_plot_chart/scatter_plot_gallery.dart +++ b/web/charts/lib/scatter_plot_chart/scatter_plot_gallery.dart @@ -23,36 +23,36 @@ import 'simple.dart'; List buildGallery() { return [ - new GalleryScaffold( - listTileIcon: new Icon(Icons.scatter_plot), + GalleryScaffold( + listTileIcon: const Icon(Icons.scatter_plot), title: 'Simple Scatter Plot Chart', subtitle: 'With a single series', - childBuilder: () => new SimpleScatterPlotChart.withRandomData(), + childBuilder: () => SimpleScatterPlotChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.scatter_plot), + GalleryScaffold( + listTileIcon: const Icon(Icons.scatter_plot), title: 'Shapes Scatter Plot Chart', subtitle: 'With custom shapes', - childBuilder: () => new ShapesScatterPlotChart.withRandomData(), + childBuilder: () => ShapesScatterPlotChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.scatter_plot), + GalleryScaffold( + listTileIcon: const Icon(Icons.scatter_plot), title: 'Comparison Points Scatter Plot Chart', subtitle: 'Scatter plot chart with comparison points', - childBuilder: () => new ComparisonPointsScatterPlotChart.withRandomData(), + childBuilder: () => ComparisonPointsScatterPlotChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.scatter_plot), + GalleryScaffold( + listTileIcon: const Icon(Icons.scatter_plot), title: 'Pan and Zoom Scatter Plot Chart', subtitle: 'Simple scatter plot chart pan and zoom behaviors enabled', - childBuilder: () => new ScatterPlotAnimationZoomChart.withRandomData(), + childBuilder: () => ScatterPlotAnimationZoomChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.scatter_plot), + GalleryScaffold( + listTileIcon: const Icon(Icons.scatter_plot), title: 'Bucketing Axis Scatter Plot Chart', - subtitle: 'Scatter plot with a measure axis that buckets values less ' + + subtitle: 'Scatter plot with a measure axis that buckets values less ' 'than 10% into a single region below the draw area', - childBuilder: () => new BucketingAxisScatterPlotChart.withRandomData(), + childBuilder: () => BucketingAxisScatterPlotChart.withRandomData(), ), ]; } diff --git a/web/charts/lib/scatter_plot_chart/shapes.dart b/web/charts/lib/scatter_plot_chart/shapes.dart index f06095072..60dca2013 100644 --- a/web/charts/lib/scatter_plot_chart/shapes.dart +++ b/web/charts/lib/scatter_plot_chart/shapes.dart @@ -35,11 +35,12 @@ class ShapesScatterPlotChart extends StatelessWidget { final List seriesList; final bool animate; - ShapesScatterPlotChart(this.seriesList, {this.animate}); + const ShapesScatterPlotChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [ScatterPlotChart] with sample data and no transition. factory ShapesScatterPlotChart.withSampleData() { - return new ShapesScatterPlotChart( + return ShapesScatterPlotChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -51,49 +52,49 @@ class ShapesScatterPlotChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory ShapesScatterPlotChart.withRandomData() { - return new ShapesScatterPlotChart(_createRandomData()); + return ShapesScatterPlotChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); - final makeRadius = (int value) => (random.nextInt(value) + 2).toDouble(); + makeRadius(int value) => (random.nextInt(value) + 2).toDouble(); final data = [ - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), 'circle', null, null), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), - null, null, null), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), - null, null, null), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), null, + null, null), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), null, + null, null), // Render a hollow circle, filled in with white. - new LinearSales(random.nextInt(100), random.nextInt(100), - makeRadius(4) + 4, 'circle', charts.MaterialPalette.white, 2.0), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), - null, null, null), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), - null, null, null), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(4) + 4, + 'circle', charts.MaterialPalette.white, 2.0), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), null, + null, null), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), null, + null, null), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), 'circle', null, null), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), - null, null, null), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), - null, null, null), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), null, + null, null), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), null, + null, null), // Render a hollow circle, filled in with white. - new LinearSales(random.nextInt(100), random.nextInt(100), - makeRadius(4) + 4, 'circle', charts.MaterialPalette.white, 2.0), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), - null, null, null), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(4) + 4, + 'circle', charts.MaterialPalette.white, 2.0), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6), null, + null, null), // Render a hollow square, filled in with white. - new LinearSales(random.nextInt(100), random.nextInt(100), - makeRadius(4) + 4, null, charts.MaterialPalette.white, 2.0), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(4) + 4, + null, charts.MaterialPalette.white, 2.0), ]; - final maxMeasure = 100; + const maxMeasure = 100; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (LinearSales sales, _) { // Color bucket the measure column value into 3 distinct colors. @@ -125,43 +126,41 @@ class ShapesScatterPlotChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.ScatterPlotChart(seriesList, + return charts.ScatterPlotChart(seriesList, animate: animate, // Configure the point renderer to have a map of custom symbol // renderers. defaultRenderer: - new charts.PointRendererConfig(customSymbolRenderers: { - 'circle': new charts.CircleSymbolRenderer(), - 'rect': new charts.RectSymbolRenderer(), + charts.PointRendererConfig(customSymbolRenderers: { + 'circle': charts.CircleSymbolRenderer(), + 'rect': charts.RectSymbolRenderer(), })); } /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new LinearSales(0, 5, 3.0, 'circle', null, null), - new LinearSales(10, 25, 5.0, null, null, null), - new LinearSales(12, 75, 4.0, null, null, null), + LinearSales(0, 5, 3.0, 'circle', null, null), + LinearSales(10, 25, 5.0, null, null, null), + LinearSales(12, 75, 4.0, null, null, null), // Render a hollow circle, filled in with white. - new LinearSales( - 13, 225, 5.0, 'circle', charts.MaterialPalette.white, 2.0), - new LinearSales(16, 50, 4.0, null, null, null), - new LinearSales(24, 75, 3.0, null, null, null), - new LinearSales(25, 100, 3.0, 'circle', null, null), - new LinearSales(34, 150, 5.0, null, null, null), - new LinearSales(37, 10, 4.5, null, null, null), + LinearSales(13, 225, 5.0, 'circle', charts.MaterialPalette.white, 2.0), + LinearSales(16, 50, 4.0, null, null, null), + LinearSales(24, 75, 3.0, null, null, null), + LinearSales(25, 100, 3.0, 'circle', null, null), + LinearSales(34, 150, 5.0, null, null, null), + LinearSales(37, 10, 4.5, null, null, null), // Render a hollow circle, filled in with white. - new LinearSales( - 45, 300, 8.0, 'circle', charts.MaterialPalette.white, 2.0), - new LinearSales(52, 15, 4.0, null, null, null), + LinearSales(45, 300, 8.0, 'circle', charts.MaterialPalette.white, 2.0), + LinearSales(52, 15, 4.0, null, null, null), // Render a hollow square, filled in with white. - new LinearSales(56, 200, 7.0, null, charts.MaterialPalette.white, 2.0), + LinearSales(56, 200, 7.0, null, charts.MaterialPalette.white, 2.0), ]; - final maxMeasure = 300; + const maxMeasure = 300; return [ - new charts.Series( + charts.Series( id: 'Sales', // Providing a color function is optional. colorFn: (LinearSales sales, _) { diff --git a/web/charts/lib/scatter_plot_chart/simple.dart b/web/charts/lib/scatter_plot_chart/simple.dart index fc2fee1f1..4b1945a90 100644 --- a/web/charts/lib/scatter_plot_chart/simple.dart +++ b/web/charts/lib/scatter_plot_chart/simple.dart @@ -24,11 +24,12 @@ class SimpleScatterPlotChart extends StatelessWidget { final List seriesList; final bool animate; - SimpleScatterPlotChart(this.seriesList, {this.animate}); + const SimpleScatterPlotChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [ScatterPlotChart] with sample data and no transition. factory SimpleScatterPlotChart.withSampleData() { - return new SimpleScatterPlotChart( + return SimpleScatterPlotChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -40,34 +41,34 @@ class SimpleScatterPlotChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory SimpleScatterPlotChart.withRandomData() { - return new SimpleScatterPlotChart(_createRandomData()); + return SimpleScatterPlotChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); - final makeRadius = (int value) => (random.nextInt(value) + 2).toDouble(); + makeRadius(int value) => (random.nextInt(value) + 2).toDouble(); final data = [ - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), - new LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), + LinearSales(random.nextInt(100), random.nextInt(100), makeRadius(6)), ]; - final maxMeasure = 100; + const maxMeasure = 100; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (LinearSales sales, _) { // Color bucket the measure column value into 3 distinct colors. @@ -92,30 +93,30 @@ class SimpleScatterPlotChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.ScatterPlotChart(seriesList, animate: animate); + return charts.ScatterPlotChart(seriesList, animate: animate); } /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new LinearSales(0, 5, 3.0), - new LinearSales(10, 25, 5.0), - new LinearSales(12, 75, 4.0), - new LinearSales(13, 225, 5.0), - new LinearSales(16, 50, 4.0), - new LinearSales(24, 75, 3.0), - new LinearSales(25, 100, 3.0), - new LinearSales(34, 150, 5.0), - new LinearSales(37, 10, 4.5), - new LinearSales(45, 300, 8.0), - new LinearSales(52, 15, 4.0), - new LinearSales(56, 200, 7.0), + LinearSales(0, 5, 3.0), + LinearSales(10, 25, 5.0), + LinearSales(12, 75, 4.0), + LinearSales(13, 225, 5.0), + LinearSales(16, 50, 4.0), + LinearSales(24, 75, 3.0), + LinearSales(25, 100, 3.0), + LinearSales(34, 150, 5.0), + LinearSales(37, 10, 4.5), + LinearSales(45, 300, 8.0), + LinearSales(52, 15, 4.0), + LinearSales(56, 200, 7.0), ]; - final maxMeasure = 300; + const maxMeasure = 300; return [ - new charts.Series( + charts.Series( id: 'Sales', // Providing a color function is optional. colorFn: (LinearSales sales, _) { diff --git a/web/charts/lib/time_series_chart/confidence_interval.dart b/web/charts/lib/time_series_chart/confidence_interval.dart index b1e4f52c8..b9a0544cc 100644 --- a/web/charts/lib/time_series_chart/confidence_interval.dart +++ b/web/charts/lib/time_series_chart/confidence_interval.dart @@ -27,11 +27,12 @@ class TimeSeriesConfidenceInterval extends StatelessWidget { final List seriesList; final bool animate; - TimeSeriesConfidenceInterval(this.seriesList, {this.animate}); + const TimeSeriesConfidenceInterval(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [TimeSeriesChart] with sample data and no transition. factory TimeSeriesConfidenceInterval.withSampleData() { - return new TimeSeriesConfidenceInterval( + return TimeSeriesConfidenceInterval( _createSampleData(), // Disable animations for image tests. animate: false, @@ -43,22 +44,22 @@ class TimeSeriesConfidenceInterval extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory TimeSeriesConfidenceInterval.withRandomData() { - return new TimeSeriesConfidenceInterval(_createRandomData()); + return TimeSeriesConfidenceInterval(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new TimeSeriesSales(new DateTime(2017, 9, 19), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 26), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 10, 3), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 10, 10), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 19), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 26), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 10, 3), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 10, 10), random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (TimeSeriesSales sales, _) => sales.time, @@ -75,7 +76,7 @@ class TimeSeriesConfidenceInterval extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.TimeSeriesChart( + return charts.TimeSeriesChart( seriesList, animate: animate, // Optionally pass in a [DateTimeFactory] used by the chart. The factory @@ -88,14 +89,14 @@ class TimeSeriesConfidenceInterval extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new TimeSeriesSales(new DateTime(2017, 9, 19), 5), - new TimeSeriesSales(new DateTime(2017, 9, 26), 25), - new TimeSeriesSales(new DateTime(2017, 10, 3), 100), - new TimeSeriesSales(new DateTime(2017, 10, 10), 75), + TimeSeriesSales(DateTime(2017, 9, 19), 5), + TimeSeriesSales(DateTime(2017, 9, 26), 25), + TimeSeriesSales(DateTime(2017, 10, 3), 100), + TimeSeriesSales(DateTime(2017, 10, 10), 75), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (TimeSeriesSales sales, _) => sales.time, diff --git a/web/charts/lib/time_series_chart/end_points_axis.dart b/web/charts/lib/time_series_chart/end_points_axis.dart index 69433615f..2d1c3ab22 100644 --- a/web/charts/lib/time_series_chart/end_points_axis.dart +++ b/web/charts/lib/time_series_chart/end_points_axis.dart @@ -26,11 +26,12 @@ class EndPointsAxisTimeSeriesChart extends StatelessWidget { final List seriesList; final bool animate; - EndPointsAxisTimeSeriesChart(this.seriesList, {this.animate}); + const EndPointsAxisTimeSeriesChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [TimeSeriesChart] with sample data and no transition. factory EndPointsAxisTimeSeriesChart.withSampleData() { - return new EndPointsAxisTimeSeriesChart( + return EndPointsAxisTimeSeriesChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -42,22 +43,22 @@ class EndPointsAxisTimeSeriesChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory EndPointsAxisTimeSeriesChart.withRandomData() { - return new EndPointsAxisTimeSeriesChart(_createRandomData()); + return EndPointsAxisTimeSeriesChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new TimeSeriesSales(new DateTime(2017, 9, 19), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 26), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 10, 3), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 10, 10), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 19), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 26), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 10, 3), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 10, 10), random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (TimeSeriesSales sales, _) => sales.time, @@ -70,28 +71,28 @@ class EndPointsAxisTimeSeriesChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.TimeSeriesChart( + return charts.TimeSeriesChart( seriesList, animate: animate, // Configures an axis spec that is configured to render one tick at each // end of the axis range, anchored "inside" the axis. The start tick label // will be left-aligned with its tick mark, and the end tick label will be // right-aligned with its tick mark. - domainAxis: new charts.EndPointsTimeAxisSpec(), + domainAxis: const charts.EndPointsTimeAxisSpec(), ); } /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new TimeSeriesSales(new DateTime(2017, 9, 19), 5), - new TimeSeriesSales(new DateTime(2017, 9, 26), 25), - new TimeSeriesSales(new DateTime(2017, 10, 3), 100), - new TimeSeriesSales(new DateTime(2017, 10, 10), 75), + TimeSeriesSales(DateTime(2017, 9, 19), 5), + TimeSeriesSales(DateTime(2017, 9, 26), 25), + TimeSeriesSales(DateTime(2017, 10, 3), 100), + TimeSeriesSales(DateTime(2017, 10, 10), 75), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (TimeSeriesSales sales, _) => sales.time, diff --git a/web/charts/lib/time_series_chart/line_annotation.dart b/web/charts/lib/time_series_chart/line_annotation.dart index 78dd36a99..ba90694aa 100644 --- a/web/charts/lib/time_series_chart/line_annotation.dart +++ b/web/charts/lib/time_series_chart/line_annotation.dart @@ -31,11 +31,12 @@ class TimeSeriesLineAnnotationChart extends StatelessWidget { final List seriesList; final bool animate; - TimeSeriesLineAnnotationChart(this.seriesList, {this.animate}); + const TimeSeriesLineAnnotationChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [TimeSeriesChart] with sample data and no transition. factory TimeSeriesLineAnnotationChart.withSampleData() { - return new TimeSeriesLineAnnotationChart( + return TimeSeriesLineAnnotationChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -47,22 +48,22 @@ class TimeSeriesLineAnnotationChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory TimeSeriesLineAnnotationChart.withRandomData() { - return new TimeSeriesLineAnnotationChart(_createRandomData()); + return TimeSeriesLineAnnotationChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new TimeSeriesSales(new DateTime(2017, 9, 19), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 26), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 10, 3), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 10, 10), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 19), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 26), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 10, 3), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 10, 10), random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (TimeSeriesSales sales, _) => sales.time, measureFn: (TimeSeriesSales sales, _) => sales.sales, @@ -74,13 +75,13 @@ class TimeSeriesLineAnnotationChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.TimeSeriesChart(seriesList, animate: animate, behaviors: [ - new charts.RangeAnnotation([ - new charts.LineAnnotationSegment( - new DateTime(2017, 10, 4), charts.RangeAnnotationAxisType.domain, + return charts.TimeSeriesChart(seriesList, animate: animate, behaviors: [ + charts.RangeAnnotation([ + charts.LineAnnotationSegment( + DateTime(2017, 10, 4), charts.RangeAnnotationAxisType.domain, startLabel: 'Oct 4'), - new charts.LineAnnotationSegment( - new DateTime(2017, 10, 15), charts.RangeAnnotationAxisType.domain, + charts.LineAnnotationSegment( + DateTime(2017, 10, 15), charts.RangeAnnotationAxisType.domain, endLabel: 'Oct 15'), ]), ]); @@ -89,14 +90,14 @@ class TimeSeriesLineAnnotationChart extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new TimeSeriesSales(new DateTime(2017, 9, 19), 5), - new TimeSeriesSales(new DateTime(2017, 9, 26), 25), - new TimeSeriesSales(new DateTime(2017, 10, 3), 100), - new TimeSeriesSales(new DateTime(2017, 10, 10), 75), + TimeSeriesSales(DateTime(2017, 9, 19), 5), + TimeSeriesSales(DateTime(2017, 9, 26), 25), + TimeSeriesSales(DateTime(2017, 10, 3), 100), + TimeSeriesSales(DateTime(2017, 10, 10), 75), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (TimeSeriesSales sales, _) => sales.time, measureFn: (TimeSeriesSales sales, _) => sales.sales, diff --git a/web/charts/lib/time_series_chart/range_annotation.dart b/web/charts/lib/time_series_chart/range_annotation.dart index 8620078ec..2282ba526 100644 --- a/web/charts/lib/time_series_chart/range_annotation.dart +++ b/web/charts/lib/time_series_chart/range_annotation.dart @@ -31,11 +31,12 @@ class TimeSeriesRangeAnnotationChart extends StatelessWidget { final List seriesList; final bool animate; - TimeSeriesRangeAnnotationChart(this.seriesList, {this.animate}); + const TimeSeriesRangeAnnotationChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [TimeSeriesChart] with sample data and no transition. factory TimeSeriesRangeAnnotationChart.withSampleData() { - return new TimeSeriesRangeAnnotationChart( + return TimeSeriesRangeAnnotationChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -47,22 +48,22 @@ class TimeSeriesRangeAnnotationChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory TimeSeriesRangeAnnotationChart.withRandomData() { - return new TimeSeriesRangeAnnotationChart(_createRandomData()); + return TimeSeriesRangeAnnotationChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new TimeSeriesSales(new DateTime(2017, 9, 19), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 26), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 10, 3), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 10, 10), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 19), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 26), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 10, 3), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 10, 10), random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (TimeSeriesSales sales, _) => sales.time, measureFn: (TimeSeriesSales sales, _) => sales.sales, @@ -74,10 +75,10 @@ class TimeSeriesRangeAnnotationChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.TimeSeriesChart(seriesList, animate: animate, behaviors: [ - new charts.RangeAnnotation([ - new charts.RangeAnnotationSegment(new DateTime(2017, 10, 4), - new DateTime(2017, 10, 15), charts.RangeAnnotationAxisType.domain), + return charts.TimeSeriesChart(seriesList, animate: animate, behaviors: [ + charts.RangeAnnotation([ + charts.RangeAnnotationSegment(DateTime(2017, 10, 4), + DateTime(2017, 10, 15), charts.RangeAnnotationAxisType.domain), ]), ]); } @@ -85,14 +86,14 @@ class TimeSeriesRangeAnnotationChart extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new TimeSeriesSales(new DateTime(2017, 9, 19), 5), - new TimeSeriesSales(new DateTime(2017, 9, 26), 25), - new TimeSeriesSales(new DateTime(2017, 10, 3), 100), - new TimeSeriesSales(new DateTime(2017, 10, 10), 75), + TimeSeriesSales(DateTime(2017, 9, 19), 5), + TimeSeriesSales(DateTime(2017, 9, 26), 25), + TimeSeriesSales(DateTime(2017, 10, 3), 100), + TimeSeriesSales(DateTime(2017, 10, 10), 75), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (TimeSeriesSales sales, _) => sales.time, measureFn: (TimeSeriesSales sales, _) => sales.sales, diff --git a/web/charts/lib/time_series_chart/range_annotation_margin.dart b/web/charts/lib/time_series_chart/range_annotation_margin.dart index 80305f15c..85b96bd98 100644 --- a/web/charts/lib/time_series_chart/range_annotation_margin.dart +++ b/web/charts/lib/time_series_chart/range_annotation_margin.dart @@ -25,11 +25,13 @@ class TimeSeriesRangeAnnotationMarginChart extends StatelessWidget { final List seriesList; final bool animate; - TimeSeriesRangeAnnotationMarginChart(this.seriesList, {this.animate}); + const TimeSeriesRangeAnnotationMarginChart(this.seriesList, + {this.animate, Key key}) + : super(key: key); /// Creates a [TimeSeriesChart] with sample data and no transition. factory TimeSeriesRangeAnnotationMarginChart.withSampleData() { - return new TimeSeriesRangeAnnotationMarginChart( + return TimeSeriesRangeAnnotationMarginChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -41,24 +43,24 @@ class TimeSeriesRangeAnnotationMarginChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory TimeSeriesRangeAnnotationMarginChart.withRandomData() { - return new TimeSeriesRangeAnnotationMarginChart(_createRandomData()); + return TimeSeriesRangeAnnotationMarginChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new TimeSeriesSales(new DateTime(2017, 9, 19), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 26), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 10, 3), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 19), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 26), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 10, 3), random.nextInt(100)), // Fix one of the points to 100 so that the annotations are consistently // placed. - new TimeSeriesSales(new DateTime(2017, 10, 10), 100), + TimeSeriesSales(DateTime(2017, 10, 10), 100), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (TimeSeriesSales sales, _) => sales.time, measureFn: (TimeSeriesSales sales, _) => sales.sales, @@ -70,37 +72,35 @@ class TimeSeriesRangeAnnotationMarginChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.TimeSeriesChart(seriesList, + return charts.TimeSeriesChart(seriesList, animate: animate, // Allow enough space in the left and right chart margins for the // annotations. - layoutConfig: new charts.LayoutConfig( - leftMarginSpec: new charts.MarginSpec.fixedPixel(60), - topMarginSpec: new charts.MarginSpec.fixedPixel(20), - rightMarginSpec: new charts.MarginSpec.fixedPixel(60), - bottomMarginSpec: new charts.MarginSpec.fixedPixel(20)), + layoutConfig: charts.LayoutConfig( + leftMarginSpec: charts.MarginSpec.fixedPixel(60), + topMarginSpec: charts.MarginSpec.fixedPixel(20), + rightMarginSpec: charts.MarginSpec.fixedPixel(60), + bottomMarginSpec: charts.MarginSpec.fixedPixel(20)), behaviors: [ // Define one domain and two measure annotations configured to render // labels in the chart margins. - new charts.RangeAnnotation([ - new charts.RangeAnnotationSegment( - new DateTime(2017, 10, 4), - new DateTime(2017, 10, 15), - charts.RangeAnnotationAxisType.domain, + charts.RangeAnnotation([ + charts.RangeAnnotationSegment(DateTime(2017, 10, 4), + DateTime(2017, 10, 15), charts.RangeAnnotationAxisType.domain, startLabel: 'D1 Start', endLabel: 'D1 End', labelAnchor: charts.AnnotationLabelAnchor.end, color: charts.MaterialPalette.gray.shade200, // Override the default vertical direction for domain labels. labelDirection: charts.AnnotationLabelDirection.horizontal), - new charts.RangeAnnotationSegment( + charts.RangeAnnotationSegment( 15, 20, charts.RangeAnnotationAxisType.measure, startLabel: 'M1 Start', endLabel: 'M1 End', labelAnchor: charts.AnnotationLabelAnchor.end, color: charts.MaterialPalette.gray.shade300), - new charts.RangeAnnotationSegment( + charts.RangeAnnotationSegment( 35, 65, charts.RangeAnnotationAxisType.measure, startLabel: 'M2 Start', endLabel: 'M2 End', @@ -113,14 +113,14 @@ class TimeSeriesRangeAnnotationMarginChart extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new TimeSeriesSales(new DateTime(2017, 9, 19), 5), - new TimeSeriesSales(new DateTime(2017, 9, 26), 25), - new TimeSeriesSales(new DateTime(2017, 10, 3), 100), - new TimeSeriesSales(new DateTime(2017, 10, 10), 75), + TimeSeriesSales(DateTime(2017, 9, 19), 5), + TimeSeriesSales(DateTime(2017, 9, 26), 25), + TimeSeriesSales(DateTime(2017, 10, 3), 100), + TimeSeriesSales(DateTime(2017, 10, 10), 75), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', domainFn: (TimeSeriesSales sales, _) => sales.time, measureFn: (TimeSeriesSales sales, _) => sales.sales, diff --git a/web/charts/lib/time_series_chart/simple.dart b/web/charts/lib/time_series_chart/simple.dart index 81e594b0a..c47abf15a 100644 --- a/web/charts/lib/time_series_chart/simple.dart +++ b/web/charts/lib/time_series_chart/simple.dart @@ -24,11 +24,12 @@ class SimpleTimeSeriesChart extends StatelessWidget { final List seriesList; final bool animate; - SimpleTimeSeriesChart(this.seriesList, {this.animate}); + const SimpleTimeSeriesChart(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [TimeSeriesChart] with sample data and no transition. factory SimpleTimeSeriesChart.withSampleData() { - return new SimpleTimeSeriesChart( + return SimpleTimeSeriesChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -40,22 +41,22 @@ class SimpleTimeSeriesChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory SimpleTimeSeriesChart.withRandomData() { - return new SimpleTimeSeriesChart(_createRandomData()); + return SimpleTimeSeriesChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new TimeSeriesSales(new DateTime(2017, 9, 19), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 26), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 10, 3), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 10, 10), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 19), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 26), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 10, 3), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 10, 10), random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (TimeSeriesSales sales, _) => sales.time, @@ -68,7 +69,7 @@ class SimpleTimeSeriesChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.TimeSeriesChart( + return charts.TimeSeriesChart( seriesList, animate: animate, // Optionally pass in a [DateTimeFactory] used by the chart. The factory @@ -81,14 +82,14 @@ class SimpleTimeSeriesChart extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new TimeSeriesSales(new DateTime(2017, 9, 19), 5), - new TimeSeriesSales(new DateTime(2017, 9, 26), 25), - new TimeSeriesSales(new DateTime(2017, 10, 3), 100), - new TimeSeriesSales(new DateTime(2017, 10, 10), 75), + TimeSeriesSales(DateTime(2017, 9, 19), 5), + TimeSeriesSales(DateTime(2017, 9, 26), 25), + TimeSeriesSales(DateTime(2017, 10, 3), 100), + TimeSeriesSales(DateTime(2017, 10, 10), 75), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (TimeSeriesSales sales, _) => sales.time, diff --git a/web/charts/lib/time_series_chart/symbol_annotation.dart b/web/charts/lib/time_series_chart/symbol_annotation.dart index 5d7b6e6d3..bd338cfb1 100644 --- a/web/charts/lib/time_series_chart/symbol_annotation.dart +++ b/web/charts/lib/time_series_chart/symbol_annotation.dart @@ -35,11 +35,13 @@ class TimeSeriesSymbolAnnotationChart extends StatelessWidget { final List seriesList; final bool animate; - TimeSeriesSymbolAnnotationChart(this.seriesList, {this.animate}); + const TimeSeriesSymbolAnnotationChart(this.seriesList, + {this.animate, Key key}) + : super(key: key); /// Creates a [TimeSeriesChart] with sample data and no transition. factory TimeSeriesSymbolAnnotationChart.withSampleData() { - return new TimeSeriesSymbolAnnotationChart( + return TimeSeriesSymbolAnnotationChart( _createSampleData(), // Disable animations for image tests. animate: false, @@ -51,33 +53,33 @@ class TimeSeriesSymbolAnnotationChart extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory TimeSeriesSymbolAnnotationChart.withRandomData() { - return new TimeSeriesSymbolAnnotationChart(_createRandomData()); + return TimeSeriesSymbolAnnotationChart(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final myDesktopData = [ - new TimeSeriesSales( - timeCurrent: new DateTime(2017, 9, 19), sales: random.nextInt(100)), - new TimeSeriesSales( - timeCurrent: new DateTime(2017, 9, 26), sales: random.nextInt(100)), - new TimeSeriesSales( - timeCurrent: new DateTime(2017, 10, 3), sales: random.nextInt(100)), - new TimeSeriesSales( - timeCurrent: new DateTime(2017, 10, 10), sales: random.nextInt(100)), + TimeSeriesSales( + timeCurrent: DateTime(2017, 9, 19), sales: random.nextInt(100)), + TimeSeriesSales( + timeCurrent: DateTime(2017, 9, 26), sales: random.nextInt(100)), + TimeSeriesSales( + timeCurrent: DateTime(2017, 10, 3), sales: random.nextInt(100)), + TimeSeriesSales( + timeCurrent: DateTime(2017, 10, 10), sales: random.nextInt(100)), ]; final myTabletData = [ - new TimeSeriesSales( - timeCurrent: new DateTime(2017, 9, 19), sales: random.nextInt(100)), - new TimeSeriesSales( - timeCurrent: new DateTime(2017, 9, 26), sales: random.nextInt(100)), - new TimeSeriesSales( - timeCurrent: new DateTime(2017, 10, 3), sales: random.nextInt(100)), - new TimeSeriesSales( - timeCurrent: new DateTime(2017, 10, 10), sales: random.nextInt(100)), + TimeSeriesSales( + timeCurrent: DateTime(2017, 9, 19), sales: random.nextInt(100)), + TimeSeriesSales( + timeCurrent: DateTime(2017, 9, 26), sales: random.nextInt(100)), + TimeSeriesSales( + timeCurrent: DateTime(2017, 10, 3), sales: random.nextInt(100)), + TimeSeriesSales( + timeCurrent: DateTime(2017, 10, 10), sales: random.nextInt(100)), ]; // Example of a series with two range annotations. A regular point shape @@ -87,15 +89,15 @@ class TimeSeriesSymbolAnnotationChart extends StatelessWidget { // Note that these series do not contain any measure values. They are // positioned automatically in rows. final myAnnotationDataTop = [ - new TimeSeriesSales( - timeCurrent: new DateTime(2017, 9, 24), - timePrevious: new DateTime(2017, 9, 19), - timeTarget: new DateTime(2017, 9, 24), + TimeSeriesSales( + timeCurrent: DateTime(2017, 9, 24), + timePrevious: DateTime(2017, 9, 19), + timeTarget: DateTime(2017, 9, 24), ), - new TimeSeriesSales( - timeCurrent: new DateTime(2017, 9, 29), - timePrevious: new DateTime(2017, 9, 29), - timeTarget: new DateTime(2017, 10, 4), + TimeSeriesSales( + timeCurrent: DateTime(2017, 9, 29), + timePrevious: DateTime(2017, 9, 29), + timeTarget: DateTime(2017, 10, 4), ), ]; @@ -103,31 +105,31 @@ class TimeSeriesSymbolAnnotationChart extends StatelessWidget { // annotations. Omitting the previous and target domain values causes that // datum to be drawn as a single point. final myAnnotationDataBottom = [ - new TimeSeriesSales( - timeCurrent: new DateTime(2017, 9, 25), - timePrevious: new DateTime(2017, 9, 21), - timeTarget: new DateTime(2017, 9, 25), + TimeSeriesSales( + timeCurrent: DateTime(2017, 9, 25), + timePrevious: DateTime(2017, 9, 21), + timeTarget: DateTime(2017, 9, 25), ), - new TimeSeriesSales(timeCurrent: new DateTime(2017, 9, 31)), - new TimeSeriesSales(timeCurrent: new DateTime(2017, 10, 5)), + TimeSeriesSales(timeCurrent: DateTime(2017, 9, 31)), + TimeSeriesSales(timeCurrent: DateTime(2017, 10, 5)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (TimeSeriesSales sales, _) => sales.timeCurrent, measureFn: (TimeSeriesSales sales, _) => sales.sales, data: myDesktopData, ), - new charts.Series( + charts.Series( id: 'Tablet', colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault, domainFn: (TimeSeriesSales sales, _) => sales.timeCurrent, measureFn: (TimeSeriesSales sales, _) => sales.sales, data: myTabletData, ), - new charts.Series( + charts.Series( id: 'Annotation Series 1', colorFn: (_, __) => charts.MaterialPalette.gray.shadeDefault, domainFn: (TimeSeriesSales sales, _) => sales.timeCurrent, @@ -142,7 +144,7 @@ class TimeSeriesSymbolAnnotationChart extends StatelessWidget { // Optional radius for the annotation shape. If not specified, this will // default to the same radius as the points. ..setAttribute(charts.boundsLineRadiusPxKey, 3.5), - new charts.Series( + charts.Series( id: 'Annotation Series 2', colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault, domainFn: (TimeSeriesSales sales, _) => sales.timeCurrent, @@ -163,12 +165,12 @@ class TimeSeriesSymbolAnnotationChart extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.TimeSeriesChart( + return charts.TimeSeriesChart( seriesList, animate: animate, // Custom renderer configuration for the point series. customSeriesRenderers: [ - new charts.SymbolAnnotationRendererConfig( + charts.SymbolAnnotationRendererConfig( // ID used to link series to this renderer. customRendererId: 'customSymbolAnnotation') ], @@ -182,17 +184,17 @@ class TimeSeriesSymbolAnnotationChart extends StatelessWidget { /// Create one series with sample hard coded data. static List> _createSampleData() { final myDesktopData = [ - new TimeSeriesSales(timeCurrent: new DateTime(2017, 9, 19), sales: 5), - new TimeSeriesSales(timeCurrent: new DateTime(2017, 9, 26), sales: 25), - new TimeSeriesSales(timeCurrent: new DateTime(2017, 10, 3), sales: 100), - new TimeSeriesSales(timeCurrent: new DateTime(2017, 10, 10), sales: 75), + TimeSeriesSales(timeCurrent: DateTime(2017, 9, 19), sales: 5), + TimeSeriesSales(timeCurrent: DateTime(2017, 9, 26), sales: 25), + TimeSeriesSales(timeCurrent: DateTime(2017, 10, 3), sales: 100), + TimeSeriesSales(timeCurrent: DateTime(2017, 10, 10), sales: 75), ]; final myTabletData = [ - new TimeSeriesSales(timeCurrent: new DateTime(2017, 9, 19), sales: 10), - new TimeSeriesSales(timeCurrent: new DateTime(2017, 9, 26), sales: 50), - new TimeSeriesSales(timeCurrent: new DateTime(2017, 10, 3), sales: 200), - new TimeSeriesSales(timeCurrent: new DateTime(2017, 10, 10), sales: 150), + TimeSeriesSales(timeCurrent: DateTime(2017, 9, 19), sales: 10), + TimeSeriesSales(timeCurrent: DateTime(2017, 9, 26), sales: 50), + TimeSeriesSales(timeCurrent: DateTime(2017, 10, 3), sales: 200), + TimeSeriesSales(timeCurrent: DateTime(2017, 10, 10), sales: 150), ]; // Example of a series with two range annotations. A regular point shape @@ -202,15 +204,15 @@ class TimeSeriesSymbolAnnotationChart extends StatelessWidget { // Note that these series do not contain any measure values. They are // positioned automatically in rows. final myAnnotationDataTop = [ - new TimeSeriesSales( - timeCurrent: new DateTime(2017, 9, 24), - timePrevious: new DateTime(2017, 9, 19), - timeTarget: new DateTime(2017, 9, 24), + TimeSeriesSales( + timeCurrent: DateTime(2017, 9, 24), + timePrevious: DateTime(2017, 9, 19), + timeTarget: DateTime(2017, 9, 24), ), - new TimeSeriesSales( - timeCurrent: new DateTime(2017, 9, 29), - timePrevious: new DateTime(2017, 9, 29), - timeTarget: new DateTime(2017, 10, 4), + TimeSeriesSales( + timeCurrent: DateTime(2017, 9, 29), + timePrevious: DateTime(2017, 9, 29), + timeTarget: DateTime(2017, 10, 4), ), ]; @@ -218,31 +220,31 @@ class TimeSeriesSymbolAnnotationChart extends StatelessWidget { // annotations. Omitting the previous and target domain values causes that // datum to be drawn as a single point. final myAnnotationDataBottom = [ - new TimeSeriesSales( - timeCurrent: new DateTime(2017, 9, 25), - timePrevious: new DateTime(2017, 9, 21), - timeTarget: new DateTime(2017, 9, 25), + TimeSeriesSales( + timeCurrent: DateTime(2017, 9, 25), + timePrevious: DateTime(2017, 9, 21), + timeTarget: DateTime(2017, 9, 25), ), - new TimeSeriesSales(timeCurrent: new DateTime(2017, 9, 31)), - new TimeSeriesSales(timeCurrent: new DateTime(2017, 10, 5)), + TimeSeriesSales(timeCurrent: DateTime(2017, 9, 31)), + TimeSeriesSales(timeCurrent: DateTime(2017, 10, 5)), ]; return [ - new charts.Series( + charts.Series( id: 'Desktop', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (TimeSeriesSales sales, _) => sales.timeCurrent, measureFn: (TimeSeriesSales sales, _) => sales.sales, data: myDesktopData, ), - new charts.Series( + charts.Series( id: 'Tablet', colorFn: (_, __) => charts.MaterialPalette.green.shadeDefault, domainFn: (TimeSeriesSales sales, _) => sales.timeCurrent, measureFn: (TimeSeriesSales sales, _) => sales.sales, data: myTabletData, ), - new charts.Series( + charts.Series( id: 'Annotation Series 1', colorFn: (_, __) => charts.MaterialPalette.gray.shadeDefault, // A point shape will be drawn at the location of the domain. @@ -260,7 +262,7 @@ class TimeSeriesSymbolAnnotationChart extends StatelessWidget { // Optional radius for the annotation range. If not specified, this will // default to the same radius as the domain point. ..setAttribute(charts.boundsLineRadiusPxKey, 3.5), - new charts.Series( + charts.Series( id: 'Annotation Series 2', colorFn: (_, __) => charts.MaterialPalette.red.shadeDefault, // A point shape will be drawn at the location of the domain. diff --git a/web/charts/lib/time_series_chart/time_series_gallery.dart b/web/charts/lib/time_series_chart/time_series_gallery.dart index f60d6dda1..dcaaac6b7 100644 --- a/web/charts/lib/time_series_chart/time_series_gallery.dart +++ b/web/charts/lib/time_series_chart/time_series_gallery.dart @@ -26,55 +26,54 @@ import 'with_bar_renderer.dart'; List buildGallery() { return [ - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Time Series Chart', subtitle: 'Simple single time series chart', - childBuilder: () => new SimpleTimeSeriesChart.withRandomData(), + childBuilder: () => SimpleTimeSeriesChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'End Points Axis Time Series Chart', subtitle: 'Time series chart with an end points axis', - childBuilder: () => new EndPointsAxisTimeSeriesChart.withRandomData(), + childBuilder: () => EndPointsAxisTimeSeriesChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Line Annotation on Time Series Chart', subtitle: 'Time series chart with future line annotation', - childBuilder: () => new TimeSeriesLineAnnotationChart.withRandomData(), + childBuilder: () => TimeSeriesLineAnnotationChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Range Annotation on Time Series Chart', subtitle: 'Time series chart with future range annotation', - childBuilder: () => new TimeSeriesRangeAnnotationChart.withRandomData(), + childBuilder: () => TimeSeriesRangeAnnotationChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Range Annotation Margin Labels on Time Series Chart', subtitle: 'Time series chart with range annotations with labels in margins', - childBuilder: () => - new TimeSeriesRangeAnnotationMarginChart.withRandomData(), + childBuilder: () => TimeSeriesRangeAnnotationMarginChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Symbol Annotation Time Series Chart', subtitle: 'Time series chart with annotation data below the draw area', - childBuilder: () => new TimeSeriesSymbolAnnotationChart.withRandomData(), + childBuilder: () => TimeSeriesSymbolAnnotationChart.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Time Series Chart with Bars', subtitle: 'Time series chart using the bar renderer', - childBuilder: () => new TimeSeriesBar.withRandomData(), + childBuilder: () => TimeSeriesBar.withRandomData(), ), - new GalleryScaffold( - listTileIcon: new Icon(Icons.show_chart), + GalleryScaffold( + listTileIcon: const Icon(Icons.show_chart), title: 'Time Series Chart with Confidence Interval', subtitle: 'Draws area around the confidence interval', - childBuilder: () => new TimeSeriesConfidenceInterval.withRandomData(), + childBuilder: () => TimeSeriesConfidenceInterval.withRandomData(), ), ]; } diff --git a/web/charts/lib/time_series_chart/with_bar_renderer.dart b/web/charts/lib/time_series_chart/with_bar_renderer.dart index 603c5952c..5bd2956f2 100644 --- a/web/charts/lib/time_series_chart/with_bar_renderer.dart +++ b/web/charts/lib/time_series_chart/with_bar_renderer.dart @@ -24,11 +24,12 @@ class TimeSeriesBar extends StatelessWidget { final List> seriesList; final bool animate; - TimeSeriesBar(this.seriesList, {this.animate}); + const TimeSeriesBar(this.seriesList, {this.animate, Key key}) + : super(key: key); /// Creates a [TimeSeriesChart] with sample data and no transition. factory TimeSeriesBar.withSampleData() { - return new TimeSeriesBar( + return TimeSeriesBar( _createSampleData(), // Disable animations for image tests. animate: false, @@ -40,39 +41,39 @@ class TimeSeriesBar extends StatelessWidget { // It is used for creating random series data to demonstrate animation in // the example app only. factory TimeSeriesBar.withRandomData() { - return new TimeSeriesBar(_createRandomData()); + return TimeSeriesBar(_createRandomData()); } /// Create random data. static List> _createRandomData() { - final random = new Random(); + final random = Random(); final data = [ - new TimeSeriesSales(new DateTime(2017, 9, 1), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 2), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 3), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 4), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 5), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 6), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 7), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 8), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 9), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 10), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 11), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 12), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 13), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 14), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 15), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 16), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 17), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 18), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 19), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 20), random.nextInt(100)), - new TimeSeriesSales(new DateTime(2017, 9, 21), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 1), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 2), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 3), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 4), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 5), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 6), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 7), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 8), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 9), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 10), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 11), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 12), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 13), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 14), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 15), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 16), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 17), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 18), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 19), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 20), random.nextInt(100)), + TimeSeriesSales(DateTime(2017, 9, 21), random.nextInt(100)), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (TimeSeriesSales sales, _) => sales.time, @@ -85,50 +86,50 @@ class TimeSeriesBar extends StatelessWidget { @override Widget build(BuildContext context) { - return new charts.TimeSeriesChart( + return charts.TimeSeriesChart( seriesList, animate: animate, // Set the default renderer to a bar renderer. // This can also be one of the custom renderers of the time series chart. - defaultRenderer: new charts.BarRendererConfig(), + defaultRenderer: charts.BarRendererConfig(), // It is recommended that default interactions be turned off if using bar // renderer, because the line point highlighter is the default for time // series chart. defaultInteractions: false, // If default interactions were removed, optionally add select nearest // and the domain highlighter that are typical for bar charts. - behaviors: [new charts.SelectNearest(), new charts.DomainHighlighter()], + behaviors: [charts.SelectNearest(), charts.DomainHighlighter()], ); } /// Create one series with sample hard coded data. static List> _createSampleData() { final data = [ - new TimeSeriesSales(new DateTime(2017, 9, 1), 5), - new TimeSeriesSales(new DateTime(2017, 9, 2), 5), - new TimeSeriesSales(new DateTime(2017, 9, 3), 25), - new TimeSeriesSales(new DateTime(2017, 9, 4), 100), - new TimeSeriesSales(new DateTime(2017, 9, 5), 75), - new TimeSeriesSales(new DateTime(2017, 9, 6), 88), - new TimeSeriesSales(new DateTime(2017, 9, 7), 65), - new TimeSeriesSales(new DateTime(2017, 9, 8), 91), - new TimeSeriesSales(new DateTime(2017, 9, 9), 100), - new TimeSeriesSales(new DateTime(2017, 9, 10), 111), - new TimeSeriesSales(new DateTime(2017, 9, 11), 90), - new TimeSeriesSales(new DateTime(2017, 9, 12), 50), - new TimeSeriesSales(new DateTime(2017, 9, 13), 40), - new TimeSeriesSales(new DateTime(2017, 9, 14), 30), - new TimeSeriesSales(new DateTime(2017, 9, 15), 40), - new TimeSeriesSales(new DateTime(2017, 9, 16), 50), - new TimeSeriesSales(new DateTime(2017, 9, 17), 30), - new TimeSeriesSales(new DateTime(2017, 9, 18), 35), - new TimeSeriesSales(new DateTime(2017, 9, 19), 40), - new TimeSeriesSales(new DateTime(2017, 9, 20), 32), - new TimeSeriesSales(new DateTime(2017, 9, 21), 31), + TimeSeriesSales(DateTime(2017, 9, 1), 5), + TimeSeriesSales(DateTime(2017, 9, 2), 5), + TimeSeriesSales(DateTime(2017, 9, 3), 25), + TimeSeriesSales(DateTime(2017, 9, 4), 100), + TimeSeriesSales(DateTime(2017, 9, 5), 75), + TimeSeriesSales(DateTime(2017, 9, 6), 88), + TimeSeriesSales(DateTime(2017, 9, 7), 65), + TimeSeriesSales(DateTime(2017, 9, 8), 91), + TimeSeriesSales(DateTime(2017, 9, 9), 100), + TimeSeriesSales(DateTime(2017, 9, 10), 111), + TimeSeriesSales(DateTime(2017, 9, 11), 90), + TimeSeriesSales(DateTime(2017, 9, 12), 50), + TimeSeriesSales(DateTime(2017, 9, 13), 40), + TimeSeriesSales(DateTime(2017, 9, 14), 30), + TimeSeriesSales(DateTime(2017, 9, 15), 40), + TimeSeriesSales(DateTime(2017, 9, 16), 50), + TimeSeriesSales(DateTime(2017, 9, 17), 30), + TimeSeriesSales(DateTime(2017, 9, 18), 35), + TimeSeriesSales(DateTime(2017, 9, 19), 40), + TimeSeriesSales(DateTime(2017, 9, 20), 32), + TimeSeriesSales(DateTime(2017, 9, 21), 31), ]; return [ - new charts.Series( + charts.Series( id: 'Sales', colorFn: (_, __) => charts.MaterialPalette.blue.shadeDefault, domainFn: (TimeSeriesSales sales, _) => sales.time, diff --git a/web/charts/pubspec.lock b/web/charts/pubspec.lock index 3107b3b26..b78dec285 100644 --- a/web/charts/pubspec.lock +++ b/web/charts/pubspec.lock @@ -14,14 +14,23 @@ packages: name: charts_common url: "https://pub.dartlang.org" source: hosted - version: "0.10.0" + version: "0.11.0" charts_flutter: dependency: "direct main" description: - name: charts_flutter + path: charts_flutter + ref: HEAD + resolved-ref: "30477090290b348ed3101bc13017aae465f59017" + url: "https://github.com/google/charts" + source: git + version: "0.11.0" + clock: + dependency: transitive + description: + name: clock url: "https://pub.dartlang.org" source: hosted - version: "0.10.0" + version: "1.1.0" collection: dependency: transitive description: @@ -34,13 +43,27 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.4" intl: dependency: "direct main" description: name: intl url: "https://pub.dartlang.org" source: hosted - version: "0.15.8" + version: "0.17.0" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" logging: dependency: transitive description: diff --git a/web/charts/pubspec.yaml b/web/charts/pubspec.yaml index 9e3f4c195..2204ad780 100644 --- a/web/charts/pubspec.yaml +++ b/web/charts/pubspec.yaml @@ -1,5 +1,6 @@ name: example description: Charts-Flutter Demo +publish_to: none environment: sdk: '>=2.10.0 <3.0.0' @@ -7,9 +8,15 @@ environment: dependencies: flutter: sdk: flutter - charts_flutter: any + charts_flutter: + git: + url: https://github.com/google/charts + path: charts_flutter meta: ^1.1.1 - intl: ^0.15.2 + intl: ^0.17.0 + +dev_dependencies: + flutter_lints: ^1.0.4 flutter: uses-material-design: true