如何使用分层网络将节点的显示居中

时间:2019-08-12 10:14:44

标签: vis.js

我有一个分层的节点网络,目前看起来像这样:

https://i.imgur.com/JGt5cKK.png

我希望它看起来更像这样,因为它们居中:

https://i.imgur.com/Q3wUNoy.png

我的网络选项配置当前为:

const graphOptions = {
    autoResize: true,
    height: '100%',
    width: '100%',
    locale: 'en',
    clickToUse: false,
    configure: {
        enabled: true,
        showButton: true
    },
    interaction: {
        selectConnectedEdges: false
    },
    nodes: {
        margin: { top: 20, right: 20, bottom: 20, left: 20},
        color: '#68b9feb3',
        borderWidth: 2,
        widthConstraint: { maximum: 320 },
        font: {
            face: "verdana",
            size: 30
        },
        shape: 'box',
        shapeProperties: {
            "borderDashes": false,
            "borderRadius": 16
        },
        shadow: {
            "enabled": true
        }
    },
    physics: {
        enabled: false,
    },
    layout: {
        improvedLayout:true,
        hierarchical: {
            enabled: true,
            nodeSpacing: 400,
            blockShifting: false,
            edgeMinimization: false,
            levelSeparation: 200,
            parentCentralization: true,
            sortMethod: 'directed',
            direction: 'UD',        // UD, DU, LR, RL
        }
    },
    manipulation : {
        enabled : true,
        initiallyActive : true,
        addNode : false
    }
}

关于如何做到这一点的任何想法?

0 个答案:

没有答案