Skip to content

Commit

Permalink
docs: add layout mds demo and test case
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcc committed Mar 8, 2024
1 parent 0d383f8 commit 0afb3de
Show file tree
Hide file tree
Showing 7 changed files with 3,077 additions and 69 deletions.
1 change: 1 addition & 0 deletions packages/g6/__tests__/demo/case/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ export * from './combo';
export * from './common-graph';
export * from './element-change-type';
export * from './graph-event';
export * from './layout-mds';
export * from './plugin-grid-line';
export * from './viewport-fit';
45 changes: 45 additions & 0 deletions packages/g6/__tests__/demo/case/layout-mds.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { Graph } from '@/src';
import data from '@@/dataset/cluster.json';
import type { STDTestCase } from '../types';

export const layoutMDS: STDTestCase = async (context) => {
const graph = new Graph({
...context,
padding: 20,
autoFit: 'view',
data,
layout: {
type: 'mds',
linkDistance: 100,
},
node: {
style: {
size: 20,
stroke: '#9ec9ff',
fill: '#eee',
lineWidth: 1,
labelText: (d: any) => d.id,
labelFontSize: 12,
labelPlacement: 'center',
labelBackground: false,
},
},
behaviors: ['drag-node', 'drag-canvas', 'zoom-canvas', 'click-select'],
});

await graph.render();

layoutMDS.form = (panel) => {
const config = {
linkDistance: 100,
};
return [
panel.add(config, 'linkDistance', 50, 120, 10).onChange((v: number) => {
graph.setLayout({ type: 'mds', linkDistance: v });
graph.layout();
}),
];
};

return graph;
};
Loading

0 comments on commit 0afb3de

Please sign in to comment.