Home
Tools & Apps
About
Contact
Execute Javascript Sample Code
Click textarea to view code at full size.
function linear_to_exponent(min_x, max_x, min_y, max_y, steepness) { var x_range = max_x - min_x; var y_range = max_y - min_y; this.y_values = new Array(); this.init = function(){ for(var i = min_x; i <= max_x; i++) { this.y_values[i] = this.lin_to_exp(i); } } this.lin_to_exp = function (x) { return (x / x_range) * y_range * Math.exp(steepness * x / x_range) / Math.exp(steepness) + min_y; } this.exp_to_lin = function (y){ if(y < this.y_values[0]) return 0; for(var i = min_x; i < max_x; i++) if(y >= this.y_values[i] && y < this.y_values[i+1]) return i; if(y >= this.y_values[max_x - 1]) return max_x; } } var max_y = 1500000; var l2e = new linear_to_exponent(0, 200, 500, max_y, 4); l2e.init(); $('#graph').remove(); $('#workspace').append('
Workspace
'); $('#graph').css('width', '500px'); $('#graph').css('height', '300px'); $('#graph').css('border', '1px solid #555'); var log_vals = new Array(); for(i=0; i<= 200; i+=20) { y_val = l2e.lin_to_exp(i); x_val = l2e.exp_to_lin(y_val); var str = '
'; $('#graph').append(str); var strx = '
'; $('#graph').append(strx); }
Search for:
Categories
Culture
(1)
Geek Tips
(7)
Latest News
(2)
Random "Analysis"
(1)
Uncategorized
(2)
Web Traffic & Analytics
(1)
Archives
January 2012
March 2011
February 2011
November 2010
June 2010
December 2009
July 2009
March 2009
February 2009
Website Links
Tommy Unger’s Home
Unger Family Blog
#000000
#1d3147
#415973
#9dacb9
#4c3724
#897661
#d1c8c0
#ffffff