/Scripts/FusionCharts/Code/ASPClass/DB_DrillDown/Default.asp

https://github.com/eriknjenga/ADT · ASP · 101 lines · 58 code · 11 blank · 32 comment · 1 complexity · 3f0c6b0222bb758efaf15cc760e01a26 MD5 · raw file

  1. <%@LANGUAGE="VBSCRIPT"%>
  2. <% option explicit %>
  3. <%
  4. 'We've included ../Includes/FusionCharts_Gen.asp, which contains
  5. 'FusionCharts ASP Class to help us easily embed charts
  6. 'We've also used ../Includes/DBConn.asp to easily connect to a database
  7. %>
  8. <!--#include file="../Includes/DBConn.asp"-->
  9. <!--#include file="../Includes/FusionCharts_Gen.asp"-->
  10. <HTML>
  11. <HEAD>
  12. <TITLE>
  13. FusionCharts V3 - Database and Drill-Down Example
  14. </TITLE>
  15. <%
  16. 'You need to include the following JS file, if you intend to embed the chart using JavaScript.
  17. 'Embedding using JavaScripts avoids the "Click to Activate..." issue in Internet Explorer
  18. 'When you make your own charts, make sure that the path to this JS file is correct. Else, you would get JavaScript errors.
  19. %>
  20. <SCRIPT LANGUAGE="Javascript" SRC="../../FusionCharts/FusionCharts.js"></SCRIPT>
  21. <style type="text/css">
  22. <!--
  23. body {
  24. font-family: Arial, Helvetica, sans-serif;
  25. font-size: 12px;
  26. }
  27. .text{
  28. font-family: Arial, Helvetica, sans-serif;
  29. font-size: 12px;
  30. }
  31. -->
  32. </style>
  33. </HEAD>
  34. <BODY>
  35. <CENTER>
  36. <h2><a href="http://www.fusioncharts.com" target="_blank">FusionCharts V3</a> - Database and Drill-Down Example</h2>
  37. <h4>Click on any pie slice to see detailed data.</h4>
  38. <%
  39. 'In this example, we show how to connect FusionCharts to a database.
  40. 'For the sake of ease, we've used an MySQL databases containing two
  41. 'tables.
  42. dim FC
  43. ' Create FusionCharts ASP class object
  44. set FC = new FusionCharts
  45. ' Set chart type to Pie 3D
  46. Call FC.setChartType("Pie3D")
  47. ' Set chart size
  48. Call FC.setSize("650","450")
  49. ' Set Relative Path of swf file.
  50. Call FC.setSWFPath("../../FusionCharts/")
  51. dim strParam
  52. ' Define chart attributes
  53. strParam="caption=Factory Output report;subCaption=By Quantity;pieSliceDepth=30;showBorder=1; showLabels=1;numberSuffix= Units"
  54. ' Set chart attributes
  55. Call FC.setChartParams(strParam)
  56. ' Fetch all factory records creating SQL query
  57. dim strQuery
  58. strQuery = "select a.FactoryID, b.FactoryName, sum(a.Quantity) as total from Factory_output a, Factory_Master b where a.FactoryId=b.FactoryId group by a.FactoryId,b.FactoryName"
  59. Dim oRs
  60. 'Create the recordset to retrieve data
  61. Set oRs = Server.CreateObject("ADODB.Recordset")
  62. Set oRs = oConn.Execute(strQuery)
  63. 'Pass the SQL query result and Drill-Down link format to ASP Class Function
  64. ' this function will automatically add chart data from database
  65. '
  66. 'The last parameter passed i.e. "Detailed.asp?FactoryId=##FactoryID##"
  67. 'drill down link from the current chart
  68. 'Here, the link redirects to another ASP file Detailed.asp
  69. 'with a query string variable -FactoryId
  70. 'whose value would be taken from the Query result created above.
  71. 'Any thing placed between ## and ## will be regarded
  72. 'as a field/column name in the SQL query result.
  73. 'value from that column will be assingned as the query variable's value
  74. 'Hence, for each dataplot in the chart the resultant query variable's value
  75. 'will be different
  76. '
  77. if Not oRs.Bof then
  78. Call FC.addDataFromDatabase(oRs, "total", "FactoryName","","Detailed.asp?FactoryId=##FactoryID##")
  79. End If
  80. oRs.Close
  81. set oRs=Nothing
  82. 'Create the chart
  83. Call FC.renderChart(false)
  84. %>
  85. <BR><BR>
  86. <a href='../NoChart.html' target="_blank">Unable to see the chart above?</a>
  87. <H5 ><a href='../default.htm'>&laquo; Back to list of examples</a></h5>
  88. </CENTER>
  89. </BODY>
  90. </HTML>