Use of Google Charts API with a POST:
I originally put up this message because I could not get the Google charts api to work with a POST, but now I have it working. Here is
the corrected code, for anyone else who wants to try it:
Instead of using *url_object() to get the result of the post, one uses the result object from http_post().
I originally put up this message because I could not get the Google charts api to work with a POST, but now I have it working. Here is
the corrected code, for anyone else who wants to try it:
Code:
'Date Created: 30-May-2011 02:43:32 PM 'Last Updated: 30-May-2011 02:43:32 PM 'Created By : peter 'Updated By : peter 'graphTest dateList=<<%lst% 20090101 20090301 20090901 20100501 20101101 20110201 20110501 %lst% weightList=<<%lst% 70 80 90 85 80 85 90 %lst% xseries1="" xaxisLabel="" firstDate=stod(word(datelist,1,crlf())) for each ln in dateList days=stod(ln.value)-firstDate xaxisLabel=xaxisLabel+days+"|" xseries1=xseries1+days+"," next xseries1=left(xseries1,len(xseries1)-1) xaxisLabel=left(xaxisLabel,len(xaxisLabel)-1) yseries1=crlf_to_comma(weightList) series=xseries1+"|"+yseries1 mystr="http://chart.apis.google.com/chart?"+\ "cht=lxy&chs=400x200&chd=t:"+series+"&chm=s,000000,0,-1,9"+\ "&chxt=x,y&chxr=0,0,1000,200|1,0,150,25&chds=0,1000,0,150" 'showvar(mystr) po=*url_object(mystr) ui_bitmap_png_load("tmp",po.content) ui_dlg_box("Weight ","{image=tmp}") body="cht=lxy&chs=400x200&chd=t:"+series+"&chm=s,000000,0,-1,9"+\ "&chxt=x,y&chxr=0,0,1000,200|1,0,150,25&chds=0,1000,0,150" url="https://chart.googleapis.com/chart" result=http_post(url,body,"",443,2000,.t.) showvar(result) ui_bitmap_png_load("tmp2",result.body) ui_dlg_box("Weight 2","{image=tmp2}")