I have a report that contains a pie chart within it. I would want the chart to be shown no matter if the query returns results or nothing at all. Typically you just need to do the plot.setNoDataMessage()
function, however since this is not exposed within iReport
, I did it within the Customizer
class just as the following:
CategoryPlot plot = (CategoryPlot) chart.getPlot();
plot.setNoDataMessage("No data available so we go into this really "
+ "long spiel about what that means and it runs off the end of the "
+ "line but what can you do about that!");
However when I run it with no data returning, it is giving me a blank page and iReport
pops up with "the document has no 开发者_JS百科pages".
Please advise.
Ok, I got an answer from elsewhere on this.
Normally if you are jfreechart
in Java, the above code would do.
But if you are doing it within iReport
, you have to find the property "When no data" in the root report level, set it to "All sections, no detail". Then your NoDataMessage
will be showing on the chart.
精彩评论