-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support tree expand collapse (#5755)
* test: rename test case * refactor(behaviors): adjust collapse-expand * feat(utils): add isCollapsed util * fix(runtime): avoid unexcepted combo refresh when update node data * refactor(elements): edge support loop config * feat(runtime): support simulate layout * feat(runtime): support collapse and expand tree node * test(behaviors): add collapse expand node test case * refactor(runtime): rename collapse expand api name * refactor: remove collapseOrigin * refactor(animation): adapat combo animation
- Loading branch information
Showing
84 changed files
with
3,225 additions
and
865 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
packages/g6/__tests__/demos/behavior-expand-collapse-node.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { Graph, treeToGraphData } from '@/src'; | ||
|
||
export const behaviorExpandCollapseNode: TestCase = async (context) => { | ||
const graph = new Graph({ | ||
...context, | ||
x: 200, | ||
y: 200, | ||
data: treeToGraphData({ | ||
id: 'A', | ||
children: [ | ||
{ id: 'B', children: [{ id: 'D' }, { id: 'E' }] }, | ||
{ id: 'C', children: [{ id: 'F' }, { id: 'G' }], style: { collapsed: true } }, | ||
], | ||
}), | ||
node: { | ||
style: { | ||
labelText: (d) => d.id, | ||
labelPlacement: 'right', | ||
ports: [{ position: 'center' }], | ||
}, | ||
}, | ||
edge: { | ||
type: 'cubic-horizontal', | ||
}, | ||
layout: { | ||
type: 'dendrogram', | ||
nodeSep: 30, | ||
rankSep: 100, | ||
}, | ||
behaviors: [{ type: 'collapse-expand', trigger: 'click' }, 'drag-element'], | ||
}); | ||
|
||
await graph.render(); | ||
|
||
behaviorExpandCollapseNode.form = (panel) => { | ||
const config = { | ||
element: 'A', | ||
collapse: () => graph.collapseElement(config.element), | ||
expand: () => graph.expandElement(config.element), | ||
}; | ||
|
||
return [ | ||
panel.add(config, 'element', ['A', 'B', 'C', 'D', 'E', 'F', 'G']).name('Node'), | ||
panel.add(config, 'collapse').name('Collapse'), | ||
panel.add(config, 'expand').name('Expand'), | ||
]; | ||
}; | ||
|
||
return graph; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.