Skip to content

Commit 0f3b31b

Browse files
committed
v0.6.0
1 parent cc0692a commit 0f3b31b

File tree

11 files changed

+125
-68
lines changed

11 files changed

+125
-68
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## 0.6.0
2+
3+
**2021-12-11**
4+
5+
- Upgrade flutter version to `'>=2.6.0'` for `ScaleUpdate.focalPointDelta`: https://github.com/entronad/graphic/issues/21.
6+
- The default `multituples` is true if a selection's variable is set.
7+
- Add `OrdinalScale.inflate`.
8+
- Remove the clip of figure annotation.
9+
- `Chart.padding` is a function of chart size now.
10+
111
## 0.5.1
212

313
**2021-12-01**

DEVLOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3892,7 +3892,7 @@ echarts example upgrade
38923892

38933893
4 chart padding 也应该是size的函数
38943894

3895-
3895+
antv scale 的 nice number计算已经早就改为用d3的了,后续需要更新。
38963896

38973897
## TODO
38983898

example/lib/echarts_data.dart

+44-2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,48 @@ const lineMarkerData = [
5454
];
5555

5656
const lineSectionsData = [
57-
['00:00', '01:15', '02:30', '03:45', '05:00', '06:15', '07:30', '08:45', '10:00', '11:15', '12:30', '13:45', '15:00', '16:15', '17:30', '18:45', '20:00', '21:15', '22:30', '23:45'],
58-
[300, 280, 250, 260, 270, 300, 550, 500, 400, 390, 380, 390, 400, 500, 600, 750, 800, 700, 600, 400],
57+
[
58+
'00:00',
59+
'01:15',
60+
'02:30',
61+
'03:45',
62+
'05:00',
63+
'06:15',
64+
'07:30',
65+
'08:45',
66+
'10:00',
67+
'11:15',
68+
'12:30',
69+
'13:45',
70+
'15:00',
71+
'16:15',
72+
'17:30',
73+
'18:45',
74+
'20:00',
75+
'21:15',
76+
'22:30',
77+
'23:45'
78+
],
79+
[
80+
300,
81+
280,
82+
250,
83+
260,
84+
270,
85+
300,
86+
550,
87+
500,
88+
400,
89+
390,
90+
380,
91+
390,
92+
400,
93+
500,
94+
600,
95+
750,
96+
800,
97+
700,
98+
600,
99+
400
100+
],
59101
];

example/lib/pages/echarts.dart

