Skip to content

Commit

Permalink
refactor: support pre layout process (#6630)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aarebecca authored Dec 14, 2024
1 parent f14f390 commit 7726eca
Show file tree
Hide file tree
Showing 126 changed files with 2,882 additions and 2,664 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ describe('bug: plugin-minimap-combo-collapsed', () => {

await graph.render();

await expect(graph).toMatchSnapshot(__filename, 'update collapsed combo');
await expect(graph).toMatchSnapshot(__filename, 'update-collapsed-combo');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const behaviorExpandCollapseNode: TestCase = async (context) => {
type: 'dendrogram',
nodeSep: 30,
rankSep: 100,
preLayout: false,
},
behaviors: [{ type: 'collapse-expand', trigger: 'click', align: false }, 'drag-element'],
});
Expand Down
14 changes: 6 additions & 8 deletions packages/g6/__tests__/demos/case-radial-dendrogram.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@ export const caseRadialDendrogram: TestCase = async (context) => {
},
},
},
layout: [
{
type: 'dendrogram',
radial: true,
nodeSep: 30,
rankSep: 200,
},
],
layout: {
type: 'dendrogram',
radial: true,
nodeSep: 30,
rankSep: 200,
},
behaviors: [
'drag-canvas',
'zoom-canvas',
Expand Down
15 changes: 7 additions & 8 deletions packages/g6/__tests__/demos/element-edge-cubic-radial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ export const elementEdgeCubicRadial: TestCase = async (context) => {
edge: {
type: 'cubic-radial',
},
layout: [
{
type: 'dendrogram',
radial: true,
nodeSep: 30,
rankSep: 200,
},
],
layout: {
type: 'dendrogram',
radial: true,
nodeSep: 30,
rankSep: 200,
preLayout: true,
},
});

await graph.render();
Expand Down
1 change: 1 addition & 0 deletions packages/g6/__tests__/demos/element-edge-line.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const elementEdgeLine: TestCase = async (context) => {
type: 'radial',
unitRadius: 220,
linkDistance: 220,
preLayout: false,
},
});

Expand Down
1 change: 1 addition & 0 deletions packages/g6/__tests__/demos/layout-dendrogram-basic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const layoutDendrogramBasic: TestCase = async (context) => {
direction: 'LR',
nodeSep: 36,
rankSep: 250,
preLayout: true,
},
behaviors: ['drag-canvas', 'zoom-canvas', 'drag-element', 'collapse-expand'],
});
Expand Down
14 changes: 6 additions & 8 deletions packages/g6/__tests__/demos/layout-dendrogram-radial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ export const layoutDendrogramRadial: TestCase = async (context) => {
labelText: (d) => d.id,
},
},
layout: [
{
type: 'dendrogram',
radial: true,
nodeSep: 30,
rankSep: 200,
},
],
layout: {
type: 'dendrogram',
radial: true,
nodeSep: 30,
rankSep: 200,
},
});

await graph.render();
Expand Down
1 change: 1 addition & 0 deletions packages/g6/__tests__/demos/layout-dendrogram-tb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export const layoutDendrogramTb: TestCase = async (context) => {
direction: 'TB',
nodeSep: 40,
rankSep: 100,
preLayout: true,
},
behaviors: ['drag-canvas', 'zoom-canvas', 'drag-element', 'collapse-expand'],
});
Expand Down
5 changes: 3 additions & 2 deletions packages/g6/__tests__/demos/layout-fishbone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const layoutFishbone: TestCase = async (context) => {
type: 'fishbone',
vGap: 48,
hGap: 48,
direction: 'RL',
},
behaviors: ['drag-canvas', 'zoom-canvas', 'drag-element'],
animation: false,
Expand All @@ -91,7 +92,7 @@ export const layoutFishbone: TestCase = async (context) => {
layoutFishbone.form = (panel) => {
const config = {
type: 'fishbone',
direction: 'LR',
direction: 'RL',
};

return [
Expand All @@ -100,7 +101,7 @@ export const layoutFishbone: TestCase = async (context) => {
.name('Direction')
.onChange((value: 'LR' | 'RL') => {
graph.setLayout((prev) => ({ ...prev, direction: value }));
graph.layout();
graph.render();
}),
];
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const layoutMindmapHCustomSide: TestCase = async (context) => {
layout: {
type: 'mindmap',
direction: 'H',
preLayout: false,
getHeight: () => {
return 16;
},
Expand Down
1 change: 1 addition & 0 deletions packages/g6/__tests__/demos/layout-mindmap-h.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export const layoutMindmapH: TestCase = async (context) => {
layout: {
type: 'mindmap',
direction: 'H',
preLayout: false,
getHeight: () => {
return 16;
},
Expand Down
15 changes: 7 additions & 8 deletions packages/g6/__tests__/demos/transform-place-radial-labels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ export const transformPlaceRadialLabels: TestCase = async (context) => {
labelText: (d) => d.id,
},
},
layout: [
{
type: 'dendrogram',
radial: true,
nodeSep: 30,
rankSep: 200,
},
],
layout: {
type: 'dendrogram',
radial: true,
nodeSep: 30,
rankSep: 200,
preLayout: false,
},
transforms: ['place-radial-labels'],
});

Expand Down
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.
Loading

0 comments on commit 7726eca

Please sign in to comment.