Jump to content
Changes to the Jaspersoft community edition download ×

NullPointerException while filling a chart

2004 IR Help

Recommended Posts

By: Tiago Rinck Caveden - caveden

NullPointerException while filling a chart

2005-09-28 10:51

Hello there!


I'm having some trouble while trying to use a TimeSeriesChart in my report. A NullPointerException is raising during the filling process.

I'm using jasperreports 1.0.2.


I'm making a prototype so it doesn't need real data yet, but I was told to do it in a way it could be re-used during development (so I can't just draw a chart).


My chart is located at the pageHeader band. I'm suspected this might be a problem, because I've already inspected the jasper code (one more reason to love Open Sources ;)) and found out that the error ocurr because the getSeries method of a JRFillTimeSeries object is being called before it's evaluate method, the one responsable for setting the series. The call to this getter is made at JRFillTimeSeriesDataset line 125, and the NullPointerException then raises at line 129.


Does always a chart has to be at the detail band?

If so, how do I do when my datasource is empty? Will I have to make a fake collection of fake beans just to fill this chart with static data (can't it be done easier, like I've tryied (bellow))

Any help is very much welcome!


Bellow is my chart xml code:



<chart evaluationTime="Report" hyperlinkTarget="Self" >
















<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>



<dataset incrementType="Column" />




<valueExpression><![CDATA[new Integer(1)]]></valueExpression>





<valueExpression><![CDATA[new Integer(9)]]></valueExpression>





<valueExpression><![CDATA[new Integer(8)]]></valueExpression>





<valueExpression><![CDATA[new Integer(6)]]></valueExpression>





<valueExpression><![CDATA[new Integer(3)]]></valueExpression>



<timeSeriesPlot >

<plot />





Above I paste the source of the method where the NullPointerException is raising, if that helps some how (crtTimeSeries.evaluate should have being called before (I think) crtTimeSeries.getSeries(), but it wasn't, not even in other methods (I checked it out with breakpoints)):



protected void customIncrement()


if (timeSeries != null && timeSeries.length > 0)


if (seriesNames == null)


seriesNames = new ArrayList();

seriesMap = new HashMap();

labelsMap = new HashMap();



for (int i = 0; i < timeSeries.length; i++)


JRFillTimeSeries crtTimeSeries = timeSeries;


Comparable seriesName = crtTimeSeries.getSeries();

TimeSeries series = (TimeSeries)seriesMap.get(seriesName);

if(series == null)


series = new TimeSeries(seriesName.toString(), getTimePeriod());


seriesMap.put(seriesName, series);



RegularTimePeriod tp =







series.addOrUpdate(tp, crtTimeSeries.getValue());


if (crtTimeSeries.getLabelExpression() != null)


Map seriesLabels = (Map)labelsMap.get(seriesName);

if (seriesLabels == null)


seriesLabels = new HashMap();

labelsMap.put(seriesName, seriesLabels);



seriesLabels.put(tp, crtTimeSeries.getLabel());





Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...