ChartDirector 7.0 (ASP/COM/VB Edition)
Pyramid Elevation
Source Code Listing
<%@ language="vbscript" %>
<%
Set cd = CreateObject("ChartDirector.API")
' This script can draw different charts depending on the chartIndex
Sub createChart(viewer, chartIndex)
' The data for the pyramid chart
data = Array(156, 123, 211, 179)
' The colors for the pyramid layers
colors = Array(&H66aaee, &Heebb22, &Hcccccc, &Hcc88ff)
' The elevation angle
angle = chartIndex * 15
' Create a PyramidChart object of size 200 x 200 pixels, with white (ffffff) background and grey
' (888888) border
Set c = cd.PyramidChart(200, 200, &Hffffff, &H888888)
' Set the pyramid center at (100, 100), and width x height to 60 x 120 pixels
Call c.setPyramidSize(100, 100, 60, 120)
' Set the elevation angle
Call c.addTitle("Elevation = " & angle, "Arial Italic", 15)
Call c.setViewAngle(angle)
' Set the pyramid data
Call c.setData(data)
' Set the layer colors to the given colors
Call c.setColors2(cd.DataColor, colors)
' Leave 1% gaps between layers
Call c.setLayerGap(0.01)
' Output the chart
Call viewer.setChart(c, cd.SVG)
End Sub
' This example includes 7 charts
Dim viewers(6)
For i = 0 To Ubound(viewers)
Set viewers(i) = cd.WebChartViewer(Request, "chart" & i)
Call createChart(viewers(i), i)
Next
%>
<!DOCTYPE html>
<html>
<head>
<title>Pyramid Elevation</title>
<!-- Include ChartDirector Javascript Library to support chart interactions -->
<script type="text/javascript" src="cdjcv.js"></script>
</head>
<body style="margin:5px 0px 0px 5px">
<div style="font:bold 18pt verdana;">
Pyramid Elevation
</div>
<hr style="border:solid 1px #000080; background:#000080" />
<div style="font:10pt verdana; margin-bottom:1.5em">
<a href="viewsource.asp?file=<%= Request("SCRIPT_NAME") %>">View Chart Source Code</a>
</div>
<!-- ****** Here are the chart images ****** -->
<%
For i = 0 To Ubound(viewers)
Call Response.Write(viewers(i).renderHTML())
Call Response.Write(" ")
Next
%>
</body>
</html>
Public Sub createChart(viewer As Object, chartIndex As Integer)
Dim cd As New ChartDirector.API
' The data for the pyramid chart
Dim data()
data = Array(156, 123, 211, 179)
' The colors for the pyramid layers
Dim colors()
colors = Array(&H66aaee, &Heebb22, &Hcccccc, &Hcc88ff)
' The elevation angle
Dim angle As Long
angle = chartIndex * 15
' Create a PyramidChart object of size 200 x 200 pixels, with white (ffffff) background and grey
' (888888) border
Dim c As PyramidChart
Set c = cd.PyramidChart(200, 200, &Hffffff, &H888888)
' Set the pyramid center at (100, 100), and width x height to 60 x 120 pixels
Call c.setPyramidSize(100, 100, 60, 120)
' Set the elevation angle
Call c.addTitle("Elevation = " & angle, "ariali.ttf", 15)
Call c.setViewAngle(angle)
' Set the pyramid data
Call c.setData(data)
' Set the layer colors to the given colors
Call c.setColors2(cd.DataColor, colors)
' Leave 1% gaps between layers
Call c.setLayerGap(0.01)
' Output the chart
Set viewer.Picture = c.makePicture()
End Sub