g6/packages/site/examples/tool/toolbar/demo/toolbar.ts
pomelo 339f28c564
feat: fix plugin demo with extensions (#4885)
* feat: fix plugin demo with extensions

* Chore:check translate (#4886)

* feat: check plugins

* chore: update docs
2023-08-31 01:43:08 +08:00

28 lines
604 B
TypeScript

import { Graph as BaseGraph, Extensions, Util, extend } from '@antv/g6';
const Graph = extend(BaseGraph, {
plugins: {
toolbar: Extensions.Toolbar,
},
});
const container = document.getElementById('container') as HTMLElement;
const width = container.scrollWidth;
const height = (container.scrollHeight || 500) - 110;
const data = Util.mock(6).circle();
const layout = {
type: 'grid',
};
new Graph({
container: 'container',
width,
height,
data,
layout,
modes: {
default: ['drag-canvas', 'drag-node', 'zoom-canvas'],
},
plugins: [{ type: 'toolbar', key: 'toolbar-1' }],
});