Hi I have a VB.NET app that is grabbing data from a source, and returning
it to my handler as a .NET DataTable. I am wondering if anyone has used
any methods to convert that DataTable to JSON that is necessary for the
google bubble chart. I've dug through the api docs for the chart, but
can't seem to figure out exactly how the data should be formatted. I get
one format if i just put straight data in my jQuery not from an external
data source but a different format if i get the data from an external
datasource. Any ideas would be much appreciated.
Code below does dataTable to JSON conversion, but its not in the format
that google charts requires. Or is it and i'm having a different issue?
Public Shared Function GetJSONString(ByVal Dt As DataTable) As String
Dim StrDc As String() = New String(Dt.Columns.Count - 1) {}
Dim HeadStr As String = String.Empty
For i As Integer = 0 To Dt.Columns.Count - 1
StrDc(i) = Dt.Columns(i).Caption
HeadStr += """" & StrDc(i) & """ : """ & StrDc(i) &
i.ToString() & "¾" & ""","
Next
HeadStr = HeadStr.Substring(0, HeadStr.Length - 1)
Dim Sb As New StringBuilder()
Sb.Append("[")
For i As Integer = 0 To Dt.Rows.Count - 1
Dim TempStr As String = HeadStr
Sb.Append("{")
For j As Integer = 0 To Dt.Columns.Count - 1
TempStr = TempStr.Replace(Convert.ToString(Dt.Columns(j)) &
j.ToString() & "¾", Dt.Rows(i)(j).ToString())
Next
Sb.Append(TempStr & "},")
Next
Sb = New StringBuilder(Sb.ToString().Substring(0,
Sb.ToString().Length - 1))
Sb.Append("]")
Return Sb.ToString()
End Function
My JSON is as below
[{"ProjectName" : "PPM Tool","Division" :
"DOA-IT;DOA-BUDG;DOA-HR;"},{"ProjectName" : "Salary Change Order","Division" :
"DOA-HR;"},{"ProjectName" : "MEO Case Management Solution","Division" :
"MEO;"},{"ProjectName" : "HR Professional Development Portal","Division" :
"DOA-HR;DOA-IT;WCG;"},{"ProjectName" : "Workforce Development
Project","Division" : "DOA-BUDG;DOA-HR;"}]
--
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.