ChartDirector 6.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
chartIndex = CInt(Request("img"))

' 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, "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
Response.ContentType = "image/png"
Response.BinaryWrite c.makeChart2(cd.PNG)
Response.End
%>

[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