Hi I am new to Jasper reports. I want to add a horizontal bar chart to a report in the group header with a bar for Kitchen & Bathroom counts. Other than the very basics e.g. dragging the chart onto the template and assigning the orientation I am clueless on how to proceed. If anyone could give me some pointers I would be most grateful thank you. Further details are below.
The data set is on SQL Server and as so. I'm using a group by in my SQL expression for the data set.
.PNG)
These are how I want to get the charts to look like. For each Group By there would be a header and a chart like so
.PNG)
.PNG)
The report template as it exists at the moment with some fields in the Group Header. The aim to to eventually have a page per Group By
.PNG)
This is the report source:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.3.1.final using JasperReports Library version 6.3.1 -->
<!-- 2017-04-11T12:41:05 -->
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="DevJasperReportsServer-1\reports\Database.xml"/>
<queryString language="SQL">
<![CDATA[SELECT [StoreId]
,MAX([Kitchen]) AS Kitchen
,MAX([Bathroom]) AS Bathroom
,MAX([Location]) AS Location
,MAX([Employees]) AS Employees
,MAX([Revenue]) AS Revenue
FROM [dbo].[CHARTTEST]
GROUP BY [StoreId]]]>
</queryString>
<field name="StoreId" class="java.lang.String"/>
<field name="Kitchen" class="java.lang.Integer"/>
<field name="Bathroom" class="java.lang.Integer"/>
<field name="Location" class="java.lang.String"/>
<field name="Employees" class="java.lang.Integer"/>
<field name="Revenue" class="java.math.BigDecimal"/>
<group name="StoreId">
<groupExpression><![CDATA[$F{StoreId}]]></groupExpression>
</group>
<group name="Group1">
<groupExpression><![CDATA[$F{StoreId}]]></groupExpression>
<groupHeader>
<band height="215">
<textField>
<reportElement x="180" y="30" width="200" height="20" uuid="d7b99763-8fa7-489f-a21b-397747554556"/>
<textFieldExpression><![CDATA[$F{Location}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="180" y="60" width="100" height="20" uuid="c408f962-bf6a-4750-9c17-69b5a5fb0db4"/>
<textFieldExpression><![CDATA[$F{Employees}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="180" y="90" width="100" height="20" uuid="f475d12c-7c11-43dc-a176-a31d9e2c6697"/>
<textFieldExpression><![CDATA[$F{Revenue}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="0" y="30" width="100" height="20" uuid="c550d318-262c-4a02-8f85-76e557b3bcbd"/>
<text><![CDATA[Location]]></text>
</staticText>
<staticText>
<reportElement x="0" y="60" width="100" height="20" uuid="4983f9ee-23f9-42dc-b9d9-d218083afa64"/>
<text><![CDATA[Employees]]></text>
</staticText>
<staticText>
<reportElement x="0" y="90" width="100" height="20" uuid="db5f8402-1784-4b3b-bf44-464941296658"/>
<text><![CDATA[Revenue]]></text>
</staticText>
<rectangle>
<reportElement x="0" y="0" width="560" height="30" forecolor="#FFFFFF" backcolor="#BF4745" uuid="a29b4137-1c40-4acc-b6d4-07876388a267"/>
</rectangle>
<textField>
<reportElement x="207" y="14" width="100" height="16" forecolor="#FFFFFF" uuid="97fe2a26-a1ce-46f7-adb4-f7da9a1e32ea"/>
<textElement>
<font isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{StoreId}]]></textFieldExpression>
</textField>
</band>
</groupHeader>
<groupFooter>
<band height="50"/>
</groupFooter>
</group>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="79" splitType="Stretch"/>
</title>
<pageHeader>
<band height="35" splitType="Stretch"/>
</pageHeader>
<detail>
<band height="125" splitType="Stretch"/>
</detail>
<pageFooter>
<band height="54" splitType="Stretch"/>
</pageFooter>
<summary>
<band height="42" splitType="Stretch"/>
</summary>
</jasperReport>