root / trunk / web / dojo / dojox / charting / plot2d / Base.js @ 9
History | View | Annotate | Download (3.05 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.Base"]){ |
9 |
dojo._hasResource["dojox.charting.plot2d.Base"]=true; |
10 |
dojo.provide("dojox.charting.plot2d.Base");
|
11 |
dojo.require("dojox.charting.scaler.primitive");
|
12 |
dojo.require("dojox.charting.Element");
|
13 |
dojo.require("dojox.charting.plot2d.common");
|
14 |
dojo.require("dojox.charting.plot2d._PlotEvents");
|
15 |
dojo.declare("dojox.charting.plot2d.Base",[dojox.charting.Element,dojox.charting.plot2d._PlotEvents],{constructor:function(_1,_2){ |
16 |
this.zoom=null,this.zoomQueue=[]; |
17 |
this.lastWindow={vscale:1,hscale:1,xoffset:0,yoffset:0}; |
18 |
},clear:function(){ |
19 |
this.series=[];
|
20 |
this._hAxis=null; |
21 |
this._vAxis=null; |
22 |
this.dirty=true; |
23 |
return this; |
24 |
},setAxis:function(_3){ |
25 |
if(_3){
|
26 |
this[_3.vertical?"_vAxis":"_hAxis"]=_3; |
27 |
} |
28 |
return this; |
29 |
},addSeries:function(_4){ |
30 |
this.series.push(_4);
|
31 |
return this; |
32 |
},getSeriesStats:function(){ |
33 |
return dojox.charting.plot2d.common.collectSimpleStats(this.series); |
34 |
},calculateAxes:function(_5){ |
35 |
this.initializeScalers(_5,this.getSeriesStats()); |
36 |
return this; |
37 |
},isDirty:function(){ |
38 |
return this.dirty||this._hAxis&&this._hAxis.dirty||this._vAxis&&this._vAxis.dirty; |
39 |
},isDataDirty:function(){ |
40 |
return dojo.some(this.series,function(_6){ |
41 |
return _6.dirty;
|
42 |
}); |
43 |
},performZoom:function(_7,_8){ |
44 |
var vs=this._vAxis.scale||1,hs=this._hAxis.scale||1,_9=_7.height-_8.b,_a=this._hScaler.bounds,_b=(_a.from-_a.lower)*_a.scale,_c=this._vScaler.bounds,_d=(_c.from-_c.lower)*_c.scale; |
45 |
rVScale=vs/this.lastWindow.vscale,rHScale=hs/this.lastWindow.hscale,rXOffset=(this.lastWindow.xoffset-_b)/((this.lastWindow.hscale==1)?hs:this.lastWindow.hscale),rYOffset=(_d-this.lastWindow.yoffset)/((this.lastWindow.vscale==1)?vs:this.lastWindow.vscale),shape=this.group,anim=dojox.gfx.fx.animateTransform(dojo.delegate({shape:shape,duration:1200,transform:[{name:"translate",start:[0,0],end:[_8.l*(1-rHScale),_9*(1-rVScale)]},{name:"scale",start:[1,1],end:[rHScale,rVScale]},{name:"original"},{name:"translate",start:[0,0],end:[rXOffset,rYOffset]}]},this.zoom)); |
46 |
dojo.mixin(this.lastWindow,{vscale:vs,hscale:hs,xoffset:_b,yoffset:_d}); |
47 |
this.zoomQueue.push(anim);
|
48 |
dojo.connect(anim,"onEnd",this,function(){ |
49 |
this.zoom=null; |
50 |
this.zoomQueue.shift();
|
51 |
if(this.zoomQueue.length>0){ |
52 |
this.zoomQueue[0].play(); |
53 |
} |
54 |
}); |
55 |
if(this.zoomQueue.length==1){ |
56 |
this.zoomQueue[0].play(); |
57 |
} |
58 |
return this; |
59 |
},render:function(_e,_f){ |
60 |
return this; |
61 |
},getRequiredColors:function(){ |
62 |
return this.series.length; |
63 |
},initializeScalers:function(dim,_10){ |
64 |
if(this._hAxis){ |
65 |
if(!this._hAxis.initialized()){ |
66 |
this._hAxis.calculate(_10.hmin,_10.hmax,dim.width);
|
67 |
} |
68 |
this._hScaler=this._hAxis.getScaler(); |
69 |
}else{
|
70 |
this._hScaler=dojox.charting.scaler.primitive.buildScaler(_10.hmin,_10.hmax,dim.width);
|
71 |
} |
72 |
if(this._vAxis){ |
73 |
if(!this._vAxis.initialized()){ |
74 |
this._vAxis.calculate(_10.vmin,_10.vmax,dim.height);
|
75 |
} |
76 |
this._vScaler=this._vAxis.getScaler(); |
77 |
}else{
|
78 |
this._vScaler=dojox.charting.scaler.primitive.buildScaler(_10.vmin,_10.vmax,dim.height);
|
79 |
} |
80 |
return this; |
81 |
}}); |
82 |
} |