TransWar File Browser

Path: C:\

<%@ language="vbscript" %>
<%
Set cd = CreateObject("ChartDirector.API")

'
' Displays the monthly revenue for the selected year. The selected year should be
' passed in as a query parameter called "year"
'
selectedYear = Request("year")
if selectedYear = "" Then selectedYear = 2001

' SQL statement to get the monthly revenues for the selected year.
SQL = "Select Software, Hardware, Services From revenue Where Year(TimeStamp) = " & _
    selectedYear & " Order By TimeStamp"

'
' Connect to database and read the query result into arrays
'

Set rs = CreateObject("ADODB.RecordSet")
Call rs.Open(SQL, "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
    Server.MapPath("sample.mdb"))
Set dbTable = cd.DBTable(rs)
rs.Close()

software = dbTable.getCol(0)
hardware = dbTable.getCol(1)
services = dbTable.getCol(2)

'
' Now we have read data into arrays, we can draw the chart using ChartDirector
'

' Create a XYChart object of size 600 x 300 pixels, with a light grey (eeeeee)
' background, black border, 1 pixel 3D border effect and rounded corners.
Set c = cd.XYChart(600, 300, &Heeeeee, &H000000, 1)
Call c.setRoundedFrame()

' Set the plotarea at (60, 60) and of size 520 x 200 pixels. Set background color to
' white (ffffff) and border and grid colors to grey (cccccc)
Call c.setPlotArea(60, 60, 520, 200, &Hffffff, -1, &Hcccccc, &Hccccccc)

' Add a title to the chart using 15pts Times Bold Italic font, with a light blue
' (ccccff) background and with glass lighting effects.
Call c.addTitle("Global Revenue for Year " & selectedYear, "timesbi.ttf", 15 _
    ).setBackground(&Hccccff, &H000000, cd.glassEffect())

' Add a legend box at (70, 32) (top of the plotarea) with 9pts Arial Bold font
Call c.addLegend(70, 32, False, "arialbd.ttf", 9).setBackground(cd.Transparent)

' Add a stacked bar chart layer using the supplied data
Set layer = c.addBarLayer2(cd.Stack)
Call layer.addDataSet(software, &Hff0000, "Software")
Call layer.addDataSet(hardware, &H00ff00, "Hardware")
Call layer.addDataSet(services, &Hffaa00, "Services")

' Use soft lighting effect with light direction from the left
Call layer.setBorderColor(cd.Transparent, cd.softLighting(cd.Left))

' Set the x axis labels. In this example, the labels must be Jan - Dec.
labels = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", _
    "Oct", "Nov", "Dec")
Call c.xAxis().setLabels(labels)

' Draw the ticks between label positions (instead of at label positions)
Call c.xAxis().setTickOffset(0.5)

' Set the y axis title
Call c.yAxis().setTitle("USD (Millions)")

' Set axes width to 2 pixels
Call c.xAxis().setWidth(2)
Call c.yAxis().setWidth(2)

' Output the chart in PNG format
Response.ContentType = "image/png"
Response.BinaryWrite c.makeChart2(cd.PNG)
Response.End
%>