/Scripts/FusionCharts/Code/ASP/DB_dataURL/PieData.asp

https://github.com/eriknjenga/ADT · ASP · 56 lines · 27 code · 10 blank · 19 comment · 1 complexity · b1cdae12d68ee97db4ea83455957ac7c MD5 · raw file

  1. <%@ Language=VBScript %>
  2. <!-- #INCLUDE FILE="../Includes/DBConn.asp" -->
  3. <%
  4. 'This page generates the XML data for the Pie Chart contained in
  5. 'Default.asp.
  6. 'For the sake of ease, we've used an Access database which is present in
  7. '../DB/FactoryDB.mdb. It just contains two tables, which are linked to each
  8. 'other.
  9. 'Database Objects - Initialization
  10. Dim oRs, oRs2, strQuery
  11. 'strXML will be used to store the entire XML document generated
  12. Dim strXML
  13. 'Default.asp has passed us a property animate. We request that.
  14. Dim animateChart
  15. animateChart = Request.QueryString("animate")
  16. 'Set default value of 1
  17. if animateChart="" then
  18. animateChart = "1"
  19. end if
  20. 'Create the recordset to retrieve data
  21. Set oRs = Server.CreateObject("ADODB.Recordset")
  22. 'Generate the chart element
  23. strXML = "<chart caption='Factory Output report' subCaption='By Quantity' pieSliceDepth='30' showBorder='1' formatNumberScale='0' numberSuffix=' Units' animation=' " & animateChart & "'>"
  24. 'Iterate through each factory
  25. strQuery = "select * from Factory_Master"
  26. Set oRs = oConn.Execute(strQuery)
  27. While Not oRs.Eof
  28. 'Now create second recordset to get details for this factory
  29. Set oRs2 = Server.CreateObject("ADODB.Recordset")
  30. strQuery = "select sum(Quantity) as TotOutput from Factory_Output where FactoryId=" & ors("FactoryId")
  31. Set oRs2 = oConn.Execute(strQuery)
  32. 'Generate <set label='..' value='..'/>
  33. strXML = strXML & "<set label='" & ors("FactoryName") & "' value='" & ors2("TotOutput") & "' />"
  34. 'Close recordset
  35. Set oRs2 = Nothing
  36. oRs.MoveNext
  37. Wend
  38. 'Finally, close <chart> element
  39. strXML = strXML & "</chart>"
  40. Set oRs = nothing
  41. 'Set Proper output content-type
  42. Response.ContentType = "text/xml"
  43. 'Just write out the XML data
  44. 'NOTE THAT THIS PAGE DOESN'T CONTAIN ANY HTML TAG, WHATSOEVER
  45. Response.Write(strXML)
  46. %>