Skip to content

Instantly share code, notes, and snippets.

@alexyoung
Created January 31, 2009 11:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexyoung/55517 to your computer and use it in GitHub Desktop.
Save alexyoung/55517 to your computer and use it in GitHub Desktop.
Ico.Base = Class.create({
/* Returns a suitable set of labels for given data points on the Y axis */
labelStep: function(data) {
var min = data.min(),
max = data.max(),
range = max - min,
step = 0;
if (range < 2) {
step = 0.1;
} else if (range < 3) {
step = 0.2;
} else if (range < 5) {
step = 0.5;
} else if (range < 11) {
step = 1;
} else if (range < 50) {
step = 5;
} else if (range < 100) {
step = 10;
} else {
step = Math.pow(10, (Math.log(range) / Math.LN10).round() - 1);
}
return step;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment