How to change the legend shapes with a LineAndShapeRenderer

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
itai.marko
Posts: 10
Joined: Mon Jun 22, 2009 2:42 pm

How to change the legend shapes with a LineAndShapeRenderer

Post by itai.marko » Sun Jun 28, 2009 10:51 am

Hi,
I have a line chart created with ChartFactory.createLineChart().
I'm trying to set the legend shapes to be filled squares without any lines through it.
code like:

Code: Select all

CategoryPlot plot = (CategoryPlot) chart.getPlot();
LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
renderer.setBaseLegendShape(new Rectangle2D.Double(-4.0, -4.0, 4.0, 4.0));
will only set the line shapes to be empty squers and will erase the lines only if the square is big enough to cover the line (which is too big).


In a chart created with ChartFactory.createXYLineChart(), code like:

Code: Select all

XYPlot plot = (XYPlot) chart.getPlot();
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
renderer.setLegendLine(new Rectangle2D.Double(-4.0, -4.0, 4.0, 4.0));
renderer.setBaseLegendShape(new Rectangle2D.Double(-4.0, -4.0, 4.0, 4.0));
will do the work.

How do I get the squares filled and how do I get rid of the lines?

Locked