1 if(!dojo._hasResource["dojox.charting.Chart3D"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
2 dojo._hasResource["dojox.charting.Chart3D"] = true;
3 dojo.provide("dojox.charting.Chart3D");
5 dojo.require("dojox.gfx3d");
8 var observerVector = {x: 0, y: 0, z: 1}, v = dojox.gfx3d.vector, n = dojox.gfx.normalizedLength;
10 dojo.declare("dojox.charting.Chart3D", null, {
11 constructor: function(node, lights, camera, theme){
13 this.node = dojo.byId(node);
14 this.surface = dojox.gfx.createSurface(this.node, n(this.node.style.width), n(this.node.style.height));
15 this.view = this.surface.createViewport();
16 this.view.setLights(lights.lights, lights.ambient, lights.specular);
17 this.view.setCameraTransform(camera);
20 // initialize internal variables
27 return this._generateWalls()._generatePlots();
29 invalidate: function(){
30 this.view.invalidate();
37 addPlot: function(plot){
38 return this._add(this.plots, plot);
40 removePlot: function(plot){
41 return this._remove(this.plots, plot);
43 addWall: function(wall){
44 return this._add(this.walls, wall);
46 removeWall: function(wall){
47 return this._remove(this.walls, wall);
51 _add: function(array, item){
52 if(!dojo.some(array, function(i){ return i == item; })){
54 this.view.invalidate();
58 _remove: function(array, item){
59 var a = dojo.filter(array, function(i){ return i != item; });
60 return a.length < array.length ? (array = a, this.invalidate()) : this;
62 _generateWalls: function(){
63 for(var i = 0; i < this.walls.length; ++i){
64 if(v.dotProduct(observerVector, this.walls[i].normal) > 0){
65 this.walls[i].generate(this);
70 _generatePlots: function(){
71 var depth = 0, m = dojox.gfx3d.matrix, i = 0;
72 for(; i < this.plots.length; ++i){
73 depth += this.plots[i].getDepth();
75 for(--i; i >= 0; --i){
76 var scene = this.view.createScene();
77 scene.setTransform(m.translate(0, 0, -depth));
78 this.plots[i].generate(this, scene);
79 depth -= this.plots[i].getDepth();