1

I am using Javascript Infovis toolkit(JIT) and want to change the shape of a node to some image.. How can I do that? The default shape is circle and it can be changed further to rectangle, square, ellipse etc but in my case, I need to change it into an image present at my local disc drive.

They say its possible to do so in the 'type' field but what all methods do we need to add or see the impact on...?? See the below link:

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

And how exactly can we do it?

Help please...

nwalke
  • 3,170
  • 6
  • 35
  • 60
raghav
  • 31
  • 6

1 Answers1

0

There's a good group message here 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&

If you want to implement the node type for forcedirected graphs, go to your jit file and go to ForceDirected.Plot.NodeTypes

this is my code, but the labels still are jumpy when I try to pan.

'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); 
                } 
         },
Alex
  • 11
  • 1