jfreechart
jfreechart copied to clipboard
HistogramDataset initialized to Double.MAX_VALUE causes IllegalArgumentException
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.
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)
Hi, Do we have a solution for this or some work around?
Do you have a sample program that shows how this is occurring?
Hi, Yes. I will post the code after I filter the sensitive data
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.
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.
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.
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.
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)