How to rotate a bar through aroung the starting point?
I want to rotate the green rect bar to point to the center of the circle how to do it.
The code below is how I draw the rect.
downNode = downNode
.data(_nodes)
.attr("id", function (d, i) {
return "nodeDown" + d.dbId;
})
.enter()
.append("rect")
.attr("class", "node").attr("class","downExpressed")
.attr("x", function (d) {
return Math.sin( Math.PI - (Math.max(0, Math.min(2 * Math.PI, x(d.dx)))+ Math.max(0, Math.min(2* Math.PI, x(d.dx + d.d_dx)))) / 2 ) * Math.max(0, y(d.dy+ d.d_dy)); })
.attr("height", function (d) {
var thea = Math.max(0, Math.min(2 * Math.PI, x(d.dx + d.d_dx))) - Math.max(0, Math.min(2 * Math.PI, x(d.dx)));
var r = Math.max(0, y(d.dy));
return Math.min(r * thea, Math.floor(_this.maxLevel));})
.attr("y", function (d) {
return Math.cos(Math.PI - (Math.max(0, Math.min(2 * Math.PI, x(d.dx)))+ Math.max(0, Math.min(2 * Math.PI, x(d.dx + d.d_dx)))) / 2) * Math.max(0, y(d.dy+ d.d_dy));})
.attr("width", function (d) {
return 1/2*Math.floor((d.expression.downs.length) / DownMax * ( Math.max(0, y(d.dy + d.d_dy)) - Math.max(0, y(d.dy)) ));
})
First I calculate the angle and r, and then get the x position through rcos(thea) y position rsin(thea);
but the result is not pointing to the center, I need to rotate it aroung the starting point of the rect bar.
Any suggestion, Thanks.