Project

General

Profile

Statistics
| Revision:

root / trunk / web / dojo / dojox / charting / plot2d / Default.js @ 13

History | View | Annotate | Download (5.25 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.Default"]){
9
dojo._hasResource["dojox.charting.plot2d.Default"]=true;
10
dojo.provide("dojox.charting.plot2d.Default");
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.fx");
17
(function(){
18
var df=dojox.lang.functional,du=dojox.lang.utils,dc=dojox.charting.plot2d.common,_1=df.lambda("item.purgeGroup()");
19
var _2=1200;
20
dojo.declare("dojox.charting.plot2d.Default",dojox.charting.plot2d.Base,{defaultParams:{hAxis:"x",vAxis:"y",lines:true,areas:false,markers:false,tension:"",animate:false},optionalParams:{stroke:{},outline:{},shadow:{},fill:{},font:"",fontColor:"",markerStroke:{},markerOutline:{},markerShadow:{},markerFill:{},markerFont:"",markerFontColor:""},constructor:function(_3,_4){
21
this.opt=dojo.clone(this.defaultParams);
22
du.updateWithObject(this.opt,_4);
23
this.series=[];
24
this.hAxis=this.opt.hAxis;
25
this.vAxis=this.opt.vAxis;
26
this.animate=this.opt.animate;
27
},render:function(_5,_6){
28
if(this.zoom&&!this.isDataDirty()){
29
return this.performZoom(_5,_6);
30
}
31
this.resetEvents();
32
this.dirty=this.isDirty();
33
if(this.dirty){
34
dojo.forEach(this.series,_1);
35
this._eventSeries={};
36
this.cleanGroup();
37
this.group.setTransform(null);
38
var s=this.group;
39
df.forEachRev(this.series,function(_7){
40
_7.cleanGroup(s);
41
});
42
}
43
var t=this.chart.theme,_8,_9,_a,_b=this.events();
44
for(var i=this.series.length-1;i>=0;--i){
45
var _c=this.series[i];
46
if(!this.dirty&&!_c.dirty){
47
t.skip();
48
this._reconnectEvents(_c.name);
49
continue;
50
}
51
_c.cleanGroup();
52
if(!_c.data.length){
53
_c.dirty=false;
54
t.skip();
55
continue;
56
}
57
var _d=t.next(this.opt.areas?"area":"line",[this.opt,_c],true),s=_c.group,_e=[],_f=[],_10=null,_11,ht=this._hScaler.scaler.getTransformerFromModel(this._hScaler),vt=this._vScaler.scaler.getTransformerFromModel(this._vScaler),_12=this._eventSeries[_c.name]=new Array(_c.data.length);
58
for(var j=0;j<_c.data.length;j++){
59
if(_c.data[j]!=null){
60
if(!_10){
61
_10=[];
62
_f.push(j);
63
_e.push(_10);
64
}
65
_10.push(_c.data[j]);
66
}else{
67
_10=null;
68
}
69
}
70
for(var seg=0;seg<_e.length;seg++){
71
if(typeof _e[seg][0]=="number"){
72
_11=dojo.map(_e[seg],function(v,i){
73
return {x:ht(i+_f[seg]+1)+_6.l,y:_5.height-_6.b-vt(v)};
74
},this);
75
}else{
76
_11=dojo.map(_e[seg],function(v,i){
77
return {x:ht(v.x)+_6.l,y:_5.height-_6.b-vt(v.y)};
78
},this);
79
}
80
var _13=this.opt.tension?dc.curve(_11,this.opt.tension):"";
81
if(this.opt.areas&&_11.length>1){
82
var _14=_d.series.fill;
83
var _15=dojo.clone(_11);
84
if(this.opt.tension){
85
var _16="L"+_15[_15.length-1].x+","+(_5.height-_6.b)+" L"+_15[0].x+","+(_5.height-_6.b)+" L"+_15[0].x+","+_15[0].y;
86
_c.dyn.fill=s.createPath(_13+" "+_16).setFill(_14).getFill();
87
}else{
88
_15.push({x:_11[_11.length-1].x,y:_5.height-_6.b});
89
_15.push({x:_11[0].x,y:_5.height-_6.b});
90
_15.push(_11[0]);
91
_c.dyn.fill=s.createPolyline(_15).setFill(_14).getFill();
92
}
93
}
94
if(this.opt.lines||this.opt.markers){
95
_8=_d.series.stroke;
96
if(_d.series.outline){
97
_9=_c.dyn.outline=dc.makeStroke(_d.series.outline);
98
_9.width=2*_9.width+_8.width;
99
}
100
}
101
if(this.opt.markers){
102
_c.dyn.marker=_d.symbol;
103
}
104
var _17=null,_18=null,_19=null;
105
if(_8&&_d.series.shadow&&_11.length>1){
106
var _1a=_d.series.shadow,_1b=dojo.map(_11,function(c){
107
return {x:c.x+_1a.dx,y:c.y+_1a.dy};
108
});
109
if(this.opt.lines){
110
if(this.opt.tension){
111
_c.dyn.shadow=s.createPath(dc.curve(_1b,this.opt.tension)).setStroke(_1a).getStroke();
112
}else{
113
_c.dyn.shadow=s.createPolyline(_1b).setStroke(_1a).getStroke();
114
}
115
}
116
if(this.opt.markers&&_d.marker.shadow){
117
_1a=_d.marker.shadow;
118
_19=dojo.map(_1b,function(c){
119
return s.createPath("M"+c.x+" "+c.y+" "+_d.symbol).setStroke(_1a).setFill(_1a.color);
120
},this);
121
}
122
}
123
if(this.opt.lines&&_11.length>1){
124
if(_9){
125
if(this.opt.tension){
126
_c.dyn.outline=s.createPath(_13).setStroke(_9).getStroke();
127
}else{
128
_c.dyn.outline=s.createPolyline(_11).setStroke(_9).getStroke();
129
}
130
}
131
if(this.opt.tension){
132
_c.dyn.stroke=s.createPath(_13).setStroke(_8).getStroke();
133
}else{
134
_c.dyn.stroke=s.createPolyline(_11).setStroke(_8).getStroke();
135
}
136
}
137
if(this.opt.markers){
138
_17=new Array(_11.length);
139
_18=new Array(_11.length);
140
_9=null;
141
if(_d.marker.outline){
142
_9=dc.makeStroke(_d.marker.outline);
143
_9.width=2*_9.width+(_d.marker.stroke?_d.marker.stroke.width:0);
144
}
145
dojo.forEach(_11,function(c,i){
146
var _1c="M"+c.x+" "+c.y+" "+_d.symbol;
147
if(_9){
148
_18[i]=s.createPath(_1c).setStroke(_9);
149
}
150
_17[i]=s.createPath(_1c).setStroke(_d.marker.stroke).setFill(_d.marker.fill);
151
},this);
152
if(_b){
153
dojo.forEach(_17,function(s,i){
154
var o={element:"marker",index:i+_f[seg],run:_c,shape:s,outline:_18[i]||null,shadow:_19&&_19[i]||null,cx:_11[i].x,cy:_11[i].y};
155
if(typeof _e[seg][0]=="number"){
156
o.x=i+_f[seg]+1;
157
o.y=_e[seg][i];
158
}else{
159
o.x=_e[seg][i].x;
160
o.y=_e[seg][i].y;
161
}
162
this._connectEvents(o);
163
_12[i+_f[seg]]=o;
164
},this);
165
}else{
166
delete this._eventSeries[_c.name];
167
}
168
}
169
}
170
_c.dirty=false;
171
}
172
if(this.animate){
173
var _1d=this.group;
174
dojox.gfx.fx.animateTransform(dojo.delegate({shape:_1d,duration:_2,transform:[{name:"translate",start:[0,_5.height-_6.b],end:[0,0]},{name:"scale",start:[1,0],end:[1,1]},{name:"original"}]},this.animate)).play();
175
}
176
this.dirty=false;
177
return this;
178
}});
179
})();
180
}