1 if(!dojo._hasResource["dojox.charting.plot3d.Cylinders"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojox.charting.plot3d.Cylinders"] = true;
3 dojo.provide("dojox.charting.plot3d.Cylinders");
5 dojo.require("dojox.charting.plot3d.Base");
9 // reduce function borrowed from dojox.fun
10 var reduce = function(/*Array*/ a, /*Function|String|Array*/ f, /*Object?*/ o){
11 // summary: repeatedly applies a binary function to an array from left
12 // to right; returns the final value.
13 a = typeof a == "string" ? a.split("") : a; o = o || dojo.global;
15 for(var i = 1; i < a.length; z = f.call(o, z, a[i++]));
19 dojo.declare("dojox.charting.plot3d.Cylinders", dojox.charting.plot3d.Base, {
20 constructor: function(width, height, kwArgs){
24 this.material = {type: "plastic", finish: "shiny", color: "lime"};
27 if("depth" in kwArgs){ this.depth = kwArgs.depth; }
28 if("gap" in kwArgs){ this.gap = kwArgs.gap; }
29 if("material" in kwArgs){
30 var m = kwArgs.material;
31 if(typeof m == "string" || m instanceof dojo.Color){
32 this.material.color = m;
37 if("outline" in kwArgs){ this.outline = kwArgs.outline; }
41 if(this.depth == "auto"){
43 if(this.data && this.data.length){
44 w = w / this.data.length;
46 return w - 2 * this.gap;
50 generate: function(chart, creator){
51 if(!this.data){ return this; }
52 var step = this.width / this.data.length, org = 0,
53 scale = this.height / reduce(this.data, Math.max);
54 if(!creator){ creator = chart.view; }
55 for(var i = 0; i < this.data.length; ++i, org += step){
58 center: {x: org + step / 2, y: 0, z: 0},
59 radius: step / 2 - this.gap,
60 height: this.data[i] * scale
62 .setTransform(dojox.gfx3d.matrix.rotateXg(-90))
63 .setFill(this.material).setStroke(this.outline);