Jump to content
We've recently updated our Privacy Statement, available here ×

mcm

Members
  • Posts

    4
  • Joined

  • Last visited

mcm's Achievements

Newbie

Newbie (1/14)

  • First Post Rare
  • Week One Done
  • One Month Later
  • One Year In

Recent Badges

0

Reputation

  1. Hi, you need to change the type of the field from the field list in your report not int spreadsheet.
  2. Hi, You can get this error because one or more cells in your Excel file are empty, try to fill the empty cells with the any character , "-" for example , and run your report again
  3. Hi, there is a solution based on using a JRMapCollectionDataSource for your Pie Chart. You need to add a dataset to your report (add empty data source). (in ireport right clik in your report name and click on add Dataset) in the added source add tow fields for the values and for the label/name for example key an val, you will use them in you pie chart create a new pie char and choose your dataset the new adder dataset. this will allow you to find your variable key and val, to use them as key expression $F{key} and value expression $F{val) Now open you pie chart properties by righ click on the pie object => pie Data. go to : connection / Datasource expression, and choose use data source expression Edit the expression to use a JRMapCollectionDataSource with your own calculated variables (in the example we uses var1, var2, var3 an var4) example new net.sf.jasperreports.engine.data.JRMapCollectionDataSource () [ ["key" : "a", val: $V{var1}], ["key" : "b", val: $V{var2}], ["key" : "c", val: $V{var3}], ["key" : "d", val: $V{var4}] ])[/code]The default label uses the key, you can change it in char Data - > Details you can fin more details on this link : https://community.jaspersoft.com/wiki/how-pass-java-list-or-list-chart-datasource-jrxml-based-reports Below the JRXML file using ireport 5.6 of the example : <?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="pie chart variables" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="0a8e5b1c-8d35-4290-a283-c7fb4e197131"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <subDataset name="mydataset" uuid="37fb9ab4-ec80-4095-9857-01219a239b9b"> <field name="key" class="java.lang.String"/> <field name="val" class="java.lang.Integer"/> </subDataset> <variable name="var1" class="java.lang.Integer"> <variableExpression><![CDATA[35*3]]></variableExpression> <initialValueExpression><![CDATA[]]></initialValueExpression> </variable> <variable name="var2" class="java.lang.Integer"> <variableExpression><![CDATA[20*1.5]]></variableExpression> <initialValueExpression><![CDATA[]]></initialValueExpression> </variable> <variable name="var3" class="java.lang.Integer"> <variableExpression><![CDATA[25*5]]></variableExpression> <initialValueExpression><![CDATA[]]></initialValueExpression> </variable> <variable name="var4" class="java.lang.Integer"> <variableExpression><![CDATA[40]]></variableExpression> <initialValueExpression><![CDATA[]]></initialValueExpression> </variable> <background> <band splitType="Stretch"/> </background> <title> <band height="79" splitType="Stretch"/> </title> <pageHeader> <band height="35" splitType="Stretch"/> </pageHeader> <columnHeader> <band height="61" splitType="Stretch"/> </columnHeader> <detail> <band height="162" splitType="Stretch"> <pie3DChart> <chart evaluationTime="Report"> <reportElement x="135" y="16" width="238" height="125" uuid="71a39643-6af3-4124-977a-16a74385968c"/> <chartTitle/> <chartSubtitle/> <chartLegend/> </chart> <pieDataset> <dataset> <datasetRun subDataset="mydataset" uuid="a159ae9c-736c-447c-9909-f883471c59bf"> <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRMapCollectionDataSource ( [ ["key" : "a", val: $V{var1}], ["key" : "b", val: $V{var2}], ["key" : "c", val: $V{var3}], ["key" : "d", val: $V{var4}] ])]]></dataSourceExpression> </datasetRun> </dataset> <keyExpression><![CDATA[$F{key}]]></keyExpression> <valueExpression><![CDATA[$F{val}]]></valueExpression> <labelExpression><![CDATA[$F{key}+":"+$F{val}]]></labelExpression> </pieDataset> <pie3DPlot> <plot/> <itemLabel/> </pie3DPlot> </pie3DChart> </band> </detail> <columnFooter> <band height="45" splitType="Stretch"/> </columnFooter> <pageFooter> <band height="54" splitType="Stretch"/> </pageFooter> <summary> <band height="42" splitType="Stretch"/> </summary></jasperReport>[/code]
  4. Thanks gdmoreno? I got this problem with ireport 5.5 with jdk 1.8 on windows 7 32 bit. the problem as resolved by finstalling JDK 1.7 instead of 1.8
×
×
  • Create New...