root / trunk / web / dojo / dojox / charting / scaler / common.js
History | View | Annotate | Download (1.12 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.scaler.common"]){ |
| 9 |
dojo._hasResource["dojox.charting.scaler.common"]=true; |
| 10 |
dojo.provide("dojox.charting.scaler.common");
|
| 11 |
(function(){
|
| 12 |
var eq=function(a,b){ |
| 13 |
return Math.abs(a-b)<=0.000001*(Math.abs(a)+Math.abs(b)); |
| 14 |
}; |
| 15 |
dojo.mixin(dojox.charting.scaler.common,{findString:function(_1,_2){
|
| 16 |
_1=_1.toLowerCase(); |
| 17 |
for(var i=0;i<_2.length;++i){ |
| 18 |
if(_1==_2[i]){
|
| 19 |
return true; |
| 20 |
} |
| 21 |
} |
| 22 |
return false; |
| 23 |
},getNumericLabel:function(_3,_4,_5){ |
| 24 |
var _6=_5.fixed?_3.toFixed(_4<0?-_4:0):_3.toString(); |
| 25 |
if(_5.labelFunc){
|
| 26 |
var r=_5.labelFunc(_6,_3,_4);
|
| 27 |
if(r){
|
| 28 |
return r;
|
| 29 |
} |
| 30 |
} |
| 31 |
if(_5.labels){
|
| 32 |
var l=_5.labels,lo=0,hi=l.length; |
| 33 |
while(lo<hi){
|
| 34 |
var _7=Math.floor((lo+hi)/2),_8=l[_7].value; |
| 35 |
if(_8<_3){
|
| 36 |
lo=_7+1;
|
| 37 |
}else{
|
| 38 |
hi=_7; |
| 39 |
} |
| 40 |
} |
| 41 |
if(lo<l.length&&eq(l[lo].value,_3)){
|
| 42 |
return l[lo].text;
|
| 43 |
} |
| 44 |
--lo; |
| 45 |
if(lo>=0&&lo<l.length&&eq(l[lo].value,_3)){ |
| 46 |
return l[lo].text;
|
| 47 |
} |
| 48 |
lo+=2;
|
| 49 |
if(lo<l.length&&eq(l[lo].value,_3)){
|
| 50 |
return l[lo].text;
|
| 51 |
} |
| 52 |
} |
| 53 |
return _6;
|
| 54 |
}}); |
| 55 |
})(); |
| 56 |
} |