Page 1 of 1

Cursor Tool

Posted: Mon Oct 07, 2013 4:22 pm
by 15355183
I Initialize the cursor Tool:

Code: Select all

cursorTool = new CursorTool(this.getChart());
cursorTool.setActive(false);
cursorTool.setFollowMouse(true);
cursorTool.setStyle(CursorToolStyle.VERTICAL);
cursorTool.getPen().setStyle(DashStyle.SOLID); 
When the user clicks on the graph (mouseClicked MouseEvent), then I enable the cursor tool:

Code: Select all

if(!cursorTool.getActive())
{
      cursorTool.setXValue(e.getX());   
      cursorTool.setActive(true);         
}
The issue that I'm having is that the vertical cursor line does not appear when the user clicks on the chart, but only after the user moves the mouse. Is there any way that the vertical line can show up upon a mouse click instead of a mouse movement once it's enabled?

Thanks

Re: Cursor Tool

Posted: Tue Oct 08, 2013 10:42 am
by yeray
Hello Turc,

Not the MouseEvent gives you the Mouse pointer position in pixels, through the getX()/getY() functions, while the CursorTool setXValue() function expects to receive a Value on the axis scale as a parameter.
So you gave to convert the e.getX() value to the Axis scale. This seems to work fine for me here:

Code: Select all

cursorTool.setXValue(tChart1.getAxes().getBottom().calcPosPoint(e.getX()));

Re: Cursor Tool

Posted: Tue Oct 08, 2013 12:48 pm
by 15355183
Thank you.