Hi Greg,
There are many sample code for 3D pie charts included in ChartDirector. Most of the sample code are using arrays filled with hard coded data. Instead of using hard coded data, you just need to read the data from your database to fill the arrays.
The exact method to read data from your database depends on your database brand and database schema. There are some examples in the section "Using Data Sources in ChartDirector" that show how to read data from a database, and use them to plot charts.
An example is like:
<%
Set cd = CreateObject("ChartDirector.API")
'
' Read data from database
'
SQL = "Select myLabels, myValues From myTable"
Set rs = CreateObject("ADODB.RecordSet")
Call rs.Open(SQL, "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("aaa.mdb"))
Set dbTable = cd.DBTable(rs)
rs.Close()
labels = dbTable.getCol(0)
data = dbTable.getCol(1)
'
'Use the data to plot the chart you like
'
' Create a PieChart object of size 360 x 300 pixels
Set c = cd.PieChart(360, 300)
' Set the center of the pie at (180, 140) and the radius to 100 pixels
Call c.setPieSize(180, 140, 100)
' Draw the pie in 3D
Call c.set3D()
' Set the pie data and the pie labels
Call c.setData(data, labels)
' Output the chart
Response.ContentType = "image/png"
Response.BinaryWrite c.makeChart2(cd.PNG)
Response.End
%>
Hope this can help.
Regards
Peter Kwan |