mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-28 07:03:17 +08:00
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:
|
||||
_shape = 'rect';
|
||||
}
|
||||
// // Add the node
|
||||
// Add the node
|
||||
const node = {
|
||||
labelStyle: styles.labelStyle,
|
||||
shape: _shape,
|
||||
|
@ -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');
|
||||
|
Loading…
x
Reference in New Issue
Block a user