Tooltip problem with XYLineAndShapeRenderer

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

Tooltip problem with XYLineAndShapeRenderer

Postby stu » Thu May 22, 2008 10:12 am

I have a chart that uses XYLineAndShapeRenderer and plots a series a points with custom shapes like this:
Code: Select all
renderer.setSeriesShape(0, new Rectangle2D.Double(-3, -3, 6, 6));

Tooltips are then generated like this:
Code: Select all
renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
renderer.setURLGenerator(new StandardXYURLGenerator());

Everything works fine until a point is plotted that has a zero value on either axis. The point appears correctly, but no tooltip is generated so it is not clickable.

I thought the problem might because the zero point is only partially visible (since the shape is centered on zero and the axis starts at zero) so i fudged the shape to be:
Code: Select all
renderer.setSeriesShape(0, new Rectangle2D.Double(-6, -6, 6, 6));

This makes the entire shape visible (although no longer centered on the data point) but still a tooltip isn't generated.

Any help would be greatly appreciated
Posts: 10
Joined: Mon Aug 01, 2005 1:44 pm

Postby RoyW » Thu May 22, 2008 5:04 pm

This appears to be a bug in XYShapeRenderer.
In the method
The check to see if a symbol should be drawn is
Code: Select all
            if (shape.intersects(dataArea)) {

However the code to decide whether to generate an entity (and thus a tooltip) is
Code: Select all
        if (entities != null && dataArea.contains(xx, yy)) {

The problem is 0,0 gets translated and the Y value apperas to be equal to the max value of the data area. However Rectangle.contains() checks y >= 0 but y<max so it make is look like a point at Y value zero is not in the data area so the entity doesn't get added.
The answer does not come from thinking outside the box, rather the answer comes from realizing the truth; There is no Box. my js site
Posts: 93
Joined: Wed Apr 23, 2008 7:42 pm

Postby david.gilbert » Thu May 22, 2008 10:16 pm

Correct, it is a bug exactly as RoyW describes. I've added an entry in the bug database at SourceForge: ... tid=115494

It shouldn't be hard to fix this one.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Ask your company to buy the JFreeChart Developer Guide
:idea: Check out other products sold by my company Object Refinery Limited
JFreeChart Project Leader
Posts: 11600
Joined: Fri Mar 14, 2003 10:29 am

Postby stu » Fri May 23, 2008 9:02 am

Roy, David, thanks for the quick reply 8) I'll monitor the bug and retest when its fixed.
Posts: 10
Joined: Mon Aug 01, 2005 1:44 pm

Return to JFreeChart

Who is online

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