mattetti / googlecharts

Ruby Google Chart API
http://mattetti.github.com/googlecharts/
MIT License
699 stars 108 forks source link

Axis labels not showing up correctly #63

Open altla opened 11 years ago

altla commented 11 years ago

I'm having some problems showing the right labels on the x axis. For example, even this line of code that comes straight from the gem page, only shows '300' on the x axis, and it shows where 0 should go.

Gchart.line(:data => [300, 100, 30, 200, 100, 200, 300, 10],
:axis_with_labels => ['x','y','r'])

http://chart.apis.google.com/chart?chxt=x,y,r&chd=s:9UGpUp9C&cht=lc&chs=300x200&chxr=0,300,300

I'm also having problems with small changes in the y-values, for example this graph, shows all the x axis labels at the first position on top of each other, making them unreadable:

@chart = Gchart.line(
  :title  => @activity.name,
  :bg     => 'ffffff',
  :data   => [1,0,1],
  :axis_with_labels => 'x',
  :axis_labels => ['Jan|July|Jan'],
  :width => 900  
)

http://chart.apis.google.com/chart?chxl=0:|Jan|July|Jan&chxt=x&chf=bg,s,ffffff&chd=s:9A9&chtt=GSM+crediet&cht=lc&chs=900x200&chxr=0,1,1

Changing chxr in the url to chxr=3,1,1 fixes the problem but this if the data has some larger values like :data => [1,0,3] that's not even necessary.