Graphs Charts Pie Charts Bar Charts Line Graphs
Pie Charts
Examples
Free Download
Help
Test Drive
...
Pricing
Purchase
Contact Us
...
Free Maps

 
Example ASP Code For Use With Dynamic Pie Chart

The following code sample shows an example of how the Pie Chart applet can be used with ASP to create a dynamic pie chart based on data from a database. In this example, Microsoft Access is used as the database, but the technique will be similar for most SQL compliant database platforms.

The code should also provide a guideline for using the pie chart applet with other dynamic web platforms such as PHP, ColdFusion and JSP.

<%
db = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\databases\database.mdb"
set conn = Server.CreateObject("ADODB.Connection")
conn.open db
set sqlQuery = Server.CreateObject("ADODB.Recordset")
sqlQuery.CursorType = 3
qtxt = "SELECT Company, Total FROM Companies ORDER BY Company"
sqlQuery.Open qtxt, conn, 3, 3
%>


<html>
<body>

<applet code="piechart.class" height=180 width=300>
<param name="title" value="Clients">
<param name="csize" value="120">
<param name="noofvals" value="<%=sqlQuery.RecordCount%>">
<%
i = 1
while (not sqlQuery.EOF) %>

<param name="val<%=i%>" value="<%=sqlQuery("Total")%>">
<param name="key<%=i%>" value="<%=sqlQuery("Company")%>">
<param name="red<%=i%>" value="<%=i*20%>">
<param name="green<%=i%>" value="<%=i*20%>">
<param name="blue<%=i%>" value="<%=255-(i*20)%>">
<%
i = i + 1
sqlQuery.MoveNext
end while %>

</applet>

</body>
</html>

<%
sqlQuery.close
set sqlQuery = nothing
conn.close
set conn = nothing
%>


Go Back
Pie Charts | Bar Charts | Line Graphs | Pricing | Purchase | Contact Us
Graphs Charts .com is a division of Roan Software Ltd.