I am using interval marker to mark a region of [a,b] on the x axis. I need to do two things now: 1.) I need to add tool-tip for the region, i.e. if a user hovers on any area of plot between [a,b] values of x, I should be able to display the tool-tip. As, I understand, I can do this by detecting the coordinates of mouseover and checking if they lie between [a,b] and accordingly display. But isn't there any property of interval marker itself or some other way to do it?
2.) I need to add the label to the region. I did that using setLabel(). But it displays the label horizontally. I want the label vertically. I searched a bit and found the suggestion of adding XYTextAnnotation or over-riding the drawDomainMarker() function of the plot's renderer. I tried with the former approach (Annotation), the annotations don't appear at correct x-values. But when I zoom in my chart, they are on correct place. Why is this happening when the interval marker is able to draw the intervals properly at correct places?
Please feel free to correct above.
Thanks
Tooltip in Interval Marker- JFreeChart
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: Tooltip in Interval Marker- JFreeChart
Both issues can be resolved by using a custom annotation. Here is a link to a forum thread with a description of some annotation classes that behave similarly to markers but offer more features.
Re: Tooltip in Interval Marker- JFreeChart
Okay. Thanks. I'm looking for the various annotation classes and get a feel that second issue can be resolved by that. But how the first issue can be fixed using these classes?
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: Tooltip in Interval Marker- JFreeChart
In this thread, I have posted a code example. RUn that and move the mouse over the range annotation labelled "Range interval" that goes from 50 to 100 along the y axis. You should see a tool tip. The text can be changed by usingh a different string as parameter for the setToolTipText-method.