Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Fixed axis values

I had some code that set my V axis scale from 0 - 4. However I deleted it and now I cannot remember how I got it working again. See below for my chart code, and the code I think I used before.

This is what I think I used before...

vAxis: { 
viewWindowMode:'explicit',
viewWindow: {
    max:100,
    min:99.8
}
}

Below is my chart

          // Create a line chart, passing some options
    var LineChart = new google.visualization.ChartWrapper({
      'chartType': 'LineChart',
      'containerId': 'chart_div',


      'options': {
        //'width': 300,
        'height': 300,
        'legend': 'top',
        'backgroundColor': '#eeeeee',
        'colors': [ '#8ea23f'],
        'pointSize': 5,
        'title': 'Selected Site and Species abundance over time'
              },
    'view':{'columns':[0,2]},


    });
like image 699
Skot Avatar asked Dec 12 '22 11:12

Skot


2 Answers

There you go:

 'vAxis': {'title': 'Something Here',
 'minValue': 0, 
 'maxValue': 4},
like image 120
Tom Avatar answered Jan 19 '23 10:01

Tom


There are two approaches to take, depending on what you need. The first one (shown by Tom's answer) sets alternative min and max values for the data set sent to the chart, eg. the chart interprets the maximum data value is must accommodate as MAX(vAxis.maxValue, data set max value). If the data set goes outside the bounds of vAxis.minValue/maxValue, those options will essentially be ignored. Also, the chart's actual axis range is only based on the min/max values - the values displayed will include the min/max, but might go beyond the min/max in order to produce clean intervals between axis labels.

If you need to explicitly limit the axis to a specific range, where your min and max values are the absolute limits you want displayed, then you use the vAxis.viewWindow.min/max options.

like image 24
asgallant Avatar answered Jan 19 '23 10:01

asgallant