JasperReports File For CSV DataSource Powered Bar Chart

<?xml version="1.0" encoding="UTF-8"  ?>
<!-- Created with iReport - A designer for JasperReports -->
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport
		 name="AllOfficesOpenCaseByAgeBarChartCSVSource"
		 columnCount="1"
		 printOrder="Vertical"
		 orientation="Portrait"
		 pageWidth="595"
		 pageHeight="842"
		 columnWidth="535"
		 columnSpacing="0"
		 leftMargin="30"
		 rightMargin="30"
		 topMargin="20"
		 bottomMargin="20"
		 whenNoDataType="NoPages"
		 isTitleNewPage="false"
		 isSummaryNewPage="false">
	<property name="ireport.scriptlethandling" value="0" />
	<property name="ireport.encoding" value="UTF-8" />
	<import value="java.util.*" />
	<import value="net.sf.jasperreports.engine.*" />
	<import value="net.sf.jasperreports.engine.data.*" />


	<field name="AllegationCode" class="java.lang.String"/>
	<field name="Office" class="java.lang.String"/>
	<field name="Investigator" class="java.lang.String"/>
	<field name="DateOpen" class="java.lang.String"/>
	<field name="Age" class="java.lang.String"/>
	<field name="Subject" class="java.lang.String"/>
	<field name="Licensee" class="java.lang.String"/>
	<field name="AllegationNumber" class="java.lang.String"/>
	<field name="Region" class="java.lang.String"/>

		<background>
			<band height="0"  isSplitAllowed="true" >
			</band>
		</background>
		<title>
			<band height="104"  isSplitAllowed="true" >
				<staticText>
					<reportElement
						x="0"
						y="40"
						width="530"
						height="38"
						key="staticText-1"/>
					<box></box>
					<textElement textAlignment="Center">
						<font pdfFontName="Helvetica-Bold" size="24" isBold="true" isUnderline="true"/>
					</textElement>
				<text><![CDATA[Open Cases By Age and Office]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="115"
						y="78"
						width="305"
						height="23"
						forecolor="#3333FF"
						key="staticText-2"/>
					<box></box>
					<textElement textAlignment="Center">
						<font pdfFontName="Helvetica-BoldOblique" size="14" isBold="true" isItalic="true"/>
					</textElement>
				<text><![CDATA[CSV File DataSource]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="0"
						y="0"
						width="280"
						height="20"
						key="staticText-3"/>
					<box></box>
					<textElement textAlignment="Left">
						<font pdfFontName="Helvetica-Bold" size="12" isBold="true"/>
					</textElement>
				<text><![CDATA[Dököll Solutions, Inc.]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="280"
						y="0"
						width="250"
						height="20"
						key="staticText-4"/>
					<box></box>
					<textElement textAlignment="Right">
						<font pdfFontName="Helvetica-Bold" size="12" isBold="true"/>
					</textElement>
				<text><![CDATA[Office of Systems Developement]]></text>
				</staticText>
				<staticText>
					<reportElement
						x="0"
						y="20"
						width="280"
						height="20"
						key="staticText-5"/>
					<box></box>
					<textElement textAlignment="Left">
						<font pdfFontName="Helvetica-Bold" size="12" isBold="true"/>
					</textElement>
				<text><![CDATA[Case Report]]></text>
				</staticText>
				<textField isStretchWithOverflow="false" pattern="EEEEE dd MMMMM yyyy" isBlankWhenNull="false" evaluationTime="Report" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="280"
						y="20"
						width="250"
						height="20"
						key="textField-1"/>
					<box></box>
					<textElement textAlignment="Right">
						<font pdfFontName="Helvetica-BoldOblique" size="12" isBold="true" isItalic="true"/>
					</textElement>
				<textFieldExpression   class="java.util.Date"><![CDATA[new java.util.Date()]]></textFieldExpression>
				</textField>
			</band>
		</title>
		<pageHeader>
			<band height="0"  isSplitAllowed="true" >
			</band>
		</pageHeader>
		<columnHeader>
			<band height="0"  isSplitAllowed="true" >
			</band>
		</columnHeader>
		<detail>
			<band height="0"  isSplitAllowed="true" >
			</band>
		</detail>
		<columnFooter>
			<band height="0"  isSplitAllowed="true" >
			</band>
		</columnFooter>
		<pageFooter>
			<band height="93"  isSplitAllowed="true" >
				<staticText>
					<reportElement
						x="0"
						y="59"
						width="530"
						height="30"
						key="staticText-6"/>
					<box></box>
					<textElement textAlignment="Center">
						<font pdfFontName="Helvetica-Oblique" isItalic="true"/>
					</textElement>
				<text><![CDATA[The information contained in this document is strictly confidential and may be used only for the purpose of 
	conducting the business of the Dököll Solutions, Inc. Office of Stupendous Conduct]]></text>
				</staticText>
				<line direction="TopDown">
					<reportElement
						x="130"
						y="19"
						width="270"
						height="0"
						key="line-1"/>
					<graphicElement stretchType="NoStretch"/>
				</line>
				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="400"
						y="29"
						width="70"
						height="20"
						key="textField-2"/>
					<box></box>
					<textElement textAlignment="Right">
						<font/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA["Page " + $V{PAGE_NUMBER} + " of "]]></textFieldExpression>
				</textField>
				<textField isStretchWithOverflow="false" isBlankWhenNull="false" evaluationTime="Report" hyperlinkType="None"  hyperlinkTarget="Self" >
					<reportElement
						x="480"
						y="29"
						width="50"
						height="20"
						key="textField-3"/>
					<box></box>
					<textElement textAlignment="Left">
						<font/>
					</textElement>
				<textFieldExpression   class="java.lang.String"><![CDATA["" + $V{PAGE_NUMBER} + ""]]></textFieldExpression>
				</textField>
			</band>
		</pageFooter>
		<summary>
			<band height="358"  isSplitAllowed="true" >
				<bar3DChart>
					<chart  hyperlinkTarget="Self" >
					<reportElement
						x="7"
						y="8"
						width="521"
						height="338"
						key="element-1"/>
					<box></box>
						<chartLegend textColor="#000000" backgroundColor="#FFFFFF" >
					</chartLegend>
					</chart>
					<categoryDataset>
						<dataset >
						</dataset>
						<categorySeries>
							<seriesExpression><![CDATA[$F{Office}.valueOf( $F{Office} )]]></seriesExpression>
							<categoryExpression><![CDATA["All Area Office"]]></categoryExpression>
							<valueExpression><![CDATA[$V{REPORT_COUNT}]]></valueExpression>
				<itemHyperlink >
				</itemHyperlink>
						</categorySeries>
					</categoryDataset>
					<bar3DPlot >
						<plot />
						<categoryAxisFormat>
							<axisFormat >
							</axisFormat>
						</categoryAxisFormat>
						<valueAxisFormat>
							<axisFormat >
							</axisFormat>
						</valueAxisFormat>
					</bar3DPlot>
				</bar3DChart>
			</band>
		</summary>
</jasperReport>





Please note:  the above code was created using iReport 3.00, best to write your own JRXML file.  However, if you have that version of iReport, copy and paste, compile and plug the necessary file(s) in your application and run the report.

Perform the following Housekeeping for iReport
(1) Create a datasource to your CSV file
(2) Create an empty JRXML file in iReport
(3) Copy and Paste the above JRXML file to replace your code
(4) Save and Compile the code

Perform the following Housekeeping for JavaAgent
(1) You need all necessary JasperReports and iReport jar files added to Notes/jvm/lib/ext
(2) Copy code JasperReports JavaAgent added earlier
(3) Run the Agent as a Static Method to view the Chart

Perform the following Housekeeping for JavaBean
(1) Create a JavaBean, add the Method provided earlier to run the Jasper file
(2) Add a button to an Xpages file to run the button code
(3) Wait a couple of seconds for chart to load

Xpages Button Code
<xp:button value="Fetch CSV JasperReports (JavaAgent)" id="button2" action="#{RunJasperReportsWithCSVDataSourceBean.doRunJasperReportsCSVBarCharts}" type="submit" save="true" />

For additional configuration support, watch last video (Döcu Content Config) from this submission
http://www.openntf.org/Internal/home.nsf/project.xsp?action=openDocument&name=D%C3%B6cu%20Content

XML
Köll S Cherizard
December 15, 2013 6:46 PM
Rating
50

All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.



No comments yetLogin first to comment...