mattetti/googlecharts

Axis Labels Generated are Wrong

Closed this issue · 4 comments

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

Returns:
"http://chart.apis.google.com/chart?cht=lc&chs=300x200&chxl=0:%7CJan%7C1:%7CJuly%7C2:%7CJan%7C3:%7CJuly%7C4:%7CJan&chd=s:9UGoUo9C&chxt=x"

Notice the axis labels:
chxl=0:%7CJan%7C1:%7CJuly%7C2:%7CJan%7C3:%7CJuly%7C4:%7CJan

This doesn't doesn't create proper labels.

This is still an issue with the new version, I'll look into it shortly

I have another problem with the generation of the labels. If I create a line chart like this:

Gchart.line(:data => [17, 17, 11, 8, 2], :axis_with_labels => ['x', 'y'], :axis_labels => [['J', 'F', 'M', 'A', 'M']])

it will produce a line chart like this:

http://chart.apis.google.com/chart?chxl=0:|J|F|M|A|M&chxt=x,y&chd=s:99odH&cht=lc&chs=300x200&chxr=1,17,2

As you can see, the labels of y are in the wrong order while the data in the x axis are right.

i noticed the same issue with a bar chart starting in descending order. ascending order works fine.

ecoment & jingta, in this specific case you have to define the axis range yourself:

graph = Gchart.line(:data => [17, 17, 11, 8, 2], 
                             :axis_with_labels => ['x', 'y'], 
                             :axis_labels => [['J', 'F', 'M', 'A', 'M']], 
                             :axis_range => [nil, [2,20,5]])

the first value is nil so the range is auto calculated then the second range (y) starts at 2 and goes up to 20 in steps of 5.