Skip to content

Commit e987cad

Browse files
committed
v2.2.0
1 parent e8d19fd commit e987cad

22 files changed

+315
-245
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## 2.2.0
2+
3+
**2023-05-15**
4+
5+
- Add `RepaintBoundary` to reduce chart repainting: https://github.com/entronad/graphic/pull/220
6+
- Fix that all items use the same shape params: https://github.com/entronad/graphic/issues/221
7+
18
## 2.1.0
29

310
**2023-04-20**

DEVLOG.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -512,4 +512,12 @@ Tuple value 应该还是不接受null:1.这是dart null-safety 倡导的原则
512512

513513
至少目前,参数定义的原则涉及多个维度的还是以list定义为主,而不是分开 aaX, aaY这样,比如 CrosshairCuide, list 成员可以为null,以达到一个设置一个不设置的效果,不要搞单独元素指代两个相同这种,取数用 [0] [1]
514514

515-
之前 scaleEnd 和 longPressEnd 是不含 localMoveStart 的,可能是因为当时为了和flutter的习惯一致。现在的原则是参数尽量给到,而且这里也似乎确实有用。但是它的类目太多太杂,也不用都加上,就update和end加上。
515+
之前 scaleEnd 和 longPressEnd 是不含 localMoveStart 的,可能是因为当时为了和flutter的习惯一致。现在的原则是参数尽量给到,而且这里也似乎确实有用。但是它的类目太多太杂,也不用都加上,就update和end加上。
516+
517+
vis lib 的核心价值?核心需求?满足奇怪的vis设计需求
518+
519+
echarts的top是放的components, series, global settings。当它setting时,通过key来进行diff,数据也是通过key来进行diff
520+
521+
坐标系的关联?比如一个直接坐标系上再放一个极坐标系,极坐标系的圆心与直角坐标系
522+
523+
item.shape 属性提示我们,似乎还是应该搞个绘制单个的方法,以强调每个数据项图形的独特性?

example/lib/pages/animation.dart

+36-18
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ class AnimationPageState extends State<AnimationPage> {
7676
{'genre': 'Other', 'sold': rdm.nextInt(300)},
7777
];
7878

79-
scatterAnimData = scatterAnimData.map((d) => [d[0], d[1], d[2], d[3], -1 * d[4]]).toList();
79+
scatterAnimData = scatterAnimData
80+
.map((d) => [d[0], d[1], d[2], d[3], -1 * d[4]])
81+
.toList();
8082
});
8183
});
8284

