var max = 195;
var min = -15;
var maxl = max.toString().length;
var minl = min.toString().length;
//get multiplier to round up
var multp = '1';
for (var i = 0; i < maxl-2; i++){
multp += '0';
}
multp = parseInt(multp);
var maxy = Math.ceil(max/multp)*multp;
//get multiplier to round down
var multn = '1';
for (var i = 0; i < minl-2; i++){
multn += '0';
}
multn = parseInt(multn);
var miny = Math.floor(min/multn)*multn;
//get max y range
rngy = maxy + Math.abs(miny);
rngl = rngy.toString().length;
//get range multiplier
var multr = '1';
for (var i = 0; i < rngl-2; i++){
multr += '0';
}
var divln = rngy/parseInt(multr);
//if divln is divisible by 2 then divide by 2 minus 1
if (divln%2 == 0) {
divln = divln/2 - 1;
}
alert(maxy);
alert(miny);
alert(divln);
Page 1 of 1
Calculate Y axis max, min, and numdivlines
#1
Posted 08 October 2009 - 02:44 AM
I'm trying to write a javascript function to calculate the Y axis max, min, and numdivlines on a FCF_MSColumn2D chart. I can't consistently get it to calculate numdivlines so that it scales nicely on the chart. See my code below (very bad coding, I know). It works as is but if you change the max value from 195 to 125 then the scaling doesn't look nice. Not sure what I'm doing. Can someone please help if you have done this before? Thanks...
Other Replies To This Topic
Page 1 of 1

Back to top
MultiQuote