带边框的图像不适用于Vis.js中的所有节点

时间:2017-04-18 09:45:34

标签: javascript vis.js vis.js-network

我搜索一个选项,将VisJS网络图与带边框的选项图像一起使用,如下例所示:

http://visjs.org/examples/network/nodeStyles/imagesWithBorders.html

但不适用于所有图像。

我尝试附加应该获得边框的节点的设置

 if(some expression){
        aService.shapeProperties = {useBorderWithImage:true};
        aService.nodes =  {
            borderWidth:100,
                size:50,
                color: {
                border: '#ff0000',
                    background: '#ff0000'
            },
            shapeProperties: {
                useBorderWithImage:true
            }
        };
    }

但这被忽略了。

我该怎么做?

1 个答案:

答案 0 :(得分:0)

您是否尝试在节点创建时直接设置节点选项?例如:

var nodes = new vis.DataSet();
var visNode = {id: 123, shape: 'image', image: 'person.png', borderWidth:    5, shapeProperties: { useBorderWithImage:true} };

nodes.update([visNode]);

虽然我自己没有在单个节点上做过这个,但我想它会起作用。顺便说一句,请注意borderWidth 100可能是一个太大的边框。您可能想先尝试使用少量数字-e.g. 5-,然后根据需要增加它。