How to change the background color of JasperReports chart - jasper-reports

The default background color of JasperReports chart is sky blue.
I want to change that background color.
How to 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.

Related

Can you set a responsive sx value for one breakpoint and not others?

Is it possible to use the sx property to set a value for one responsive breakpoint, but not touch that property for other breakpoints?
For example, I want a box with the color set to red on extra-small and small displays, and blue on medium and larger displays. I could do this:
<Box sx={{color: {xs:'red', md:'blue'}}}>
Hello, world
</Box>
But let's say I don't want blue on medium and larger displays. For those sizes, I want the box to behave as if I hadn't specified the property at all. Let the component pull that value from the theme or wherever it would normally get it from.
This doesn't work:
<Box sx={{color: {xs:'red', md:undefined}}}>
Hello, world
</Box>
Neither does md:null, or md:'initial'.
I'm not looking for a color specific solution, either. I'm trying to find the general pattern I could use for setting any sx property for a smaller breakpoint, without touching it for a larger one.

Jasper Reports 5: Title Band, how to create a footer?

i have a title band. my report is landscape 595 by 842. i simply want the title band to take up a full page and be able to add text to the very bottom of that title page/band.
i have tried position fix relative to bottom. it still floats up. i have tried making the title band 559 high (with 36 top margin to make 595). that works except there is tons of white space and so if something on the title expands (dynamic data) the text at title page bottom breaks to second page.
Got it! Problem is that title band does not stretch, so fix relative to bottom does not work. Solution is to add a background band, height of report (minus margin). Then put page footer there, is will show on title and all other pages. Then add a blank page footer to save white space for the real footer in the background. done.
Why not use only the pageFooter and then if you only like it to display on first page use the printWhenExpression.
<pageFooter>
<band height="50">
<printWhenExpression><![CDATA[$V{PAGE_NUMBER}.intValue()==1]]></printWhenExpression>
<textField>
<reportElement x="0" y="0" width="100" height="20" uuid="dd4c229b-7453-4026-b01e-cfc325053335"/>
<textFieldExpression><![CDATA["You will only see me on first page"]]></textFieldExpression>
</textField>
</band>
</pageFooter>
Note the pageFooter will be present on every page (even if blank), this is the famous firstPageFooter request / tracker, but this seems not to be your case since you are already adding it later...

How to Hide lines after isPrintRepeatedValues="false" in Jasper reports

I have requirement to hide the line after setting a property isPrintRepeatedValues="false" and values is not repeated but the getting line.and check the below image and highlighted with red color arrow.
That is shouldn't come and USA will come central. Can i achive this requirement if possible?
You can use subreport for all fields exclude first field.
First field and subreport placed into frame with borders.
For first field set properties:
stretchType="RelativeToBandHeight"
verticalAlignment="Middle"
First field haven't borders.

Take sensitive frame with height of detail row

I try to border my bands in this way:
But I have a text field of my row detail with property isStretchWithOverflow="true"
In this way when I try to print my report, on the rows with overflowed text field, I've a discontinue on my border (white space instead draw line of frame).
Very simple.
I've added this property stretchType="RelativeToTallestObject" on my frame object.
So the line has not discontinuity.

JasperReports text field stretching - can stretch height be limited?

I've got the following problem with a JasperReports subreport that I've been trying to solve for the past couple of days with no success. Below is an image of what I'm trying to do.
I've got a subreport in one of my reports that is relatively simple. Its got a title band with a single text field (marked brown in the image) for the subreport title and a detail band with two items: a subreport (marked blue in the image) printing my line items and a text field (marked red in the image) printing the comments associated with the line items printed to the left of it. The line item subreport can print a variable number of line items (datasource backed by a bean collection). My customers requirement is that the comments field stretches and shows the text entered, but be limited by the height of the line item section (represented by the arrows on the image). I somehow need to prevent the comments from stretching beyond the line items and make them of equal height (there should be no green box in the image).
Does anyone have any tips how this could be (and can it at all be) achieved in JasperReports?
p.s.
We are currently compiling our reports with JR version 3.6
Put both the subreport and the text field into a frame. For the text field, set "Stretch with overflow" to false and "Stretch type" to "Relative to tallest object"
The text field will stretch relative to the tallest object in it's container. It's container is now the frame, so the "tallest object" can only be the subreport. Make sure the elements are the same height when you define them, otherwise they will grow at different rates.
JRXML sample:
<band height="50">
<frame>
<reportElement x="0" y="0" width="555" height="50"/>
<subreport>
<reportElement x="0" y="0" width="378" height="50"/>
...
</subreport>
<textField isStretchWithOverflow="false">
<reportElement stretchType="RelativeToTallestObject" x="378" y="0" width="177" height="50"/>
...
</textField>
</frame>
</band>