-
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: snake layout * test: add snake layout unit tests * docs: add snake layout docs * fix: typo * chore: update deps * fix: update remarks
- Loading branch information
Showing
26 changed files
with
2,471 additions
and
54 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
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
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,66 @@ | ||
import { Graph } from '@antv/g6'; | ||
|
||
const data = { | ||
nodes: [ | ||
{ id: '0', data: { label: '开始流程', time: '17:00:00' } }, | ||
{ id: '1', data: { label: '流程1', time: '17:00:05' } }, | ||
{ id: '2', data: { label: '流程2', time: '17:00:12' } }, | ||
{ id: '3', data: { label: '流程3', time: '17:00:30' } }, | ||
{ id: '4', data: { label: '流程4', time: '17:02:00' } }, | ||
{ id: '5', data: { label: '流程5', time: '17:02:40' } }, | ||
{ id: '6', data: { label: '流程6', time: '17:05:50' } }, | ||
{ id: '7', data: { label: '流程7', time: '17:10:00' } }, | ||
{ id: '8', data: { label: '流程8', time: '17:11:20' } }, | ||
{ id: '9', data: { label: '流程9', time: '17:15:00' } }, | ||
{ id: '10', data: { label: '流程10', time: '17:30:00' } }, | ||
{ id: '11', data: { label: '流程11' } }, | ||
{ id: '12', data: { label: '流程12' } }, | ||
{ id: '13', data: { label: '流程13' } }, | ||
{ id: '14', data: { label: '流程14' } }, | ||
{ id: '15', data: { label: '流程结束' } }, | ||
], | ||
edges: [ | ||
{ source: '0', target: '1', data: { done: true } }, | ||
{ source: '1', target: '2', data: { done: true } }, | ||
{ source: '2', target: '3', data: { done: true } }, | ||
{ source: '3', target: '4', data: { done: true } }, | ||
{ source: '4', target: '5', data: { done: true } }, | ||
{ source: '5', target: '6', data: { done: true } }, | ||
{ source: '6', target: '7', data: { done: true } }, | ||
{ source: '7', target: '8', data: { done: true } }, | ||
{ source: '8', target: '9', data: { done: true } }, | ||
{ source: '9', target: '10', data: { done: true } }, | ||
{ source: '10', target: '11', data: { done: false } }, | ||
{ source: '11', target: '12', data: { done: false } }, | ||
{ source: '12', target: '13', data: { done: false } }, | ||
{ source: '13', target: '14', data: { done: false } }, | ||
{ source: '14', target: '15', data: { done: false } }, | ||
], | ||
}; | ||
|
||
export const layoutSnake: TestCase = async (context) => { | ||
const graph = new Graph({ | ||
...context, | ||
data, | ||
node: { | ||
style: { | ||
labelText: (d) => d.id, | ||
labelPlacement: 'center', | ||
labelFill: '#fff', | ||
}, | ||
}, | ||
edge: { | ||
style: { | ||
endArrow: true, | ||
}, | ||
}, | ||
layout: { | ||
key: 'snake', | ||
type: 'snake', | ||
}, | ||
}); | ||
|
||
await graph.render(); | ||
|
||
return graph; | ||
}; |
336 changes: 336 additions & 0 deletions
336
packages/g6/__tests__/snapshots/layouts/snake/anti-clockwise.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
336 changes: 336 additions & 0 deletions
336
packages/g6/__tests__/snapshots/layouts/snake/cols-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
336 changes: 336 additions & 0 deletions
336
packages/g6/__tests__/snapshots/layouts/snake/cols-20.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
336 changes: 336 additions & 0 deletions
336
packages/g6/__tests__/snapshots/layouts/snake/default.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
336 changes: 336 additions & 0 deletions
336
packages/g6/__tests__/snapshots/layouts/snake/gap-50.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
336 changes: 336 additions & 0 deletions
336
packages/g6/__tests__/snapshots/layouts/snake/padding-20.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,44 @@ | ||
import type { Graph } from '@/src'; | ||
import { layoutSnake } from '@@/demos/layout-snake'; | ||
import { createDemoGraph } from '@@/utils'; | ||
|
||
describe('snake', () => { | ||
let graph: Graph; | ||
|
||
beforeAll(async () => { | ||
graph = await createDemoGraph(layoutSnake); | ||
}); | ||
|
||
afterAll(() => { | ||
graph.destroy(); | ||
}); | ||
|
||
it('default', async () => { | ||
await expect(graph).toMatchSnapshot(__filename, 'default'); | ||
}); | ||
|
||
it('padding', async () => { | ||
graph.setLayout((prev) => ({ ...prev, padding: 20 })), await graph.layout(); | ||
await expect(graph).toMatchSnapshot(__filename, 'padding-20'); | ||
}); | ||
|
||
it('set cols as 1', async () => { | ||
graph.setLayout((prev) => ({ ...prev, padding: 0, cols: 1 })), await graph.layout(); | ||
await expect(graph).toMatchSnapshot(__filename, 'cols-1'); | ||
}); | ||
|
||
it('set cols as 20', async () => { | ||
graph.setLayout((prev) => ({ ...prev, padding: 0, cols: 20 })), await graph.layout(); | ||
await expect(graph).toMatchSnapshot(__filename, 'cols-20'); | ||
}); | ||
|
||
it('colSep and rowSep', async () => { | ||
graph.setLayout((prev) => ({ ...prev, cols: 6, colGap: 50, rowGap: 50 })), await graph.layout(); | ||
await expect(graph).toMatchSnapshot(__filename, 'gap-50'); | ||
}); | ||
|
||
it('anti-clockwise', async () => { | ||
graph.setLayout((prev) => ({ ...prev, clockwise: false })), await graph.layout(); | ||
await expect(graph).toMatchSnapshot(__filename, 'anti-clockwise'); | ||
}); | ||
}); |
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
Oops, something went wrong.