manuatilomb Posted February 29, 2016 Share Posted February 29, 2016 I have a sub-report with a time series line-chart, associated with a customizer that creates a second area-chart behind the line one, to make it more visually appealing.Normally it outputs something like this:But recently it outputed this beauty:I made a test with custom data, to see if I could force a similar result, and I could in fact reproduce it; the line-chart part works fine and is faithful to the data, but the area-chart part is sort-of-faithful, but not correct. Now, I don't know if that is a problem with the area part, that simply renders in certain way under certain info, or if it's a problem with the customizer class. Also, I don't know how to make it so it always render in the expected way.Here's the customizer method:public void customize(JFreeChart chart, JRChart jasperChart) { ItemRenderer areaRender=new XYAreaRenderer(); XYPlot plot=chart.getXYPlot(); XYDataset dataset=plot.getDataset(); plot.setDataset(1, dataset); plot.mapDatasetToRangeAxis(1,1); ValueAxis axis2=new NumberAxis(); axis2.setVisible(false); lineRender.setSeriesPaint(0, new Color(0,0,255)); lineRender.setSeriesPaint(1, new Color(0,255,0)); lineRender.setSeriesPaint(2, new Color(255,0,0)); areaRender.setBaseSeriesVisibleInLegend(false); areaRender.setSeriesPaint(0, new Color(0f,0f,1.0f,0.2f)); areaRender.setSeriesPaint(1, new Color(0f,1.0f,0f,0.2f)); areaRender.setSeriesPaint(2, new Color(1.0f,0f,0f,0.2f));}[/code] Link to comment Share on other sites More sharing options...
Solution manuatilomb Posted February 29, 2016 Author Solution Share Posted February 29, 2016 Solved. The problem was in the customizer class. Here's the final result:public void customize(JFreeChart chart, JRChart jasperChart) { XYItemRenderer areaRender=new XYAreaRenderer(); XYPlot plot=chart.getXYPlot(); XYDataset dataset=plot.getDataset(); plot.setDataset(1, dataset); plot.mapDatasetToRangeAxis(1,0); plot.setRenderer(1, areaRender); XYItemRenderer lineRender=plot.getRenderer(0); lineRender.setSeriesPaint(0, new Color(0,0,255)); lineRender.setSeriesPaint(1, new Color(0,255,0)); lineRender.setSeriesPaint(2, new Color(255,0,0)); areaRender.setBaseSeriesVisibleInLegend(false); areaRender.setSeriesPaint(0, new Color(0f,0f,1.0f,0.2f)); areaRender.setSeriesPaint(1, new Color(0f,1.0f,0f,0.2f)); areaRender.setSeriesPaint(2, new Color(1.0f,0f,0f,0.2f)); }[/code] 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