开发者

How to change the background color of JasperReports chart

The default background color of JasperReports chart is sky blue.

I want to change that background color.

How t开发者_开发问答o change it?


If you are using iReport select the charts properties and change the background property to the colour you desire.

If not in the XML for the chart there should be an xml tag called <itemLabel>.

Within this you can set the foreground and the background of the chart as seen bellow.

<itemLabel color="#000000" backgroundColor="#FFFFFF"/>


I had this problem. Contrary to even some of the official documentation, the itemLabel tag has no effect on the chart appearance.

Instead, to set the background colour of the entire chart area, create or change the backcolor attribute in the reportElement tag for your chart. E.g:

<barChart>
    <chart>
        <reportElement mode="Opaque" backcolor="#CCCCCC" x="0" y="0" width="400" height="400"/>
...

Note that the mode attribute must be set to "Opaque" for the colour to be rendered. If you are using iReport, you can of course change the colour by using the properties tab.

If you want to set the background colour for only the actual chart (area within the axes where the data is displayed), set the backcolor attribute within the plot element of your chart. E.g:

<barChart>
...
    <barPlot>
        <plot backcolor="#CCCCCC"/>
...

This does not feature on the properties tab, so you will need to edit the xml directly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