Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// restore the highlighted graph and hide the edges which are not tree edges.
graph.unhighlightGraph();
const edges = graph.getEdges();
Util.each(edges, edge => {
if (edge.isVisible() && !edge.getModel().isTreeEdge) {
edge.hide();
}
});
graph.draw();
}
}
});
}
}
G6.Plugins['template.maxSpanningForest'] = Plugin;
module.exports = Plugin;
if (nodes[i].getModel().x === undefined) return;
this.oriPos.set(nodes[i].id, { x: nodes[i].getModel().x, y: nodes[i].getModel().y });
}
} else if (ev.item.type !== 'node' || (ev.updateModel.x === undefined && ev.updateModel.y === undefined)) {
return;
} else {
this.oriPos.set(ev.originModel.id, { x: ev.updateModel.x, y: ev.updateModel.y });
}
}, 30);
// record the layout positions, in order to restore the positions after fisheye zooming
graph.on('afterchange', cacheLocation);
graph.on('afterlayout', cacheLocation);
}
}
G6.Plugins['tool.fisheye'] = Plugin;
module.exports = Plugin;
});
this.show(mask);
}
unhighlightGraph() {
// hide the mask
const itemGroup = this.getItemGroup();
// reset origin item children children zindex
// TODO: canvas render only. svg renderer will not work
const originChildren = this.originChildren;
originChildren && itemGroup.set('children', originChildren);
this.hide('mask');
}
}
G6.Plugins['tool.highlightSubgraph'] = Plugin;
module.exports = Plugin;
init() {
const graph = this.graph;
const minimap = new Minimap({
getGraph() {
return graph;
},
...this.options
});
minimap.bindGraph(graph);
this.minimap = minimap;
}
destroy() {
this.minimap.destroy();
}
}
G6.Plugins['tool.minimap'] = Plugin;
G6.Components.Minimap = Minimap;
module.exports = Plugin;
init() {
const graph = this.graph;
if (this.fisheye) {
const fisheye = new G6.Plugins['tool.fisheye']({
radius: 100
});
graph.addPlugin(fisheye);
}
if (this.textDisplay) {
const textDisplay = new G6.Plugins['tool.textDisplay']();
this.interactive && graph.addPlugin(textDisplay);
}
const freezeSize = new G6.Plugins['tool.freezeSize']();
graph.addPlugin(freezeSize);
graph.on('afteritemdraw', ({ item }) => {
const label = item.getLabel();
if (label) {
label.set('freezePoint', {
x: 0,
y: 0
});
}
});
graph.on('afterinit', () => {
const highlighter = new G6.Plugins['tool.highlightSubgraph']();
this.interactive && graph.addPlugin(highlighter);
};
switch (type) {
case 'Category':
return Scale.cat({
values: domain
});
default:
return Scale.linear(params);
}
}
destroy() {
this.legendCanvas && this.legendCanvas.destroy();
}
}
G6.Plugins['tool.mapper'] = Plugin;
module.exports = Plugin;
public setEvent() {
Object.keys(this.config.events || []).forEach((k) => {
const eventName = k.replace('on', '').toLocaleLowerCase();
this.graph.on(eventName, (ev: any) => {
this.config.events[k](ev, this.graph);
});
});
}
}
export const registerNode = G6.registerNode;
export const registerEdge = G6.registerEdge;
export const registerGuide = G6.registerGuide;
export const Layouts = G6.Layouts;
export const Util = G6.Util;
export const Plugins = G6.Plugins;
export const GlobalG6 = G6;
const zoom = graph.getZoom();
const type = this.type;
const lineWidth = type === 'line' ? 1 / zoom : 2 / zoom;
if (this.cell * zoom < 8 || this.cell * zoom > 32) {
this.cell = 16 / zoom;
}
gridEl.attr('lineWidth', lineWidth);
gridEl.attr('path', path);
}
destroy() {
const gridEl = this.gridEl;
gridEl && gridEl.remove();
}
}
G6.Plugins['tool.grid'] = Plugin;
module.exports = Plugin;
Util.each(freezeElements, freezeElement => {
const freezePoint = freezeElement.get('freezePoint');
const zoom = graph.getZoom();
if (freezeElement.isShape && freezePoint && freezeElement.get('visible')) {
freezeElement.resetMatrix();
freezeElement.transform([
[ 't', -freezePoint.x, -freezePoint.y ],
[ 's', 1 / zoom, 1 / zoom ],
[ 't', freezePoint.x, freezePoint.y ]
]);
}
});
}
}
G6.Plugins['tool.freezeSize'] = Plugin;
module.exports = Plugin;
const channel = this.channel;
const mapper = {};
mapper[channel] = model => {
if (itemType === 'node' && channel === 'size') {
return scale(model[dim]);
}
return scale(model[dim]);
};
graph[itemType](mapper);
}
destroy() {
this.legendCanvas && this.legendCanvas.remove();
}
}
G6.Plugins['tool.d3.mapper'] = Plugin;
module.exports = Plugin;