如何以编程方式在 Sigma.Js 中显示 overNode 标签

How to display overNode label in Sigma.Js programmatically?

本文关键字:Js 显示 overNode 标签 Sigma 编程 方式      更新时间:2023-09-26

我正在使用Sigma.Js库在我的Node.Js应用程序中显示图形可视化。

有一个overNode事件,当您将鼠标悬停在节点上时,该事件会在白色矩形中显示节点的标签。

我想在单击节点时显示此标签矩形,有人知道该怎么做吗?

这是解决方案:

  1. GitHub下载源代码(因为很难修改缩小版本)
  2. 在此路径中找到sigma.misc.bindEvents.js的文件:sigma.js-master'sigma.js-master'src'misc
  3. 使用良好的代码编辑器打开此文件(例如崇高的文本)。
  4. 导航到第 494
  5. 找到此代码:

绑定事件:

      captor.bind('click', onClick);
      captor.bind('mousedown', onMove);
      captor.bind('mouseup', onMove);
      captor.bind('mousemove', onMove);
      captor.bind('mouseout', onOut);
      captor.bind('doubleclick', onDoubleClick);
      captor.bind('rightclick', onRightClick);
      self.bind('render', onMove);
  1. 将两个事件"click""move"更改为如下所示:

绑定事件:

      captor.bind('click', onMove);
      captor.bind('mousedown', onMove);
      captor.bind('mouseup', onMove);
      //captor.bind('mousemove', onMove);
      captor.bind('mouseout', onOut);
      captor.bind('doubleclick', onDoubleClick);
      captor.bind('rightclick', onRightClick);
      self.bind('render', onMove);
  1. 保存您的 JS 文件 ,现在尝试例如在浏览器中测试sigma.js-master'sigma.js-master'examples'basic.html

下面是一个示例