Jump to content
We've recently updated our Privacy Statement, available here ×

yet another charting question


itchytoes

Recommended Posts

Hi --

 

<linePlot> has a "isShowLines" attribute. Does anyone know where that ends up under JFreeChart, and is it changeable on a chart series basis? I would like one of my linePlot series to have lines, but the remaining ones not to have lines.

 

Thanks

 

Betty

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

This is a quote from the source of JRFillChart.evaluateLineChart():

Code:

CategoryPlot categoryPlot = (CategoryPlot) chart.getPlot();
..
LineAndShapeRenderer lineRenderer = (LineAndShapeRenderer) categoryPlot.getRenderer();
..
lineRenderer.setLinesVisible(linePlot.isShowLines());

 

If you want to set the flag per series, you will have to write a chart customizer and do lineRenderer.setSeriesLinesVisible(..).

 

Regards,

Lucian

Link to comment
Share on other sites

Hi --

 

Thanks for the reply. On further investigation, I did find the LineAndShapeRenderer calls in the jfreechart API and I thought I solved my problem. But alas, I fussed for hours and no matter what I did, the setSeriesLineVisible() seems to have no effect whatsoever. The setLinesVisible() call does work, but it sets the state for all the lines. I really want this feature. I upgraded to the latest jfreechart 1.0.9 version and everything, and still no luck. I think I have to find the jfreechart forum somewhere and ask about it.

 

Betty

Link to comment
Share on other sites

Apparently the setLinesVisible that we are doing in JRFillChart acts as an override, so you'll have to reset it to null in order for setSeriesLinesVisible to become effective.

 

I've tested this solution with the following customizer

Code:

public class LineChartCustomizer extends JRAbstractChartCustomizer
{
public void customize(JFreeChart chart, JRChart jasperChart)
{
CategoryPlot categoryPlot = (CategoryPlot) chart.getPlot();
LineAndShapeRenderer lineRenderer = (LineAndShapeRenderer) categoryPlot.getRenderer();

Boolean override = lineRenderer.getLinesVisible();
if (override != null) {
lineRenderer.setLinesVisible(null);
lineRenderer.setBaseLinesVisible(override.booleanValue());
}

lineRenderer.setSeriesLinesVisible(0, true);
}
}

and it worked fine, i.e. lines were rendered for the first series only (the chart had isShowLines="false"). I used JFreeChart 1.0.0, but I guess it should work with 1.0.9 as well.

 

It might make more sense for JRFillChart to do setBaseLinesVisible instead of setLinesVisible; please log this as a bug/enhancement if you think this would help.

 

Regards,

Lucian

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...