Tooltip in Interval Marker- JFreeChart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).

Tooltip in Interval Marker- JFreeChart

Postby ekta1994 » Tue Dec 05, 2017 5:58 am

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
ekta1994
 
Posts: 26
Joined: Fri May 12, 2017 8:06 am

Re: Tooltip in Interval Marker- JFreeChart

Postby paradoxoff » Tue Dec 05, 2017 12:40 pm

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.
paradoxoff
 
Posts: 1619
Joined: Sat Feb 17, 2007 1:51 pm

Re: Tooltip in Interval Marker- JFreeChart

Postby ekta1994 » Wed Dec 06, 2017 8:15 am

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?
ekta1994
 
Posts: 26
Joined: Fri May 12, 2017 8:06 am

Re: Tooltip in Interval Marker- JFreeChart

Postby paradoxoff » Wed Dec 06, 2017 7:50 pm

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.
paradoxoff
 
Posts: 1619
Joined: Sat Feb 17, 2007 1:51 pm


Return to JFreeChart

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 13 guests