TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
-
Turc
- Newbie
![Newbie Newbie](./images/ranks/1star.gif)
- Posts: 34
- Joined: Wed Feb 03, 2010 12:00 am
Post
by Turc » Mon Oct 07, 2013 4:22 pm
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
-
Yeray
- Site Admin
![Site Admin Site Admin](./images/ranks/6stars.gif)
- Posts: 9570
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
Post
by Yeray » Tue Oct 08, 2013 10:42 am
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()));
-
Turc
- Newbie
![Newbie Newbie](./images/ranks/1star.gif)
- Posts: 34
- Joined: Wed Feb 03, 2010 12:00 am
Post
by Turc » Tue Oct 08, 2013 12:48 pm
Thank you.