【问题标题】:How to set the image size in Vis.js network graph如何在 Vis.js 网络图中设置图像大小
【发布时间】:2014-09-27 22:40:30
【问题描述】:

我正在使用 vis.js 构建网络图

问题是,如何使所有图像尺寸相同? (在此处查看实时示例 --> comparison of wordpress & drupal

这是图形代码:

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

【问题讨论】:

  • 您的 .png 文件开始时的尺寸是否都相同?
  • 对不起,我没有提到它.. 显然文件的大小不一样 :(
  • 我也有同样的问题,你解决了吗?

标签: javascript canvas d3.js data-visualization chap-links-library


【解决方案1】:

查找节点的大小属性。

例子

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

参考:http://visjs.org/docs/network/nodes.html

【讨论】:

  • 设置节点本身的大小,而不是节点内部的图像。
  • 由于节点类型是'image',这将起到改变图像大小的作用。
猜你喜欢
  • 2021-04-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-08-29
  • 2018-12-11
  • 1970-01-01
  • 2019-10-04
  • 1970-01-01
相关资源
最近更新 更多