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