Click event resets chart orientation

Share RGraph:   Share or Like RGraph on Facebook!

« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by Argie on 3rd December 2013
Hi, I have a problem with click events resetting the orientation of donut charts after using RotateCanvas function. I need the charts to remain in their set orientations. Can you help?

Here's the fiddle: jsfiddle.net/argie/uEEFN/1/

Regards,
Argie
Posted by RGraph support on 4th December 2013
Hi there,

Charts shouldn't lose their rotate/scale/translate status from just a click - like this example:

www.rgraph.net/fiddle/view/a-pie-chart-using-rotatecanvas

But regardless - what you can do is put the rotate inside an onbeforedraw event:

myDonut.onbeforedraw = function (obj)
{
     // Put the RotateCanvas function here
}





Richard, RGraph Support
Posted by Argie on 4th December 2013
Hi, thanks for the reply!

It seems the problem boils down to using RotateCanvas multiple times on multiple charts on a single canvas. A click then, even outside the canvas, kind of undoes the former RotateCanvas calls and sets the rotation of the respective charts align with the chart that was last rotated.

So if you add another chart to your example canvas, this behavior should demonstrate:

var pie2 = new RGraph.Pie('cvs', data)
   .Set('variant', 'donut')
   .Set('chart.radius', 55);
   RGraph.RotateCanvas(pie2.canvas, 150, 150, 0 - (PI / 4));
   pie2.Draw();

I also tried putting the rotation inside an onbeforedraw event, but it kept rotating the charts over and over with every click, according to the parameters of the last rotation. I think this implies the charts are redrawn on click?

Regards,
Argie
Posted by RGraph support on 4th December 2013
Hi there,

Still OK:

www.rgraph.net/fiddle/view/a-pie-chart-using-rotatecanvas

Though the tooltips aren't positioned correctly because the canvas has been rotated.


Richard, RGraph Support
Posted by Argie on 4th December 2013
Hi,

thanks, but there's no second rotation in the revised example. I need to draw the charts in specific rotations. My use case is analogous to an analog clock. E.g. by default the first donut starts to draw at twelve o'clock if no rotation is made. If I need to start drawing the second donut from three o'clock I would rotate to that and then draw the chart. I'm using the clock metaphor to illustrate the start times of data sets collected within 12 hours. I don't need tooltips.

Regards,
Argie
Posted by RGraph support on 4th December 2013
Hi there,

If you can live without dynamic features completely you can rotate the canvas, draw the first chart, rotate again, and draw the second chart:

www.rgraph.net/fiddle/view/a-pie-chart-using-rotatecanvas

But if you include the dynamic library things will be redrawn when you click and the Pie will revert to whatever the current rotation state is. Also clicking won't work as the dynamic library is needed for that. It is possible to get click support without the dynamic library as can be seen from the example - but bbecause of the rotation the angles ill not be correct.

If you want I can add the angles.start option to the Pie chart as a "license holders customisation". The Rose chart has this, and with that you'll be able to stipulate the start angle instead of using the RotateCanvas() function.





Richard, RGraph Support
Posted by Argie on 5th December 2013
Hi,

I think this solution will do for now. I'll continue my experiments. I appreciate the help!

Regards,
Argie

Add a reply




« Back to message list