-
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.
* test: layout dendrogram * fix: resolve conversation
- Loading branch information
Showing
11 changed files
with
4,034 additions
and
340 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
34 changes: 34 additions & 0 deletions
34
packages/g6/__tests__/demo/case/layout-dendrogram-basic.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,34 @@ | ||
import { Graph, Utils } from '@/src'; | ||
import data from '@@/dataset/algorithm-category.json'; | ||
import type { STDTestCase } from '../types'; | ||
|
||
export const layoutDendrogramBasic: STDTestCase = async (context) => { | ||
const graph = new Graph({ | ||
...context, | ||
autoFit: 'view', | ||
data: Utils.treeToGraphData(data), | ||
node: { | ||
style: { | ||
labelText: (d) => d.id, | ||
labelPlacement: (model) => (model.style!.children?.length ? 'left' : 'right'), | ||
ports: [{ placement: 'right' }, { placement: 'left' }], | ||
}, | ||
}, | ||
edge: { | ||
style: { | ||
type: 'cubic-horizontal', | ||
}, | ||
}, | ||
layout: { | ||
type: 'dendrogram', | ||
direction: 'LR', | ||
nodeSep: 36, | ||
rankSep: 250, | ||
}, | ||
behaviors: ['drag-canvas', 'zoom-canvas', 'drag-node', 'collapse-expand-tree'], | ||
}); | ||
|
||
await graph.render(); | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Graph, Utils } from '@/src'; | ||
import data from '@@/dataset/algorithm-category.json'; | ||
import type { STDTestCase } from '../types'; | ||
|
||
export const layoutDendrogramTb: STDTestCase = async (context) => { | ||
const graph = new Graph({ | ||
...context, | ||
autoFit: 'view', | ||
data: Utils.treeToGraphData(data), | ||
node: { | ||
style: (model) => { | ||
const hasChildren = !!model.style!.children?.length; | ||
return { | ||
labelMaxWidth: 200, | ||
labelPlacement: hasChildren ? 'right' : 'bottom', | ||
labelText: model.id, | ||
labelTextAlign: 'start', | ||
labelTextBaseline: hasChildren ? 'middle' : 'bottom', | ||
transform: hasChildren ? '' : 'rotate(90)', | ||
ports: [{ placement: 'bottom' }, { placement: 'top' }], | ||
}; | ||
}, | ||
}, | ||
edge: { | ||
style: { | ||
type: 'cubic-vertical', | ||
}, | ||
}, | ||
layout: { | ||
type: 'dendrogram', | ||
direction: 'TB', | ||
nodeSep: 40, | ||
rankSep: 100, | ||
}, | ||
behaviors: ['drag-canvas', 'zoom-canvas', 'drag-node', 'collapse-expand-tree'], | ||
}); | ||
|
||
await graph.render(); | ||
|
||
return graph; | ||
}; |
Oops, something went wrong.