jfreechart icon indicating copy to clipboard operation
jfreechart copied to clipboard

HistogramDataset initialized to Double.MAX_VALUE causes IllegalArgumentException

Open argote opened this issue 8 years ago • 9 comments

When a HistogramDataset is initialized with a maximum bin range of Double.MAX_VALUE and axis autoscaling is enabled the following exception happens:

java.lang.IllegalArgumentException: Must be finite.
    at org.jfree.chart.axis.NumberTickUnitSource.getCeilingTickUnit(NumberTickUnitSource.java:114)
    at org.jfree.chart.axis.NumberAxis.selectHorizontalAutoTickUnit(NumberAxis.java:855)
    at org.jfree.chart.axis.NumberAxis.selectAutoTickUnit(NumberAxis.java:824)
    at org.jfree.chart.axis.NumberAxis.refreshTicksHorizontal(NumberAxis.java:949)
    at org.jfree.chart.axis.NumberAxis.refreshTicks(NumberAxis.java:921)
    at org.jfree.chart.axis.ValueAxis.reserveSpace(ValueAxis.java:822)
    at org.jfree.chart.plot.XYPlot.calculateDomainAxisSpace(XYPlot.java:3031)
    at org.jfree.chart.plot.XYPlot.calculateAxisSpace(XYPlot.java:2990)
    at org.jfree.chart.plot.XYPlot.draw(XYPlot.java:3132)
    at org.jfree.chart.JFreeChart.draw(JFreeChart.java:1229)
    at org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1399)
    at org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1379)
    at org.jfree.chart.ChartUtilities.writeChartAsPNG(ChartUtilities.java:184)
    at org.jfree.chart.ChartUtilities.writeChartAsPNG(ChartUtilities.java:138)

This is on version 1.0.19.

argote avatar Mar 02 '16 01:03 argote

This also happens when creating a Scatter Plot with an XYSeriesCollection with an empty XYSeries (one without any values)

java.lang.IllegalArgumentException: Must be finite.
    at org.jfree.chart.axis.NumberTickUnitSource.getCeilingTickUnit(NumberTickUnitSource.java:114)
    at org.jfree.chart.axis.NumberAxis.selectHorizontalAutoTickUnit(NumberAxis.java:855)
    at org.jfree.chart.axis.NumberAxis.selectAutoTickUnit(NumberAxis.java:824)
    at org.jfree.chart.axis.NumberAxis.refreshTicksHorizontal(NumberAxis.java:949)
    at org.jfree.chart.axis.NumberAxis.refreshTicks(NumberAxis.java:921)
    at org.jfree.chart.axis.ValueAxis.reserveSpace(ValueAxis.java:822)
    at org.jfree.chart.plot.XYPlot.calculateDomainAxisSpace(XYPlot.java:3031)
    at org.jfree.chart.plot.XYPlot.calculateAxisSpace(XYPlot.java:2990)
    at org.jfree.chart.plot.XYPlot.draw(XYPlot.java:3132)
    at org.jfree.chart.JFreeChart.draw(JFreeChart.java:1229)
    at org.jfree.chart.ChartPanel.paintComponent(ChartPanel.java:1628)

argote avatar Mar 19 '16 00:03 argote

Hi, Do we have a solution for this or some work around?

ShaunDeng avatar Jul 04 '19 03:07 ShaunDeng

Do you have a sample program that shows how this is occurring?

jfree avatar Jul 05 '19 14:07 jfree

Hi, Yes. I will post the code after I filter the sensitive data

ShaunDeng avatar Jul 08 '19 02:07 ShaunDeng

ChartPanelDemo.txt

Do you have a sample program that shows how this is occurring?

Hi, now please see the attachment. After the program run, you should keep zoom in the graph to reproduce the exception.

ShaunDeng avatar Jul 08 '19 06:07 ShaunDeng

Are you sure you uploaded the correct file? There’s no use of the dataset mentioned in the title. Also, it doesn’t compile with the latest version of jfreechart. David removed the traceline functionality back in February of 2018.

tracylynne99 avatar Jul 08 '19 16:07 tracylynne99

Well, I post here is because I got the same exception print as the original reporter argote. And the traceline is not the cause of this exception I think, the traceline things you saw in the code is because I can't post the real code from my project to public network, so I create a demo class to reproduce it. Anyway, I will recompile with the latest version of jfreechart and see if this is reproduceable.

ShaunDeng avatar Jul 09 '19 01:07 ShaunDeng

ChartPanelDemo.txt I prepared another file base on 1.5(I notice your latest tag in this repository is 1.5), please help. The exception above is still reproduceable.

ShaunDeng avatar Jul 09 '19 02:07 ShaunDeng

JFreeChart 1.5.3 still have the same bug :(

java.lang.IllegalArgumentException: Must be finite.
	at org.jfree.chart.axis.NumberTickUnitSource.getCeilingTickUnit(NumberTickUnitSource.java:108)
	at org.jfree.chart.axis.NumberAxis.selectVerticalAutoTickUnit(NumberAxis.java:837)
	at org.jfree.chart.axis.NumberAxis.selectAutoTickUnit(NumberAxis.java:760)
	at org.jfree.chart.axis.NumberAxis.refreshTicksVertical(NumberAxis.java:989)
	at org.jfree.chart.axis.NumberAxis.refreshTicks(NumberAxis.java:869)
	at org.jfree.chart.axis.ValueAxis.reserveSpace(ValueAxis.java:730)
	at org.jfree.chart.plot.XYPlot.calculateRangeAxisSpace(XYPlot.java:2785)
	at org.jfree.chart.plot.XYPlot.calculateAxisSpace(XYPlot.java:2696)
	at org.jfree.chart.plot.XYPlot.draw(XYPlot.java:2840)
	at org.jfree.chart.JFreeChart.draw(JFreeChart.java:1160)
	at org.jfree.chart.ChartPanel.paintComponent(ChartPanel.java:1452)

Camill13 avatar Apr 24 '21 11:04 Camill13