Skip to content

Commit 019c0d2

Browse files
committed
v2.0.1
1 parent afc8e69 commit 019c0d2

11 files changed

+37
-20
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 2.0.1
2+
3+
**2023-04-04**
4+
5+
- Fix LineShape dash: https://github.com/entronad/graphic/issues/212
6+
17
## 2.0.0
28

39
**2023-04-02**

DEVLOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -498,4 +498,6 @@ elements个数不一样的情况太复杂,数据个数不一样时tag也往往
498498

499499
**elements打tag的原则**:pre和current的tag集合要一致,这样每一个current元素总能找到自己的对应项
500500

501-
tagEncode 先不要搞默认值了,变量情况复杂不要弄巧成拙,只有在手动改变了data顺序对应被打乱了才要
501+
tagEncode 先不要搞默认值了,变量情况复杂不要弄巧成拙,只有在手动改变了data顺序对应被打乱了才要
502+
503+
内部工具函数,尽量保留位置参数或必选参数,哪怕填null,减少错误

example/lib/pages/polygon_custom.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class TriangleShape extends IntervalShape {
2525
}
2626
}
2727

28-
final style = getPaintStyle(item, false, 0);
28+
final style = getPaintStyle(item, false, 0, null, null);
2929

3030
final start = coord.convert(item.position[0]);
3131
final end = coord.convert(item.position[1]);

lib/src/shape/area.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class BasicAreaShape extends AreaShape {
8585

8686
final primitives = <MarkElement>[];
8787

88-
final style = getPaintStyle(group.first, false, 0, coord.region);
88+
final style = getPaintStyle(group.first, false, 0, coord.region, null);
8989

9090
for (var contour in contours) {
9191
final starts = <Offset>[];

lib/src/shape/custom.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class CandlestickShape extends Shape {
6161
for (var item in group) {
6262
assert(item.shape is CandlestickShape);
6363

64-
final style = getPaintStyle(item, hollow, strokeWidth);
64+
final style = getPaintStyle(item, hollow, strokeWidth, null, null);
6565

6666
// Candle stick shape dosen't allow NaN value.
6767
final points = item.position.map((p) => coord.convert(p)).toList();

lib/src/shape/interval.dart

+5-5
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ class RectShape extends IntervalShape {
353353
) {
354354
assert(item.shape is RectShape);
355355

356-
final style = getPaintStyle(item, false, 0, coord.region);
356+
final style = getPaintStyle(item, false, 0, coord.region, null);
357357

358358
return RectElement(rect: rect, borderRadius: borderRadius, style: style, tag: item.tag);
359359
}
@@ -387,7 +387,7 @@ class RectShape extends IntervalShape {
387387
) {
388388
assert(item.shape is RectShape);
389389

390-
final style = getPaintStyle(item, false, 0, coord.region);
390+
final style = getPaintStyle(item, false, 0, coord.region, null);
391391

392392
return SectorElement(
393393
center: coord.center,
@@ -480,7 +480,7 @@ class FunnelShape extends IntervalShape {
480480
coord.convert(Offset(bandStart, position[0].dy)),
481481
];
482482
rst.add(PolygonElement(
483-
points: corners, style: getPaintStyle(item, false, 0, coord.region), tag: item.tag));
483+
points: corners, style: getPaintStyle(item, false, 0, coord.region, null), tag: item.tag));
484484
// Middle items.
485485
for (var i = 1; i < group.length - 1; i++) {
486486
item = group[i];
@@ -496,7 +496,7 @@ class FunnelShape extends IntervalShape {
496496
coord.convert(Offset(bandStart, position[0].dy)),
497497
];
498498
rst.add(PolygonElement(
499-
points: corners, style: getPaintStyle(item, false, 0, coord.region), tag: item.tag));
499+
points: corners, style: getPaintStyle(item, false, 0, coord.region, null), tag: item.tag));
500500
}
501501
// Last item.
502502
item = group.last;
@@ -513,7 +513,7 @@ class FunnelShape extends IntervalShape {
513513
coord.convert(Offset(bandStart, position[0].dy)),
514514
];
515515
rst.add(PolygonElement(
516-
points: corners, style: getPaintStyle(item, false, 0, coord.region), tag: item.tag));
516+
points: corners, style: getPaintStyle(item, false, 0, coord.region, null), tag: item.tag));
517517

