Set fixed axis values

I had code that sets the V axis scale from 0 to 4. However, I deleted it, and now I can’t remember how I started working again. See below the code for my chart and the code that I think I used before.

This is what I think before ...

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

Below is my schedule

  // 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]}, }); 
+4
source share
2 answers

There you go:

  'vAxis': {'title': 'Something Here', 'minValue': 0, 'maxValue': 4}, 
+9
source

There are two approaches, depending on what you need. The first of them (shown by Tom's answer) sets alternative minimum and maximum values ​​for the data set sent to the chart, for example. the chart interprets the maximum data value that must match MAX (vAxis.maxValue, maximum data set value). If the dataset goes beyond vAxis.minValue / maxValue, these parameters will be essentially ignored. In addition, the range of the actual axis of the graph is based only on the min / max values ​​- the displayed values ​​will include min / max, but may go beyond min / max to ensure clean intervals between axis labels.

If you need to explicitly limit the axis to a specific range where your minimum and maximum values ​​are the absolute limits that you want to display, then you use the vAxis.viewWindow.min / max parameters.

+4
source

Source: https://habr.com/ru/post/1499402/


All Articles