+53-39
Original file line numberDiff line numberDiff line change
@@ -94,23 +94,23 @@ class EchartsPage extends StatelessWidget {
9494
onSelection: {
9595
'groupMouse': {
9696
false: (gradient) => LinearGradient(
97-
begin: const Alignment(0, 0),
98-
end: const Alignment(0, 1),
99-
colors: [
100-
gradient.colors.first.withAlpha(25),
101-
gradient.colors.last.withAlpha(25),
102-
],
103-
),
97+
begin: const Alignment(0, 0),
98+
end: const Alignment(0, 1),
99+
colors: [
100+
gradient.colors.first.withAlpha(25),
101+
gradient.colors.last.withAlpha(25),
102+
],
103+
),
104104
},
105105
'groupTouch': {
106106
false: (gradient) => LinearGradient(
107-
begin: const Alignment(0, 0),
108-
end: const Alignment(0, 1),
109-
colors: [
110-
gradient.colors.first.withAlpha(25),
111-
gradient.colors.last.withAlpha(25),
112-
],
113-
),
107+
begin: const Alignment(0, 0),
108+
end: const Alignment(0, 1),
109+
colors: [
110+
gradient.colors.first.withAlpha(25),
111+
gradient.colors.last.withAlpha(25),
112+
],
113+
),
114114
},
115115
},
116116
),
@@ -240,51 +240,63 @@ class EchartsPage extends StatelessWidget {
240240
),
241241
),
242242
MarkAnnotation(
243-
relativePath: Paths.circle(center: Offset.zero, radius: 5),
243+
relativePath:
244+
Paths.circle(center: Offset.zero, radius: 5),
244245
style: Paint()..color = const Color(0xff5470c6),
245246
values: ['Wed', 13],
246247
),
247248
MarkAnnotation(
248-
relativePath: Paths.circle(center: Offset.zero, radius: 5),
249+
relativePath:
250+
Paths.circle(center: Offset.zero, radius: 5),
249251
style: Paint()..color = const Color(0xff5470c6),
250252
values: ['Sun', 9],
251253
),
252254
MarkAnnotation(
253-
relativePath: Paths.circle(center: Offset.zero, radius: 5),
255+
relativePath:
256+
Paths.circle(center: Offset.zero, radius: 5),
254257
style: Paint()..color = const Color(0xff91cc75),
255258
values: ['Tue', -2],
256259
),
257260
MarkAnnotation(
258-
relativePath: Paths.circle(center: Offset.zero, radius: 5),
261+
relativePath:
262+
Paths.circle(center: Offset.zero, radius: 5),
259263
style: Paint()..color = const Color(0xff91cc75),
260264
values: ['Thu', 5],
261265
),
262266
TagAnnotation(
263-
label: Label('13', LabelStyle(
264-
Defaults.textStyle,
265-
offset: const Offset(0, -10),
266-
)),
267+
label: Label(
268+
'13',
269+
LabelStyle(
270+
Defaults.textStyle,
271+
offset: const Offset(0, -10),
272+
)),
267273
values: ['Wed', 13],
268274
),
269275
TagAnnotation(
270-
label: Label('9', LabelStyle(
271-
Defaults.textStyle,
272-
offset: const Offset(0, -10),
273-
)),
276+
label: Label(
277+
'9',
278+
LabelStyle(
279+
Defaults.textStyle,
280+
offset: const Offset(0, -10),
281+
)),
274282
values: ['Sun', 9],
275283
),
276284
TagAnnotation(
277-
label: Label('-2', LabelStyle(
278-
Defaults.textStyle,
279-
offset: const Offset(0, -10),
280-
)),
285+
label: Label(
286+
'-2',
287+
LabelStyle(
288+
Defaults.textStyle,
289+
offset: const Offset(0, -10),
290+
)),
281291
values: ['Tue', -2],
282292
),
283293
TagAnnotation(
284-
label: Label('5', LabelStyle(
285-
Defaults.textStyle,
286-
offset: const Offset(0, -10),
287-
)),
294+
label: Label(
295+
'5',
296+
LabelStyle(
297+
Defaults.textStyle,
298+
offset: const Offset(0, -10),
299+
)),
288300
values: ['Thu', 5],
289301
),
290302
],
@@ -300,7 +312,7 @@ class EchartsPage extends StatelessWidget {
300312
variables: {
301313
'time': Variable(
302314
accessor: (List datum) => datum[0] as String,
303-
scale: OrdinalScale(inflate: true),
315+
scale: OrdinalScale(inflate: true, maxTickCount: 6),
304316
),
305317
'value': Variable(
306318
accessor: (List datum) => datum[1] as num,
@@ -311,9 +323,11 @@ class EchartsPage extends StatelessWidget {
311323
),
312324
),
313325
},
314-
elements: [LineElement(
315-
shape: ShapeAttr(value: BasicLineShape(smooth: true)),
316-
)],
326+
elements: [
327+
LineElement(
328+
shape: ShapeAttr(value: BasicLineShape(smooth: true)),
329+
)
330+
],
317331
axes: [
318332
Defaults.horizontalAxis,
319333
Defaults.verticalAxis,
@@ -357,4 +371,4 @@ class EchartsPage extends StatelessWidget {
357371
),
358372
);
359373
}
360-
}
374+
}

