mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 22:09:06 +00:00
web/chart: fix sample (#909)
This commit is contained in:
@@ -25,11 +25,12 @@ class ScatterPlotAnimationZoomChart extends StatelessWidget {
|
||||
final List<charts.Series> 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<charts.Series<LinearSales, num>> _createRandomData() {
|
||||
final random = new Random();
|
||||
final random = Random();
|
||||
|
||||
final data = <LinearSales>[];
|
||||
|
||||
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<LinearSales, int>(
|
||||
charts.Series<LinearSales, int>(
|
||||
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<charts.Series<LinearSales, int>> _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<LinearSales, int>(
|
||||
charts.Series<LinearSales, int>(
|
||||
id: 'Sales',
|
||||
colorFn: (LinearSales sales, _) {
|
||||
// Color bucket the measure column value into 3 distinct colors.
|
||||
|
||||
@@ -29,11 +29,12 @@ class BucketingAxisScatterPlotChart extends StatelessWidget {
|
||||
final List<charts.Series> 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<charts.Series<LinearSales, num>> _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<LinearSales, int>(
|
||||
charts.Series<LinearSales, int>(
|
||||
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<LinearSales, int>(
|
||||
charts.Series<LinearSales, int>(
|
||||
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<LinearSales, int>(
|
||||
charts.Series<LinearSales, int>(
|
||||
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<LinearSales, int>(
|
||||
charts.Series<LinearSales, int>(
|
||||
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<LinearSales, int>(
|
||||
charts.Series<LinearSales, int>(
|
||||
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<LinearSales, int>(
|
||||
charts.Series<LinearSales, int>(
|
||||
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<charts.Series<LinearSales, int>> _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<LinearSales, int>(
|
||||
charts.Series<LinearSales, int>(
|
||||
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<LinearSales, int>(
|
||||
charts.Series<LinearSales, int>(
|
||||
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<LinearSales, int>(
|
||||
charts.Series<LinearSales, int>(
|
||||
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<LinearSales, int>(
|
||||
charts.Series<LinearSales, int>(
|
||||
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<LinearSales, int>(
|
||||
charts.Series<LinearSales, int>(
|
||||
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<LinearSales, int>(
|
||||
charts.Series<LinearSales, int>(
|
||||
id: 'Other',
|
||||
colorFn: (LinearSales sales, _) =>
|
||||
charts.MaterialPalette.gray.shadeDefault,
|
||||
|
||||
@@ -24,11 +24,13 @@ class ComparisonPointsScatterPlotChart extends StatelessWidget {
|
||||
final List<charts.Series> 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<charts.Series<LinearSales, num>> _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<LinearSales, int>(
|
||||
charts.Series<LinearSales, int>(
|
||||
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<charts.Series<LinearSales, int>> _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<LinearSales, int>(
|
||||
charts.Series<LinearSales, int>(
|
||||
id: 'Sales',
|
||||
// Providing a color function is optional.
|
||||
colorFn: (LinearSales sales, _) {
|
||||
|
||||
@@ -23,36 +23,36 @@ import 'simple.dart';
|
||||
|
||||
List<GalleryScaffold> 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(),
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -35,11 +35,12 @@ class ShapesScatterPlotChart extends StatelessWidget {
|
||||
final List<charts.Series> 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<charts.Series<LinearSales, num>> _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<LinearSales, int>(
|
||||
charts.Series<LinearSales, int>(
|
||||
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<num>(customSymbolRenderers: {
|
||||
'circle': new charts.CircleSymbolRenderer(),
|
||||
'rect': new charts.RectSymbolRenderer(),
|
||||
charts.PointRendererConfig<num>(customSymbolRenderers: {
|
||||
'circle': charts.CircleSymbolRenderer(),
|
||||
'rect': charts.RectSymbolRenderer(),
|
||||
}));
|
||||
}
|
||||
|
||||
/// Create one series with sample hard coded data.
|
||||
static List<charts.Series<LinearSales, int>> _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<LinearSales, int>(
|
||||
charts.Series<LinearSales, int>(
|
||||
id: 'Sales',
|
||||
// Providing a color function is optional.
|
||||
colorFn: (LinearSales sales, _) {
|
||||
|
||||
@@ -24,11 +24,12 @@ class SimpleScatterPlotChart extends StatelessWidget {
|
||||
final List<charts.Series> 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<charts.Series<LinearSales, num>> _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<LinearSales, int>(
|
||||
charts.Series<LinearSales, int>(
|
||||
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<charts.Series<LinearSales, int>> _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<LinearSales, int>(
|
||||
charts.Series<LinearSales, int>(
|
||||
id: 'Sales',
|
||||
// Providing a color function is optional.
|
||||
colorFn: (LinearSales sales, _) {
|
||||
|
||||
Reference in New Issue
Block a user