root / trunk / web / dojo / dojox / charting / plot2d / StackedColumns.js @ 10
History | View | Annotate | Download (2.78 KB)
1 |
/*
|
---|---|
2 |
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
3 |
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
4 |
see: http://dojotoolkit.org/license for details
|
5 |
*/
|
6 |
|
7 |
|
8 |
if(!dojo._hasResource["dojox.charting.plot2d.StackedColumns"]){ |
9 |
dojo._hasResource["dojox.charting.plot2d.StackedColumns"]=true; |
10 |
dojo.provide("dojox.charting.plot2d.StackedColumns");
|
11 |
dojo.require("dojox.charting.plot2d.common");
|
12 |
dojo.require("dojox.charting.plot2d.Columns");
|
13 |
dojo.require("dojox.lang.functional");
|
14 |
dojo.require("dojox.lang.functional.reversed");
|
15 |
(function(){
|
16 |
var df=dojox.lang.functional,dc=dojox.charting.plot2d.common,_1=df.lambda("item.purgeGroup()"); |
17 |
dojo.declare("dojox.charting.plot2d.StackedColumns",dojox.charting.plot2d.Columns,{getSeriesStats:function(){ |
18 |
var _2=dc.collectStackedStats(this.series); |
19 |
this._maxRunLength=_2.hmax;
|
20 |
_2.hmin-=0.5;
|
21 |
_2.hmax+=0.5;
|
22 |
return _2;
|
23 |
},render:function(_3,_4){ |
24 |
if(this._maxRunLength<=0){ |
25 |
return this; |
26 |
} |
27 |
var _5=df.repeat(this._maxRunLength,"-> 0",0); |
28 |
for(var i=0;i<this.series.length;++i){ |
29 |
var _6=this.series[i]; |
30 |
for(var j=0;j<_6.data.length;++j){ |
31 |
var _7=_6.data[j];
|
32 |
if(_7!==null){ |
33 |
var v=typeof _7=="number"?_7:_7.y; |
34 |
if(isNaN(v)){
|
35 |
v=0;
|
36 |
} |
37 |
_5[j]+=v; |
38 |
} |
39 |
} |
40 |
} |
41 |
if(this.zoom&&!this.isDataDirty()){ |
42 |
return this.performZoom(_3,_4); |
43 |
} |
44 |
this.resetEvents();
|
45 |
this.dirty=this.isDirty(); |
46 |
if(this.dirty){ |
47 |
dojo.forEach(this.series,_1);
|
48 |
this._eventSeries={};
|
49 |
this.cleanGroup();
|
50 |
var s=this.group; |
51 |
df.forEachRev(this.series,function(_8){ |
52 |
_8.cleanGroup(s); |
53 |
}); |
54 |
} |
55 |
var t=this.chart.theme,f,_9,_a,ht=this._hScaler.scaler.getTransformerFromModel(this._hScaler),vt=this._vScaler.scaler.getTransformerFromModel(this._vScaler),_b=this.events(); |
56 |
f=dc.calculateBarSize(this._hScaler.bounds.scale,this.opt); |
57 |
_9=f.gap; |
58 |
_a=f.size; |
59 |
for(var i=this.series.length-1;i>=0;--i){ |
60 |
var _6=this.series[i]; |
61 |
if(!this.dirty&&!_6.dirty){ |
62 |
t.skip(); |
63 |
this._reconnectEvents(_6.name);
|
64 |
continue;
|
65 |
} |
66 |
_6.cleanGroup(); |
67 |
var _c=t.next("column",[this.opt,_6]),s=_6.group,_d=new Array(_5.length); |
68 |
for(var j=0;j<_5.length;++j){ |
69 |
var _7=_6.data[j];
|
70 |
if(_7!==null){ |
71 |
var v=_5[j],_e=vt(v),_f=typeof _7!="number"?t.addMixin(_c,"column",_7,true):t.post(_c,"column"); |
72 |
if(_a>=1&&_e>=1){ |
73 |
var _10={x:_4.l+ht(j+0.5)+_9,y:_3.height-_4.b-vt(v),width:_a,height:_e}; |
74 |
var _11=this._plotFill(_f.series.fill,_3,_4); |
75 |
_11=this._shapeFill(_11,_10);
|
76 |
var _12=s.createRect(_10).setFill(_11).setStroke(_f.series.stroke);
|
77 |
_6.dyn.fill=_12.getFill(); |
78 |
_6.dyn.stroke=_12.getStroke(); |
79 |
if(_b){
|
80 |
var o={element:"column",index:j,run:_6,shape:_12,x:j+0.5,y:v}; |
81 |
this._connectEvents(o);
|
82 |
_d[j]=o; |
83 |
} |
84 |
if(this.animate){ |
85 |
this._animateColumn(_12,_3.height-_4.b,_e);
|
86 |
} |
87 |
} |
88 |
} |
89 |
} |
90 |
this._eventSeries[_6.name]=_d;
|
91 |
_6.dirty=false;
|
92 |
for(var j=0;j<_6.data.length;++j){ |
93 |
var _7=_6.data[j];
|
94 |
if(_7!==null){ |
95 |
var v=typeof _7=="number"?_7:_7.y; |
96 |
if(isNaN(v)){
|
97 |
v=0;
|
98 |
} |
99 |
_5[j]-=v; |
100 |
} |
101 |
} |
102 |
} |
103 |
this.dirty=false; |
104 |
return this; |
105 |
}}); |
106 |
})(); |
107 |
} |