518518
return rst;
519519
}

lib/src/shape/line.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class BasicLineShape extends LineShape {
106106

107107
final represent = group.first;
108108
final style = getPaintStyle(
109-
represent, true, represent.size ?? defaultSize, coord.region);
109+
represent, true, represent.size ?? defaultSize, coord.region, dash);
110110

111111
for (var contour in contours) {
112112
if (smooth) {

lib/src/shape/point.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class CircleShape extends PointShape {
121121
return CircleElement(
122122
center: point,
123123
radius: size / 2,
124-
style: getPaintStyle(item, hollow, strokeWidth), tag: item.tag,);
124+
style: getPaintStyle(item, hollow, strokeWidth, null, null), tag: item.tag,);
125125
}
126126
}
127127

@@ -143,6 +143,6 @@ class SquareShape extends PointShape {
143143
final size = item.size ?? defaultSize;
144144
return RectElement(
145145
rect: Rect.fromCenter(center: point, width: size, height: size),
146-
style: getPaintStyle(item, hollow, strokeWidth), tag: item.tag,);
146+
style: getPaintStyle(item, hollow, strokeWidth, null, null), tag: item.tag,);
147147
}
148148
}

lib/src/shape/polygon.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class HeatmapShape extends PolygonShape {
7575
for (var item in group) {
7676
assert(item.shape is HeatmapShape);
7777

78-
final style = getPaintStyle(item, false, 0, coord.region);
78+
final style = getPaintStyle(item, false, 0, null, null);
7979

8080
final point = item.position.last;
8181
if (coord is RectCoordConv) {

lib/src/shape/util/style.dart

+15-6
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,43 @@ import 'package:graphic/src/graffiti/element/element.dart';
66
PaintStyle getPaintStyle(
77
Attributes attributes,
88
bool hollow,
9-
double strokeWidth, [
9+
double strokeWidth,
1010
Rect? gradientBounds,
11-
]) {
11+
List<double>? dash,
12+
) {
1213
if (hollow) {
1314
if (attributes.gradient != null) {
1415
return PaintStyle(
1516
strokeGradient: attributes.gradient,
1617
strokeWidth: strokeWidth,
1718
elevation: attributes.elevation,
18-
gradientBounds: gradientBounds);
19+
gradientBounds: gradientBounds,
20+
dash: dash,
21+
);
1922
} else {
2023
return PaintStyle(
2124
strokeColor: attributes.color,
2225
strokeWidth: strokeWidth,
2326
elevation: attributes.elevation,
24-
gradientBounds: gradientBounds);
27+
gradientBounds: gradientBounds,
28+
dash: dash,
29+
);
2530
}
2631
} else {
2732
if (attributes.gradient != null) {
2833
return PaintStyle(
2934
fillGradient: attributes.gradient,
3035
elevation: attributes.elevation,
31-
gradientBounds: gradientBounds);
36+
gradientBounds: gradientBounds,
37+
dash: dash,
38+
);
3239
} else {
3340
return PaintStyle(
3441
fillColor: attributes.color,
3542
elevation: attributes.elevation,
36-
gradientBounds: gradientBounds);
43+
gradientBounds: gradientBounds,
44+
dash: dash,
45+
);
3746
}
3847
}
3948
}

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: graphic
22
description: A grammar of data visualization and Flutter charting library.
3-
version: 2.0.0
3+
version: 2.0.1
44
homepage: https://github.com/entronad/graphic
55

66
environment:

0 commit comments

Comments
 (0)