<?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="SubDatasetChartReport" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="30" bottomMargin="30">
	<style name="Sans_Bold" isDefault="false" fontName="DejaVu Sans" fontSize="8" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false"/>
	<style name="Serif_Bold" isDefault="false" fontName="DejaVu Serif" fontSize="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false"/>
	<subDataset name="Country_Orders">
		<parameter name="Country" class="java.lang.String"/>
		<queryString>
			<![CDATA[SELECT OrderDate, Freight
			FROM Orders
			WHERE
				ShipCountry = $P{Country} AND
				OrderDate IS NOT NULL
			ORDER BY OrderDate]]>
		</queryString>
		<field name="OrderDate" class="java.sql.Timestamp"/>
		<field name="Freight" class="java.lang.Double"/>
		<variable name="OrderMonth" class="java.util.Date">
			<variableExpression><![CDATA[ChartsApp.truncateToMonth($F{OrderDate})]]></variableExpression>
		</variable>
		<variable name="FreightSum" class="java.lang.Double" resetType="Group" resetGroup="MonthGroup" calculation="Sum">
			<variableExpression><![CDATA[$F{Freight}]]></variableExpression>
		</variable>
		<group name="MonthGroup">
			<groupExpression><![CDATA[$V{OrderMonth}]]></groupExpression>
		</group>
	</subDataset>
	<queryString>
		<![CDATA[SELECT DISTINCT ShipCountry
		FROM Orders
		ORDER BY ShipCountry]]>
	</queryString>
	<field name="ShipCountry" class="java.lang.String"/>
	<title>
		<band height="50">
			<staticText>
				<reportElement style="Serif_Bold" x="0" y="0" width="555" height="35"/>
				<box>
					<topPen lineWidth="0.5"/>
				</box>
				<textElement textAlignment="Center">
					<font size="22"/>
				</textElement>
				<text><![CDATA[Sub Dataset Chart Report]]></text>
			</staticText>
		</band>
	</title>
	<detail>
		<band height="230">
			<line>
				<reportElement x="0" y="19" width="550" height="1"/>
			</line>
			<textField>
				<reportElement style="Sans_Bold" x="10" y="2" width="150" height="16"/>
				<textElement>
					<font size="12"/>
				</textElement>
				<textFieldExpression class="java.lang.String"><![CDATA[$F{ShipCountry}]]></textFieldExpression>
			</textField>
			<timeSeriesChart>
				<chart>
					<reportElement positionType="Float" x="0" y="25" width="550" height="190"/>
					<chartTitle/>
					<chartSubtitle/>
					<chartLegend/>
				</chart>
				<timeSeriesDataset timePeriod="Month">
					<dataset incrementType="Group" incrementGroup="MonthGroup">
						<datasetRun subDataset="Country_Orders">
							<datasetParameter name="Country">
								<datasetParameterExpression><![CDATA[$F{ShipCountry}]]></datasetParameterExpression>
							</datasetParameter>
						</datasetRun>
					</dataset>
					<timeSeries>
						<seriesExpression><![CDATA["Freight"]]></seriesExpression>
						<timePeriodExpression><![CDATA[$V{OrderMonth}]]></timePeriodExpression>
						<valueExpression><![CDATA[$V{FreightSum}]]></valueExpression>
						<labelExpression><![CDATA[]]></labelExpression>
					</timeSeries>
					<timeSeries>
						<seriesExpression><![CDATA["Half Freight"]]></seriesExpression>
						<timePeriodExpression><![CDATA[$V{OrderMonth}]]></timePeriodExpression>
						<valueExpression><![CDATA[new Double($V{FreightSum}.doubleValue() / 2d)]]></valueExpression>
						<labelExpression><![CDATA[]]></labelExpression>
					</timeSeries>
				</timeSeriesDataset>
				<timeSeriesPlot isShowLines="true" isShowShapes="true">
					<plot/>
					<timeAxisFormat>
						<axisFormat>
							<labelFont/>
							<tickLabelFont/>
						</axisFormat>
					</timeAxisFormat>
					<valueAxisFormat>
						<axisFormat>
							<labelFont/>
							<tickLabelFont/>
						</axisFormat>
					</valueAxisFormat>
				</timeSeriesPlot>
			</timeSeriesChart>
		</band>
	</detail>
	<pageFooter>
		<band height="30">
			<rectangle>
				<reportElement mode="Transparent" x="0" y="5" width="555" height="25"/>
			</rectangle>
			<textField>
				<reportElement x="200" y="10" width="75" height="20"/>
				<textElement textAlignment="Right">
					<font size="14"/>
				</textElement>
				<textFieldExpression class="java.lang.Integer"><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
			</textField>
			<staticText>
				<reportElement x="275" y="10" width="5" height="20"/>
				<textElement textAlignment="Center">
					<font size="14"/>
				</textElement>
				<text><![CDATA[/]]></text>
			</staticText>
			<textField evaluationTime="Report">
				<reportElement x="280" y="10" width="75" height="20"/>
				<textElement>
					<font size="14"/>
				</textElement>
				<textFieldExpression class="java.lang.Integer"><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
			</textField>
		</band>
	</pageFooter>
</jasperReport>
