Search code examples
jasper-reportsjfreechartappearance

JFreeChart charts appearance when combined with JasperReports


I use JFreeChart in my java application to display charts like this one: enter image description here

But after creating a report with JasperReports that chart now looks like this: enter image description here

And that's not all, this is how a chart looks like inside the first PDF report generated with the app: first report

And this is how it looks when I generate a second report, without changing anything, just generating it again: second report

This happens again and again, everytime I restart the application. Charts are ok until I create a report. What's happening?


Solution

  • I've moved the edits here as an answer:

    The theme problem

    Thanks to @trashgod I've tried the following line:

    ChartFactory.setChartTheme(StandardChartTheme.createJFreeTheme());
    

    If I use this line before creating charts in my application, reports no longer affect the appearance of them. I think it is enough to put this line just once after report creation.

    So now I just have one problem: the first report is different from subsequent reports: charts are different, fonts are bolder and not antialiased...

    The Problem of the second report

    The pdf issue is not caused by jasper reports nor jfreechart. It is a problem of Adobe Reader. This happens when you have more than one instance of Adobe Reader running (for example, when you have two different files opened).
    An example of the problem: enter image description here Similar issues: