Hello, Thanks for your reply, i am stuck in to bind data in to google.visualization.datatable. actualy i m retrieving data from data base in DataTable of .net and i want to fill data in google datatable. i tried to convert into json table and assign to google.datatable. i attached 2 files of my project. please suggest your best.
On Tuesday, 13 May 2014 23:24:53 UTC+5:30, Andrew Gallant wrote:
>
> When using AJAX, you should handle all of the chart drawing in the
> "success" callback, as AJAX is asynchronous:
>
> $.ajax({
> type: "POST",
> url: "getdata.aspx/GetLocation",
> contentType: "application/json; charset=utf-8",
> dataType: "json",
> async: true,
> success: function (msg1) {
> alert(msg1.d);
> datat = msg1.d;
> // Create the data table.
> var data = new google.visualization.DataTable(datat);
> // create and draw charts here
> }
> });
>
> On Tuesday, May 13, 2014 9:08:25 AM UTC-4, Vikas Sangal wrote:
>>
>> Hello,
>>
>> I want to create chart using google API in ASP.net please guide me to how
>> to populate data in google.visualization.datatable() i m using this below
>> code to call web method to get data from oracle tables and failed to fill
>> jsontable.
>>
>> $.ajax({
>> type: "POST",
>> url: "getdata.aspx/GetLocation",
>> contentType: "application/json; charset=utf-8",
>> dataType: "json",
>> async: true,
>> success: function (msg1) {
>> alert(msg1.d);
>> datat = msg1.d;
>> }
>> });
>> // Create the data table.
>> var data = new google.visualization.DataTable(datat);
>>
>> On Wednesday, 27 July 2011 01:37:35 UTC+5:30, asgallant wrote:
>>>
>>> There's a simple example here:
>>> http://code.google.com/apis/chart/interactive/docs/php_example.html and
>>> the documentation for creating a data source is here:
>>> http://code.google.com/apis/chart/interactive/docs/dev/implementing_data_source.html
>>>
>>> I tend to use a middle road, where I pull my data from mySQL and/or
>>> Oracle and encode it in JSON. I use jQuery's AJAX to make requests to my
>>> source and pass the data to the chart drawing functions.
>>>
>>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.
Default2.aspx
Description: Binary data
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;
using System.Data;
using System.Text;
public partial class getdata : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public static string GetLocation()
{
DataTable dt = new DataTable();
dt = CommonClass.GetDataTableRecord("select distinct location , count(emp_no) emp_no from table_name where department='BUSINESS INFORMATION SYSTEM' group by location ");
string[] StrDc = new string[dt.Columns.Count];
string HeadStr = string.Empty;
for (int i = 0; i < dt.Columns.Count; i++)
{
StrDc[i] = dt.Columns[i].Caption;
HeadStr += "\"" + StrDc[i] + "\" : \"" + StrDc[i] + i.ToString() + "¾" + "\",";
}
HeadStr = HeadStr.Substring(0, HeadStr.Length - 1);
StringBuilder Sb = new StringBuilder();
Sb.Append("{\"" + dt.TableName + "\" : [");
for (int i = 0; i < dt.Rows.Count; i++)
{
string TempStr = HeadStr;
Sb.Append("{");
for (int j = 0; j < dt.Columns.Count; j++)
{
TempStr = TempStr.Replace(dt.Columns[j] + j.ToString() + "¾", dt.Rows[i][j].ToString());
}
Sb.Append(TempStr + "},");
}
Sb = new StringBuilder(Sb.ToString().Substring(0, Sb.ToString().Length - 1));
Sb.Append("]}");
return Sb.ToString();
//return str;
}
}
