Path: C:\
<%@ language="vbscript" %>
<%
Set cd = CreateObject("ChartDirector.API")
' Get the selected year.
selectedYear = Request("xLabel")
'
' In real life, the data may come from a database based on selectedYear. In this
' example, we just use a random number generator.
'
seed = 50 + (CInt(selectedYear) - 1996) * 15
Set rantable = cd.RanTable(seed, 1, 12)
Call rantable.setCol2(0, seed, -seed * 0.25, seed * 0.33, seed * 0.1, seed * 3)
data = rantable.getCol(0)
'
' Now we obtain the data into arrays, we can start to draw the chart using
' ChartDirector
'
' Create a XYChart object of size 600 x 320 pixels
Set c = cd.XYChart(600, 360)
' Add a title to the chart using 18pts Times Bold Italic font
Call c.addTitle("Month Revenue for Star Tech for " & selectedYear, "timesbi.ttf", _
18)
' Set the plotarea at (60, 40) and of size 500 x 280 pixels. Use a vertical gradient
' color from light blue (eeeeff) to deep blue (0000cc) as background. Set border and
' grid lines to white (ffffff).
Call c.setPlotArea(60, 40, 500, 280, c.linearGradientColor(60, 40, 60, 280, _
&Heeeeff, &H0000cc), -1, &Hffffff, &Hffffff)
' Add a red line (ff0000) chart layer using the data
Set dataSet = c.addLineLayer().addDataSet(data, &Hff0000, "Revenue")
' Set the line width to 3 pixels
Call dataSet.setLineWidth(3)
' Use a 13 point circle symbol to plot the data points
Call dataSet.setDataSymbol(cd.CircleSymbol, 13)
' Set the labels on the x axis. 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)
' When auto-scaling, use tick spacing of 40 pixels as a guideline
Call c.yAxis().setTickDensity(40)
' Add a title to the x axis to reflect the selected year
Call c.xAxis().setTitle("Year " & selectedYear, "timesbi.ttf", 12)
' Add a title to the y axis
Call c.yAxis().setTitle("USD (millions)", "timesbi.ttf", 12)
' Set axis label style to 8pts Arial Bold
Call c.xAxis().setLabelStyle("arialbd.ttf", 8)
Call c.yAxis().setLabelStyle("arialbd.ttf", 8)
' Set axis line width to 2 pixels
Call c.xAxis().setWidth(2)
Call c.yAxis().setWidth(2)
' Create the image and save it in a temporary location
chart1URL = c.makeSession(Session, "chart1")
' Create an image map for the chart
imageMap = c.getHTMLImageMap("clickpie.asp?year=" & selectedYear, "", _
"title='{xLabel}: US$ {value|0}M'")
%>
<html>
<body style="margin:5px 0px 0px 5px">
<div style="font-size:18pt; font-family:verdana; font-weight:bold">
Simple Clickable Line Chart
</div>
<hr style="border:solid 1px #000080" />
<div style="font-size:10pt; font-family:verdana; margin-bottom:20">
<a href="viewsource.asp?file=<%=Request("SCRIPT_NAME")%>">View Source Code</a>
</div>
<img src="getchart.asp?<%=chart1URL%>" border="0" usemap="#map1">
<map name="map1">
<%=imageMap%>
</map>
</body>
</html>