Trouble fixing range on x axis on line chart

478 views
Skip to first unread message

Perry

unread,
Sep 1, 2008, 12:29:25 PM9/1/08
to Google Chart API
Hi everyone,

Can someone give me a hand with this chart. I am attempting to chart
some project work items using a line chart with 3 lines. The Y-axis
represents the units of work, and the X axis represents the number of
weeks.

The Y axis seems fine, the X still seems to use the default range of
100, even if I applied my own labels...
(I applied my own range as well, but it still looks to graph 0-100 on
the X)

What am I doing wrong?

http://chart.apis.google.com/chart?cht=lxy&chd=t:0,1,2,3,4,5,6,7,8,9,10,11,12|0,16,32,48,60,76,92,108,124,140,156,172,188|0,15|0,20|0,16|0,1&chs=600x500&chco=0000ff,00ff00,ff0000&chtt=Work%20Schedule&chdl=Velocity|Stories%20Completed|Stories%20Added&chxt=x,y&chxr=0,0,12|1,0,200&chxl=0:|0|4|12&chxp=0,0,4,12

Any help would be appreciated
P
Message has been deleted

keithb

unread,
Sep 1, 2008, 7:43:16 PM9/1/08
to Google Chart API
This was a learning experience for me too.

From the documentation -- "the Chart API assumes a range of 0 to 100
for all axes in the line chart." Adding "chds=0,200" will tell the API
to correctly scale all three of your series. This will fix the y-axis
display of your first series (it was being cut off) and correctly show
the max value of 188 slightly below the top of the graph.

The CHXR parameter tells the Chart API which min/max values to use
when displaying axis labels, but (as far as I can tell) doesn't fix/
modify the data point values themselves. As such, you'll most likely
need to scale your x-axis values: specify min/max x-axis values of 16
(chxr=0,0,16) and then scale all your points to fit accordingly (12
becomes 12 / 16 * 200 = 150).

I removed most of the data points from your first series, since it was
close to a straight line. I updated the non-zero x values to fit in
the 0-200 data scaled x-axis. Here's a quick updated link:

http://chart.apis.google.com/chart?cht=lxy&chd=t:0,150|0,188|0,187.5|0,20|0,200|0,1&chs=600x500&chco=0000ff,00ff00,ff0000&chtt=Work%20Schedule&chdl=Velocity|Stories%20Completed|Stories%20Added&chxt=x,y&chxr=0,0,16|1,0,200&chds=0,200

I don't really understand why your data has different x-axis maximums
(12, 15, 16). If you could standardize on 16 values (even if some/most
were missing) you could use the CHT=LC chart time with -1 values
which, I think, might be easier to work with instead of manually
scaling your data.

It's also completely possible that I've missed some sort of Chart API
capability that would automatically scale your X and Y values for you.

Hope this helps,
K

Perry

unread,
Sep 2, 2008, 1:02:27 AM9/2/08
to Google Chart API
Keith -

Thanks for your reply. This is exactly what I came up with after re-
reading the API docs for a 2nd time.

I pretty much did exactly what you said and set the scaling to handle
my issue.
Thanks for the advice on moving to a standard LC type. I'll give that
a whack now that I'm a bit
more comfortable.

All in all, I am super impressed with this API.
Thanks again (and to the folks at Google)

P
Reply all
Reply to author
Forward
0 new messages