I've been working on a Infovis toolkit project and though all functionality is done I haven't been able to finish the visuals. The Infovis toolkit API documentation is good but my custom node types don't work. I'm using a hypertree and I want make two different custom node types. One that's from an image and the other as a drawn path. All help is greatly appreciated, thanks!
EDIT: [ The solution I was trying turned out to be not so handy. Instead I used onCreateLabel() from the JIT controllers to customize the nodes with HTML. Saw a clear improvement in performance and got much more flexibility in customizing the nodes. ]
This is what I've come up with so far:
$jit.Hypertree.Plot.NodeTypes.implement({
'customNode': {
'render': function(node, canvas) {
var img = new Image();
img.src = "../icon.png";
var pos = node.pos.getc(true);
var ctx = canvas.getCtx();
ctx.drawImage(img, pos.x-15, pos.y-15);
/*
//...And an other one like this but drawn as a path
ctx.beginPath();
ctx.moveTo(pos.x-25, pos.y-15);
ctx.lineTo(25, -15);
ctx.lineTo(-35, 0);
ctx.closePath();
ctx.strokeStyle = "#fff";
ctx.fillStyle = "#bf5fa4";
ctx.fill();
ctx.stroke();*/
}
}
});