Frage

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?

War es hilfreich?

Lösung 2

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:

Andere Tipps

It looks like JasperReports is using a more prosaic BarPainter in it's ChartTheme, probably to accommodate destinations that handle gradients poorly.

This forum thread suggests applying the desired theme directly to the chart. The createLegacyTheme() method "returns a ChartTheme that doesn't apply any changes to the JFreeChart defaults. It, or something similar, might be worth a try:

StandardChartTheme.createLegacyTheme().apply(chart)
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top