Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Axis scale in google charts (from google spreadsheets)

Tags:

I've generated chart form google spreadsheets. In my report for horizontal axis I have values: 1 ,2 ,3 ,4 ,5 ,10 ,20 ,30 ,40 ,50 ,100 ,200 ,300 ,400 ,500 ,600 ,700 ,800 ,900 ,1000. Chart interprets them as a labels, not a number:

enter image description here

So the distance between 1 and 4 is the same as between 20 and 50. How to change it? (Maybe I have to transform input data - how?)

Here is my spreadsheet with input data, query and the chart.

I want to embed it in a webpage with such script:

    <script type="text/javascript" src="//ajax.googleapis.com/ajax/static/modules/gviz/1.0/chart.js"> 
{"dataSourceUrl":"//spreadsheets.google.com/spreadsheet/tq?key=0AtdHElsKyNw9dERVZ1lZRVNmYmRqSlVVbWszd3BVdGc&transpose=0&headers=1&range=F1%3AI21&gid=0&pub=1",
"options":{
    "reverseCategories":false,"titleX":"thousand objects","backgroundColor":"#FFFFFF","pointSize":0,
    "width":510,
    "vAxis":{"format":"#0.##########"},
    "smoothLine":true,"lineWidth":2,"logScale":false,"hasLabelsColumn":true,
    "hAxis":{"maxAlternation":1},
    "vAxes":[{"min":null,"title":"ms","max":null,"maxValue":null}],
    "title":"Performance of exposing previous value in AspectJ set-pointcut",
    "height":400,"interpolateNulls":false,"legend":"bottom","reverseAxis":false
},
"state":{},
"chartType":"LineChart",
"chartName":"Performance test"
} </script>
like image 712
zacheusz Avatar asked Jul 25 '11 14:07

zacheusz


People also ask

How do I get the Y axis percentage in Google Sheets?

Simply set the format of cells to percent and Google Sheets will do the rest. Copy it down your table. Go to Format > Number > Percent in Google Sheets menu to apply the percentage view.


3 Answers

You can do this by configuring the vertical axis in the Advanced Settings area.

enter image description here

I just did and it worked like a charm. :)

like image 98
Josh Koenig Avatar answered Sep 20 '22 18:09

Josh Koenig


In Google Spreadsheet, the only chart type that I know understand the axes as numbers is the Scatter.

If it does not suit you (e.g. because you want a line specifically), then you have to work the data. That is, you have to determine a fixed step your axes, e.g. 10 (or any other resolution you find necessary) and fill the data columns using some formula based on your data, like a linear regression between the adjacent points, or a polynomial interpolation.

I'm not very skilled in the QUERY function, maybe it can help you do it automagically. I only know how to do it using other "more complicated" formulas structures with ArrayFormulas and so.

like image 39
Henrique G. Abreu Avatar answered Sep 20 '22 18:09

Henrique G. Abreu


I found other solution. Use type for X axis data as "number" (not as string) and line chart

Check that documentation for details: https://developers.google.com/chart/interactive/docs/customizing_axes#Discrete_vs_Continuous

like image 6
Andrzej Avatar answered Sep 21 '22 18:09

Andrzej