<?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="OpenFlashChartsReport" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20">
	<queryString>
		<![CDATA[SELECT * FROM sales_fact 
    INNER JOIN sales_person ON sales_person.id = sales_fact.sales_person_id
    INNER JOIN sales_state ON sales_state.id = sales_fact.sales_state_id 
    WHERE sales_state.id > 1 AND sales_state.id < 6 and full_name like '%a%'
    ORDER BY full_name, sales_state]]>
	</queryString>
	<field name="full_name" class="java.lang.String">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="amount" class="java.lang.Integer">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<field name="sales_state" class="java.lang.String">
		<fieldDescription><![CDATA[]]></fieldDescription>
	</field>
	<variable name="personAmount" class="java.lang.Integer" resetType="Group" resetGroup="person" calculation="Sum">
		<variableExpression><![CDATA[$F{amount}]]></variableExpression>
	</variable>
	<variable name="personStateAmount" class="java.lang.Integer" resetType="Group" resetGroup="salesState" calculation="Sum">
		<variableExpression><![CDATA[$F{amount}]]></variableExpression>
	</variable>
	<group name="person">
		<groupExpression><![CDATA[$F{full_name}]]></groupExpression>
	</group>
	<group name="salesState">
		<groupExpression><![CDATA[$F{sales_state}]]></groupExpression>
	</group>
	<summary>
		<band height="800">
			<staticText>
				<reportElement width="555" y="0" x="0" height="100"/>
				<textElement textAlignment="Center" verticalAlignment="Middle">
					<font size="14"/>
				</textElement>
				<text>Note: This sample is provided as a Proof of Concept that demonstrates the use of JasperReports custom components inside JasperServer; it is not supported by the Jaspersoft team.</text>
			</staticText>
			<componentElement>
				<reportElement x="0" y="100" width="555" height="300"/>
				<ofc:pieChart xmlns:ofc="http://jasperreports.sourceforge.net/openflashchart"
						xsi:schemaLocation="http://jasperreports.sourceforge.net/openflashchart http://jasperreports.sourceforge.net/xsd/openflashchart.xsd"
						evaluationTime="Report">
					<ofc:pieDataset>
						<dataset incrementType="Group" incrementGroup="person"/>
						<ofc:keyExpression>$F{full_name}</ofc:keyExpression>
						<ofc:valueExpression>$V{personAmount}</ofc:valueExpression>
					</ofc:pieDataset>
					<ofc:titleExpression>"Pie Chart"</ofc:titleExpression>
				</ofc:pieChart>
			</componentElement>
			<componentElement>
				<reportElement x="0" y="450" width="555" height="300"/>
				<ofc:barChart xmlns:ofc="http://jasperreports.sourceforge.net/openflashchart"
						xsi:schemaLocation="http://jasperreports.sourceforge.net/openflashchart http://jasperreports.sourceforge.net/xsd/openflashchart.xsd"
						evaluationTime="Report">
					<ofc:barDataset>
						<dataset incrementType="Group" incrementGroup="salesState"/>
						<ofc:barSeries>
							<ofc:seriesExpression>$F{sales_state}</ofc:seriesExpression>
							<ofc:categoryExpression>$F{full_name}</ofc:categoryExpression>
							<ofc:valueExpression>$V{personStateAmount}</ofc:valueExpression>
						</ofc:barSeries>
					</ofc:barDataset>
					<ofc:titleExpression>"Bar Chart"</ofc:titleExpression>
				</ofc:barChart>
			</componentElement>
		</band>
	</summary>
</jasperReport>
