ASP.net et Google Vizualisation
Bonjour a tous !
J'utilise ce code-ci qui fonctionne parfaitement http://code.google.com/p/bortosky-go...on/wiki/ReadMe comme ci dessous(avec un piechart)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| Dim gdt As New Bortosky.Google.Visualization.GoogleDataTable(Me.GetData)
Using mem As New System.IO.MemoryStream()
gdt.WriteJson(mem)
mem.Position = 0
Dim sr As New System.IO.StreamReader(mem)
Page.ClientScript.RegisterStartupScript(Me.[GetType](), "vis", String.Format("var fundata = {0}", sr.ReadToEnd()), True)
sr.Close()
End Using
Dim Ams_header As Web.UI.HtmlControls.HtmlHead
Ams_header = TryCast(Me.Page.Header, Web.UI.HtmlControls.HtmlHead)
Ams_header.InnerHtml = "<title>MarketContext Report</title> " & _
"<script type='text/javascript' src='http://www.google.com/jsapi'></script> " & _
"<script type='text/javascript'> " & _
"google.load('visualization', '1', { 'packages': ['piechart'] }); " & _
" google.setOnLoadCallback(drawChart); " & _
"function drawChart() { " & _
" var data = new google.visualization.DataTable(fundata, 0.5); " & _
" var chart = new google.visualization.PieChart(document.getElementById('chart_div')); " & _
" chart.draw(data, { width: 400, height: 240, is3D: true, title: 'Test' }); " & _
" }</script>" |
pour charger depuis la table renvoye par cette fonction :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| Private Function GetData() as DataTable
Dim idPtypeCondition As String = ""
Dim idCountryCondition As String = ""
Dim StrCmd As String = ""
'Country Condition
If ddCountry.SelectedValue <> 0 Then
idCountryCondition = " AND idCountry = " & ddCountry.SelectedValue & " "
ddType.Enabled = True
End If
'PropertyType Condition
If ddType.SelectedValue = 0 Then
idPtypeCondition = " AND (P.idPType = 1 OR P.idPType = 2 OR P.idPType = 3 OR P.idPType = 4 OR P.idPType = 36 OR P.idPType = 38 )"
Else
idPtypeCondition = " AND P.idPType = " & ddType.SelectedValue & " "
End If
Dim Request As String = "SELECT COUNT(P.idList) as BedRoom, PT.PTypeName as Type, BL.TotalRooms as TotalRoom " & _
"From Property as P, PropertyType as PT, BedroomList as BL " & _
"WHERE PT.idPType = P.idPType " & _
"AND P.idList = BL.idList " & _
"AND idPropMarket = 2 " & _
"AND idCRule = 1 " & _
"AND BL.TotalRooms > 0 " & idCountryCondition & idPtypeCondition & _
"GROUP BY PT.PTypeName, BL.TotalRooms "
Dim objConn As SqlConnection = openDBConnection()
Dim objCmd As SqlCommand = New SqlCommand(Request, objConn)
'Force the connection to be closed
objConn.Close()
objConn.Open()
Dim reader As SqlDataReader = objCmd.ExecuteReader(CommandBehavior.CloseConnection)
Dim DataT As New DataTable
DataT.Load(reader)
Return DataT |
Le probleme c'est que je n'arrive pas avoir la legende...Pourriez vous m'aider ?
Merci a tous