ChartDirector 7.0 (ASP/COM/VB Edition)
Pyramid Gap
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 layer gap
gap = chartIndex * 0.01
' 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 layer gap
Call c.addTitle("Gap = " & gap, "Arial Italic", 15)
Call c.setLayerGap(gap)
' Set the elevation to 15 degrees
Call c.setViewAngle(15)
' Set the pyramid data
Call c.setData(data)
' Set the layer colors to the given colors
Call c.setColors2(cd.DataColor, colors)
' Output the chart
Call viewer.setChart(c, cd.SVG)
End Sub
' This example includes 6 charts
Dim viewers(5)
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 Gap</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 Gap
</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 layer gap
Dim gap As Double
gap = chartIndex * 0.01
' 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 layer gap
Call c.addTitle("Gap = " & gap, "ariali.ttf", 15)
Call c.setLayerGap(gap)
' Set the elevation to 15 degrees
Call c.setViewAngle(15)
' Set the pyramid data
Call c.setData(data)
' Set the layer colors to the given colors
Call c.setColors2(cd.DataColor, colors)
' Output the chart
Set viewer.Picture = c.makePicture()
End Sub