Salve a tutti, ho da poco acquistato un software che crea i grafici (Swiff Chart Generator).
Tutto funziona molto bene ma vorrei che il grafico si generi in modo dinamico prendendo i dato da un database di MS access 2000.
Di seguito vi propongo il codice proposto dalla casa:
<% @Language=VBScript %>
<%
Response.Expires= 0
Dim chart
Set chart= Server.CreateObject("SwiffChartObject.ChartObj")
' Fill the series and categories
categories= "ITALIA;Germany;United Kingdom"
chart.SetCategoriesFromString categories
series= "45;28;16"
chart.SetSeriesValuesFromString 0, series
' Set the chart title
chart.SetTitle "Geographical Distribution"
' Apply a Pie style
' The chart type is stored in the style file (*.scs)
' Here the selected style is the predefined pie style "Honolulu"
chart.LoadStyle "pie/Washington"
chart.SetLooping false
chart_res= chart.GetHTMLTag
Set chart= Nothing
%>
<H1>Pie Chart</H1>
<br><%=chart_res%>
Detto questo vorrei che i valori della variabile "categories" siano generati dinamicamente prendendo i dati da una tabella di MS ACCESS 2000 ed ho preparato questo codice:
<% @Language=VBScript %>
<%
Response.Expires= 0
Dim chart
Set chart= Server.CreateObject("SwiffChartObject.ChartObj")
set conn = server.createobject("ADODB.Connection")
conn.open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=C:\Inetpub\wwwroot\Database\Database.mdb"
Dim Rec
Set Rec = Server.CreateObject("ADODB.Recordset")
Dim strSQL
strSQL="Select * From Tb_Array ORDER BY ID"
Rec.Open strSQL, Conn
dim totArray()
dim i
i = 0
Do While Not Rec.EOF
redim preserve totArray(i)
totArray(i) = Rec("ID")
' Fill the series and categories
categories= totArray(i)&";"
chart.SetCategoriesFromString categories
i = i + 1
Rec.MoveNext
Loop
series= "45;28;16"
chart.SetSeriesValuesFromString 0, series
' Set the chart title
chart.SetTitle "Geographical Distribution"
' Apply a Pie style
' The chart type is stored in the style file (*.scs)
' Here the selected style is the predefined pie style "Honolulu"
chart.LoadStyle "bar/Boston"
chart.SetLooping false
chart_res= chart.GetHTMLTag
Set chart= Nothing
%>
<H1>Pie Chart</H1>
<br><%=chart_res%>
ma nelle categorie esce solo l'ultima voce.
Secondo me sbaglio l'array che dovrebbe mettere in fila il valori del database.
Grazie
Tutto funziona molto bene ma vorrei che il grafico si generi in modo dinamico prendendo i dato da un database di MS access 2000.
Di seguito vi propongo il codice proposto dalla casa:
<% @Language=VBScript %>
<%
Response.Expires= 0
Dim chart
Set chart= Server.CreateObject("SwiffChartObject.ChartObj")
' Fill the series and categories
categories= "ITALIA;Germany;United Kingdom"
chart.SetCategoriesFromString categories
series= "45;28;16"
chart.SetSeriesValuesFromString 0, series
' Set the chart title
chart.SetTitle "Geographical Distribution"
' Apply a Pie style
' The chart type is stored in the style file (*.scs)
' Here the selected style is the predefined pie style "Honolulu"
chart.LoadStyle "pie/Washington"
chart.SetLooping false
chart_res= chart.GetHTMLTag
Set chart= Nothing
%>
<H1>Pie Chart</H1>
<br><%=chart_res%>
Detto questo vorrei che i valori della variabile "categories" siano generati dinamicamente prendendo i dati da una tabella di MS ACCESS 2000 ed ho preparato questo codice:
<% @Language=VBScript %>
<%
Response.Expires= 0
Dim chart
Set chart= Server.CreateObject("SwiffChartObject.ChartObj")
set conn = server.createobject("ADODB.Connection")
conn.open "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=C:\Inetpub\wwwroot\Database\Database.mdb"
Dim Rec
Set Rec = Server.CreateObject("ADODB.Recordset")
Dim strSQL
strSQL="Select * From Tb_Array ORDER BY ID"
Rec.Open strSQL, Conn
dim totArray()
dim i
i = 0
Do While Not Rec.EOF
redim preserve totArray(i)
totArray(i) = Rec("ID")
' Fill the series and categories
categories= totArray(i)&";"
chart.SetCategoriesFromString categories
i = i + 1
Rec.MoveNext
Loop
series= "45;28;16"
chart.SetSeriesValuesFromString 0, series
' Set the chart title
chart.SetTitle "Geographical Distribution"
' Apply a Pie style
' The chart type is stored in the style file (*.scs)
' Here the selected style is the predefined pie style "Honolulu"
chart.LoadStyle "bar/Boston"
chart.SetLooping false
chart_res= chart.GetHTMLTag
Set chart= Nothing
%>
<H1>Pie Chart</H1>
<br><%=chart_res%>
ma nelle categorie esce solo l'ultima voce.
Secondo me sbaglio l'array che dovrebbe mettere in fila il valori del database.
Grazie