Logscale steps Google Visualization API

96 views
Skip to first unread message

Alex Hovenkamp

unread,
Oct 4, 2012, 3:36:10 AM10/4/12
to google-visua...@googlegroups.com
Hi,
I implemented a column chart with a logscale. The chart does show the x-axis with a logscale, but the steps are a bit strange.

The current logscale: 1-    31.6-    1000-    31622,8-    1000000
I would like to remove the steps that are in between the log steps.
Wanted: 0.0  -  0.1  -  1  -  10  -  100  -  1000  -  10000  -  100000  -  1000000

How can I accomplish this? Thanks in advance

alex89

unread,
Oct 4, 2012, 3:44:27 AM10/4/12
to google-visua...@googlegroups.com
The problem seems to be the number of gridlines. The default is 5, which explains the strange axis. I can change the number of gridlines with "gridlines:{count:NUMBER}", but I would like to have a logical axis without having to edit the axis manually. How can I do this?

Op donderdag 4 oktober 2012 09:36:10 UTC+2 schreef Alex Hovenkamp het volgende:

asgallant

unread,
Oct 4, 2012, 11:04:27 AM10/4/12
to google-visua...@googlegroups.com
There is no setting that forces the axis to use only integer powers of 10 when in log scale.  A while back, I wrote this function:

/*  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;
}

which will auto-calculate the max value to use as vAxis.maxValue.  It occurs to me now that I missed including the min value in the logscale calculation, but as long as you leave the vAxis.minValue at its default, you should be fine.

This code also assumes that you leave the gridlines.count option at its default (5), as this option didn't exist when I wrote the code.

Alex Hovenkamp

unread,
Oct 8, 2012, 3:27:06 AM10/8/12
to google-visua...@googlegroups.com
Thank you for your answer, I will try this:)

2012/10/4 asgallant <drew_g...@abtassoc.com>

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-visualization-api/-/Fg-PZX1I1jMJ.

To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.

Reply all
Reply to author
Forward
0 new messages