We do this automatically on the NetQuarry platform - it's quite simple, although you force the image to enter through your site against charts.google.com, causing your browser to run the request through a single connection.
Since the chart is just a link to the image, we do to build a link to the chart (a much more complicated process, obviously), and then add the entire link to the query string on the internal handler (.ashx? Req = chart & handler). So, the new link looks like this:
?
handler.ashx act = CHRT & REQ = chart & CHT = p3 & candidate of historical sciences = 450x170 & CHD = s: HAR9GBA & CHL = New | In% 20Progress | Answered | Wouldn't% 20Respond | At% 20Hold | Future | Review | & Chg = 20,20,1,5 & Chg = 10,25,1,5 & CHCO = 0A477D
Then we simply upload the image data and record it as an answer.
Here is the code:
Blockquote
private void GoogleChart(HttpContext cxt) { const string csPrefix = "?act=chrt&req=chart&"; HttpRequest req = cxt.Request; HttpResponse rsp = cxt.Response; string sUrl = cxt.Request.RawUrl; int nStart = sUrl.IndexOf(csPrefix, StringComparison.OrdinalIgnoreCase); rsp.Clear(); if (nStart > 0) { sUrl = "http://chart.apis.google.com/chart?" + sUrl.Substring(nStart + csPrefix.Length); System.Net.WebClient wc = new System.Net.WebClient(); byte[] buffer = wc.DownloadData(sUrl); cxt.Response.ClearContent(); cxt.Response.ClearHeaders(); cxt.Response.ContentType = "application/octet-stream"; cxt.Response.AppendHeader("content-length", buffer.Length.ToString()); cxt.Response.BinaryWrite(buffer); } }
source share