Gianni Rivera
Gianni Rivera

Reputation: 95

Integrate Google Chart Interactive with ASP.NET and C#

I want to create chart using Google Chart Interactive with ASP.NET and C# I was found this example http://code.google.com/apis/visualization/documentation/using_overview.html but i find problem how to i Integrated this with c# and how to integrate data from c# to javascript.. can someone hint me what I should do?

Upvotes: 4

Views: 1595

Answers (1)

Khattab
Khattab

Reputation: 737

What you need to do is send the command to the google charts api and convert the response to an image like below, and then you can take the image object and write it to a file or perform any operation you want:

 string ChartURL = "http://chart.apis.google.com/chart?";
            ChartURL += "chxr=0,0," + MaxX + "";
            ChartURL += "&chxt=y";
            ChartURL += "&chbh=a";
            ChartURL += "&chs=" + ChartWidth + "x" + ChartHeight + "";
            ChartURL += "&cht=bvg";
            ChartURL += "&chco=" + ChartColors + "";
            ChartURL += "&chds=" + ChartDataRange + "";
            ChartURL += "&chd=t:" + ChartValues + "";
            ChartURL += "&chdl=" + ChartLegend + "";
            ChartURL += "&chtt=" + ChartTitle + "";

            HttpWebRequest myRequest = WebRequest.Create(ChartURL) as HttpWebRequest;
            HttpWebResponse ServerResponse = myRequest.GetResponse() as HttpWebResponse;
            Stream ResponseStream = myRequest.GetResponse().GetResponseStream();
            return System.Drawing.Image.FromStream(ResponseStream);

Upvotes: 2

Related Questions