My charts are stockmarket charts but the question is general for JFreeChart.
It's really hard to raise a tooltip with the mouse. The charts have hundreds or thousands of entities, many of them only 1 pixel wide (OHLC bars, volume bars, dots from DotRenderer etc). Raising a tooltip is nearly impossible because it's so hard to get the mouse over the exact right pixel on a hi-res screen (1600 x 1200 pixels).
The standard process goes through an exact-match algorithm at EntityCollection.getEntity(x,y). It would be perfectly fine for my purposes if, whenever that returned nothing, a second search was done for an approximate match. I imagine something that enlarges the Shape rectangle of each entity by some delta in both x and y before comparing the entity to the mouse location, but otherwise works the same as the existing code. Other approaches to defining the match criteria might be acceptable too.
But I do not see any easy way to do this. If I wrote a subclass of StandardEntityCollection, or an alternate implementation of the EntityCollection interface, there is no way as far as I can see to get JFreeChart to use my version without actually editing and building JFreechart itself, which is more trouble than I would bother with.
Also, that approach would modify it for everything and I really only want to affect tooltips, but i can't find the place where the general code for handling mouse motion events calls specific code for tooltips.
I wonder if anyone else sees a better way to do this.
I'm using JFreeChart 1.0.14.
TIA/JG
Raising tooltips when mouse is not exactly over the entity
Re: Raising tooltips when mouse is not exactly over the enti
Upon further study, I see that the code I was looking at (in ChartPanel.mouseMoved etc)
has nothing to do with raising tooltip balloons. The tooltip stuff is all handed off to the
Java runtimes, so the matching code is entirely inaccessible and hardwired to do the exact
match. Oh well.
ChartPanel.mouseMoved provides a user-definable way to respond to mouse movement,
which I didn't know about. I can use that, and print the necessary info in some corner of
the chart, instead of raising a balloon, I guess.
/jg
has nothing to do with raising tooltip balloons. The tooltip stuff is all handed off to the
Java runtimes, so the matching code is entirely inaccessible and hardwired to do the exact
match. Oh well.
ChartPanel.mouseMoved provides a user-definable way to respond to mouse movement,
which I didn't know about. I can use that, and print the necessary info in some corner of
the chart, instead of raising a balloon, I guess.
/jg
Re: Raising tooltips when mouse is not exactly over the enti
You might want to take a look at TooltipChartPanel which has basic framework for generating the tooltips on-the-fly when needed (instead of creating all tooltip entities before rendering).
It had also a parameter for defining the hotspot radius.
See http://www.jfree.org/phpBB2/viewtopic.p ... 588#p69588, RoyW is the author
It had also a parameter for defining the hotspot radius.
See http://www.jfree.org/phpBB2/viewtopic.p ... 588#p69588, RoyW is the author
Re: Raising tooltips when mouse is not exactly over the enti
mkivinie,
Thanks, I'll have a look at that.
/jwg
Thanks, I'll have a look at that.
/jwg