problem with dotrenderer

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
ahury
Posts: 14
Joined: Tue Apr 24, 2007 3:20 pm

problem with dotrenderer

Post by ahury » Thu May 03, 2007 9:23 am

I make a scatter plot with urlgenerator like this:


jfreechart.getXYPlot().setDataset(0, datasetPoint);
jfreechart.getXYPlot().getRenderer().setToolTipGenerator(
toolTipGenerator);
jfreechart.getXYPlot().setRenderer(1,dotRenderer); jfreechart.getXYPlot().getRenderer().setURLGenerator(urlGenerator);

and I have a very nice and working graph butI want to reduce the width of the dot.
I add this code to make dots smaller

XYDotRenderer dotRenderer = new XYDotRenderer();
dotRenderer.setDotHeight(taillePoint); dotRenderer.setDotWidth(taillePoint); dotRenderer.setURLGenerator(urlGenerator);
jfreechart.getXYPlot().setRenderer(0,dotRenderer);

just before the line : jfreechart.getXYPlot().getRenderer().setURLGenerator(urlGenerator);

I indeed have a graph new with smaller points but I don't have URL anymore on every point.
Can anybody help me ?

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Thu May 03, 2007 9:37 am

The XYDotRenderer doesn't have any code to generate chart entities, which is required to support tooltips and URLs. Which renderer was your chart using before you switched to XYDotRenderer?
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

ahury
Posts: 14
Joined: Tue Apr 24, 2007 3:20 pm

Post by ahury » Thu May 03, 2007 10:15 am

it's an XYItemRenderer.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Thu May 03, 2007 10:32 am

Of course it is - XYItemRenderer is the *interface* that all renderers must implement. Which renderer *class* are you using?
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

ahury
Posts: 14
Joined: Tue Apr 24, 2007 3:20 pm

Post by ahury » Thu May 03, 2007 10:51 am

Its a LineAndShapeRenderer

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Thu May 03, 2007 11:24 am

Really? LineAndShapeRenderer does *not* implement XYItemRenderer.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

ahury
Posts: 14
Joined: Tue Apr 24, 2007 3:20 pm

Post by ahury » Thu May 03, 2007 11:38 am

If I want to make this code
XYDotRenderer dotRenderer=
(XYDotRenderer) jfreechart.getXYPlot().getRenderer();
I have this error
java.lang.ClassCastException: org.jfree.chart.renderer.xy.XYLineAndShapeRenderer.
that's why I say it was an XYLineAndShapeRenderer.
I don't create any renderer i think it's the renderer by default.. If there is one there!
In any case d I have no renderer in my import

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Thu May 03, 2007 12:02 pm

ahury wrote:that's why I say it was an XYLineAndShapeRenderer.
I wish you had. If you want smaller shapes with this renderer, why don't you try calling setSeriesShape(int, Shape) and specify the shape you want. Hint: the shape you specify should be centered on (0, 0), e.g. new Rectangle2D.Double(-1.0, -1.0, 2.0, 2.0).
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

ahury
Posts: 14
Joined: Tue Apr 24, 2007 3:20 pm

Thanks and another questions

Post by ahury » Thu May 03, 2007 1:20 pm

Thanks for your help I have an other question.
Is it possible to create an Y axis, which has his ticks increased all 500 and number label all 1000?

Locked