RE: Problems (NullPointer or ArrayIndex) if no d ata available for barchart

Fredrik Bertilsson <[email protected]>
Newsgroups gmane.comp.krysalis.jcharts.user
Message-ID <[email protected]>
I agree with Tamer that a validation would be a very nice thing indeed to
have. When systems get connected together, the presentation system is not in
control of the data. Introducing a check would imho have a minimal
performance overhead.

Best regards,
Fredrik

-----Original Message-----
From: Nathaniel G. Auvil [mailto:[email protected]] 
Sent: 27. februar 2004 15:02
To: [email protected]
Subject: RE: [jCharts-users] Problems (NullPointer or ArrayIndex) if no data
available for barchart



Well, i guess the decision was why would someone try to plot a null dataset?
I am not sure this is something that happens very often so I would like to
avoid the overhead and code of a validation.


--- [email protected] wrote:
> providing a placeholder image is exactly how we solved this issue.
> 
> still I was wondering, whether the cart implementation couldn't handle 
> that. or let's say I was surprised it didn't catch that scenario and 
> throw at least some validation exception instead of running into 
> nullpointer.
> 
> 
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]]On Behalf Of 
> Nathaniel G. Auvil
> Sent: Freitag, 27. Februar 2004 01:29
> To: [email protected]
> Subject: Re: [jCharts-users] Problems (NullPointer or ArrayIndex) if 
> no data available for barchart
> 
> 
> 
> If there is no data what do you expect to see in a chart?  What would 
> be on the y-axis if there are no data elements?
> 
> I would think your logic, would see there was no data, and stream a 
> placeholder image instead of the chart or a chart with a few zero 
> values and labels of empty Strings.
> 
> 
> 
> 
> --- [email protected] wrote:
> > hi all
> > 
> > we are generating clusteredbarcharts based on the result of some 
> > database selects, so the data to display is not static. we have a 
> > problem if there is no data. I have tried different ways to tweak 
> > this issue, but always ran into troubles:
> > 
> > I'm using jcharts 0.7.4 (the posted methods are the same in 0.7.5)
> > 
> > - legendlabels and data array (double[][]) are null
> > 
> > java.lang.NullPointerException
> > 	at
org.jCharts.chartData.AxisChartDataSet.getNumberOfDataSets(AxisChartDataSet.
java:136)
> > 	at 
> > org.jCharts.chartData.AxisDataSeries.addIAxisPlotDataSet(AxisDataSer
> > ies.java:166)
> > 
> > code which throws exception [AxisChartDataSet.getNumberOfDataSets]:
> > 	public final int getNumberOfDataSets()
> > 	{
> > 		return this.data.length;
> > 	}
> > 
> > - legenlabels is null, data array is new double[0][0];
> > 
> > java.lang.ArrayIndexOutOfBoundsException: 0
> > 	at
org.jCharts.chartData.DataSet.getNumberOfDataItems(DataSet.java:148)
> > 	at 
> > org.jCharts.chartData.AxisDataSeries.addIAxisPlotDataSet(AxisDataSer
> > ies.java:168)
> > 
> > code which throws exception [DataSet.getNumberOfDataItems]:
> > 	public int getNumberOfDataItems()
> > 	{
> > 		return this.data[ 0 ].length;
> > 	}
> > 
> > is there any reason, why null and/or length is not checked in those 
> > methods ??
> > 
> > is there any other way to get a empty chart, I do set
> > setUserDefinedScale(0, 2)
> > setNumItems(5)
> > 
> > 
> > regards
> > 
> > tamer
> > 
> > 
> > -------------------------------------------------------
> > SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and 
> > deploy apps & Web services for Linux with a free DVD software kit 
> > from IBM. Click Now! 
> > http://ads.osdn.com/?ad_id56&alloc_id438&op=click
> > _______________________________________________
> > jCharts-users mailing list [email protected]
> > https://lists.sourceforge.net/lists/listinfo/jcharts-users
> 
> 
> __________________________________
> Do you Yahoo!?
> Get better spam protection with Yahoo! Mail. 
> http://antispam.yahoo.com/tools
> 
> 
> -------------------------------------------------------
> SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and 
> deploy apps & Web services for Linux with a free DVD software kit from 
> IBM. Click Now! http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
> _______________________________________________
> jCharts-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jcharts-users
> 
> 
> -------------------------------------------------------
> SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and 
> deploy apps & Web services for Linux with a free DVD software kit from 
> IBM. Click Now! http://ads.osdn.com/?ad_id56&alloc_id438&op=click
> _______________________________________________
> jCharts-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jcharts-users


__________________________________
Do you Yahoo!?
Get better spam protection with Yahoo! Mail. http://antispam.yahoo.com/tools


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
jCharts-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jcharts-users


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.powel.no
**********************************************************************



-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.