@@ -3,95 +3,104 @@ import 'package:graphic/graphic.dart';
3
3
4
4
import '../data.dart' ;
5
5
6
- const adjustData = [
7
- {"type" : "Email" , "index" : 0 , "value" : 120 },
8
- {"type" : "Email" , "index" : 1 , "value" : 132 },
9
- {"type" : "Email" , "index" : 2 , "value" : 101 },
10
- {"type" : "Email" , "index" : 3 , "value" : 134 },
11
- {"type" : "Email" , "index" : 4 , "value" : 90 },
12
- {"type" : "Email" , "index" : 5 , "value" : 230 },
13
- {"type" : "Email" , "index" : 6 , "value" : 210 },
14
- {"type" : "Affiliate" , "index" : 0 , "value" : 220 },
15
- {"type" : "Affiliate" , "index" : 1 , "value" : 182 },
16
- {"type" : "Affiliate" , "index" : 2 , "value" : 191 },
17
- {"type" : "Affiliate" , "index" : 3 , "value" : 234 },
18
- {"type" : "Affiliate" , "index" : 4 , "value" : 290 },
19
- {"type" : "Affiliate" , "index" : 5 , "value" : 330 },
20
- {"type" : "Affiliate" , "index" : 6 , "value" : 310 },
21
- {"type" : "Video" , "index" : 0 , "value" : 150 },
22
- {"type" : "Video" , "index" : 1 , "value" : 232 },
23
- {"type" : "Video" , "index" : 2 , "value" : 201 },
24
- {"type" : "Video" , "index" : 3 , "value" : 154 },
25
- {"type" : "Video" , "index" : 4 , "value" : 190 },
26
- {"type" : "Video" , "index" : 5 , "value" : 330 },
27
- {"type" : "Video" , "index" : 6 , "value" : 410 },
28
- {"type" : "Direct" , "index" : 0 , "value" : 320 },
29
- {"type" : "Direct" , "index" : 1 , "value" : 332 },
30
- {"type" : "Direct" , "index" : 2 , "value" : 301 },
31
- {"type" : "Direct" , "index" : 3 , "value" : 334 },
32
- {"type" : "Direct" , "index" : 4 , "value" : 390 },
33
- {"type" : "Direct" , "index" : 5 , "value" : 330 },
34
- {"type" : "Direct" , "index" : 6 , "value" : 320 },
35
- {"type" : "Search" , "index" : 0 , "value1" : 320 },
36
- {"type" : "Search" , "index" : 1 , "value1" : 432 },
37
- {"type" : "Search" , "index" : 2 , "value1" : 401 },
38
- {"type" : "Search" , "index" : 3 , "value1" : 434 },
39
- {"type" : "Search" , "index" : 4 , "value1" : 390 },
40
- {"type" : "Search" , "index" : 5 , "value1" : 430 },
41
- {"type" : "Search" , "index" : 6 , "value1" : 420 },
42
- ];
43
-
44
6
class DebugPage extends StatelessWidget {
45
- const DebugPage ({Key ? key}) : super (key: key);
7
+ DebugPage ({Key ? key}) : super (key: key);
8
+
9
+ final GlobalKey <ScaffoldState > _scaffoldKey = GlobalKey <ScaffoldState >();
46
10
47
11
@override
48
12
Widget build (BuildContext context) {
49
13
return Scaffold (
50
- body: Center (
51
- child: Container (
52
- margin: const EdgeInsets .only (top: 10 ),
53
- width: 350 ,
54
- height: 300 ,
55
- child: Chart (
56
- rebuild: true ,
57
- data: basicData,
58
- variables: {
59
- 'genre' : Variable (
60
- accessor: (Map map) => map['genre' ] as String ,
61
- ),
62
- 'sold' : Variable (
63
- accessor: (Map map) => map['sold' ] as num ,
64
- ),
65
- },
66
- marks: [
67
- IntervalMark (
68
- label: LabelEncode (
69
- encoder: (tuple) => Label (tuple['sold' ].toString ())),
70
- elevation: ElevationEncode (value: 0 , updaters: {
71
- 'tap' : {true : (_) => 5 }
72
- }),
73
- color: ColorEncode (value: Defaults .primaryColor, updaters: {
74
- 'tap' : {false : (color) => color.withAlpha (100 )}
75
- }),
76
- selected: {
77
- 'tap' : {0 }
78
- },
79
- )
80
- ],
81
- axes: [
82
- Defaults .horizontalAxis,
83
- Defaults .verticalAxis,
14
+ key: _scaffoldKey,
15
+ appBar: AppBar (
16
+ title: const Text ('Rectangle Interval Mark' ),
17
+ ),
18
+ backgroundColor: Colors .white,
19
+ body: SingleChildScrollView (
20
+ child: Center (
21
+ child: Column (
22
+ children: < Widget > [
23
+
24
+ buildChart ('single point' , [Data (0 , 5 , 1 )]),
25
+ buildChart ('2 points in the same sector at different radiuses' ,
26
+ [Data (0 , 5 , 1 ), Data (0 , 6 , 2 )]),
27
+ buildChart ('2 points with different sector and radius' ,
28
+ [Data (0 , 5 , 1 ), Data (4 , 6 , 2 )]),
29
+ buildChart ('3 points with different everything' ,
30
+ [Data (0 , 5 , 1 ), Data (1 , 6 , 2 ), Data (2 , 7 , 3 )]),
31
+ buildChart ('3 points with a duplicate' ,
32
+ [Data (0 , 5 , 1 ), Data (1 , 6 , 2 ), Data (1 , 6 , 2 )]),
33
+
34
+
84
35
],
85
- selections: {'tap' : PointSelection (dim: Dim .x)},
86
- tooltip: TooltipGuide (),
87
- crosshair: CrosshairGuide (),
88
36
),
89
37
),
90
38
),
91
39
);
92
40
}
93
41
}
42
+ Widget buildChart (String name, List <Data > data) => Row (
43
+ mainAxisSize: MainAxisSize .min,
44
+ children: [
45
+ Container (width: 300 , child: Text (name)),
46
+ SizedBox (width: 100 ),
47
+ Container (
48
+ width: 150 ,
49
+ height: 150 ,
50
+ child: Chart (
51
+ data: data,
52
+ variables: {
53
+ 'sector' : Variable (
54
+ accessor: (Data d) => d.sector.toString (),
55
+ scale: OrdinalScale (
56
+ values: List <int >.generate (10 , (i) => i++ )
57
+ .map ((s) => s.toString ())
58
+ .toList (),
59
+ ),
60
+ ),
61
+ 'radius' : Variable (
62
+ accessor: (Data d) => d.radius,
63
+ scale: LinearScale (
64
+ min: 0 ,
65
+ max: 10 ,
66
+ ),
67
+ ),
68
+ 'value' : Variable (
69
+ accessor: (Data d) => d.value,
70
+ scale: LinearScale (
71
+ min: 0 ,
72
+ max: 10 ,
73
+ ),
74
+ ),
75
+ },
76
+ marks: [
77
+ PolygonMark (
78
+ shape: ShapeEncode (value: HeatmapShape (sector: true , tileCounts: [10 , 10 ])),
79
+ color: ColorEncode (
80
+ variable: 'value' ,
81
+ values: [Colors .blue, Colors .red],
82
+ ),
83
+ )
84
+ ],
85
+ coord: PolarCoord (),
86
+ axes: [
87
+ Defaults .circularAxis,
88
+ Defaults .radialAxis,
89
+ ],
90
+ ),
91
+ ),
92
+ ],
93
+
94
+ );
95
+
94
96
97
+ class Data {
98
+ final int sector;
99
+ final double radius;
100
+ final double value;
101
+
102
+ Data (this .sector, this .radius, this .value);
103
+ }
95
104
// class DebugPage extends StatefulWidget {
96
105
// const DebugPage({Key? key}) : super(key: key);
97
106
0 commit comments