root / trunk / web / dojo / dojox / charting / plot2d / Columns.js
History | View | Annotate | Download (3.17 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.Columns"]){ |
||
9 | dojo._hasResource["dojox.charting.plot2d.Columns"]=true; |
||
10 | dojo.provide("dojox.charting.plot2d.Columns");
|
||
11 | dojo.require("dojox.charting.plot2d.common");
|
||
12 | dojo.require("dojox.charting.plot2d.Base");
|
||
13 | dojo.require("dojox.gfx.fx");
|
||
14 | dojo.require("dojox.lang.utils");
|
||
15 | dojo.require("dojox.lang.functional");
|
||
16 | dojo.require("dojox.lang.functional.reversed");
|
||
17 | (function(){
|
||
18 | var df=dojox.lang.functional,du=dojox.lang.utils,dc=dojox.charting.plot2d.common,_1=df.lambda("item.purgeGroup()"); |
||
19 | dojo.declare("dojox.charting.plot2d.Columns",dojox.charting.plot2d.Base,{defaultParams:{hAxis:"x",vAxis:"y",gap:0,animate:null},optionalParams:{minBarSize:1,maxBarSize:1,stroke:{},outline:{},shadow:{},fill:{},font:"",fontColor:""},constructor:function(_2,_3){ |
||
20 | this.opt=dojo.clone(this.defaultParams); |
||
21 | du.updateWithObject(this.opt,_3);
|
||
22 | du.updateWithPattern(this.opt,_3,this.optionalParams); |
||
23 | this.series=[];
|
||
24 | this.hAxis=this.opt.hAxis; |
||
25 | this.vAxis=this.opt.vAxis; |
||
26 | this.animate=this.opt.animate; |
||
27 | },getSeriesStats:function(){ |
||
28 | var _4=dc.collectSimpleStats(this.series); |
||
29 | _4.hmin-=0.5;
|
||
30 | _4.hmax+=0.5;
|
||
31 | return _4;
|
||
32 | },render:function(_5,_6){ |
||
33 | if(this.zoom&&!this.isDataDirty()){ |
||
34 | return this.performZoom(_5,_6); |
||
35 | } |
||
36 | this.resetEvents();
|
||
37 | this.dirty=this.isDirty(); |
||
38 | if(this.dirty){ |
||
39 | dojo.forEach(this.series,_1);
|
||
40 | this._eventSeries={};
|
||
41 | this.cleanGroup();
|
||
42 | var s=this.group; |
||
43 | df.forEachRev(this.series,function(_7){ |
||
44 | _7.cleanGroup(s); |
||
45 | }); |
||
46 | } |
||
47 | var t=this.chart.theme,f,_8,_9,ht=this._hScaler.scaler.getTransformerFromModel(this._hScaler),vt=this._vScaler.scaler.getTransformerFromModel(this._vScaler),_a=Math.max(0,this._vScaler.bounds.lower),_b=vt(_a),_c=this.events(); |
||
48 | f=dc.calculateBarSize(this._hScaler.bounds.scale,this.opt); |
||
49 | _8=f.gap; |
||
50 | _9=f.size; |
||
51 | for(var i=this.series.length-1;i>=0;--i){ |
||
52 | var _d=this.series[i]; |
||
53 | if(!this.dirty&&!_d.dirty){ |
||
54 | t.skip(); |
||
55 | this._reconnectEvents(_d.name);
|
||
56 | continue;
|
||
57 | } |
||
58 | _d.cleanGroup(); |
||
59 | var _e=t.next("column",[this.opt,_d]),s=_d.group,_f=new Array(_d.data.length); |
||
60 | for(var j=0;j<_d.data.length;++j){ |
||
61 | var _10=_d.data[j];
|
||
62 | if(_10!==null){ |
||
63 | var v=typeof _10=="number"?_10:_10.y,vv=vt(v),_11=vv-_b,h=Math.abs(_11),_12=typeof _10!="number"?t.addMixin(_e,"column",_10,true):t.post(_e,"column"); |
||
64 | if(_9>=1&&h>=1){ |
||
65 | var _13={x:_6.l+ht(j+0.5)+_8,y:_5.height-_6.b-(v>_a?vv:_b),width:_9,height:h}; |
||
66 | var _14=this._plotFill(_12.series.fill,_5,_6); |
||
67 | _14=this._shapeFill(_14,_13);
|
||
68 | var _15=s.createRect(_13).setFill(_14).setStroke(_12.series.stroke);
|
||
69 | _d.dyn.fill=_15.getFill(); |
||
70 | _d.dyn.stroke=_15.getStroke(); |
||
71 | if(_c){
|
||
72 | var o={element:"column",index:j,run:_d,shape:_15,x:j+0.5,y:v}; |
||
73 | this._connectEvents(o);
|
||
74 | _f[j]=o; |
||
75 | } |
||
76 | if(this.animate){ |
||
77 | this._animateColumn(_15,_5.height-_6.b-_b,h);
|
||
78 | } |
||
79 | } |
||
80 | } |
||
81 | } |
||
82 | this._eventSeries[_d.name]=_f;
|
||
83 | _d.dirty=false;
|
||
84 | } |
||
85 | this.dirty=false; |
||
86 | return this; |
||
87 | },_animateColumn:function(_16,_17,_18){ |
||
88 | dojox.gfx.fx.animateTransform(dojo.delegate({shape:_16,duration:1200,transform:[{name:"translate",start:[0,_17-(_17/_18)],end:[0,0]},{name:"scale",start:[1,1/_18],end:[1,1]},{name:"original"}]},this.animate)).play(); |
||
89 | }}); |
||
90 | })(); |
||
91 | } |