【问题标题】:Change Node Shape in Javascript Infovis Toolit/ Force Directed Graph在 Javascript Infovis Toolkit/Force Directed Graph 中更改节点形状
【发布时间】:2012-01-28 10:18:57
【问题描述】:

我正在使用 Javascript Infovis 工具包 (JIT) 并希望将节点的形状更改为某个图像。我该怎么做?默认形状是圆形,可以进一步更改为矩形、正方形、椭圆等,但就我而言,我需要将其更改为本地磁盘驱动器上的图像。

他们说可以在“类型”字段中这样做,但是我们需要添加哪些所有方法或查看对...的影响? 请看以下链接:

http://thejit.org/static/v20/Docs/files/Options/Options-Node-js.html

我们究竟该怎么做呢?

请帮忙...

【问题讨论】:

    标签: javascript jit directed-graph infovis


    【解决方案1】:

    这里有一个很好的群消息https://groups.google.com/group/javascript-information-visualization-toolkit/tree/browse_frm/month/2010-10?_done=%2Fgroup%2Fjavascript-information-visualization-toolkit%2Fbrowse_frm%2Fmonth%2F2010-10%3F&

    如果要实现强制有向图的节点类型,请转到您的 jit 文件并转到 ForceDirected.Plot.NodeTypes

    这是我的代码,但当我尝试平移时标签仍然跳动。

    'icon': { 
                 'render': function(node, canvas){ 
                            var ctx = canvas.getCtx(); 
                            var img = new Image(); 
                            var pos = node.getPos(); 
                            img.onload = function() { 
                                    ctx.drawImage(img, pos.x-24, pos.y-24); 
                            }; 
                            img.src='../img/icon.png'; 
                    }, 
                    'contains': function(node,pos){ 
                            var npos = node.pos.getc(true); 
                            dim = node.getData('dim'); 
                            return this.nodeHelper.square.contains(npos, pos, dim); 
                    } 
             },
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-18
      • 2013-07-03
      • 2017-06-18
      • 1970-01-01
      • 1970-01-01
      • 2017-10-10
      • 1970-01-01
      • 2012-03-27
      相关资源
      最近更新 更多