Skip to content

Commit

Permalink
Split cytoscape
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthv96 committed Feb 16, 2023
1 parent ea7aaa5 commit f81f9f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 9 additions & 6 deletions packages/mermaid/src/diagrams/mindmap/mindmapRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit f81f9f7

Please sign in to comment.