abinabraham Posted November 18, 2009 Share Posted November 18, 2009 hi all, I am trying to create a ireport chart using jasperReports-Pro 3.1.2.The query populates 3 rows and 2 fields (Fields=a category expression and a value expression).i am able to create a report but the report is displaying 3 charts(or as many rows the query populates).Do i need to specify any other properties? or do i hav to write the query in any other form?i am attaching the query and code below.thanks in advancejoe Code:SELECT TYPE, count(STATUS)FROM TableGROUP BY TYPE-----------------------------------<?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="report name" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20"> <style name="style1" isDefault="false"/> <queryString> <![CDATA[sELECT TYPE, count(STATUS)FROM TableGROUP BY TYPE]]> </queryString> <field name="TYPE" class="java.lang.String"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <field name="COUNT(STATUS)" class="java.math.BigDecimal"> <fieldDescription><![CDATA[]]></fieldDescription> </field> <background> <band/> </background> <title> <band height="37"/> </title> <pageHeader> <band height="35"/> </pageHeader> <columnHeader> <band/> </columnHeader> <detail> <band height="311" isSplitAllowed="false"> <lineChart> <chart isShowLegend="false" hyperlinkType="None"> <reportElement isPrintRepeatedValues="false" x="200" y="10" width="345" height="149"/> <box> <pen lineColor="#FFFF00"/> <topPen lineColor="#FFFF00"/> <leftPen lineColor="#FFFF00"/> <bottomPen lineColor="#FFFF00"/> <rightPen lineColor="#FFFF00"/> </box> <chartTitle/> <chartSubtitle/> <chartLegend/> </chart> <categoryDataset> <dataset resetType="None"/> <categorySeries> <seriesExpression><![CDATA["OPEN"]]></seriesExpression> <categoryExpression><![CDATA[$F{TYPE}]]></categoryExpression> <valueExpression><![CDATA[$F{COUNT(STATUS)}]]></valueExpression> <itemHyperlink hyperlinkType="None"/> </categorySeries> <categorySeries> <seriesExpression><![CDATA["CLOSED"]]></seriesExpression> <categoryExpression><![CDATA[$F{TYPE}]]></categoryExpression> <valueExpression><![CDATA[$F{COUNT(STATUS)}]]></valueExpression> <itemHyperlink hyperlinkType="None"/> </categorySeries> <categorySeries> <seriesExpression><![CDATA["ABANDONED"]]></seriesExpression> <categoryExpression><![CDATA[$F{TYPE}]]></categoryExpression> <valueExpression><![CDATA[$F{COUNT(STATUS)}]]></valueExpression> <itemHyperlink hyperlinkType="None"/> </categorySeries> </categoryDataset> <linePlot> <plot/> </linePlot> </lineChart> <pieChart> <chart isShowLegend="false" hyperlinkType="None"> <reportElement x="11" y="10" width="189" height="149"/> <chartTitle/> <chartSubtitle/> <chartLegend/> </chart> <pieDataset> <keyExpression><![CDATA[$F{TYPE}]]></keyExpression> <valueExpression><![CDATA[$F{COUNT(STATUS)}]]></valueExpression> <sectionHyperlink hyperlinkType="None"/> </pieDataset> <piePlot isCircular="true"> <plot/> </piePlot> </pieChart> <stackedBarChart> <chart isShowLegend="false" hyperlinkType="None"> <reportElement x="329" y="159" width="216" height="141"/> <chartTitle/> <chartSubtitle/> <chartLegend/> </chart> <categoryDataset> <categorySeries> <seriesExpression><![CDATA["OPEN"]]></seriesExpression> <categoryExpression><![CDATA[$F{TYPE}]]></categoryExpression> <valueExpression><![CDATA[$F{COUNT(STATUS)}]]></valueExpression> <itemHyperlink hyperlinkType="None"/> </categorySeries> <categorySeries> <seriesExpression><![CDATA["CLOSED"]]></seriesExpression> <categoryExpression><![CDATA[$F{TYPE}]]></categoryExpression> <valueExpression><![CDATA[$F{COUNT(STATUS)}]]></valueExpression> <itemHyperlink hyperlinkType="None"/> </categorySeries> <categorySeries> <seriesExpression><![CDATA["ABANDONED"]]></seriesExpression> <categoryExpression><![CDATA[$F{TYPE}]]></categoryExpression> <valueExpression><![CDATA[$F{COUNT(STATUS)}]]></valueExpression> <itemHyperlink hyperlinkType="None"/> </categorySeries> </categoryDataset> <barPlot isShowLabels="false" isShowTickLabels="true" isShowTickMarks="true"> <plot/> </barPlot> </stackedBarChart> <bar3DChart> <chart isShowLegend="false" hyperlinkType="None"> <reportElement x="11" y="159" width="318" height="141"/> <chartTitle/> <chartSubtitle/> <chartLegend/> </chart> <categoryDataset> <categorySeries> <seriesExpression><![CDATA["OPEN"]]></seriesExpression> <categoryExpression><![CDATA[$F{TYPE}]]></categoryExpression> <valueExpression><![CDATA[$F{COUNT(STATUS)}]]></valueExpression> <itemHyperlink hyperlinkType="None"/> </categorySeries> <categorySeries> <seriesExpression><![CDATA["CLOSED"]]></seriesExpression> <categoryExpression><![CDATA[$F{TYPE}]]></categoryExpression> <valueExpression><![CDATA[$F{COUNT(STATUS)}]]></valueExpression> <itemHyperlink hyperlinkType="None"/> </categorySeries> <categorySeries> <seriesExpression><![CDATA["ABANDONED"]]></seriesExpression> <categoryExpression><![CDATA[$F{TYPE}]]></categoryExpression> <valueExpression><![CDATA[$F{COUNT(STATUS)}]]></valueExpression> <itemHyperlink hyperlinkType="None"/> </categorySeries> </categoryDataset> <bar3DPlot isShowLabels="false"> <plot/> </bar3DPlot> </bar3DChart> </band> </detail> <columnFooter> <band height="40"/> </columnFooter> <pageFooter> <band height="41"/> </pageFooter> <summary> <band height="42"/> </summary></jasperReport> Link to comment Share on other sites More sharing options...
jnguyen75 Posted November 18, 2009 Share Posted November 18, 2009 You need to put the report in your summary band, not your detail band. The detail band repeats for each record, thus giving you 3 charts. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now