lib/src/chart/chart.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class Chart<D> extends StatefulWidget {
8080
final Coord? coord;
8181

8282
/// The padding from coordinate region to the widget border.
83-
///
83+
///
8484
/// This is a function with chart size as input that you may need to calculate
8585
/// the padding.
8686
///

lib/src/common/defaults.dart

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import 'dart:ui';
2-
31
import 'package:flutter/gestures.dart';
42
import 'package:flutter/painting.dart';
53
import 'package:graphic/src/common/label.dart';
@@ -162,14 +160,14 @@ abstract class Defaults {
162160
/// A signal update for scaling and panning horizontal coordinate range.
163161
static SignalUpdater<List<double>> get horizontalRangeSignal =>
164162
_getRangeUpdate(
165-
(detail) => detail.delta.dx,
163+
(detail) => detail.focalPointDelta.dx,
166164
(detail) => detail.horizontalScale,
167165
(size) => size.width,
168166
);
169167

170168
/// A signal update for scaling and panning vertical coordinate range.
171169
static SignalUpdater<List<double>> get verticalRangeSignal => _getRangeUpdate(
172-
(detail) => -detail.delta.dy,
170+
(detail) => -detail.focalPointDelta.dy,
173171
(detail) => detail.verticalScale,
174172
(size) => size.height,
175173
);

lib/src/guide/interaction/tooltip.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,8 @@ class TooltipRenderOp extends Render<TooltipScene> {
231231
return;
232232
}
233233

234-
final multiTuplesRst =
235-
multiTuples ?? (selector is IntervalSelector || selector.variable != null);
234+
final multiTuplesRst = multiTuples ??
235+
(selector is IntervalSelector || selector.variable != null);
236236

237237
final selectedTuples = <Tuple>[];
238238
for (var index in indexes) {

lib/src/interaction/selection/selection.dart

+2-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ class SelectorOp extends Operator<Map<String, Selector>?> {
195195
} else {
196196
// Pans to move.
197197

198-
final delta = detail.delta - gesture.preScaleDetail!.delta;
198+
final delta = detail.focalPointDelta -
199+
gesture.preScaleDetail!.focalPointDelta;
199200
points = [prePoints.first + delta, prePoints.last + delta];
200201
}
201202
} else {

lib/src/parse/parse.dart

+3-7
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,10 @@ import 'package:graphic/src/variable/transform/sort.dart';
5757
import 'package:graphic/src/variable/variable.dart';
5858

5959
/// The default padding function for rectangle coordinate.
60-
EdgeInsets _defaultRectPadding(Size _) =>
61-
EdgeInsets.fromLTRB(40, 5, 10, 20);
60+
EdgeInsets _defaultRectPadding(Size _) => EdgeInsets.fromLTRB(40, 5, 10, 20);
6261

6362
/// The default padding function for polar coordinate.
64-
EdgeInsets _defaultPolarPadding(Size _) =>
65-
EdgeInsets.all(10);
63+
EdgeInsets _defaultPolarPadding(Size _) => EdgeInsets.all(10);
6664

6765
/// Parses the specification for a view.
6866
void parse<D>(Chart<D> spec, View<D> view) {
@@ -122,9 +120,7 @@ void parse<D>(Chart<D> spec, View<D> view) {
122120
final region = view.add(RegionOp({
123121
'size': size,
124122
'padding': spec.padding ??
125-
(spec.coord is PolarCoord
126-
? _defaultPolarPadding
127-
: _defaultRectPadding),
123+
(spec.coord is PolarCoord ? _defaultPolarPadding : _defaultRectPadding),
128124
}));
129125

130126
final coordSpec = spec.coord ?? RectCoord();

lib/src/scale/discrete.dart

+5-9
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ abstract class DiscreteScale<V> extends Scale<V, int> {
1919
List<V>? ticks,
2020
int? tickCount,
2121
int? maxTickCount,
22-
}) : assert(isSingle([inflate, align], allowNone: true)),
23-
super(
22+
}) : assert(isSingle([inflate, align], allowNone: true)),
23+
super(
2424
title: title,
2525
formatter: formatter,
2626
ticks: ticks,
@@ -35,7 +35,7 @@ abstract class DiscreteScale<V> extends Scale<V, int> {
3535
List<V>? values;
3636

3737
/// Whether the points distribution will inflate the axis range.
38-
///
38+
///
3939
/// If true, The points will distribute in the axis range from end to end, with
4040
/// equal intervals. The [align] is not allowd then.
4141
bool? inflate;
@@ -85,12 +85,8 @@ abstract class DiscreteScaleConv<V, SP extends DiscreteScale<V>>
8585
title = spec.title ?? variable;
8686
formatter = spec.formatter ?? defaultFormatter;
8787
inflate = spec.inflate ?? false;
88-
band = inflate
89-
? 1 / (values.length - 1)
90-
: 1 / values.length;
91-
align = inflate
92-
? 0
93-
: spec.align ?? 0.5;
88+
band = inflate ? 1 / (values.length - 1) : 1 / values.length;
89+
align = inflate ? 0 : spec.align ?? 0.5;
9490
}
9591

9692
/// The candidate values.

pubspec.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
name: graphic
22
description: A declarative, interactive grammar of data visualization. It provides a Flutter charting library.
3-
version: 0.5.1
3+
version: 0.6.0
44
homepage: https://github.com/entronad/graphic
55

66
environment:
77
sdk: '>=2.13.0 <3.0.0'
8-
flutter: '>=2.4.0 <2.6.0'
8+
flutter: '>=2.6.0'
99

1010
dependencies:
1111
collection: ^1.15.0

0 commit comments

Comments
 (0)