ChartDirector 6.0 (ColdFusion Edition)
Pyramid Gap
Source Code Listing
<cfscript> // ChartDirector for ColdFusion API Access Point cd = CreateObject("java", "ChartDirector.CFChart"); // A utility to allow us to create arrays with data in one line of code function Array() { var result = ArrayNew(1); var i = 0; for (i = 1; i LTE ArrayLen(arguments); i = i + 1) result[i] = arguments[i]; return result; } // Function to create the demo charts function createChart(chartIndex) { // Declare local variables var data = 0; var colors = 0; var gap = 0; var c = 0; // The data for the pyramid chart data = Array(156, 123, 211, 179); // The colors for the pyramid layers colors = Array("0x66aaee", "0xeebb22", "0xcccccc", "0xcc88ff"); // 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 c = cd.PyramidChart(200, 200, "0xffffff", "0x888888"); // Set the pyramid center at (100, 100), and width x height to 60 x 120 pixels c.setPyramidSize(100, 100, 60, 120); // Set the layer gap c.addTitle("Gap = " & gap, "Arial Italic", 15); c.setLayerGap(gap); // Set the elevation to 15 degrees c.setViewAngle(15); // Set the pyramid data c.setData(data); // Set the layer colors to the given colors c.setColors2(cd.DataColor, colors); // Output the chart return c.makeSession(GetPageContext(), "chart" & chartIndex); } chart0URL = createChart(0); chart1URL = createChart(1); chart2URL = createChart(2); chart3URL = createChart(3); chart4URL = createChart(4); chart5URL = createChart(5); </cfscript> <html> <body style="margin:5px 0px 0px 5px"> <div style="font-size:18pt; font-family:verdana; font-weight:bold"> Pyramid Gap </div> <hr style="border:solid 1px #000080" /> <cfoutput> <div style="font-size:9pt; font-family:verdana; margin-bottom:1.5em"> <a href='viewsource.cfm?file=#CGI.SCRIPT_NAME#'>View Source Code</a> </div> <img src="getchart.cfm?#chart0URL#" /> <img src="getchart.cfm?#chart1URL#" /> <img src="getchart.cfm?#chart2URL#" /> <img src="getchart.cfm?#chart3URL#" /> <img src="getchart.cfm?#chart4URL#" /> <img src="getchart.cfm?#chart5URL#" /> </cfoutput> </body> </html> |