Under certain circumstances the gridind value can be -1 when attempting to use it in the draw() method in the ValueAxis class. This causes an ArrayIndexOutOfBounds exception when drawing the graph...
I didn't fully understand what was going on in the code of that method, but here is some modified code that seems to fix the problem
int j = 0;
for (int i = 0; ylab[i].grid > 0; i++) {
j = i;
pixel = (int) (im.ysize / (scaledrange / ylab[i].grid));
if (gridind == -1 && pixel > 5) {
gridind = i;
break;
}
}
if (gridind < 0) {
gridind = j;
}
Logged In: NO
Although the above fix prevents the exception from occurring, sometimes, if the graph y-axis has very large values (thousands), the number of horizontal minor lines drawn will be too many and the graph will appear to be swamped with minor horizontal axis...
Two and a half years after someone reported this bug I also run into it. Here is the relevant part of the backtrace with JRobin 1.5.9.1:
java.lang.ArrayIndexOutOfBoundsException: -1
at org.jrobin.graph.ValueAxis.draw(ValueAxis.java:129)
at org.jrobin.graph.RrdGraph.drawGrid(RrdGraph.java:212)
at org.jrobin.graph.RrdGraph.createGraph(RrdGraph.java:93)
at org.jrobin.graph.RrdGraph.<init>(RrdGraph.java:59)