Hi:
I wanted to draw a vertical line in the HighLow chart whenever a user clicked on it. By calling setHorizontalAxisTrace(true) on a chartPanel object, I can have a vertical line which pretty much tracks my mouse. But, what I really wanted is that when I click on a chart, it draws a vertical line at that point but does not track the mouse movements.
I tried to add the code for this by having my application implement the ChartMouseListener interface and add the following code in the event handler.
public void chartMouseClicked(ChartMouseEvent event)
{
int x = event.getTrigger().getX();
int y = event.getTrigger().getY();
drawVerticalLine(x);
}
where drawVerticalLine does exactly what the private function, drawHorizontalAxisTrace() does in the ChartPanel class. ( I would have liked to call it but it is a private function)
However what I see is that the line is drawn when I click on the chart but it is immediately erased. Next time I click on a point in the graph, it draws a vertical line where I click and ALSO a line where I last clicked, but again immediately erased. It seems to me that the chart is automatically refreshing itself after a mouse click and erasing whatever is temporarily drawn. Is there a way to get around this?
- Himanshu
Drawing a vartical trace line on ChartMouseClicked event
Re: Drawing a vartical trace line on ChartMouseClicked event
The tracing lines are part of the ChartPanel. You probably need to use cross hairs, which is in the ValueAxis class. Try the setCrossHairVisible(boolean) method.
I have to say I've lost track of how both of these features work, when I get a chance I'll sit down and write up some documentation for them, and iron out some more bugs/inconsistencies.
Regards,
DG.
I have to say I've lost track of how both of these features work, when I get a chance I'll sit down and write up some documentation for them, and iron out some more bugs/inconsistencies.
Regards,
DG.
Re: Drawing a vartical trace line on ChartMouseClicked event
Hi David,
I tried to use the setCrossHairVisible(true) method, but somehow I did not see the cross-hair on either the horizontal axis or vertical axis. I do it before drawing the plot, just like in the
Do you know why?
- Himanshu
I tried to use the setCrossHairVisible(true) method, but somehow I did not see the cross-hair on either the horizontal axis or vertical axis. I do it before drawing the plot, just like in the
Do you know why?
- Himanshu