How to set Axis step in Google Chart?

I am wondering how to set the axis step in a google diagram built from JavaScript? I use this to set min and max:

vAxis: { title: 'temps (ms)', viewWindowMode: 'explicit', viewWindow: { max: 180, min: 0 }, } 

And I need to add another constraint to fix the vertical pitch to 0.1, for example.

+8
javascript google-visualization
source share
3 answers

Finally, I found a trick using:

  vAxis: { title: 'temps (ms)', viewWindowMode: 'explicit', viewWindow: { //max: 180, min: 0, }, gridlines: { count: 10, } } 

He does not set steps, but instead says that

max / (nb steps) = count (here 10 )

So, for example, with max set to 180 , each step will have a value of 18 , using count: 10 .

+26
source share

I essentially did what I did, calculating the maximum value, multiplying it by 1.1 (to account for the filling over the maximum element in the diagram) and dividing it by the steps I wanted to give me which steps I needed.

 vAxis: { title: 'vAxis', minValue: 0, gridlines: { count: Math.ceil(max * 1.1 / interval) // try to pick the correct number to create intervals of 50000 } } 

where max is the maximum value and interval is the desired interval. This has not been thoroughly verified, so the constant 1.1 and the use of Math.ceil may need to be changed.

+1
source share

You can do this with the checkboxes:

 vAxis: { title: 'temps (ms)', viewWindow: { min: 0, max: 180 }, ticks: [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180] // display labels every 10 } 
+1
source share

All Articles