I have multiple axis, each can have multiple lines in them. I want to display a tooltip when the mouse is over the axis, with the chart lines as text in it. Better yet would be a legend box.
How can I achieve this? I can get the x/y coordinates of the mouse, even the axis itself that the mouse is over. But when I try showing e. g. a legend box like in the legend box tracking example, it doesn't work.
Just a guess: is it possible that the drawarea isn't created correctly when the mouse isn't over the plotarea?
Simple example which draws a black rectangle at the mouse position:
private void trackBoxLegend(XYChart c, int mouseX, int mouseY)
{
DrawArea d = c.initDynamicLayer();
int boxLeft = mouseX;
int boxRight = mouseX+100;
int boxTop = mouseY;
int boxBottom = mouseY+100;
d.rect(boxLeft, boxTop, boxRight, boxBottom, 0x000000, Chart.Transparent);
}
It works in the trackcursorlistener, when the mouse is over the plotarea. Doesn't work when invoked in a mousemotionlistener.
Thank you very much for the help! |