Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting the lower limit of a LogAxis to zero creates a blank chart #215

Open
JP95Git opened this issue Feb 11, 2021 · 1 comment
Open

Setting the lower limit of a LogAxis to zero creates a blank chart #215

JP95Git opened this issue Feb 11, 2021 · 1 comment

Comments

@JP95Git
Copy link

JP95Git commented Feb 11, 2021

Hi,

I use JFreeChart 1.5.2 to display various things. One of my testers discovered that if he sets the lower limit (setLowerBound) of the LogAxis to zero, a blank chart is shown. It happens in all charts, which uses a LogAxis. If I replace LogAxis with NumberAxis, everything works without a problem.

Here is some example code, which runs as a Tomcat webapp:

try (OutputStream out = response.getOutputStream();) {
	String axisName = "Pressure";
	JFreeChart chart = ChartFactory.createTimeSeriesChart("", "Date", axisName, seriesCollection, true, false, false);
	XYPlot plot = (XYPlot) chart.getPlot();

	LogAxis rangeLogAxis = new LogAxis(axisName);
	// Customize the axis..., but this does not affect the bug.
	plot.setRangeAxis(rangeLogAxis);
	if (minY != null) {
		rangeLogAxis.setLowerBound(minY.doubleValue());
	}
	if (maxY != null) {
		rangeLogAxis.setUpperBound(maxY.doubleValue());
	}
	ChartUtils.writeChartAsPNG(out, chart, 800, 600);
}

minY and maxY are the lower and upper limit of the axis, which can be changed by the user.

Setting a very small value like 0.1 instead of zero creates my chart again and is a nice workaround, but zero should work too.

@JP95Git JP95Git changed the title Setting the lower limit of a LogAxis creates a blank chart Setting the lower limit of a LogAxis to zero creates a blank chart Feb 11, 2021
@trashgod
Copy link
Contributor

As the logarithm approaches negative infinity for arguments approaching zero, why not use the initial minimum range value, 0.01, or getSmallestValue()?

mgdixon pushed a commit to mgdixon/jfreechart that referenced this issue Nov 9, 2021
jfree#215

Math.log(0) is undefined, but doesn't throw an error. This commit
just makes it so the min value on the axis is the min value
acceptable (1e-100). Added two tests to check this works.
richardxs added a commit to MadFoal/jfreechart that referenced this issue Nov 10, 2021
richardxs added a commit to MadFoal/jfreechart that referenced this issue Nov 18, 2021
richardxs added a commit to MadFoal/jfreechart that referenced this issue Nov 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants