Shiva Srikanth Thummidi
Shiva Srikanth Thummidi

Reputation: 2908

how to draw line chart using Google charts

Why the line is starting at 100 on y-axis, Can any body solve my problem.

code:

<img src="http://chart.apis.google.com/chart?
chs=500x200
&amp;chd=t:533,100,423,200|179,50
&amp;cht=lc
&amp;chxt=x,y
&amp;chxl=0:|JAN|FEB|MAR|APR|MAY|JUNE|JULY|AUG|SEP|OCT|NOV|DEC|
1:||20|40|60|80|100
&amp;chco=FF9900,FF0000,0000FF"
alt="Sample chart" />

if i changed the y-axis values the line is coming at 1000!

1:||200|400|600|800|1000

how can i get that starting point at 533 ?

thanks

Upvotes: 2

Views: 5927

Answers (2)

David Webb
David Webb

Reputation: 193814

Axis 1 is the left y-Axis and with the chxl parameter you have specified labels of 0,20,40,60,80 and 100.

You could change the top value to 533 but I think this would look odd.

The thing to realise is that the labels work independently of the values. You change the scale of your data using the chds parameter.

So I think you should specify a round value on the Y-axis label like 600 and scale the data to match.

Try this:

<img src="http://chart.apis.google.com/chart?
chs=500x200
&amp;chd=t:533,100,423,200|179,50
&amp;chds=0,600
&amp;cht=lc
&amp;chxt=x,y
&amp;chxl=0:|JAN|FEB|MAR|APR|MAY|JUNE|JULY|AUG|SEP|OCT|NOV|DEC|
1:|0|300|600
&amp;chco=FF9900,FF0000,0000FF"
alt="Sample chart" />

Graph

Upvotes: 2

Jon Winstanley
Jon Winstanley

Reputation: 23321

All Google charts are represented proportionally to 100. So the highest value will always run along the top of the graph.

As you have specified your axis as 20,40,60,80,100 it now looks as though your top value is 100, but actually, whatever value you have, it will always look like 100 as it will run along the top.

Either remove the axis settings, or adjust your axis values to represent the maximum value in your values. In this case 533.

Upvotes: 1

Related Questions