itchytoes Posted March 26, 2008 Share Posted March 26, 2008 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 More sharing options...
lucianc Posted March 26, 2008 Share Posted March 26, 2008 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 More sharing options...
itchytoes Posted March 27, 2008 Author Share Posted March 27, 2008 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 More sharing options...
lucianc Posted March 27, 2008 Share Posted March 27, 2008 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 customizerCode: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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now