XYLineAndShapeRenderer help please.

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Rodney
Posts: 20
Joined: Mon Jun 02, 2003 4:17 am
Location: Adelaide, Australia

XYLineAndShapeRenderer help please.

Post by Rodney » Mon Jun 07, 2004 7:22 am

Can someone guide me in the right direction with the following code?

XYItemRenderer r = plot.getRenderer();
if (r instanceof XYLineAndShapeRenderer) {
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;

The plot is an XYPlot for a TimeSeriesCollection. It works if I replace XYLineAndShapeRenderer with StandardXYItemRenderer (as in the developers guide), but they both implement XYItemRenderer, so I don't see what the difference is.

I need to use the XYLineAndShapeRenderer cause I want to have some series with just shapes and other with just lines.

Any help would be greatly appreciated as it's driving me insane!

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 » Mon Jun 07, 2004 10:08 am

If you created a time series chart, the renderer will be a StandardXYItemRenderer. You can *replace* it with an XYLineAndShapeRenderer like this:

Code: Select all

XYPlot plot = (XYPlot) chart.getPlot();
XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
plot.setRenderer(renderer);
For later reference, I've added a "Usage" section to the XYLineAndShapeRenderer entry in the JFreeChart Developer Guide, with the above code example.
David Gilbert
JFreeChart Project Leader

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

Rodney
Posts: 20
Joined: Mon Jun 02, 2003 4:17 am
Location: Adelaide, Australia

Post by Rodney » Tue Jun 08, 2004 7:34 am

CHeers, works like a charm. :D

Locked