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

Chart not rendering as it should


manuatilomb
Go to solution Solved by manuatilomb,

Recommended Posts

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:

graph1(1).png.6e5964381c024eb6624d2bceeff58de3.png

But recently it outputed this beauty:

graph2(1).png.20f72724ac15e86be1dc355bbf27b23d.png

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

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted Images

  • Solution

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

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...