Hi, I would like to programmatically create pins and markers for a chart created using the Google Charts API. This relies on knowing the location of the chart's data points within the chart image.
The chof=json parameter to a Google Chart will return me the JSON required to create an image map, and therefore this data will also be usable to position pins or markers over the chart image. For example the URL: http://chart.apis.google.com/chart?cht=bvg&chs=250x150&chd=s:Monkeys&chxt=x,y&chxs=0,ff0000,12,0,lt|1,0000ff,10,1,lt&chof=json Returns the JSON: {"chartshape":[{"name":"axis0_0","type":"RECT","coords": [32,135,37,144]},{"name":"axis0_1","type":"RECT","coords": [63,136,66,144]},{"name":"axis0_2","type":"RECT","coords": [94,136,99,144]},{"name":"axis0_3","type":"RECT","coords": [125,135,130,144]},{"name":"axis0_4","type":"RECT","coords": [156,136,162,144]},{"name":"axis0_5","type":"RECT","coords": [187,135,192,144]},{"name":"axis0_6","type":"RECT","coords": [218,135,223,144]},{"name":"axis1_0","type":"RECT","coords": [11,126,16,133]},{"name":"axis1_1","type":"RECT","coords": [6,100,16,108]},{"name":"axis1_2","type":"RECT","coords":[6,75,16,83]}, {"name":"axis1_3","type":"RECT","coords":[6,50,16,57]}, {"name":"axis1_4","type":"RECT","coords":[6,25,16,32]}, {"name":"axis1_5","type":"RECT","coords":[0,0,15,7]}, {"name":"bar0_0","type":"RECT","coords":[24,129,47,104]}, {"name":"bar0_1","type":"RECT","coords":[55,129,78,46]}, {"name":"bar0_2","type":"RECT","coords":[86,129,109,48]}, {"name":"bar0_3","type":"RECT","coords":[117,129,140,55]}, {"name":"bar0_4","type":"RECT","coords":[148,129,171,67]}, {"name":"bar0_5","type":"RECT","coords":[179,129,202,26]}, {"name":"bar0_6","type":"RECT","coords":[210,129,233,38]}]} I have two problems. One, I cannot use XMLHTTPRequest to get the JSON as cross-domain requests are not allowed. I appreciate that I could set up a URL on my own server that proxies the request to Google Charts, but I'm looking for a purely client-side solution. And two, if I use a SCRIPT tag that points to the chart URL with chof=json then I get back a JSON object string. But I cannot parse or execute it as I cannot grab the contents of a SCRIPT tag when its "src" attribute is being used (i.e. the innerHTML of the SCRIPT returns ""). If there was a chof=jsonp, then I could pass the name of a Javascript function to be executed with the chart JSON data as a parameter. For example, the URL: http://chart.apis.google.com/chart?cht=bvg&chs=250x150&chd=s:Monkeys&chxt=x,y&chxs=0,ff0000,12,0,lt|1,0000ff,10,1,lt&chof=jsonp&methodName=useResults Would return: useResults({"chartshape":[ ... ]}) which would be executed within the context of my page, and pass me the JSON data. Does anyone else think this feature would be useful, or know if there is an alternative? Thanks. -- You received this message because you are subscribed to the Google Groups "Google Chart API" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-chart-api?hl=en.
