简体   繁体   English

带HTML标签的Infovis-节点拖动不再起作用

[英]Infovis with Html label - node drag no longer working

I am using a html label for my nodes in a force directed graph. 我在力向图中为节点使用html标签。

Label:{
  type: 'HTML'
},

onCreateLabel: function (domElement, node) {
  domElement.innerHTML = node.name;
  var style = domElement.style;
  style.border = "1px solid red"
  style.fontSize = "1.5em";
  style.color = "#ddd";
},

onPlaceLabel: function (domElement, node) {
  var style = domElement.style;
  var left = parseInt(style.left);
  var top = parseInt(style.top);
  var w = domElement.offsetWidth;
  style.left = (left - w / 2) + 'px';
  style.top = (top + 30) + 'px';
  style.display = '';
}

This looks fine. 看起来不错。 However, when I try to move the nodes around the canvas...I am not able to. 但是,当我尝试在画布上移动节点时……我无法。 If place my mouse over a node, left click, and then drag, the whole graph moves -- not just the selected node. 如果将鼠标放在节点上,单击鼠标左键,然后拖动,整个图形将移动-而不仅仅是选定的节点。 The html is placed below the node, but I am still not able to drag any specific node around the canvas any more. html放置在该节点下方,但是我仍然无法在画布上拖动任何特定的节点。 Any idea how I can fix this? 知道我该如何解决吗?

As a temporary workaround, I ended up creating a transparent border for the label that extended up over the node (border-top: 150px solid transparent); 作为一个临时的解决方法,我最终为标签创建了一个透明的边框,该边框延伸到整个节点上(border-top:150像素纯透明)。 ...the border makes the node clickable. ...边框使节点可单击。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM