Range(double, double): require lower (Infinity) <= ...

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
cmose
Posts: 5
Joined: Wed Mar 07, 2007 3:25 pm

Range(double, double): require lower (Infinity) <= ...

Post by cmose » Thu Mar 08, 2007 3:41 pm

Hello again,
I've got a stackedxyareachart based on a timetablexydataset. When the timetablexydataset is populated with only 0 value tasks, I receive the following exception from the chart:

Code: Select all

java.lang.IllegalArgumentException raised:
Range(double, double): require lower (Infinity) <= upper (-Infinity).

java.lang.IllegalArgumentException raised:Range(double, double): require lower (Infinity) <= upper (-Infinity).
at org.jfree.data.Range.<init>(Range.java:89)
at org.jfree.chart.plot.XYPlot.getDataRange(XYPlot.java:3194)
at org.jfree.axis.NumberAxis.autoAdjustRange(NumberAxis.java:390)
at org.jfree.axis.NumberAxis.configure(NumberAxis.java:373)
at org.jfree.axis.Axis.setPlot(Axis.java:732)
at org jfree.chart.plot.XYPlot<init>(XYPlot.java:511)
...
any suggestions as to what might be the problem here?
Thanks much.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Thu Mar 08, 2007 5:08 pm

It sounds like you've triggered a bug. I'll try to reproduce it, but if you can supply a small self-contained demo that shows the problem, that will help a lot.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

cmose
Posts: 5
Joined: Wed Mar 07, 2007 3:25 pm

Post by cmose » Fri Mar 09, 2007 3:07 pm

david thanks for the info. Unfortunately my code is on a development network without internet access and I don't fancy hand typing all that over. I'll hop back on in a few though and type in the relevant (at least, what I believe to be relevant given my limited understanding of the library) bits.

oscar
Posts: 26
Joined: Fri May 28, 2004 10:01 am
Location: Switzerland

Post by oscar » Tue Mar 13, 2007 11:45 am

I get the same exception in an XYPlot. The plot object is created with a null dataset (no problem doing that according to the API...). Then later, I try to set the max and min values of the date axis to constant values (ie, 0900h and 1830h) and I get the exception:

Code: Select all

java.lang.IllegalArgumentException: Range(double, double): require lower (1.17285432E12) <= upper (1.172853E12).
	at org.jfree.data.Range.<init>(Range.java:89)
	at org.jfree.data.time.DateRange.<init>(DateRange.java:83)
	at org.jfree.chart.axis.DateAxis.setMaximumDate(DateAxis.java:555)
	at swx.eservices.chart.ChartReader.createChart(ChartReader.java:561)
	at swx.eservices.chart.ChartReader.generate(ChartReader.java:313)
I will try to reproduce this in the demo code and post an example...

cmose
Posts: 5
Joined: Wed Mar 07, 2007 3:25 pm

Post by cmose » Tue Mar 13, 2007 1:03 pm

whoops, been out sick so didn't get a chance to pop back on here....
I think I had been setting a max range but there was never a null dataset. The dataset was always 0 filled in the event that there was no data (have a line chart based on the same dataset and that works fine).

It's late but I'll try to print out the creation of the dataset and the chart and transcribe them here in a bit. Have to get settled in for the morning yet ;-)

cmose
Posts: 5
Joined: Wed Mar 07, 2007 3:25 pm

Post by cmose » Wed Mar 14, 2007 12:45 pm

ok, here are the relevant bits of code.

where I create the chart:

Code: Select all

NumberAxis yAxis = new NumberAxis("Bytes");
DateAxis dateAxis = new DateAxis("Hour");
TimeTableXYDataset ttd = (TimeTableXYDataset)data;
dateAxis.setTickUnit(new DateTickUnit(DateTickUnit.HOUR), 1));
XYPlot plot = new XYPlot(ttd, dateAxis, yAxis, new StackedXYAreaRenderer2());
JFreeChart chart = new JFreeChart(plot);
where I populate the dataset:

Code: Select all

TimeTableXYDataset ttd = new TimeTableXYDataset();
...
//fetch data from database grouped by hour
//loop through last 24 hours, if there is data for a given hour:
if(data for given hour){
   ttd.add(new Hour(tempDate), type.getTotalBytes(), type.getType());
}else{//if no data for that hour
   for(String s : Series){
      ttd.add(new Hour(tempDate), 0f, s);
   }
}
bascially all I'm doing is populating the dataset if there is data from the database. If there isn't any data from the database, I 0 fill the dataset for each hour of the last 24, setting a 0 value for each series. I've verified that a null dataset is not being returned...

