Google Groups

Re: multiple y axes on a line graph using logarithmic scale


asgallant Aug 19, 2011 11:40 AM
Posted in group: Google Visualization API
The axis values are calculated automatically at the minValue, maxValue, and 1/4 increments of the axis between them (ex: 0, 25, 50, 75, 100).  I wrote a function that calculates the maxValue based on a given largest value in the series, minimum axis value, and whether the scale is linear or logarithmic

/*  this function finds the smallest integer value >= val that gives integer values for the 
 *  25%, 50%, and 75% axis increments, given a minimum value of min
 *  parameters:
 *      val = the value to start at
 *      min = the minimum axis value
 *      log = boolean, true if the axis has a logarithmic scale
 *  returns the max axis value
 */

function findMaxAxisValue(valminlog{
    var max Math.ceil(val);
    if (log{
        while(Math.pow(max0.25!== parseInt(Math.pow(max0.25)){
            max++;
        }
    }
    else {
        while ((max min)/!== parseInt((max min)/4){
            max++;
        }
    }
    return max;
}