Skip to content

Commit

Permalink
✨ feat(common): replace degre with badge and explore it to user
Browse files Browse the repository at this point in the history
degre is a inner property for node layout
  • Loading branch information
萌萌的老胖子 committed Apr 21, 2020
1 parent f5f2f6f commit df4c426
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ data.nodes = data.nodes.map((node) => {
node.style = node.style || {};
// 修改节点大小
node.style.nodeSize = 36;
// 设置节点徽标
node.badge = 4;
return node;
});
data.edges = data.edges.map((edge, index) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/graphin/src/shape/graph-studio/CircleNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default (g6: any) => {
});
}

if (!cfg.degree) return keyShape;
if (!cfg.badge) return keyShape;

const children = group.addGroup(
{
Expand All @@ -114,7 +114,7 @@ export default (g6: any) => {
id: 'circle-children-icon',
x: outerSize / 2 - 9,
y: -outerSize / 2 + 9,
text: cfg.degree > 100 ? '99+' : cfg.degree,
text: cfg.badge,
fontSize: 10,
textAlign: 'center',
textBaseline: 'middle',
Expand Down
4 changes: 2 additions & 2 deletions packages/graphin/src/shape/graph-studio/HexagonNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default (g6: any) => {
});
}

if (!cfg.degree) return keyShape;
if (!cfg.badge) return keyShape;

const children = group.addGroup(
{
Expand All @@ -122,7 +122,7 @@ export default (g6: any) => {
id: 'hexagon-children-icon',
x: 16 / 2,
y: 16 / 2,
text: cfg.degree > 100 ? '99+' : cfg.degree,
text: cfg.badge,
fontSize: 10,
textAlign: 'center',
textBaseline: 'middle',
Expand Down
4 changes: 2 additions & 2 deletions packages/graphin/src/shape/graph-studio/RectNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default (g6: any) => {
});
}

if (!cfg.degree) return keyShape;
if (!cfg.badge) return keyShape;

const children = group.addGroup(
{
Expand All @@ -122,7 +122,7 @@ export default (g6: any) => {
id: 'rect-children-icon',
x: 12 / 2,
y: 12 / 2,
text: cfg.degree > 100 ? '99+' : cfg.degree,
text: cfg.badge,
fontSize: 10,
textAlign: 'center',
textBaseline: 'middle',
Expand Down
2 changes: 2 additions & 0 deletions packages/graphin/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ export interface Node {
layout?: NodeLayoutType;
/** 节点度数 */
degree?: number;
/** 徽标文案 */
badge?: number | string;
searchTypes?: string[];
}

Expand Down

0 comments on commit df4c426

Please sign in to comment.