1 if(!dojo._hasResource["dojox.charting.plot3d.Bars"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojox.charting.plot3d.Bars"] = true;
3 dojo.provide("dojox.charting.plot3d.Bars");
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.Bars", dojox.charting.plot3d.Base, {
20 constructor: function(width, height, kwArgs){
24 this.material = {type: "plastic", finish: "dull", color: "lime"};
26 if("depth" in kwArgs){ this.depth = kwArgs.depth; }
27 if("gap" in kwArgs){ this.gap = kwArgs.gap; }
28 if("material" in kwArgs){
29 var m = kwArgs.material;
30 if(typeof m == "string" || m instanceof dojo.Color){
31 this.material.color = m;
39 if(this.depth == "auto"){
41 if(this.data && this.data.length){
42 w = w / this.data.length;
44 return w - 2 * this.gap;
48 generate: function(chart, creator){
49 if(!this.data){ return this; }
50 var step = this.width / this.data.length, org = 0,
51 depth = this.depth == "auto" ? step - 2 * this.gap : this.depth,
52 scale = this.height / reduce(this.data, Math.max);
53 if(!creator){ creator = chart.view; }
54 for(var i = 0; i < this.data.length; ++i, org += step){
57 bottom: {x: org + this.gap, y: 0, z: 0},
58 top: {x: org + step - this.gap, y: this.data[i] * scale, z: depth}
60 .setFill(this.material);