Ivan Gasparetto
unread,May 1, 2012, 9:59:12 AM5/1/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to JavaScript InfoVis Toolkit
Hello,
I am using the RGraph and I need to create circles with a gradients,
so they look to be 3D spheres.
I have created a new node type called blob and I have implemented the
code as follows. However, the gradient is applied to the entire
canvas.
Not sure I could explain it, but is there anyone that can help?
$jit.RGraph.Plot.NodeTypes.implement({
'blob': {
render: function (node, canvas) {
var pos = node.pos.getc(true),
dim = node.getData("dim");
var ctx = canvas.getCtx();
var radgrad = ctx.createRadialGradient(0, 0, dim, 0, 0,
node.getPos().rho);
radgrad.addColorStop(0, '#A7D30C');
radgrad.addColorStop(0.9, '#019F62');
radgrad.addColorStop(1, 'rgba(1,159,98,0)');
ctx.fillStyle = radgrad;
this.nodeHelper.circle.render("fill", pos, dim, canvas)
},
contains: function (node, canvas) {
var pos = node.pos.getc(true),
dim = node.getData("dim");
return this.nodeHelper.circle.contains(pos, canvas, dim)
}
}
});
Many thanks
Ivan