Created
January 31, 2009 11:27
-
-
Save alexyoung/55517 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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