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
little circles at points in graph
Re: little circles at points in graph
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
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
Re: little circles at points in graph
how were you able to originally get the points to be plotted with markers at each for the TimeSeriesChart?
Re: little circles at points in graph
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.
//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.
Re: little circles at points in graph
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
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