@@ -97,7 +99,12 @@ class AnimationPageState extends State<AnimationPage> {
9799
title: const Text('Animation'),
98100
),
99101
backgroundColor: Colors.white,
100-
floatingActionButton: FloatingActionButton(onPressed: () => setState(() {rebuild = true;}), child: Icon(Icons.refresh),),
102+
floatingActionButton: FloatingActionButton(
103+
onPressed: () => setState(() {
104+
rebuild = true;
105+
}),
106+
child: Icon(Icons.refresh),
107+
),
101108
body: SingleChildScrollView(
102109
child: Center(
103110
child: Column(
@@ -132,13 +139,18 @@ class AnimationPageState extends State<AnimationPage> {
132139
scale: LinearScale(min: 0),
133140
),
134141
},
135-
transforms: [Sort(compare: (tuple1, tuple2) => tuple1['sold'] - tuple2['sold'])],
142+
transforms: [
143+
Sort(
144+
compare: (tuple1, tuple2) =>
145+
tuple1['sold'] - tuple2['sold'])
146+
],
136147
marks: [
137148
IntervalMark(
138-
transition: Transition(duration: Duration(seconds: 1)),
139-
entrance: {MarkEntrance.y},
140-
label: LabelEncode(encoder: (tuple) => Label(tuple['sold'].toString())),
141-
tag: (tuple) => tuple['genre'].toString(),
149+
transition: Transition(duration: Duration(seconds: 1)),
150+
entrance: {MarkEntrance.y},
151+
label: LabelEncode(
152+
encoder: (tuple) => Label(tuple['sold'].toString())),
153+
tag: (tuple) => tuple['genre'].toString(),
142154
)
143155
],
144156
axes: [
@@ -147,8 +159,6 @@ class AnimationPageState extends State<AnimationPage> {
147159
],
148160
),
149161
),
150-
151-
152162
Container(
153163
padding: const EdgeInsets.fromLTRB(20, 40, 20, 5),
154164
child: const Text(
@@ -198,14 +208,15 @@ class AnimationPageState extends State<AnimationPage> {
198208
color: ColorEncode(
199209
variable: 'name', values: Defaults.colors10),
200210
elevation: ElevationEncode(value: 5),
201-
transition: Transition(duration: Duration(seconds: 2), curve: Curves.elasticOut),
211+
transition: Transition(
212+
duration: Duration(seconds: 2),
213+
curve: Curves.elasticOut),
202214
entrance: {MarkEntrance.y},
203215
)
204216
],
205217
coord: PolarCoord(startRadius: 0.15),
206218
),
207219
),
208-
209220
Container(
210221
padding: const EdgeInsets.fromLTRB(20, 40, 20, 5),
211222
child: const Text(
@@ -231,9 +242,8 @@ class AnimationPageState extends State<AnimationPage> {
231242
accessor: (List datum) => datum[2] as num,
232243
),
233244
'4': Variable(
234-
accessor: (List datum) => datum[4].toString(),
235-
scale: OrdinalScale(values: ['-1', '1'])
236-
),
245+
accessor: (List datum) => datum[4].toString(),
246+
scale: OrdinalScale(values: ['-1', '1'])),
237247
},
238248
marks: [
239249
PointMark(
@@ -273,7 +283,6 @@ class AnimationPageState extends State<AnimationPage> {
273283
coord: PolarCoord(),
274284
),
275285
),
276-
277286
Container(
278287
padding: const EdgeInsets.fromLTRB(20, 40, 20, 5),
279288
child: const Text(
@@ -368,18 +377,27 @@ class AnimationPageState extends State<AnimationPage> {
368377
marks: [
369378
AreaMark(
370379
shape: ShapeEncode(value: BasicAreaShape(smooth: true)),
371-
gradient: GradientEncode(value: LinearGradient(colors: [
380+
gradient: GradientEncode(
381+
value: LinearGradient(colors: [
372382
Defaults.colors10.first.withAlpha(80),
373383
Defaults.colors10.first.withAlpha(10),
374384
])),
375385
transition: Transition(duration: Duration(seconds: 2)),
376-
entrance: {MarkEntrance.x, MarkEntrance.y, MarkEntrance.opacity},
386+
entrance: {
387+
MarkEntrance.x,
388+
MarkEntrance.y,
389+
MarkEntrance.opacity
390+
},
377391
),
378392
LineMark(
379393
shape: ShapeEncode(value: BasicLineShape(smooth: true)),
380394
size: SizeEncode(value: 0.5),
381395
transition: Transition(duration: Duration(seconds: 2)),
382-
entrance: {MarkEntrance.x, MarkEntrance.y, MarkEntrance.opacity},
396+
entrance: {
397+
MarkEntrance.x,
398+
MarkEntrance.y,
399+
MarkEntrance.opacity
400+
},
383401
),
384402
],
385403
axes: [

example/lib/pages/debug.dart

+58-61
Original file line numberDiff line numberDiff line change
@@ -20,79 +20,76 @@ class DebugPage extends StatelessWidget {
2020
child: Center(
2121
child: Column(
2222
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-
23+
buildChart('single point', [Data(0, 5, 1)]),
24+
buildChart('2 points in the same sector at different radiuses',
25+
[Data(0, 5, 1), Data(0, 6, 2)]),
26+
buildChart('2 points with different sector and radius',
27+
[Data(0, 5, 1), Data(4, 6, 2)]),
28+
buildChart('3 points with different everything',
29+
[Data(0, 5, 1), Data(1, 6, 2), Data(2, 7, 3)]),
30+
buildChart('3 points with a duplicate',
31+
[Data(0, 5, 1), Data(1, 6, 2), Data(1, 6, 2)]),
3532
],
3633
),
3734
),
3835
),
3936
);
4037
}
4138
}
39+
4240
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-
),
41+
mainAxisSize: MainAxisSize.min,
42+
children: [
43+
Container(width: 300, child: Text(name)),
44+
SizedBox(width: 100),
45+
Container(
46+
width: 150,
47+
height: 150,
48+
child: Chart(
49+
data: data,
50+
variables: {
51+
'sector': Variable(
52+
accessor: (Data d) => d.sector.toString(),
53+
scale: OrdinalScale(
54+
values: List<int>.generate(10, (i) => i++)
55+
.map((s) => s.toString())
56+
.toList(),
6057
),
61-
'radius': Variable(
62-
accessor: (Data d) => d.radius,
63-
scale: LinearScale(
64-
min: 0,
65-
max: 10,
66-
),
58+
),
59+
'radius': Variable(
60+
accessor: (Data d) => d.radius,
61+
scale: LinearScale(
62+
min: 0,
63+
max: 10,
6764
),
68-
'value': Variable(
69-
accessor: (Data d) => d.value,
70-
scale: LinearScale(
71-
min: 0,
72-
max: 10,
73-
),
65+
),
66+
'value': Variable(
67+
accessor: (Data d) => d.value,
68+
scale: LinearScale(
69+
min: 0,
70+
max: 10,
7471
),
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-
),
72+
),
73+
},
74+
marks: [
75+
PolygonMark(
76+
shape: ShapeEncode(
77+
value: HeatmapShape(sector: true, tileCounts: [10, 10])),
78+
color: ColorEncode(
79+
variable: 'value',
80+
values: [Colors.blue, Colors.red],
81+
),
82+
)
83+
],
84+
coord: PolarCoord(),
85+
axes: [
86+
Defaults.circularAxis,
87+
Defaults.radialAxis,
9288
],
93-
94-
);
95-
89+
),
90+
),
91+
],
92+
);
9693

9794
class Data {
9895
final int sector;

example/lib/pages/polygon_custom.dart

+4-4
Original file line numberDiff line numberDiff line change
@@ -852,10 +852,10 @@ class DodgeSizeModifier extends Modifier {
852852
index: attributes.index,
853853
tag: attributes.tag,
854854
position: oldPosition
855-
.map(
856-
(point) => Offset(point.dx + accumulated + bias, point.dy),
857-
)
858-
.toList(),
855+
.map(
856+
(point) => Offset(point.dx + accumulated + bias, point.dy),
857+
)
858+
.toList(),
859859
shape: attributes.shape,
860860
color: attributes.color,
861861
gradient: attributes.gradient,

lib/graphic.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
///
112112
/// They include [Axis] specified by [Chart.axes], [Tooltip] specified by [Chart.tooltip],
113113
/// [Crosshair] specified by [Chart.crosshair], and [Annotation]s specified by [Chart.annotations],
114-
///
114+
///
115115
/// ## Animation
116116
/// Marks can specify transition animation by [Mark.transition] on entrance or changed.
117117
/// [Mark.entrance] defines which encode attributes are zero at the begining of

lib/src/common/builtin_layers.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/// Built-in layer orders of chart components.
2-
///
2+
///
33
/// It works when components have same layer.
44
abstract class BuiltinLayers {
55
static const regionBackground = 0;

lib/src/dataflow/tuple.dart

+16-12
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,16 @@ class Attributes {
8282
///
8383
/// This method is mainly used for [Modifier]s.
8484
Attributes withPosition(List<Offset> p) => Attributes(
85-
index: index,
86-
tag: tag,
87-
position: p,
88-
shape: shape,
89-
color: color,
90-
gradient: gradient,
91-
elevation: elevation,
92-
label: label,
93-
size: size,
94-
);
85+
index: index,
86+
tag: tag,
87+
position: p,
88+
shape: shape,
89+
color: color,
90+
gradient: gradient,
91+
elevation: elevation,
92+
label: label,
93+
size: size,
94+
);
9595

9696
/// Returns the original state of an item attributes in animation according to
9797
/// [entrance] type.
@@ -102,7 +102,9 @@ class Attributes {
102102
rst = Attributes(
103103
index: rst.index,
104104
tag: rst.tag,
105-
position: rst.position.map((p) => Offset(p.dx.isFinite ? 0 : p.dx, p.dy)).toList(),
105+
position: rst.position
106+
.map((p) => Offset(p.dx.isFinite ? 0 : p.dx, p.dy))
107+
.toList(),
106108
shape: rst.shape,
107109
color: rst.color,
108110
gradient: rst.gradient,
@@ -116,7 +118,9 @@ class Attributes {
116118
rst = Attributes(
117119
index: rst.index,
118120
tag: rst.tag,
119-
position: rst.position.map((p) => Offset(p.dx, p.dy.isFinite ? 0 : p.dy)).toList(),
121+
position: rst.position
122+
.map((p) => Offset(p.dx, p.dy.isFinite ? 0 : p.dy))
123+
.toList(),
120124
shape: rst.shape,
121125
color: rst.color,
122126
gradient: rst.gradient,

lib/src/graffiti/element/arc.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'segment/move.dart';
77
import 'segment/arc.dart';
88

99
/// Gets the arc point by [angle] on an [oval].
10-
///
10+
///
1111
/// The algrithom is from https://blog.csdn.net/chenlu5201314/article/details/99678398
1212
Offset getArcPoint(Rect oval, double angle) {
1313
final a = oval.width / 2;

0 commit comments

Comments
 (0)