Google Chart API Axis Scaling Based on Chart Size

18 views
Skip to first unread message

Tristan McCann

unread,
Dec 2, 2009, 9:18:00 AM12/2/09
to Google Chart API
Hello,

Forgive me if this has been mentioned previously. I have searched the
archives but have not found this specific issue.

I have a chart with two data sets. The data sets and the Y-axis are
scaled from 0 to 13362. The data scales properly.

The axis is scaled, but at a chart size of 240x200, the top label ends
at 12000. This causes the axis to not line up with the data.

In preparing this message, I changed the size of the example chart to
600x500 (max pixels). In this case, the top label ends at 13000. This
makes the data line up better, even though it still isn't exact.

I realize that 13362 is not a great data/axis scale. I want to
implement a proper ceiling function to make the API use my top number,
so the scaling is exact. Would ceiling the number to two significant
figures (in this case, 14000) work across the board? I am also
wondering in smaller (9132 rounding to 9200) and larger (143323
rounding to 150000) cases what the API should do.

Incorrectly scaled graph:
http://chart.apis.google.com/chart?chs=240x200&cht=bvg&chbh=r,0,1.0&chxt=x,y&chco=000000,777777&chdlp=b&chd=t:7748,8150,8764,9939,10690|4148,4761,5238,5716,6074&chxl=0:|2004|2005|2006|2007|2008&chxr=1,0,13362&chds=0,13362

More-correctly scaled graph:
http://chart.apis.google.com/chart?chs=600x500&cht=bvg&chbh=r,0,1.0&chxt=x,y&chco=000000,777777&chdlp=b&chd=t:7748,8150,8764,9939,10690|4148,4761,5238,5716,6074&chxl=0:|2004|2005|2006|2007|2008&chxr=1,0,13362&chds=0,13362

The only difference between these graphs is the size. Notice that the
first value for the second data set is 4148, and is shown as <4000 in
the first chart.

Thank you,
Tristan McCann

JV

unread,
Dec 16, 2009, 11:22:08 AM12/16/09
to Google Chart API
One thing you can do is changing your axis scaling chxr=1,0,13362 into
chxr=1,0,13362,2000

On Dec 2, 9:18 am, Tristan McCann <tristan_mcc...@onesource.com>
wrote:
> Hello,
>
> Forgive me if this has been mentioned previously. I have searched the
> archives but have not found this specific issue.
>
> I have a chart with two data sets. The data sets and the Y-axis are
> scaled from 0 to 13362. The data scales properly.
>
> The axis is scaled, but at a chart size of 240x200, the top label ends
> at 12000. This causes the axis to not line up with the data.
>
> In preparing this message, I changed the size of the example chart to
> 600x500 (max pixels). In this case, the top label ends at 13000. This
> makes the data line up better, even though it still isn't exact.
>
> I realize that 13362 is not a great data/axis scale. I want to
> implement a proper ceiling function to make the API use my top number,
> so the scaling is exact. Would ceiling the number to two significant
> figures (in this case, 14000) work across the board? I am also
> wondering in smaller (9132 rounding to 9200) and larger (143323
> rounding to 150000) cases what the API should do.
>
> Incorrectly scaled graph:http://chart.apis.google.com/chart?chs=240x200&cht=bvg&chbh=r,0,1.0&c...4148,4761,5238,5716,6074&chxl=0:|2004|2005|2006|2007|2008&chxr=1,0,13362&chds=0,13362
>
> More-correctly scaled graph:http://chart.apis.google.com/chart?chs=600x500&cht=bvg&chbh=r,0,1.0&c...4148,4761,5238,5716,6074&chxl=0:|2004|2005|2006|2007|2008&chxr=1,0,13362&chds=0,13362
Reply all
Reply to author
Forward
0 new messages