-
-
Notifications
You must be signed in to change notification settings - Fork 180
/
Copy pathbigdata.dart
104 lines (96 loc) · 3.11 KB
/
bigdata.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:graphic/graphic.dart';
List<List<num>> getPointBigData(int n) {
final rdm = Random();
final rst = <List<num>>[];
for (var i = 0; i < n; i++) {
rst.add([
rdm.nextDouble(),
rdm.nextDouble(),
rdm.nextDouble(),
rdm.nextDouble(),
]);
}
return rst;
}
final pointBigData = getPointBigData(10000);
class BigdataPage extends StatelessWidget {
BigdataPage({Key? key}) : super(key: key);
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
@override
Widget build(BuildContext context) {
return Scaffold(
key: _scaffoldKey,
appBar: AppBar(
title: const Text('Bigdata'),
),
backgroundColor: Colors.white,
body: SingleChildScrollView(
child: Center(
child: Column(
children: <Widget>[
Container(
padding: const EdgeInsets.fromLTRB(20, 40, 20, 5),
child: const Text(
'Bigdata scatter Chart',
style: TextStyle(fontSize: 20),
),
),
Container(
padding: const EdgeInsets.fromLTRB(10, 5, 10, 0),
alignment: Alignment.centerLeft,
child: const Text(
'- 10000 points with various sizes and colors.',
),
),
Container(
padding: const EdgeInsets.fromLTRB(10, 5, 10, 0),
alignment: Alignment.centerLeft,
child: const Text(
'- Scroll to see the rendering performance.',
),
),
Container(
margin: const EdgeInsets.symmetric(vertical: 400),
width: 350,
height: 300,
child: Chart(
data: pointBigData,
variables: {
'x': Variable(
accessor: (List<num> datumn) => datumn[0],
scale: LinearScale(min: 0, max: 1),
),
'y': Variable(
accessor: (List<num> datumn) => datumn[1],
scale: LinearScale(min: 0, max: 1),
),
'size': Variable(
accessor: (List<num> datumn) => datumn[2],
),
'color': Variable(
accessor: (List<num> datumn) => datumn[3],
),
},
marks: [
PointMark(
size: SizeEncode(variable: 'size', values: [1, 4]),
color: ColorEncode(variable: 'color', values: [
const Color(0xffbae7ff),
const Color(0xff0050b3),
]))
],
axes: [
Defaults.horizontalAxis,
Defaults.verticalAxis,
],
),
),
],
),
),
),
);
}
}