Line charts without shape

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

Line charts without shape

Post by Pat » Mon Feb 04, 2002 8:32 pm

I'm trying to drop the shapes from a line chart I've created. It looks like I need to change the default renderer, from what I'm reading, but I can't locate a good example of how to implement that. I've looked through the API, and even the source from the demo program. Any pointers?

David Gilbert

Re: Line charts without shape

Post by David Gilbert » Tue Feb 05, 2002 10:24 am

Hi Pat,

This would be easier if LinePlot had the following methods in it (which it will from the next version):

/**
* Returns the renderer for the plot.
* @return The renderer for the plot.
*/
public CategoryItemRenderer getRenderer() {
return this.renderer;
}

/**
* Sets the renderer for this plot.
* <P>
* For now, the LineAndShapeRenderer class is the only available renderer for the LinePlot
* class.
* @param renderer The new renderer.
*/
public void setRenderer(CategoryItemRenderer renderer) {

// check arguments...
if (renderer==null) {
throw new IllegalArgumentException("LinePlot.setRenderer(...): "
+"null not permitted.");
}

// make the change...
this.renderer = renderer;
notifyListeners(new PlotChangeEvent(this));

}

Then, you can do the following:

LinePlot plot = (LinePlot)chart.getPlot();
plot.setRenderer(new LineAndShapeRenderer(LineAndShapeRenderer.LINES));

Hope that helps,

DG.

Locked