Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(data => {
const width = document.getElementById('container').scrollWidth;
const height = document.getElementById('container').scrollHeight || 500;
const graph = new G6.TreeGraph({
container: 'container',
width,
height,
pixelRatio: 2,
modes: {
default: [{
type: 'collapse-expand',
onChange: function onChange(item, collapsed) {
const data = item.get('model').data;
data.collapsed = collapsed;
return true;
}
}, 'drag-canvas', 'zoom-canvas' ]
},
defaultNode: {
size: 26,
});
}
rect.attr({
x: bbox.minX - 4,
y: bbox.minY - 6,
width: bbox.width + (hasChildren ? 26 : 8),
height: bbox.height + 12
});
return rect;
}
}, 'single-shape');
const width = document.getElementById('container').scrollWidth;
const height = document.getElementById('container').scrollHeight || 500;
const graph = new G6.TreeGraph({
container: 'container',
width,
height,
modes: {
default: [{
type: 'collapse-expand',
onChange: function onChange(item, collapsed) {
const data = item.get('model');
const icon = item.get('group').findByClassName('collapse-icon');
if (collapsed) {
icon.attr('symbol', EXPAND_ICON);
} else {
icon.attr('symbol', COLLAPSE_ICON);
}
data.collapsed = collapsed;
return true;
}, {
id: 'SubTreeNode7'
}, {
id: 'SubTreeNode8'
}, {
id: 'SubTreeNode9'
}, {
id: 'SubTreeNode10'
}, {
id: 'SubTreeNode11'
}]
};
const width = document.getElementById('container').scrollWidth;
const height = document.getElementById('container').scrollHeight || 500;
const graph = new G6.TreeGraph({
container: 'container',
width,
height,
pixelRatio: 2,
linkCenter: true,
modes: {
default: [{
type: 'collapse-expand',
onChange: function onChange(item, collapsed) {
const data = item.get('model').data;
data.collapsed = collapsed;
return true;
}
}, 'drag-canvas', 'zoom-canvas' ]
},
defaultNode: {
.then(data => {
const width = document.getElementById('container').scrollWidth;
const height = document.getElementById('container').scrollHeight || 500;
const graph = new G6.TreeGraph({
container: 'container',
width,
height,
pixelRatio: 2,
modes: {
default: [{
type: 'collapse-expand',
onChange: function onChange(item, collapsed) {
const data = item.get('model').data;
data.collapsed = collapsed;
return true;
}
}, 'drag-canvas', 'zoom-canvas' ]
},
defaultNode: {
size: 26,
import G6 from '@antv/g6';
/**
* 该案例演示,当点击叶子节点时,如何向树图中动态添加数据。
* 主要演示addChild和refreshLayout的用法。
*/
const width = document.getElementById('container').scrollWidth;
const height = document.getElementById('container').scrollHeight || 500;
const graph = new G6.TreeGraph({
container: 'container',
width,
height,
pixelRatio: 2,
renderer: 'svg',
modes: {
default: [ 'collapse-expand', 'drag-canvas' ]
},
fitView: true,
layout: {
type: 'compactBox',
direction: 'LR',
defalutPosition: [],
getId: function getId(d) {
return d.id;
},
.then(data => {
const width = document.getElementById('container').scrollWidth;
const height = document.getElementById('container').scrollHeight || 500;
const graph = new G6.TreeGraph({
container: 'container',
width,
height,
pixelRatio: 2,
linkCenter: true,
modes: {
default: [{
type: 'collapse-expand',
onChange: function onChange(item, collapsed) {
const data = item.get('model').data;
data.collapsed = collapsed;
return true;
}
}, 'drag-canvas', 'zoom-canvas' ]
},
defaultNode: {
.then(data => {
const width = document.getElementById('container').scrollWidth;
const height = document.getElementById('container').scrollHeight || 500;
const graph = new G6.TreeGraph({
container: 'container',
width,
height,
pixelRatio: 2,
linkCenter: true,
modes: {
default: [{
type: 'collapse-expand',
onChange: function onChange(item, collapsed) {
const data = item.get('model').data;
data.collapsed = collapsed;
return true;
}
}, 'drag-canvas', 'zoom-canvas' ]
},
defaultNode: {
'zoom-canvas': {
type: 'zoom-canvas',
shouldUpdate: this.canDragOrZoomCanvas,
},
},
},
behaviorManager.getRegisteredBehaviors(GraphType.Mind),
);
Object.keys(modes).forEach(mode => {
const behaviors = modes[mode];
modes[mode] = Object.values(customModes ? customModes(mode, behaviors) : behaviors);
});
this.graph = new G6.TreeGraph({
container: containerId,
width,
height,
modes,
layout: {
type: 'mindmap',
direction: 'H',
getHGap: this.getHGap,
getVGap: this.getVGap,
},
animate: false,
defaultNode: {
shape: 'bizMindNode',
},
defaultEdge: {
shape: 'biz-cubic',
.then(data => {
const width = document.getElementById('container').scrollWidth;
const height = document.getElementById('container').scrollHeight || 500;
const graph = new G6.TreeGraph({
container: 'container',
width,
height,
pixelRatio: 2,
modes: {
default: [{
type: 'collapse-expand',
onChange: function onChange(item, collapsed) {
const data = item.get('model').data;
data.collapsed = collapsed;
return true;
}
}, 'drag-canvas', 'zoom-canvas' ]
},
defaultNode: {
size: 26,
.then(data => {
const width = document.getElementById('container').scrollWidth;
const height = document.getElementById('container').scrollHeight || 500;
const graph = new G6.TreeGraph({
container: 'container',
width,
height,
pixelRatio: 2,
modes: {
default: [{
type: 'collapse-expand',
onChange: function onChange(item, collapsed) {
const data = item.get('model').data;
data.collapsed = collapsed;
return true;
}
}, 'drag-canvas', 'zoom-canvas' ]
},
defaultNode: {
size: 26,