Skip to content

Commit

Permalink
v2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
entronad committed Apr 4, 2023
1 parent afc8e69 commit 019c0d2
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 20 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 2.0.1

**2023-04-04**

- Fix LineShape dash: https://github.com/entronad/graphic/issues/212

## 2.0.0

**2023-04-02**
Expand Down
4 changes: 3 additions & 1 deletion DEVLOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -498,4 +498,6 @@ elements个数不一样的情况太复杂,数据个数不一样时tag也往往

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

tagEncode 先不要搞默认值了,变量情况复杂不要弄巧成拙,只有在手动改变了data顺序对应被打乱了才要
tagEncode 先不要搞默认值了,变量情况复杂不要弄巧成拙,只有在手动改变了data顺序对应被打乱了才要

内部工具函数,尽量保留位置参数或必选参数,哪怕填null,减少错误
2 changes: 1 addition & 1 deletion example/lib/pages/polygon_custom.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TriangleShape extends IntervalShape {
}
}

final style = getPaintStyle(item, false, 0);
final style = getPaintStyle(item, false, 0, null, null);

final start = coord.convert(item.position[0]);
final end = coord.convert(item.position[1]);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/shape/area.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class BasicAreaShape extends AreaShape {

final primitives = <MarkElement>[];

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

for (var contour in contours) {
final starts = <Offset>[];
Expand Down
2 changes: 1 addition & 1 deletion lib/src/shape/custom.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class CandlestickShape extends Shape {
for (var item in group) {
assert(item.shape is CandlestickShape);

final style = getPaintStyle(item, hollow, strokeWidth);
final style = getPaintStyle(item, hollow, strokeWidth, null, null);

// Candle stick shape dosen't allow NaN value.
final points = item.position.map((p) => coord.convert(p)).toList();
Expand Down
10 changes: 5 additions & 5 deletions lib/src/shape/interval.dart
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ class RectShape extends IntervalShape {
) {
assert(item.shape is RectShape);

final style = getPaintStyle(item, false, 0, coord.region);
final style = getPaintStyle(item, false, 0, coord.region, null);

return RectElement(rect: rect, borderRadius: borderRadius, style: style, tag: item.tag);
}
Expand Down Expand Up @@ -387,7 +387,7 @@ class RectShape extends IntervalShape {
) {
assert(item.shape is RectShape);

final style = getPaintStyle(item, false, 0, coord.region);
final style = getPaintStyle(item, false, 0, coord.region, null);

return SectorElement(
center: coord.center,
Expand Down Expand Up @@ -480,7 +480,7 @@ class FunnelShape extends IntervalShape {
coord.convert(Offset(bandStart, position[0].dy)),
];
rst.add(PolygonElement(
points: corners, style: getPaintStyle(item, false, 0, coord.region), tag: item.tag));
points: corners, style: getPaintStyle(item, false, 0, coord.region, null), tag: item.tag));
// Middle items.
for (var i = 1; i < group.length - 1; i++) {
item = group[i];
Expand All @@ -496,7 +496,7 @@ class FunnelShape extends IntervalShape {
coord.convert(Offset(bandStart, position[0].dy)),
];
rst.add(PolygonElement(
points: corners, style: getPaintStyle(item, false, 0, coord.region), tag: item.tag));
points: corners, style: getPaintStyle(item, false, 0, coord.region, null), tag: item.tag));
}
// Last item.
item = group.last;
Expand All @@ -513,7 +513,7 @@ class FunnelShape extends IntervalShape {
coord.convert(Offset(bandStart, position[0].dy)),
];
rst.add(PolygonElement(
points: corners, style: getPaintStyle(item, false, 0, coord.region), tag: item.tag));
points: corners, style: getPaintStyle(item, false, 0, coord.region, null), tag: item.tag));

return rst;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/src/shape/line.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class BasicLineShape extends LineShape {

final represent = group.first;
final style = getPaintStyle(
represent, true, represent.size ?? defaultSize, coord.region);
represent, true, represent.size ?? defaultSize, coord.region, dash);

for (var contour in contours) {
if (smooth) {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/shape/point.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class CircleShape extends PointShape {
return CircleElement(
center: point,
radius: size / 2,
style: getPaintStyle(item, hollow, strokeWidth), tag: item.tag,);
style: getPaintStyle(item, hollow, strokeWidth, null, null), tag: item.tag,);
}
}

Expand All @@ -143,6 +143,6 @@ class SquareShape extends PointShape {
final size = item.size ?? defaultSize;
return RectElement(
rect: Rect.fromCenter(center: point, width: size, height: size),
style: getPaintStyle(item, hollow, strokeWidth), tag: item.tag,);
style: getPaintStyle(item, hollow, strokeWidth, null, null), tag: item.tag,);
}
}
2 changes: 1 addition & 1 deletion lib/src/shape/polygon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class HeatmapShape extends PolygonShape {
for (var item in group) {
assert(item.shape is HeatmapShape);

final style = getPaintStyle(item, false, 0, coord.region);
final style = getPaintStyle(item, false, 0, null, null);

final point = item.position.last;
if (coord is RectCoordConv) {
Expand Down
21 changes: 15 additions & 6 deletions lib/src/shape/util/style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,43 @@ import 'package:graphic/src/graffiti/element/element.dart';
PaintStyle getPaintStyle(
Attributes attributes,
bool hollow,
double strokeWidth, [
double strokeWidth,
Rect? gradientBounds,
]) {
List<double>? dash,
) {
if (hollow) {
if (attributes.gradient != null) {
return PaintStyle(
strokeGradient: attributes.gradient,
strokeWidth: strokeWidth,
elevation: attributes.elevation,
gradientBounds: gradientBounds);
gradientBounds: gradientBounds,
dash: dash,
);
} else {
return PaintStyle(
strokeColor: attributes.color,
strokeWidth: strokeWidth,
elevation: attributes.elevation,
gradientBounds: gradientBounds);
gradientBounds: gradientBounds,
dash: dash,
);
}
} else {
if (attributes.gradient != null) {
return PaintStyle(
fillGradient: attributes.gradient,
elevation: attributes.elevation,
gradientBounds: gradientBounds);
gradientBounds: gradientBounds,
dash: dash,
);
} else {
return PaintStyle(
fillColor: attributes.color,
elevation: attributes.elevation,
gradientBounds: gradientBounds);
gradientBounds: gradientBounds,
dash: dash,
);
}
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: graphic
description: A grammar of data visualization and Flutter charting library.
version: 2.0.0
version: 2.0.1
homepage: https://github.com/entronad/graphic

environment:
Expand Down

0 comments on commit 019c0d2

Please sign in to comment.