【问题标题】:Images with border not for all nodes in Vis.js带边框的图像不适用于 Vis.js 中的所有节点
【发布时间】:2017-12-27 21:00:55
【问题描述】:

我搜索了一个选项来使用 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
            }
        };
    }

但这被忽略了。

我怎样才能做到正确?

【问题讨论】:

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


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 2011-11-28
      • 1970-01-01
      • 2022-08-23
      • 1970-01-01
      • 2021-09-12
      • 2021-09-14
      • 2020-10-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多