1

I have the following URL to generate a line chart, however I'm struggling to get the Y Axis to cooperate with the range.

I was under the impression that adding the chxr parameter would fix this?

http://chart.apis.google.com/chart?cht=lc&chs=500x250&chco=FF0000,00FFFF,00FF00&chxr=0,10,200&chxt=x,y&chxl=0:|01/01/2017|02/01/2017|03/01/2017&chdl=first+legend%7Csecond+legend%7Cthird+legend&chtt=My+Google+Chart&chts=000000,24&chd=t:5,10,50|50,65,120|26,65,42

Brendan Gooden
  • 1,460
  • 2
  • 21
  • 40

1 Answers1

1

chxr is used to set the axis range

as noted in the docs, the parameter uses the following syntax...

chxr = <axis_index>,<start_val>,<end_val>,<opt_step>

where...

<axis_index> = 0 for x-axis

<axis_index> = 1 for y-axis

as such, the parameter is defined incorrectly...

where you have --> chxr=0,10,200

change to --> chxr=1,10,200

see following link...

http://chart.apis.google.com/chart?cht=lc&chs=500x250&chco=FF0000,00FFFF,00FF00&chxr=1,10,200&chxt=x,y&chxl=0:|01/01/2017|02/01/2017|03/01/2017&chdl=first+legend%7Csecond+legend%7Cthird+legend&chtt=My+Google+Chart&chts=000000,24&chd=t:5,10,50|50,65,120|26,65,42


note: This API has been deprecated. See the deprecation policy for details.

WhiteHat
  • 59,912
  • 7
  • 51
  • 133
  • Thanks for that! If it has been deprecated, is there any other solution you would recommend for generating chart images via API? – Brendan Gooden May 10 '17 at 22:37
  • sure, try the newer library found here --> [Google Charts](https://developers.google.com/chart/) -- see [Load the Libraries](https://developers.google.com/chart/interactive/docs/basic_load_libs) and here is the reference for [line charts](https://developers.google.com/chart/interactive/docs/gallery/linechart) -- i have several examples, if you need help, just ask! -- will you please mark the answer as accepted? cheers! – WhiteHat May 10 '17 at 22:46
  • Thanks bro, can these be called from a URL? As with the old API? I can't use javascript as I'm using HTML to PDF library in C# (HtmlRenderer.PdfSharp) – Brendan Gooden May 10 '17 at 22:49
  • can't be called from a url necessarily -- but you can create a `.png` image of the chart once it has been generated -- basically, you would have to create a page that generates the chart, then sends the png image back to the server via ajax, then continue with the html to pdf from there -- [this answer and its comments](http://stackoverflow.com/a/38464203/5090771) _somewhat_ describe the process -- _some_ additional info can be found in this [answer / question](http://stackoverflow.com/a/38846683/5090771) – WhiteHat May 10 '17 at 23:00
  • but the deprecation notice was mainly for others that may stumble upon this post, as for the image chart library, google says --> _This gives us the right to turn it off without notice, although we have no plans to do so._ – WhiteHat May 10 '17 at 23:01