Skip to content

Commit

Permalink
feat: add legend in graph.
Browse files Browse the repository at this point in the history
  • Loading branch information
CorvusYe committed Feb 1, 2023
1 parent e1db2c5 commit a4740b5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
## 0.0.1+9
- feat: create random color for tag.

## 0.0.1+8
- feat(convert): cache the edge names and vertex tags in graph.
- feat: support customize background.
- feat(options style): support assigning colors to vertexes through tags (name or index).

## 0.0.1+7
- feat: supported customize vertex ui.
Expand Down
21 changes: 13 additions & 8 deletions lib/core/options/style/graph_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,7 @@ class GraphStyle {
List<Color> colors = [];

for (var tag in tags) {
Color? color;
if (tagColor != null) {
color = tagColor![tag];
}
if (color == null) {
var idx = allTags.indexOf(tag);
if (idx < tagColorByIndex.length) color = tagColorByIndex[idx];
}
Color? color = colorByTag(tag, allTags);
if (color != null) {
colors.add(color);
}
Expand All @@ -65,6 +58,18 @@ class GraphStyle {
return colors;
}

Color? colorByTag(String tag, List<String> allTags) {
Color? color;
if (tagColor != null) {
color = tagColor![tag];
}
if (color == null) {
var idx = allTags.indexOf(tag);
if (idx < tagColorByIndex.length) color = tagColorByIndex[idx];
}
return color;
}

/// when there is not color matched in [tagColor] on [tagColorByIndex], return random color.
///
/// 当在 [tagColor][tagColorByIndex] 中匹配不到颜色时,返回随机颜色
Expand Down

0 comments on commit a4740b5

Please sign in to comment.