最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to set the image size in Vis.js network graph - Stack Overflow

programmeradmin1浏览0评论

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 --> parison 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);

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 --> parison 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);
Share edited Sep 17, 2014 at 9:07 laaposto 12.2k15 gold badges58 silver badges72 bronze badges asked Aug 5, 2014 at 9:55 NimoNimo 8,3147 gold badges43 silver badges41 bronze badges 3
  • are your .png files all the same dimensions starting out? – RandomDeduction Commented Aug 5, 2014 at 16:39
  • Sorry I didn't mention it.. Obviously the files are not the same size to begin with :( – Nimo Commented Aug 5, 2014 at 20:26
  • I have same problem, have you solved this problem? – Mochammad Taufiq Commented Nov 23, 2018 at 7:15
Add a ment  | 

1 Answer 1

Reset to default 3

Go for size attribute of node.

Example

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

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

发布评论

评论列表(0)

  1. 暂无评论