ChartDirector 7.0 (ASP/COM/VB Edition)

Pyramid Rotation


            

This example demonstrates viewing the pyramid at different rotation angles, configured with PyramidChart.setViewAngle.

Source Code Listing

[Web Version (in ASP)] aspdemo\pyramidrotation.asp
<%@ 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 semi-transparent colors for the pyramid layers colors = Array(&H400000cc, &H4066aaee, &H40ffbb00, &H40ee6622) ' The rotation 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 to 15 degrees and use the given rotation angle Call c.addTitle("Rotation = " & angle, "Arial Italic", 15) Call c.setViewAngle(15, 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 Rotation</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 Rotation </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>

[Windows Version (in Visual Basic)] vbdemo\pyramidrotation.cls
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 semi-transparent colors for the pyramid layers Dim colors() colors = Array(&H400000cc, &H4066aaee, &H40ffbb00, &H40ee6622) ' The rotation 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 to 15 degrees and use the given rotation angle Call c.addTitle("Rotation = " & angle, "ariali.ttf", 15) Call c.setViewAngle(15, 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