root / trunk / web / dojo / dojox / charting / axis2d / common.js @ 11
History | View | Annotate | Download (1.98 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.axis2d.common"]){ |
||
9 | dojo._hasResource["dojox.charting.axis2d.common"]=true; |
||
10 | dojo.provide("dojox.charting.axis2d.common");
|
||
11 | dojo.require("dojox.gfx");
|
||
12 | (function(){
|
||
13 | var g=dojox.gfx;
|
||
14 | var _1=function(s){ |
||
15 | s.marginLeft="0px";
|
||
16 | s.marginTop="0px";
|
||
17 | s.marginRight="0px";
|
||
18 | s.marginBottom="0px";
|
||
19 | s.paddingLeft="0px";
|
||
20 | s.paddingTop="0px";
|
||
21 | s.paddingRight="0px";
|
||
22 | s.paddingBottom="0px";
|
||
23 | s.borderLeftWidth="0px";
|
||
24 | s.borderTopWidth="0px";
|
||
25 | s.borderRightWidth="0px";
|
||
26 | s.borderBottomWidth="0px";
|
||
27 | }; |
||
28 | var _2=function(n){ |
||
29 | if(n["getBoundingClientRect"]){ |
||
30 | var _3=n.getBoundingClientRect();
|
||
31 | return _3.width||(_3.right-_3.left);
|
||
32 | }else{
|
||
33 | return dojo.marginBox(n).w;
|
||
34 | } |
||
35 | }; |
||
36 | dojo.mixin(dojox.charting.axis2d.common,{createText:{gfx:function(_4,_5,x,y,_6,_7,_8,_9){ |
||
37 | return _5.createText({x:x,y:y,text:_7,align:_6}).setFont(_8).setFill(_9); |
||
38 | },html:function(_a,_b,x,y,_c,_d,_e,_f,_10){ |
||
39 | var p=dojo.doc.createElement("div"),s=p.style,_11; |
||
40 | _1(s); |
||
41 | s.font=_e; |
||
42 | p.innerHTML=String(_d).replace(/\s/g," "); |
||
43 | s.color=_f; |
||
44 | s.position="absolute";
|
||
45 | s.left="-10000px";
|
||
46 | dojo.body().appendChild(p); |
||
47 | var _12=g.normalizedLength(g.splitFontString(_e).size);
|
||
48 | if(!_10){
|
||
49 | _11=_2(p); |
||
50 | } |
||
51 | dojo.body().removeChild(p); |
||
52 | s.position="relative";
|
||
53 | if(_10){
|
||
54 | s.width=_10+"px";
|
||
55 | switch(_c){
|
||
56 | case "middle": |
||
57 | s.textAlign="center";
|
||
58 | s.left=(x-_10/2)+"px"; |
||
59 | break;
|
||
60 | case "end": |
||
61 | s.textAlign="right";
|
||
62 | s.left=(x-_10)+"px";
|
||
63 | break;
|
||
64 | default:
|
||
65 | s.left=x+"px";
|
||
66 | s.textAlign="left";
|
||
67 | break;
|
||
68 | } |
||
69 | }else{
|
||
70 | switch(_c){
|
||
71 | case "middle": |
||
72 | s.left=Math.floor(x-_11/2)+"px"; |
||
73 | break;
|
||
74 | case "end": |
||
75 | s.left=Math.floor(x-_11)+"px";
|
||
76 | break;
|
||
77 | default:
|
||
78 | s.left=Math.floor(x)+"px";
|
||
79 | break;
|
||
80 | } |
||
81 | } |
||
82 | s.top=Math.floor(y-_12)+"px";
|
||
83 | s.whiteSpace="nowrap";
|
||
84 | var _13=dojo.doc.createElement("div"),w=_13.style; |
||
85 | _1(w); |
||
86 | w.width="0px";
|
||
87 | w.height="0px";
|
||
88 | _13.appendChild(p); |
||
89 | _a.node.insertBefore(_13,_a.node.firstChild); |
||
90 | return _13;
|
||
91 | }}}); |
||
92 | })(); |
||
93 | } |