little circles at points in graph

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

little circles at points in graph

Post by Wim Deblauwe » Fri Dec 13, 2002 9:13 am

Hi,

how do I get little circles at the points of my graph? I use a TimeSeriesChart. I have 2 series in my dataset and I only want these little circles on my first series.

kind regards,

Wim

Wim Deblauwe

Re: little circles at points in graph

Post by Wim Deblauwe » Fri Dec 13, 2002 10:01 am

No need to worry, I've found it. Overriding the getShape() method in StandardXYItemRenderer did the trick for me.

However I did need to do things like this:

protected Shape getShape( Plot plot, int series, int item, double x, double y, double scale )
{
if (series != 0)
{
return new Ellipse2D.Double( x, y, 0, 0 );
}
return new Ellipse2D.Double( x - 0.5 * scale, y - 0.5 * scale, scale, scale );
}

because I only want circles for my first series, not for the others. If there is a better way, please let me know.

kind regards,

Wim

beth

Re: little circles at points in graph

Post by beth » Thu Jan 23, 2003 9:00 pm

how were you able to originally get the points to be plotted with markers at each for the TimeSeriesChart?

rahulb

Re: little circles at points in graph

Post by rahulb » Thu Jan 23, 2003 9:22 pm

I think you mean this:

//where chart is an instance of JFreeChart
XYPlot plot = chart.getXYPlot();
plot.setRenderer(
new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES)
);

that works for me on an a TimeSeriesChart.

David Gilbert

Re: little circles at points in graph

Post by David Gilbert » Fri Jan 24, 2003 10:33 am

Hi Rahulb,

Replacing the renderer, as you have done, is fine. You can also modify the existing renderer if you want to:

StandardXYItemRenderer renderer = (StandardXYItemRenderer) plot.getRenderer();
renderer.setPlotShapes(true);
renderer.setDefaultShapesFilled(true);

Regards,

Dave Gilbert

Locked