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:
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>
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.
You can do this by configuring the vertical axis in the Advanced Settings area.
I just did and it worked like a charm. :)
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With