使用iReport的JasperReports:setNoDataMessage不起作用 [英] JasperReports with iReport: setNoDataMessage not working
问题描述
我的报告中包含一个饼图。无论查询是返回结果还是什么都没有,我希望显示图表。通常你只需要执行 plot.setNoDataMessage()
函数,但是因为这不会在 iReport中公开
,我是在 Customizer
类中完成的,如下所示:
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!");
然而,当我在没有数据返回的情况下运行它时,它给了我一个空白页面和 iReport
弹出文档没有页面。
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 pages".
请指教。
推荐答案
好的,我从其他地方得到了答案。
Ok, I got an answer from elsewhere on this.
通常如果你 <$用Java编写的c $ c> jfreechart ,上面的代码就可以了。
Normally if you are jfreechart
in Java, the above code would do.
但是如果你在<$ c内做$ c> iReport ,您必须在根报表级别找到何时无数据属性,将其设置为所有部分,无详细信息。然后您的 NoDataMessage
将显示在图表上。
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.
这篇关于使用iReport的JasperReports:setNoDataMessage不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!