I'm using a YIntervalRenderer and would like to enable tooltips on the high & low points.
I gather that they have not been implemented for this renderer, so I've been trying to work out how to do it, but am having difficulties understanding the process.
Following the logic in createScatterPlot(), I set up my renderer as:
YIntervalRenderer renderer = new YIntervalRenderer();
renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
but it seems I need more than that. Looking at XYLineAndShapeRenderer as an example I can't see what I'm missing?
Adding tooltips to YIntervalRenderer
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: Adding tooltips to YIntervalRenderer
After checking the source, I think that this is a bug in the YIntervalRenderer class. The class is using the bounds of the line between the minimum and maximum y value as hot spot in which eventual mouse events are captured.
Since the bounds will be a mathematical line with either a height or a width of zero, the mouse can never really be within the bounds of the hot spot.
To fix that, you could try to change the line 242 (I am referring to the current JFreeChart version) of YIntervalRenderer and replace
with
I you have still trouble to hit the entity with the mouse, just use a larger value than 4.0f.
Since the bounds will be a mathematical line with either a height or a width of zero, the mouse can never really be within the bounds of the hot spot.
To fix that, you could try to change the line 242 (I am referring to the current JFreeChart version) of YIntervalRenderer and replace
Code: Select all
addEntity(entities, line.getBounds(), dataset, series, item, 0.0,
Code: Select all
addEntity(entities, ShapeUtilities.createLineRegion(line,4.0f), dataset, series, item, 0.0,
Re: Adding tooltips to YIntervalRenderer
That worked, thanks very much!
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
Re: Adding tooltips to YIntervalRenderer
I committed this fix for inclusion in the upcoming 1.0.20 release.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program