Axis Range and Labels

40 views
Skip to first unread message

Cameron

unread,
Dec 16, 2009, 7:27:13 PM12/16/09
to Google Chart API
I'm having a strange problem regarding axis ranges and labels.

Here is my chart:

http://chart.apis.google.com/chart?chs=880x250&cht=bvs&chd=t:89,97,104,98,103,80,82,90,98,88,82,48|198,216,215,210,212,168,180,132,161,148,152,108|348,342,334,321,333,315,358,347,392,372,360,213|93,86,92,87,103,91,93,84,94,131,131,70|17,12,18,22,20,7,8,4,0,0,0,0|0,0,0,0,0,0,0,0,0,0,0,0&chds=0,771&chco=C00122,FFD500,0099DC,89BA17,F08A00,363B34&chdl=A|B|C|D|E|F&chts=646464,18&chxt=x,y&chbh=r,0.5,2.0&chxl=0:|Jan-09|Feb-09|Mar-09|Apr-09|May-09|Jun-09|Jul-09|Aug-09|Sep-09|Oct-09|Nov-09|Dec-09|&chxr=1,0,771&chg=0,12.97,1,5

The maximum value is 771. I've set the chart scale using chds=0,771
and the y-axis scale using chxr=1,0,771

However, the y-axis draws labels and tick-marks every 100 and doesn't
extend above 700.

Surely the y-axis should continue upward past 700 a bit. Take this
line chart for example:

http://chart.apis.google.com/chart?chs=880x200&cht=lc&chd=t:2.558757,2.543227,2.61534,2.670002,2.932049,3.283787,3.574706,3.93379,4.146549,4.426245,4.68534,4.892495,5.060707,5.171474,5.267617,5.350277,5.204396,4.925716,4.77723,4.574178,4.458802,4.373413,4.260319,4.1897|1.231077,1.288985,1.377939,1.448573,1.631616,1.802071,1.854823,1.970402,2.059494,2.212658,2.381459,2.480286,2.572686,2.614105,2.617675,2.651492,2.593353,2.498651,2.471063,2.390127,2.345088,2.248557,2.147053,2.103061|2.048668,2.075659,2.167134,2.238967,2.484401,2.785501,2.993992,3.268992,3.438313,3.67333,3.900332,4.068952,4.209987,4.295875,4.359243,4.425839,4.311245,4.097315,3.99205,3.832217,3.742246,3.654485,3.546592,3.486064&chds=0,5.350277&chco=C00122,FFD500,0099DC&chdl=A|B|C&chxt=x,y&chbh=r,0.5,2.0&chxl=0:|Dec-07|Feb-08|Apr-08|Jun-08|Aug-08|Oct-08|Dec-08|Feb-09|Apr-09|Jun-09|Aug-09|Oct-09|&chxr=1,0,5.350277&chg=0,18.69,1,5

It has values between 0 and 5.35, and the y-axis continues up past 5.

Am I doing something wrong?

KeithB

unread,
Dec 17, 2009, 1:02:22 AM12/17/09
to Google Chart API
This appears to be a bug related to automatic resizing of bar width/
spacing (CHBH parameter). Removing your CHBH parameter completely (or
*not* using the "a" and "r" resize options) will make the y-axis range
display correctly. You should be able to specify pixel values for bar
width/spacing to get the chart to look better than the default.

Cheers,
Keith

Oliver Eikel

unread,
Dec 17, 2009, 3:12:14 AM12/17/09
to google-c...@googlegroups.com
Dear all,
thats's something I also examined similar. To me, it looks like the
max y-axis labeling is rounded. e.g. 700 down to the next hundred
(700). 19897 to 19000,...

I also tried hard to automatically label and size my chart to minimum
and maximum. For small values it seems to be no problem. I did it with
values like 36.2 48.1 or 15.7

The minimum (!=0) out of an array -2 and the max +2. It worked great.
But bigger values especially with 1 extreme like 25,19,34,26 and 700
seem to make problems.

Automatic labeling is not that good in ome cases , because it makes
the chart sometimes useless. If my values are all between 20 and 30
and the automatic range is 0-100, it is hard to get a look.

Best regards
Oliver

2009/12/17 Cameron <pric...@gmail.com>:

> --
>
> 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.
>
>
>

--
Korrektes Emailen:
_______________
http://www.olivereikel.de/privat/html/email_knigge.html

correct emailing
http://www.olivereikel.de/privat/english/html/email_knigge.html

Cameron

unread,
Dec 17, 2009, 5:52:36 PM12/17/09
to Google Chart API
Thanks for the replies.

Setting explicit pixel widths for the columns isn't an option for me,
because I'm writing a wrapper class in ASP.NET which must be general
enough to support charts of various widths.

Instead, I rounded my values up prior to rendering the chart (e.g. 771
became 800 in both the chart scale and axis range).

This seems to be working, but it's an ugly fix.

For anyone else having this problem, to scale up, I use the formula
10^x where x = floor(log10(chart_max)). If the chart max is in the
hundreds (e.g. 224, 771 etc) it rounds up to the next 100 (300, 800
respectively). If the chart max is in the tens (e.g. 24, 81) it rounds
up to the nearest 10 (30, 90 respectively). Same for thousands etc.

Reply all
Reply to author
Forward
0 new messages