Adding custom labels on a bar chart

1,188 views
Skip to first unread message

Peter

unread,
May 3, 2010, 3:59:28 PM5/3/10
to Google Chart API
I have this image now:
http://chart.apis.google.com/chart?cht=bvo&chbh=20,10,0&chs=400x200&chxt=x,y&chd=t:5,10,23,2&chxl=0:|25|30|35|40&chxr=1,0,80,10

How can I have the same chart, but with
X-axis label: "Age"
Y-axis label: "Amount"

I checked here: http://code.google.com/apis/chart/docs/gallery/line_charts.html#axis_labels

But I just dont get it :)

Thanks!

--
You received this message because you are subscribed to the Google Groups "Google Chart API" group.
To post to this group, send email to google-c...@googlegroups.com.
To unsubscribe from this group, send email to google-chart-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-chart-api?hl=en.

KeithB

unread,
May 4, 2010, 8:27:38 AM5/4/10
to Google Chart API
Hi Peter,

You're looking at the correct section, but are having problems
interpreting the following:

chxl=
<axis_index>:|<label_1>|...|<label_n>
|...|
<axis_index>:|<label_1>|...|<label_n>


Take a look at the last sample chart in that section. The key parts
are "chxt=x,x,y,y" and "chxl=1:|Martinis|3:|Score"

Keep in mind the following:
<axis_index> --> Which axis to apply labels to. This is an index into
the chxt parameter array. For example, if you have chxt=x,x,y,y then
index 0 would be the first x-axis, 1 would be the second x-axis.

Have fun,
Keith

Peter

unread,
May 4, 2010, 10:01:48 AM5/4/10
to Google Chart API
Hi Keith,

Yes, I had been playing with that, I tried this as well:
http://chart.apis.google.com/chart?cht=bvo&chbh=20,10,0&chs=400x200&chxt=x,x,y&chd=t:5,10,23,2&chxl=0:|25|30|35|40|1:|Age&chxr=1,0,80,10

But the results just seem weird to me. I tried adding an extra axis
and label it with the right axis index, but as you can see it totally
screws up the image! :S

What am I doing wrong here?

Thanks again!

Regards,
Peter

KeithB

unread,
May 4, 2010, 2:34:25 PM5/4/10
to Google Chart API
This should get you started:

http://tinyurl.com/2bstkqs

The key changes were to the following parameters:

chxt=x,x,y,y
chxl=0:|25|30|35|40|1:|Age|3:|Amount
chxp=1,50|3,50
chxr=2,0,80,10

Peter

unread,
May 4, 2010, 3:03:50 PM5/4/10
to Google Chart API
Hi Keith, thats a very useful link indeed! Thank you!
Now, I have been playing with it, but when I altered one value in my
request and suddenly it looks as if the scales of the values dont
match at all!
For example, I follow your link and for this: chd=t:5,10,23,2 I
change "23" in "80". That SHOULD draw the bar all the way up to the
top (since I have 80 as max accoding to param: chxr=2,0,80,10), but it
doesnt!
The other way around, when I change this: chxr=2,0,80,10 to
chxr=2,0,50,10, the bars remain the same height!

What is happening here?

KeithB

unread,
May 4, 2010, 4:37:03 PM5/4/10
to Google Chart API
Hi Peter,

Take a look at my answer in your other thread:
http://groups.google.com/group/google-chart-api/browse_thread/thread/21c746bf51a5ee26?hl=en

You'll want to look at using text encoding with data scaling:
http://code.google.com/apis/chart/docs/data_formats.html#data_scaling
making sure to keep your CHXR and CHDS parameters in sync.

Hope that helps,
Reply all
Reply to author
Forward
0 new messages