Split cytoscape
This commit is contained in:
parent
ea7aaa5d56
commit
f81f9f7c95
|
@ -186,7 +186,7 @@ export const addVertices = function (vert, svgId, root, doc, diagObj, parentLook
|
||||||
default:
|
default:
|
||||||
_shape = 'rect';
|
_shape = 'rect';
|
||||||
}
|
}
|
||||||
// // Add the node
|
// Add the node
|
||||||
const node = {
|
const node = {
|
||||||
labelStyle: styles.labelStyle,
|
labelStyle: styles.labelStyle,
|
||||||
shape: _shape,
|
shape: _shape,
|
||||||
|
|
|
@ -4,13 +4,9 @@ import { log } from '../../logger';
|
||||||
import { getConfig } from '../../config';
|
import { getConfig } from '../../config';
|
||||||
import { setupGraphViewbox } from '../../setupGraphViewbox';
|
import { setupGraphViewbox } from '../../setupGraphViewbox';
|
||||||
import svgDraw from './svgDraw';
|
import svgDraw from './svgDraw';
|
||||||
import cytoscape from 'cytoscape';
|
|
||||||
import coseBilkent from 'cytoscape-cose-bilkent';
|
|
||||||
import * as db from './mindmapDb';
|
import * as db from './mindmapDb';
|
||||||
|
|
||||||
// Inject the layout algorithm into cytoscape
|
let cytoscape;
|
||||||
cytoscape.use(coseBilkent);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {any} svg The svg element to draw the diagram onto
|
* @param {any} svg The svg element to draw the diagram onto
|
||||||
* @param {object} mindmap The mindmap data and hierarchy
|
* @param {object} mindmap The mindmap data and hierarchy
|
||||||
|
@ -93,7 +89,14 @@ function addNodes(mindmap, cy, conf, level) {
|
||||||
* @param conf
|
* @param conf
|
||||||
* @param cy
|
* @param cy
|
||||||
*/
|
*/
|
||||||
function layoutMindmap(node, conf) {
|
async function layoutMindmap(node, conf) {
|
||||||
|
if (!cytoscape) {
|
||||||
|
cytoscape = (await import('cytoscape')).default;
|
||||||
|
const coseBilkent = (await import('cytoscape-cose-bilkent')).default;
|
||||||
|
// Inject the layout algorithm into cytoscape
|
||||||
|
cytoscape.use(coseBilkent);
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
// Add temporary render element
|
// Add temporary render element
|
||||||
const renderEl = select('body').append('div').attr('id', 'cy').attr('style', 'display:none');
|
const renderEl = select('body').append('div').attr('id', 'cy').attr('style', 'display:none');
|
||||||
|
|
Loading…
Reference in New Issue