Chart with multiple series on each row
I am trying to make an iReport chart with this table
name|totalcalls|handled|abandoned|rejected
customerservice|300|100|100|100
itsupport|500|300|100|100
The idea is that in this case there should be 2 diagrams that can be solved easily by putting the diagram in the detail line.
But I can't figure out how to make iReport handle the 3 last columns (processed, abandoned, rejected) as different series.
Ideally, I want to make a complex velvet that looks like this:
customerservice|-100-|-100-|-100-
itsupport|---300---|-100-|100
I do not know how to do that.
source to share
For this you can use a glass breakdown histogram. Open iReport and drag a chart element from the palette to the report designer. In the wizard, select Stacked Bar, then click Finish.
Right click on the chart and select Chart Data> Details:
- click Add, enter Serial Expression:,
"Handled"
Category$F{name}
Expression:, Value Expression:,$F{handled}
Click OK - Add, Series Expression:,
"Abandoned"
Category Expression:,$F{name}
Value Expression:,$F{abandoned}
Ok - Add, Series Expression:,
"Rejected"
Category Expression:,$F{name}
Value Expression:,$F{rejected}
Ok
Then click Close. Now select the chart object in the report designer and change the orientation of the property pane to horizontal.
I put the chart in a summary group containing both rows of data in one chart. You can apply the same settings to the chart that is configured in the detail strip for a similar result, if desired.
I am attaching JRXML for more reference as well:
<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report7" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="42d0d6ab-85f6-496b-8e61-c3d7588cfd8e">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<queryString>
<![CDATA[select 'customerservice' as name, 300 as totalcalls, 100 as handled, 100 as abandoned, 100 as rejected
union select 'itsupport', 500, 300, 100, 100]]>
</queryString>
<field name="name" class="java.lang.String"/>
<field name="totalcalls" class="java.lang.Long"/>
<field name="handled" class="java.lang.Long"/>
<field name="abandoned" class="java.lang.Long"/>
<field name="rejected" class="java.lang.Long"/>
<summary>
<band height="92">
<stackedBarChart>
<chart>
<reportElement uuid="f0bfeda6-003e-40c0-8d75-0c61bc620978" x="0" y="0" width="555" height="92"/>
<chartTitle/>
<chartSubtitle/>
<chartLegend/>
</chart>
<categoryDataset>
<categorySeries>
<seriesExpression><![CDATA["Handled"]]></seriesExpression>
<categoryExpression><![CDATA[$F{name}]]></categoryExpression>
<valueExpression><![CDATA[$F{handled}]]></valueExpression>
</categorySeries>
<categorySeries>
<seriesExpression><![CDATA["Abandoned"]]></seriesExpression>
<categoryExpression><![CDATA[$F{name}]]></categoryExpression>
<valueExpression><![CDATA[$F{abandoned}]]></valueExpression>
</categorySeries>
<categorySeries>
<seriesExpression><![CDATA["Rejected"]]></seriesExpression>
<categoryExpression><![CDATA[$F{name}]]></categoryExpression>
<valueExpression><![CDATA[$F{rejected}]]></valueExpression>
</categorySeries>
</categoryDataset>
<barPlot>
<plot orientation="Horizontal"/>
<itemLabel/>
</barPlot>
</stackedBarChart>
</band>
</summary>
</jasperReport>
source to share