root / trunk / web / dojo / dojox / charting / axis2d / Invisible.js @ 12
History | View | Annotate | Download (3.87 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.axis2d.Invisible"]){ |
9 |
dojo._hasResource["dojox.charting.axis2d.Invisible"]=true; |
10 |
dojo.provide("dojox.charting.axis2d.Invisible");
|
11 |
dojo.require("dojox.charting.scaler.linear");
|
12 |
dojo.require("dojox.charting.axis2d.common");
|
13 |
dojo.require("dojox.charting.axis2d.Base");
|
14 |
dojo.require("dojo.string");
|
15 |
dojo.require("dojox.gfx");
|
16 |
dojo.require("dojox.lang.functional");
|
17 |
dojo.require("dojox.lang.utils");
|
18 |
(function(){
|
19 |
var dc=dojox.charting,df=dojox.lang.functional,du=dojox.lang.utils,g=dojox.gfx,_1=dc.scaler.linear,_2=du.merge,_3=4,_4=45; |
20 |
dojo.declare("dojox.charting.axis2d.Invisible",dojox.charting.axis2d.Base,{defaultParams:{vertical:false,fixUpper:"none",fixLower:"none",natural:false,leftBottom:true,includeZero:false,fixed:true,majorLabels:true,minorTicks:true,minorLabels:true,microTicks:false,rotation:0},optionalParams:{min:0,max:1,from:0,to:1,majorTickStep:4,minorTickStep:2,microTickStep:1,labels:[],labelFunc:null,maxLabelSize:0},constructor:function(_5,_6){ |
21 |
this.opt=dojo.delegate(this.defaultParams,_6); |
22 |
du.updateWithPattern(this.opt,_6,this.optionalParams); |
23 |
},dependOnData:function(){ |
24 |
return !("min" in this.opt)||!("max" in this.opt); |
25 |
},clear:function(){ |
26 |
delete this.scaler; |
27 |
delete this.ticks; |
28 |
this.dirty=true; |
29 |
return this; |
30 |
},initialized:function(){ |
31 |
return "scaler" in this&&!(this.dirty&&this.dependOnData()); |
32 |
},setWindow:function(_7,_8){ |
33 |
this.scale=_7;
|
34 |
this.offset=_8;
|
35 |
return this.clear(); |
36 |
},getWindowScale:function(){ |
37 |
return "scale" in this?this.scale:1; |
38 |
},getWindowOffset:function(){ |
39 |
return "offset" in this?this.offset:0; |
40 |
},_groupLabelWidth:function(_9,_a){ |
41 |
if(!_9.length){
|
42 |
return 0; |
43 |
} |
44 |
if(dojo.isObject(_9[0])){ |
45 |
_9=df.map(_9,function(_b){
|
46 |
return _b.text;
|
47 |
}); |
48 |
} |
49 |
var s=_9.join("<br>"); |
50 |
return dojox.gfx._base._getTextBox(s,{font:_a}).w||0; |
51 |
},calculate:function(_c,_d,_e,_f){ |
52 |
if(this.initialized()){ |
53 |
return this; |
54 |
} |
55 |
var o=this.opt; |
56 |
this.labels="labels" in o?o.labels:_f; |
57 |
this.scaler=_1.buildScaler(_c,_d,_e,o);
|
58 |
var tsb=this.scaler.bounds; |
59 |
if("scale" in this){ |
60 |
o.from=tsb.lower+this.offset;
|
61 |
o.to=(tsb.upper-tsb.lower)/this.scale+o.from;
|
62 |
if(!isFinite(o.from)||isNaN(o.from)||!isFinite(o.to)||isNaN(o.to)||o.to-o.from>=tsb.upper-tsb.lower){
|
63 |
delete o.from;
|
64 |
delete o.to;
|
65 |
delete this.scale; |
66 |
delete this.offset; |
67 |
}else{
|
68 |
if(o.from<tsb.lower){
|
69 |
o.to+=tsb.lower-o.from; |
70 |
o.from=tsb.lower; |
71 |
}else{
|
72 |
if(o.to>tsb.upper){
|
73 |
o.from+=tsb.upper-o.to; |
74 |
o.to=tsb.upper; |
75 |
} |
76 |
} |
77 |
this.offset=o.from-tsb.lower;
|
78 |
} |
79 |
this.scaler=_1.buildScaler(_c,_d,_e,o);
|
80 |
tsb=this.scaler.bounds;
|
81 |
if(this.scale==1&&this.offset==0){ |
82 |
delete this.scale; |
83 |
delete this.offset; |
84 |
} |
85 |
} |
86 |
var ta=this.chart.theme.axis,_10=0,_11=o.rotation%360,_12=o.font||(ta.majorTick&&ta.majorTick.font)||(ta.tick&&ta.tick.font),_13=_12?g.normalizedLength(g.splitFontString(_12).size):0,_14=Math.abs(Math.cos(_11*Math.PI/180)),_15=Math.abs(Math.sin(_11*Math.PI/180)); |
87 |
if(_11<0){ |
88 |
_11+=360;
|
89 |
} |
90 |
if(_13){
|
91 |
if(this.vertical?_11!=0&&_11!=180:_11!=90&&_11!=270){ |
92 |
if(o.maxLabelSize){
|
93 |
_10=o.maxLabelSize; |
94 |
}else{
|
95 |
if(this.labels){ |
96 |
_10=this._groupLabelWidth(this.labels,_12); |
97 |
}else{
|
98 |
var _16=Math.ceil(Math.log(Math.max(Math.abs(tsb.from),Math.abs(tsb.to)))/Math.LN10),t=[];
|
99 |
if(tsb.from<0||tsb.to<0){ |
100 |
t.push("-");
|
101 |
} |
102 |
t.push(dojo.string.rep("9",_16));
|
103 |
var _17=Math.floor(Math.log(tsb.to-tsb.from)/Math.LN10);
|
104 |
if(_17>0){ |
105 |
t.push(".");
|
106 |
t.push(dojo.string.rep("9",_17));
|
107 |
} |
108 |
_10=dojox.gfx._base._getTextBox(t.join(""),{font:_12}).w; |
109 |
} |
110 |
} |
111 |
}else{
|
112 |
_10=_13; |
113 |
} |
114 |
switch(_11){
|
115 |
case 0: |
116 |
case 90: |
117 |
case 180: |
118 |
case 270: |
119 |
break;
|
120 |
default:
|
121 |
var _18=Math.sqrt(_10*_10+_13*_13),_19=this.vertical?_13*_14+_10*_15:_10*_14+_13*_15; |
122 |
_10=Math.min(_18,_19); |
123 |
break;
|
124 |
} |
125 |
} |
126 |
this.scaler.minMinorStep=_10+_3;
|
127 |
this.ticks=_1.buildTicks(this.scaler,o); |
128 |
return this; |
129 |
},getScaler:function(){ |
130 |
return this.scaler; |
131 |
},getTicks:function(){ |
132 |
return this.ticks; |
133 |
}}); |
134 |
})(); |
135 |
} |