Null 'key' argument - Charts

0

My reports is working. But at the moment I add a chart.. I always receive following error:

Null 'key' argument

This is since I upgraded frop iReport to Jaspersoft Studio!

full error message:

java.lang.IllegalArgumentException: Null 'key' argument.
at org.jfree.data.DefaultKeyedValues.setValue(DefaultKeyedValues.java:229)
at org.jfree.data.DefaultKeyedValues2D.setValue(DefaultKeyedValues2D.java:337)
at org.jfree.data.DefaultKeyedValues2D.addValue(DefaultKeyedValues2D.java:303)
at org.jfree.data.category.DefaultCategoryDataset.addValue(DefaultCategoryDataset.java:222)
at net.sf.jasperreports.charts.fill.JRFillCategoryDataset.customIncrement(JRFillCategoryDataset.java:143)
at net.sf.jasperreports.engine.fill.JRFillElementDataset.increment(JRFillElementDataset.java:191)
at net.sf.jasperreports.engine.fill.JRCalculator.calculateVariables(JRCalculator.java:183)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:740)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:263)
at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:123)
at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:539)
at net.sf.jasperreports.engine.fill.JRFiller.fill(JRFiller.java:153)
at net.sf.jasperreports.engine.JasperFillManager.fill(JasperFillManager.java:474)
at com.jaspersoft.studio.utils.ExpressionUtil.initBuiltInParameters(ExpressionUtil.java:339)
at com.jaspersoft.studio.editor.preview.view.control.ReportControler$5.run(ReportControler.java:330)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
 
samhast's picture
92
Joined: Nov 4 2011 - 6:41am
Last seen: 2 years 9 months ago

4 Answers:

0

Have you set your chart components? Exactly which chart component are you trying to add and what is the exact steps you're taking?

I'm not getting any such error.

hozawa's picture
46897
Joined: Apr 24 2010 - 4:31pm
Last seen: 2 months 1 week ago
0

Screenshot from my chart wizard:

This is my report:

 

 

samhast's picture
92
Joined: Nov 4 2011 - 6:41am
Last seen: 2 years 9 months ago
0

Also - looking for help with Charting. I have the same  NULL KEY issue stated above.

 

Is there a good "How to" guide for charts?

mwolven's picture
29
Joined: Jun 3 2015 - 11:21am
Last seen: 3 years 7 months ago
0

I'm trying the tutorial at http://community.jaspersoft.com/wiki/creating-charts-and-subreports-jasp... and am getting the same error. 

This is using JasperReports 6.2 andjasper studio 6.2.

The graph in that tutorial is also a bar chart.

Are there any tricks for debugging this stuff?  Java stack traces into code you don't have sources to (org.jfree in this case) and exception messages like "null 'key' argument" are pretty useless.

Here's the jrxml generated from the example:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.2.0.final using JasperReports Library version 6.2.0  -->
<!-- 2016-01-28T16:16:22 -->
<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="GraphReport" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="c029557d-c3bc-47e9-a5ff-f7544e7265cb">
    <property name="com.jaspersoft.studio.data.sql.tables" value=""/>
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="Sample DB"/>
    <queryString>
        <![CDATA[select count(*), SHIPCITY from orders group by SHIPCITY]]>
    </queryString>
    <field name="C1" class="java.lang.Long"/>
    <field name="SHIPCITY" class="java.lang.String"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="350" splitType="Stretch">
            <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
            <barChart>
                <chart evaluationTime="Report">
                    <reportElement x="0" y="0" width="555" height="350" uuid="eb78ea14-af53-4212-90f4-0186ec9effcf"/>
                    <chartTitle/>
                    <chartSubtitle/>
                    <chartLegend/>
                </chart>
                <categoryDataset>
                    <categorySeries>
                        <seriesExpression><![CDATA[$F{SHIPCITY}]]></seriesExpression>
                        <valueExpression><![CDATA[$F{C1}]]></valueExpression>
                        <labelExpression><![CDATA[$F{SHIPCITY}]]></labelExpression>
                    </categorySeries>
                </categoryDataset>
                <barPlot>
                    <plot/>
                    <itemLabel/>
                    <categoryAxisLabelExpression><![CDATA[" "]]></categoryAxisLabelExpression>
                    <categoryAxisFormat>
                        <axisFormat/>
                    </categoryAxisFormat>
                    <valueAxisFormat>
                        <axisFormat/>
                    </valueAxisFormat>
                </barPlot>
            </barChart>
        </band>
    </title>
</jasperReport>
 

kcrews's picture
8
Joined: Jan 20 2016 - 2:12pm
Last seen: 2 years 5 months ago
Feedback
randomness