-->

How to set the image size in Vis.js network graph

2019-05-11 05:28发布

问题:

I am building a network graph using vis.js

The problem is, how do I make all the images the same size? (see live example here --> comparison of wordpress & drupal)

here's the graph code:

    var nodes = [];
    nodes.push({
        id: 7,
        shape: 'image',
        image: '/static/windows8_icons/PNG/Industry/circuit/circuit-26.png',
        label: 'sharepoint',
        widthMin: 20,
        widthMax: 20
    });
    edges.push({
        from: 1,
        to: 7,
        length: 100
    });

    var data = {
        nodes: nodes,
        edges: edges
    };

    var options = {
        smoothCurves: false,
        stabilize: false,
        nodes: {
            shape: 'image',
            radius: 24,
            fontSize: 18,
            widthMin: 20,
            widthMax: 20
        },
        edges: {
            width: 2
        }
    };
    network = new vis.Network(container, data, options);

回答1:

Go for size attribute of node.

Example

nodes:{shape:'image',size:20}

Reference: http://visjs.org/docs/network/nodes.html