<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE report PUBLIC "-//JFreeReport//DTD report definition//EN//simple/version 0.8.5"
                        "http://jfreereport.sourceforge.net/report-085.dtd">
<!--
  The report needs JFreeReport 0.8.6 or the message-field
  contents will look funny.
-->
<report bottommargin="10" leftmargin="10" name="Quadrant For Region" orientation="portrait" pageformat="LETTER" rightmargin="10" topmargin="10">
  <!-- This is what is called 'title' in JasperReports -->
  <pageheader fontname="Arial" fontsize="10">
    <label alignment="right" height="15" width="100%" x="0" y="2">Pentaho Sample Report</label>
    <label alignment="right" height="15" width="100%" x="0" y="17">JFreeReport</label>
  </pageheader>
  <pagefooter>
    <!--<message-field alignment="center" fontname="Arial" fontsize="10"
  height="15" width="100%" x="0">$(PageofPages)</message-field>
-->
  </pagefooter>
  <reportheader>
    <drawable-field x="0" y="0" fieldname="BarLineChart" width="600" height="400"/>
  </reportheader>
  <groups>
    <group name="RegionGroup">
      <fields>
        <field>REGION</field>
      </fields>
      <groupheader fontname="Arial" fontsize="12" fontstyle="bold">
        <message-field color="#009999" height="18" vertical-alignment="middle" width="100%" x="0" y="5">Region: $(REGION)</message-field>
      </groupheader>
      <groupfooter fontname="Arial" fontsize="12" fontstyle="bold" pagebreak-after-print="true">
        <rectangle color="#009999" draw="false" fill="true" height="15" width="100%" x="0" y="0"/>
        <message-field color="white" height="15" vertical-alignment="middle" width="55%" x="0" y="0">$(REGION) Total</message-field>
        <number-field alignment="right" fieldname="RegionActual" format="$#,##0" height="15" vertical-alignment="middle" width="15%" x="55%" y="0"/>
        <number-field alignment="right" fieldname="RegionBudget" format="$#,##0" height="15" vertical-alignment="middle" width="15%" x="70%" y="0"/>
        <number-field alignment="right" fieldname="RegionVariance" format="$#,##0" height="15" name="Variance Region Field" vertical-alignment="middle" width="15%" x="85%" y="0"/>
        <line color="black" weight=".5" width="14%" x1="56%" x2="70%" y1="16" y2="16"/>
        <line color="black" weight=".5" width="14%" x1="71%" x2="85%" y1="16" y2="16"/>
        <line color="black" weight=".5" width="14%" x1="86%" x2="100%" y1="16" y2="16"/>
        <line color="black" weight=".5" width="14%" x1="56%" x2="70%" y1="17" y2="17"/>
        <line color="black" weight=".5" width="14%" x1="71%" x2="85%" y1="17" y2="17"/>
        <line color="black" weight=".5" width="14%" x1="86%" x2="100%" y1="17" y2="17"/>
        <rectangle color="white" fill="true" height="14" width="100%" x="0" y="18"/>
      </groupfooter>
    </group>
    <group name="DepartmentGroup">
      <fields>
        <field>REGION</field>
        <field>DEPARTMENT</field>
      </fields>
      <groupheader color="white" fontname="Arial" fontsize="10" fontstyle="bold" repeat="true">
        <rectangle color="#FF6600" draw="false" fill="true" height="15" width="100%" x="0" y="0"/>
        <label alignment="left" height="15" vertical-alignment="middle" width="15%" x="0" y="0">Department</label>
        <label alignment="left" height="15" vertical-alignment="middle" width="40%" x="15%" y="0">Position</label>
        <label alignment="right" height="15" vertical-alignment="middle" width="15%" x="55%" y="0">Actual</label>
        <label alignment="right" height="15" vertical-alignment="middle" width="15%" x="70%" y="0">Budget</label>
        <label alignment="right" height="15" vertical-alignment="middle" width="15%" x="85%" y="0">Variance</label>
        <message-field color="black" fontsize="12" height="15" width="100%" x="0" y="16">$(DEPARTMENT)</message-field>
      </groupheader>
      <!--
      By specifiying a band height that is greater than the used size, we
      enforce some empty space between the groups.
      -->
      <groupfooter fontname="Arial" fontsize="11" fontstyle="bold">
        <rectangle color="#66FF66" fill="true" height="14" width="85%" x="15%" y="0"/>
        <label height="14" width="40%" x="15%" y="0">Total</label>
        <number-field alignment="right" fieldname="DepartmentActual" format="$#,##0" height="14" width="15%" x="55%" y="0"/>
        <number-field alignment="right" fieldname="DepartmentBudget" format="$#,##0" height="14" width="15%" x="70%" y="0"/>
        <number-field alignment="right" fieldname="DepartmentVariance" format="$#,##0" height="14" name="Variance Department Field" width="15%" x="85%" y="0"/>
        <line color="black" weight=".25" width="14%" x1="56%" x2="70%" y1="16" y2="16"/>
        <line color="black" weight=".25" width="14%" x1="71%" x2="85%" y1="16" y2="16"/>
        <line color="black" weight=".25" width="14%" x1="86%" x2="100%" y1="16" y2="16"/>
        <line color="black" weight=".25" width="14%" x1="56%" x2="70%" y1="17" y2="17"/>
        <line color="black" weight=".25" width="14%" x1="71%" x2="85%" y1="17" y2="17"/>
        <line color="black" weight=".25" width="14%" x1="86%" x2="100%" y1="17" y2="17"/>
        <rectangle color="white" fill="true" height="14" width="100%" x="0" y="18"/>
      </groupfooter>
    </group>
  </groups>
  <!-- This is what is called 'detail' in JasperReports -->
  <items fontname="Arial" fontsize="10" vertical-alignment="middle">
    <string-field fieldname="POSITIONTITLE" height="15" vertical-alignment="middle" width="40%" x="15%" y="0"/>
    <number-field alignment="right" fieldname="ACTUAL" format="$#,##0" height="15" width="15%" x="55%" y="0"/>
    <number-field alignment="right" fieldname="BUDGET" format="$#,##0" height="15" width="15%" x="70%" y="0"/>
    <number-field alignment="right" fieldname="VARIANCE" format="$#,##0" height="15" name="Variance Field" width="15%" x="85%" y="0"/>
    <line color="gray" height="0" weight=".25" width="85%" x1="15%" x2="100%" y1="16" y2="16"/>
    <line color="white" height="0" weight=".25" width="85%" x1="15%" x2="100%" y1="17" y2="17"/>
  </items>
  <functions>
    <!-- This makes sure, that we can access the parameter as if it was a column from the table -->
    <property-ref name="REGION"/>
    <expression class="org.jfree.report.modules.misc.beanshell.BSHExpression" name="isVarianceNegative" depLevel="1">
      <properties>
        <property name="expression">           Object getValue()           {             Object value = dataRow.get(&quot;VARIANCE&quot;);             if (value instanceof Number == false)             {               return Boolean.FALSE;             }             Number number = (Number) value;             if (number.doubleValue() &lt; 0)             {               return Boolean.TRUE;             }             return Boolean.FALSE;           }</property>
      </properties>
    </expression>
    <expression class="org.jfree.report.function.ElementColorFunction" name="changeColor" depLevel="1">
      <properties>
        <property name="element">Variance Field</property>
        <property name="field">isVarianceNegative</property>
        <property name="colorTrue">red</property>
        <property name="colorFalse">black</property>
      </properties>
    </expression>
    <expression class="org.jfree.report.modules.misc.beanshell.BSHExpression" name="isDepartmentVarianceNegative" depLevel="1">
      <properties>
        <property name="expression">           Object getValue()           {             Object value = dataRow.get(&quot;DepartmentVariance&quot;);             if (value instanceof Number == false)             {               return Boolean.FALSE;             }             Number number = (Number) value;             if (number.doubleValue() &lt; 0)             {               return Boolean.TRUE;             }             return Boolean.FALSE;           }</property>
      </properties>
    </expression>
    <expression class="org.jfree.report.function.ElementColorFunction" name="changeDepartmentColor" depLevel="1">
      <properties>
        <property name="element">Variance Department Field</property>
        <property name="field">isDepartmentVarianceNegative</property>
        <property name="colorTrue">red</property>
        <property name="colorFalse">black</property>
      </properties>
    </expression>
    <expression class="org.jfree.report.modules.misc.beanshell.BSHExpression" name="isRegionVarianceNegative" depLevel="1">
      <properties>
        <property name="expression">           Object getValue()           {             Object value = dataRow.get(&quot;RegionVariance&quot;);             if (value instanceof Number == false)             {               return Boolean.FALSE;             }             Number number = (Number) value;             if (number.doubleValue() &lt; 0)             {               return Boolean.TRUE;             }             return Boolean.FALSE;           }</property>
      </properties>
    </expression>
    <expression class="org.jfree.report.function.ElementColorFunction" name="changeRegionColor" depLevel="1">
      <properties>
        <property name="element">Variance Region Field</property>
        <property name="field">isRegionVarianceNegative</property>
        <property name="colorTrue">red</property>
        <property name="colorFalse">black</property>
      </properties>
    </expression>
    <expression class="org.jfree.report.function.ItemSumFunction" name="RegionActual" depLevel="1">
      <properties>
        <property name="field">ACTUAL</property>
        <property name="group">RegionGroup</property>
      </properties>
    </expression>
    <expression class="org.jfree.report.function.ItemSumFunction" name="RegionBudget" depLevel="1">
      <properties>
        <property name="field">BUDGET</property>
        <property name="group">RegionGroup</property>
      </properties>
    </expression>
    <expression class="org.jfree.report.function.ItemSumFunction" name="RegionVariance" depLevel="1">
      <properties>
        <property name="field">VARIANCE</property>
        <property name="group">RegionGroup</property>
      </properties>
    </expression>
    <expression class="org.jfree.report.function.ItemSumFunction" name="DepartmentActual" depLevel="1">
      <properties>
        <property name="field">ACTUAL</property>
        <property name="group">DepartmentGroup</property>
      </properties>
    </expression>
    <expression class="org.jfree.report.function.ItemSumFunction" name="DepartmentBudget" depLevel="1">
      <properties>
        <property name="field">BUDGET</property>
        <property name="group">DepartmentGroup</property>
      </properties>
    </expression>
    <expression class="org.jfree.report.function.ItemSumFunction" name="DepartmentVariance" depLevel="1">
      <properties>
        <property name="field">VARIANCE</property>
        <property name="group">DepartmentGroup</property>
      </properties>
    </expression>
        <expression name="barsData" class="org.pentaho.plugin.jfreereport.reportcharts.CategorySetCollectorFunction" depLevel="1">
            <properties>
                <property name="categoryColumn">DEPARTMENT</property>
                <property name="categoryStartColumn" class="java.lang.Integer">0</property>
                <property name="generatedReport" class="java.lang.Boolean">false</property>
                <property name="seriesColumn" class="java.lang.Boolean">false</property>
                <property name="seriesName[0]" class="java.lang.String">Actual</property>
                <property name="seriesName[1]" class="java.lang.String">Budget</property>
                <property name="summaryOnly" class="java.lang.Boolean">false</property>
                <property name="valueColumn[0]" class="java.lang.String">ACTUAL</property>
                <property name="valueColumn[1]" class="java.lang.String">BUDGET</property>
            </properties>
        </expression>
        <expression name="linesData" class="org.pentaho.plugin.jfreereport.reportcharts.CategorySetCollectorFunction" depLevel="1">
            <properties>
                <property name="categoryColumn">DEPARTMENT</property>
                <property name="categoryStartColumn" class="java.lang.Integer">0</property>
                <property name="generatedReport" class="java.lang.Boolean">false</property>
                <property name="seriesColumn" class="java.lang.Boolean">false</property>
                <property name="seriesName[0]" class="java.lang.String">Variance</property>
                <property name="summaryOnly" class="java.lang.Boolean">false</property>
                <property name="valueColumn[0]" class="java.lang.String">VARIANCE</property>
            </properties>
        </expression>
        <expression name="BarLineChart" class="org.pentaho.plugin.jfreereport.reportcharts.BarLineChartExpression" depLevel="1">
            <properties>
		        <property name="title">Demo Combination Chart</property>
       			<property name="titleFont">Arial-BOLD-26</property>
                <property name="dataSource">barsData</property>
                <property name="chartWidth">600</property>
                <property name="chartHeight">400</property>
                <property name="useDrawable">true</property>
                <property name="linesDataSource">linesData</property>
                <property name="categoryAxisLabel">Department</property>
				<property name="valueAxisLabel">Actual and Budget</property>
				<property name="secondValueAxisLabel">Variance</property>
				<property name="showBorder" class="java.lang.Boolean">true</property>
				<property name="backgroundColor">white</property>
				<property name="borderColor">black</property>
				<property name="titleFont" class="java.lang.String">SansSerif-bold-10</property>
				<property name="labelFont" class="java.lang.String">SansSerif--8</property>
				<property name="barsLabelFont" class="java.lang.String">SansSerif--8</property>
				<property name="linesLabelFont" class="java.lang.String">SansSerif--8</property>
				<property name="legendFont" class="java.lang.String">SansSerif--6</property>
				<property name="labelRotation" class="java.lang.Double">0.45</property>
				<property name="showLegend" class="java.lang.Boolean">true</property>
				<property name="drawLegendBorder" class="java.lang.Boolean">false</property>
				<property name="legendLocation">bottom</property>	
				<property name="lineSeriesColor[0]">#333333</property>
				<property name="seriesColor[0]">#A52A2A</property>
				<property name="seriesColor[1]">#5555FF</property>
				<property name="threeD" class="java.lang.Boolean">false</property>
				<property name="lineTicksLabelFormat">$#,##0.00</property>
				<property name="barTicksLabelFormat">$#,##0.00</property>
				<property name="markersVisible" class="java.lang.Boolean">true</property>
            </properties>
        </expression>
    <function class="org.jfree.report.function.PageOfPagesFunction" name="PageofPages"/>
  </functions>
  <configuration>
    <!--property name="org.pentaho.plugin.jfreereport.CacheChartExpressionResults">true</property-->
    <property name="org.jfree.report.modules.output.table.html.BodyFragment">true</property>
    <property name="org.jfree.report.modules.output.pageable.pdf.Encoding">Identity-H</property>
    <property name="org.jfree.report.modules.output.pageable.pdf.EmbedFonts">true</property>
  </configuration>
</report>