vis.js setOptions to change color on network node

不问归期 提交于 2019-12-06 07:31:32

For the Network, I believe colors are handled such that you can specify default color properties via the Network options, but if you also provide color properties for individual nodes in that network, those node-specific color properties will always override any defaults you set.

So that's why this isn't working for you -- on click events you're attempting to change the Network default color properties, but those changes will always be ignored due to your nodes having their own color superseding properties.

Take a look at http://jsfiddle.net/9knw26nc/1/

  var nodeID = params['nodes']['0'];
  if (nodeID) {
    var clickedNode = nodes.get(nodeID);
    clickedNode.color = {
      border: '#000000',
      background: '#000000',
      highlight: {
        border: '#2B7CE9',
        background: '#D2E5FF'
      }
    }
    nodes.update(clickedNode);
  }

Just simplified your example, but I'm changing the node color properties directly for the clicked node by updating the DataSet to reflect that.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!