Skip to content

Instantly share code, notes, and snippets.

@kevinsdooapp
Created August 1, 2012 12:43
Show Gist options
  • Save kevinsdooapp/3226509 to your computer and use it in GitHub Desktop.
Save kevinsdooapp/3226509 to your computer and use it in GitHub Desktop.
calculateTickValues implementation for logarithmic axis
/**
* {@inheritDoc}
*/
@Override
protected List<Number> calculateTickValues(double length, Object range) {
List<Number> tickPositions = new ArrayList<Number>();
if (range != null) {
Number lowerBound = ((Number[]) range)[0];
Number upperBound = ((Number[]) range)[1];
double logLowerBound = Math.log10(lowerBound.doubleValue());
double logUpperBound = Math.log10(upperBound.doubleValue());
for (double i = 0; i <= logUpperBound; i += 1) {
for (double j = 1; j <= 9; j++) {
double value = j * Math.pow(10, i);
tickPositions.add(value);
}
}
}
return tickPositions;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment