Skip to content

Commit a4740b5

Browse files
committed
feat: add legend in graph.
1 parent e1db2c5 commit a4740b5

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
## 0.0.1+9
2+
- feat: create random color for tag.
3+
14
## 0.0.1+8
25
- feat(convert): cache the edge names and vertex tags in graph.
36
- feat: support customize background.
7+
- feat(options style): support assigning colors to vertexes through tags (name or index).
48

59
## 0.0.1+7
610
- feat: supported customize vertex ui.

lib/core/options/style/graph_style.dart

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,7 @@ class GraphStyle {
4646
List<Color> colors = [];
4747

4848
for (var tag in tags) {
49-
Color? color;
50-
if (tagColor != null) {
51-
color = tagColor![tag];
52-
}
53-
if (color == null) {
54-
var idx = allTags.indexOf(tag);
55-
if (idx < tagColorByIndex.length) color = tagColorByIndex[idx];
56-
}
49+
Color? color = colorByTag(tag, allTags);
5750
if (color != null) {
5851
colors.add(color);
5952
}
@@ -65,6 +58,18 @@ class GraphStyle {
6558
return colors;
6659
}
6760

61+
Color? colorByTag(String tag, List<String> allTags) {
62+
Color? color;
63+
if (tagColor != null) {
64+
color = tagColor![tag];
65+
}
66+
if (color == null) {
67+
var idx = allTags.indexOf(tag);
68+
if (idx < tagColorByIndex.length) color = tagColorByIndex[idx];
69+
}
70+
return color;
71+
}
72+
6873
/// when there is not color matched in [tagColor] on [tagColorByIndex], return random color.
6974
///
7075
/// 当在 [tagColor][tagColorByIndex] 中匹配不到颜色时,返回随机颜色

0 commit comments

Comments
 (0)