oscar
Posts: 26
Joined: Fri May 28, 2004 10:01 am
Location: Switzerland

Patch to reproduce bug

Post by oscar » Thu Apr 19, 2007 10:29 am

The bug is still present in 1.0.5. To reproduce it, apply the patch below to jfreechart-1.0.5-demo/source/demo/TimeSeriesDemo1.java then recompile and run the demo. You will get the IllegalArgumentException...

Code: Select all

11a12
> import java.util.Date;
92a94,95
> 	axis.setMinimumDate(new Date(2007, 01, 01));
> 	axis.setMaximumDate(new Date(2007, 01, 02));
107,124d109
<         s1.add(new Month(2, 2001), 181.8);
<         s1.add(new Month(3, 2001), 167.3);
<         s1.add(new Month(4, 2001), 153.8);
<         s1.add(new Month(5, 2001), 167.6);
<         s1.add(new Month(6, 2001), 158.8);
<         s1.add(new Month(7, 2001), 148.3);
<         s1.add(new Month(8, 2001), 153.9);
<         s1.add(new Month(9, 2001), 142.7);
<         s1.add(new Month(10, 2001), 123.2);
<         s1.add(new Month(11, 2001), 131.8);
<         s1.add(new Month(12, 2001), 139.6);
<         s1.add(new Month(1, 2002), 142.9);
<         s1.add(new Month(2, 2002), 138.7);
<         s1.add(new Month(3, 2002), 137.3);
<         s1.add(new Month(4, 2002), 143.9);
<         s1.add(new Month(5, 2002), 139.8);
<         s1.add(new Month(6, 2002), 137.0);
<         s1.add(new Month(7, 2002), 132.8);
127,144d111
<         s2.add(new Month(2, 2001), 129.6);
<         s2.add(new Month(3, 2001), 123.2);
<         s2.add(new Month(4, 2001), 117.2);
<         s2.add(new Month(5, 2001), 124.1);
<         s2.add(new Month(6, 2001), 122.6);
<         s2.add(new Month(7, 2001), 119.2);
<         s2.add(new Month(8, 2001), 116.5);
<         s2.add(new Month(9, 2001), 112.7);
<         s2.add(new Month(10, 2001), 101.5);
<         s2.add(new Month(11, 2001), 106.1);
<         s2.add(new Month(12, 2001), 110.3);
<         s2.add(new Month(1, 2002), 111.7);
<         s2.add(new Month(2, 2002), 111.0);
<         s2.add(new Month(3, 2002), 109.6);
<         s2.add(new Month(4, 2002), 113.2);
<         s2.add(new Month(5, 2002), 111.6);
<         s2.add(new Month(6, 2002), 108.8);
<         s2.add(new Month(7, 2002), 101.6);
Basically, you remove all the data points in the createDataset method (nothing wrong with that...) then try to setMinimumDate/setMaximumDate in the createChart method.[/code]

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Thu Apr 19, 2007 3:01 pm

Thanks for the steps to reproduce. Be careful when you use that deprecated java.util.Date constructor - the year argument must be supplied as 'year - 1900' (that is, 107 if you want 2007). Still, it reproduces the bug either way. For the next release (1.0.6) I'll make the setMaximumDate() and setMinimumDate() methods check to see where the new bound is relative to the opposite bound on the axis, and adjust if necessary.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

oscar
Posts: 26
Joined: Fri May 28, 2004 10:01 am
Location: Switzerland

Post by oscar » Fri Apr 20, 2007 11:13 am

Thanks for having a look at this buglet... I await 1.0.6 with anticipation!

Rgds,
Oscar

oscar
Posts: 26
Joined: Fri May 28, 2004 10:01 am
Location: Switzerland

Patch added to sourceforge

Post by oscar » Fri Apr 27, 2007 1:51 pm

I took your tips on how to avoid the exception and implemented them on our server. I submitted the patch to DataAxis.java on sourceforge (see https://sourceforge.net/tracker/index.p ... tid=315494)

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Fri Apr 27, 2007 4:08 pm

Here is the patch I already applied:

http://jfreechart.cvs.sourceforge.net/j ... ABLE_1-0-0
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Locked