root / trunk / web / dojo / dojox / charting / plot2d / Scatter.js @ 12
History | View | Annotate | Download (3.98 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.Scatter"]){ |
9 |
dojo._hasResource["dojox.charting.plot2d.Scatter"]=true; |
10 |
dojo.provide("dojox.charting.plot2d.Scatter");
|
11 |
dojo.require("dojox.charting.plot2d.common");
|
12 |
dojo.require("dojox.charting.plot2d.Base");
|
13 |
dojo.require("dojox.lang.utils");
|
14 |
dojo.require("dojox.lang.functional");
|
15 |
dojo.require("dojox.lang.functional.reversed");
|
16 |
dojo.require("dojox.gfx.gradutils");
|
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.Scatter",dojox.charting.plot2d.Base,{defaultParams:{hAxis:"x",vAxis:"y",shadows:null,animate:null},optionalParams:{markerStroke:{},markerOutline:{},markerShadow:{},markerFill:{},markerFont:"",markerFontColor:""},constructor:function(_2,_3){ |
20 |
this.opt=dojo.clone(this.defaultParams); |
21 |
du.updateWithObject(this.opt,_3);
|
22 |
this.series=[];
|
23 |
this.hAxis=this.opt.hAxis; |
24 |
this.vAxis=this.opt.vAxis; |
25 |
this.animate=this.opt.animate; |
26 |
},render:function(_4,_5){ |
27 |
if(this.zoom&&!this.isDataDirty()){ |
28 |
return this.performZoom(_4,_5); |
29 |
} |
30 |
this.resetEvents();
|
31 |
this.dirty=this.isDirty(); |
32 |
if(this.dirty){ |
33 |
dojo.forEach(this.series,_1);
|
34 |
this._eventSeries={};
|
35 |
this.cleanGroup();
|
36 |
var s=this.group; |
37 |
df.forEachRev(this.series,function(_6){ |
38 |
_6.cleanGroup(s); |
39 |
}); |
40 |
} |
41 |
var t=this.chart.theme,_7=this.events(); |
42 |
for(var i=this.series.length-1;i>=0;--i){ |
43 |
var _8=this.series[i]; |
44 |
if(!this.dirty&&!_8.dirty){ |
45 |
t.skip(); |
46 |
this._reconnectEvents(_8.name);
|
47 |
continue;
|
48 |
} |
49 |
_8.cleanGroup(); |
50 |
if(!_8.data.length){
|
51 |
_8.dirty=false;
|
52 |
t.skip(); |
53 |
continue;
|
54 |
} |
55 |
var _9=t.next("marker",[this.opt,_8]),s=_8.group,_a,ht=this._hScaler.scaler.getTransformerFromModel(this._hScaler),vt=this._vScaler.scaler.getTransformerFromModel(this._vScaler); |
56 |
if(typeof _8.data[0]=="number"){ |
57 |
_a=dojo.map(_8.data,function(v,i){
|
58 |
return {x:ht(i+1)+_5.l,y:_4.height-_5.b-vt(v)}; |
59 |
},this);
|
60 |
}else{
|
61 |
_a=dojo.map(_8.data,function(v,i){
|
62 |
return {x:ht(v.x)+_5.l,y:_4.height-_5.b-vt(v.y)}; |
63 |
},this);
|
64 |
} |
65 |
var _b=new Array(_a.length),_c=new Array(_a.length),_d=new Array(_a.length); |
66 |
dojo.forEach(_a,function(c,i){
|
67 |
var _e=typeof _8.data[i]=="number"?t.post(_9,"marker"):t.addMixin(_9,"marker",_8.data[i],true),_f="M"+c.x+" "+c.y+" "+_e.symbol; |
68 |
if(_e.marker.shadow){
|
69 |
_b[i]=s.createPath("M"+(c.x+_e.marker.shadow.dx)+" "+(c.y+_e.marker.shadow.dy)+" "+_e.symbol).setStroke(_e.marker.shadow).setFill(_e.marker.shadow.color); |
70 |
if(this.animate){ |
71 |
this._animateScatter(_b[i],_4.height-_5.b);
|
72 |
} |
73 |
} |
74 |
if(_e.marker.outline){
|
75 |
var _10=dc.makeStroke(_e.marker.outline);
|
76 |
_10.width=2*_10.width+_e.marker.stroke.width;
|
77 |
_d[i]=s.createPath(_f).setStroke(_10); |
78 |
if(this.animate){ |
79 |
this._animateScatter(_d[i],_4.height-_5.b);
|
80 |
} |
81 |
} |
82 |
var _11=dc.makeStroke(_e.marker.stroke),_12=this._plotFill(_e.marker.fill,_4,_5); |
83 |
if(_12&&(_12.type==="linear"||_12.type=="radial")){ |
84 |
var _13=dojox.gfx.gradutils.getColor(_12,{x:c.x,y:c.y}); |
85 |
if(_11){
|
86 |
_11.color=_13; |
87 |
} |
88 |
_c[i]=s.createPath(_f).setStroke(_11).setFill(_13); |
89 |
}else{
|
90 |
_c[i]=s.createPath(_f).setStroke(_11).setFill(_12); |
91 |
} |
92 |
if(this.animate){ |
93 |
this._animateScatter(_c[i],_4.height-_5.b);
|
94 |
} |
95 |
},this);
|
96 |
if(_c.length){
|
97 |
_8.dyn.stroke=_c[_c.length-1].getStroke();
|
98 |
_8.dyn.fill=_c[_c.length-1].getFill();
|
99 |
} |
100 |
if(_7){
|
101 |
var _14=new Array(_c.length); |
102 |
dojo.forEach(_c,function(s,i){
|
103 |
var o={element:"marker",index:i,run:_8,shape:s,outline:_d&&_d[i]||null,shadow:_b&&_b[i]||null,cx:_a[i].x,cy:_a[i].y}; |
104 |
if(typeof _8.data[0]=="number"){ |
105 |
o.x=i+1;
|
106 |
o.y=_8.data[i]; |
107 |
}else{
|
108 |
o.x=_8.data[i].x; |
109 |
o.y=_8.data[i].y; |
110 |
} |
111 |
this._connectEvents(o);
|
112 |
_14[i]=o; |
113 |
},this);
|
114 |
this._eventSeries[_8.name]=_14;
|
115 |
}else{
|
116 |
delete this._eventSeries[_8.name]; |
117 |
} |
118 |
_8.dirty=false;
|
119 |
} |
120 |
this.dirty=false; |
121 |
return this; |
122 |
},_animateScatter:function(_15,_16){ |
123 |
dojox.gfx.fx.animateTransform(dojo.delegate({shape:_15,duration:1200,transform:[{name:"translate",start:[0,_16],end:[0,0]},{name:"scale",start:[0,0],end:[1,1]},{name:"original"}]},this.animate)).play(); |
124 |
}}); |
125 |
})(); |
126 |
} |