Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Chart: is it possible to use Strings for the x axis?

So I tried messing around with my charts and noticed that integers/floats/dates work perfectly fine for the x axis, but the moment that you put in a string, it blows up.

I'm trying to graph a: Word/Count graph, but unfortunately I can't seem to be able to put strings in the x axis. Is this allowed in Google Charts, or is it strictly int/floats/dates?

like image 307
Stupid.Fat.Cat Avatar asked Nov 25 '14 00:11

Stupid.Fat.Cat


People also ask

What is continuous axis?

An imaginary line running around the ice surface that serves as a basis for a dance pattern . Usually the continuous axis consists of two lines running parallel to the long axis of the ice surface, approximately halfway between the long axis and the perimeter of the rink.

How do I plot a log scale in Google Sheets?

Double-click on the chart to bring up Chart editor. Go to the Customize tab. Open the Vertical axis tab and check Log scale. Open the Horizontal axis tab and check Log scale.


1 Answers

use vAxis and hAxis property as below

google.visualization.ColumnChart(document.getElementById('visualization')).
  draw(data,
       {title:"Yearly Coffee Consumption by Country",
        width:600, height:400,
        vAxis: {title: "Year",ticks: [{v:100, f:"100$"},{v:150, f:"150$"},{v:200, f:"200$"},{v:300, f:"300$"}]},
        hAxis: {title: "Cups",ticks: [{v:4, f:"3-4"},{v:8, f:"5-9"},{v:10, f:"9-13"},{v:14, f:"13-14"},{v:20, f:"15-20"}]} }
  );

for more detail check this How to get the vaxis line in column chart of google api chart?

like image 111
rjdmello Avatar answered Sep 23 '22 15:09

rjdmello