Axis Min and Max values
A common request when creating charts is to fix the minimum and maximum values for the vertical axis¹. One common reason for doing this is that the position of the line within the chart conveys important meaning. The default behavior is to plot the smallest data point at the lowest point and the largest data point at the highest point. It’s great default. But sometimes the axis should display 0 to 100 regardless of what the data values are.
In the chart below I invented downtime statistics for a server I’m administering. It was unavailable for one hour on Wednesday. One hour corresponds to 3,600,000 milliseconds, or about 4% of a 24 hour day. This chart nicely shows how downtime spikes on Wednesday. But the chart fails to put into perspective the idea that 4% is relatively small compared to 100%.
It has always been possible to create a chart customizer that forces the axis min and max. But this is not a pleasant option for new users as it requires knowledge of Java and of JFreeChart. Starting with iReport 3.5 (and the corresponding JasperReports 3.5) it’s as easy to set these values as it should be.
In the chart below I have set the min and max to 0 and 1. Now we see visually how the downtime is small. The corresponding trade off is that the chart is able to show less precision between the different values. In this case I’m happy with the trade off. I want to focus on the fact that downtime was minimal.
More importantly, it took me approximately 5 seconds to set the min and max values for this chart. This is a huge benefit compared with the prospect of writing a Java class in order to set this property.
Sysadmins out there who target 5 9′s or more may scoff at my claim that one hour of downtime isn’t much. (5 9′s corresponds to 99.999% uptime.) But of course the point is that there are times when using fixed axes is desirable.
Other reasons for wanting fixed axes include reports that serve a dashboarding function. With these we need to very quickly identify if lines (or bars) fall into acceptable ranges. If the range on the chart may be different depending on the data, then it will require more effort to assess if the values are acceptable. Likewise, if I place two charts next to each other it’s common that I’ll want to make comparisons between them. Forcing the min and max values for the axes allow me to do this.
Now that this ability has gone from possible to dead easy, I think we’ll see a lot more Jaspersoft users taking advantage of it.
¹ Although I wrote “vertical axis”, this is not quite correct. Line and bar charts can display vertically or horizontally. The axis I want to fix is therefore not necessarily the vertical axis. More formally the horizontal axis in my examples is called the category axis, and the vertical axis is called the value axis or range axis. For this reason the properties that I set in iReport are called “Range Axis Min Value Expression” and “Range Axis Max Value Expression”.