root / trunk / web / dojo / dojox / charting / plot2d / ClusteredBars.js @ 11
History | View | Annotate | Download (2.37 KB)
1 | 9 | andrej.cim | /*
|
---|---|---|---|
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.ClusteredBars"]){ |
||
9 | dojo._hasResource["dojox.charting.plot2d.ClusteredBars"]=true; |
||
10 | dojo.provide("dojox.charting.plot2d.ClusteredBars");
|
||
11 | dojo.require("dojox.charting.plot2d.common");
|
||
12 | dojo.require("dojox.charting.plot2d.Bars");
|
||
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.ClusteredBars",dojox.charting.plot2d.Bars,{render:function(_2,_3){ |
||
18 | if(this.zoom&&!this.isDataDirty()){ |
||
19 | return this.performZoom(_2,_3); |
||
20 | } |
||
21 | this.resetEvents();
|
||
22 | this.dirty=this.isDirty(); |
||
23 | if(this.dirty){ |
||
24 | dojo.forEach(this.series,_1);
|
||
25 | this._eventSeries={};
|
||
26 | this.cleanGroup();
|
||
27 | var s=this.group; |
||
28 | df.forEachRev(this.series,function(_4){ |
||
29 | _4.cleanGroup(s); |
||
30 | }); |
||
31 | } |
||
32 | var t=this.chart.theme,f,_5,_6,_7,ht=this._hScaler.scaler.getTransformerFromModel(this._hScaler),vt=this._vScaler.scaler.getTransformerFromModel(this._vScaler),_8=Math.max(0,this._hScaler.bounds.lower),_9=ht(_8),_a=this.events(); |
||
33 | f=dc.calculateBarSize(this._vScaler.bounds.scale,this.opt,this.series.length); |
||
34 | _5=f.gap; |
||
35 | _6=_7=f.size; |
||
36 | for(var i=this.series.length-1;i>=0;--i){ |
||
37 | var _b=this.series[i],_c=_7*(this.series.length-i-1); |
||
38 | if(!this.dirty&&!_b.dirty){ |
||
39 | t.skip(); |
||
40 | this._reconnectEvents(_b.name);
|
||
41 | continue;
|
||
42 | } |
||
43 | _b.cleanGroup(); |
||
44 | var _d=t.next("bar",[this.opt,_b]),s=_b.group,_e=new Array(_b.data.length); |
||
45 | for(var j=0;j<_b.data.length;++j){ |
||
46 | var _f=_b.data[j];
|
||
47 | if(_f!==null){ |
||
48 | var v=typeof _f=="number"?_f:_f.y,hv=ht(v),_10=hv-_9,w=Math.abs(_10),_11=typeof _f!="number"?t.addMixin(_d,"bar",_f,true):t.post(_d,"bar"); |
||
49 | if(w>=1&&_6>=1){ |
||
50 | var _12={x:_3.l+(v<_8?hv:_9),y:_2.height-_3.b-vt(j+1.5)+_5+_c,width:w,height:_6}; |
||
51 | var _13=this._plotFill(_11.series.fill,_2,_3); |
||
52 | _13=this._shapeFill(_13,_12);
|
||
53 | var _14=s.createRect(_12).setFill(_13).setStroke(_11.series.stroke);
|
||
54 | _b.dyn.fill=_14.getFill(); |
||
55 | _b.dyn.stroke=_14.getStroke(); |
||
56 | if(_a){
|
||
57 | var o={element:"bar",index:j,run:_b,shape:_14,x:v,y:j+1.5}; |
||
58 | this._connectEvents(o);
|
||
59 | _e[j]=o; |
||
60 | } |
||
61 | if(this.animate){ |
||
62 | this._animateBar(_14,_3.l+_9,-_10);
|
||
63 | } |
||
64 | } |
||
65 | } |
||
66 | } |
||
67 | this._eventSeries[_b.name]=_e;
|
||
68 | _b.dirty=false;
|
||
69 | } |
||
70 | this.dirty=false; |
||
71 | return this; |
||
72 | }}); |
||
73 | })(); |
||
74 | } |