Split cytoscape

This commit is contained in:
Sidharth Vinod 2023-02-16 15:21:45 +05:30
parent ea7aaa5d56
commit f81f9f7c95
No known key found for this signature in database
GPG Key ID: FB5CCD378D3907CD
2 changed files with 10 additions and 7 deletions

View File

@ -186,7 +186,7 @@ export const addVertices = function (vert, svgId, root, doc, diagObj, parentLook
default:
_shape = 'rect';
}
// // Add the node
// Add the node
const node = {
labelStyle: styles.labelStyle,
shape: _shape,

View File

@ -4,13 +4,9 @@ import { log } from '../../logger';
import { getConfig } from '../../config';
import { setupGraphViewbox } from '../../setupGraphViewbox';
import svgDraw from './svgDraw';
import cytoscape from 'cytoscape';
import coseBilkent from 'cytoscape-cose-bilkent';
import * as db from './mindmapDb';
// Inject the layout algorithm into cytoscape
cytoscape.use(coseBilkent);
let cytoscape;
/**
* @param {any} svg The svg element to draw the diagram onto
* @param {object} mindmap The mindmap data and hierarchy
@ -93,7 +89,14 @@ function addNodes(mindmap, cy, conf, level) {
* @param conf
* @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) => {
// Add temporary render element
const renderEl = select('body').append('div').attr('id', 'cy').attr('style', 'display:none');