//>>built
define("dojox/charting/scaler/linear",["dojo/_base/lang","./common"],function(r,w){function m(b,d){b=b.toLowerCase();for(var a=d.length-1;0<=a;--a)if(b===d[a])return!0;return!1}var u=r.getObject("dojox.charting.scaler.linear",!0),v=w.getNumericLabel,n=function(b,d,a,c,e,g,f){a=r.delegate(a);c||("major"==a.fixUpper&&(a.fixUpper="minor"),"major"==a.fixLower&&(a.fixLower="minor"));e||("minor"==a.fixUpper&&(a.fixUpper="micro"),"minor"==a.fixLower&&(a.fixLower="micro"));g||("micro"==a.fixUpper&&(a.fixUpper=
"none"),"micro"==a.fixLower&&(a.fixLower="none"));var k=m(a.fixLower,["major"])?Math.floor(a.min/c)*c:m(a.fixLower,["minor"])?Math.floor(a.min/e)*e:m(a.fixLower,["micro"])?Math.floor(a.min/g)*g:a.min,l=m(a.fixUpper,["major"])?Math.ceil(a.max/c)*c:m(a.fixUpper,["minor"])?Math.ceil(a.max/e)*e:m(a.fixUpper,["micro"])?Math.ceil(a.max/g)*g:a.max;a.useMin&&(b=k);a.useMax&&(d=l);var h=!c||a.useMin&&m(a.fixLower,["major"])?b:Math.ceil(b/c)*c,q=!e||a.useMin&&m(a.fixLower,["major","minor"])?b:Math.ceil(b/e)*
e,p=!g||a.useMin&&m(a.fixLower,["major","minor","micro"])?b:Math.ceil(b/g)*g,x=c?(a.useMax&&m(a.fixUpper,["major"])?Math.round((d-h)/c):Math.floor((d-h)/c))+1:0,y=e?(a.useMax&&m(a.fixUpper,["major","minor"])?Math.round((d-q)/e):Math.floor((d-q)/e))+1:0;a=g?(a.useMax&&m(a.fixUpper,["major","minor","micro"])?Math.round((d-p)/g):Math.floor((d-p)/g))+1:0;var z=e?Math.round(c/e):0,A=g?Math.round(e/g):0,B=c?Math.floor(Math.log(c)/Math.LN10):0,C=e?Math.floor(Math.log(e)/Math.LN10):0,t=f/(d-b);isFinite(t)||
(t=1);return{bounds:{lower:k,upper:l,from:b,to:d,scale:t,span:f},major:{tick:c,start:h,count:x,prec:B},minor:{tick:e,start:q,count:y,prec:C},micro:{tick:g,start:p,count:a,prec:0},minorPerMajor:z,microPerMinor:A,scaler:u}};return r.mixin(u,{buildScaler:function(b,d,a,c,e,g){var f={fixUpper:"none",fixLower:"none",natural:!1};c&&("fixUpper"in c&&(f.fixUpper=String(c.fixUpper)),"fixLower"in c&&(f.fixLower=String(c.fixLower)),"natural"in c&&(f.natural=!!c.natural));g=!g||3>g?3:g;"min"in c&&(b=c.min);"max"in
c&&(d=c.max);c.includeZero&&(0<b&&(b=0),0>d&&(d=0));f.min=b;f.useMin=!0;f.max=d;f.useMax=!0;"from"in c&&(b=c.from,f.useMin=!1);"to"in c&&(d=c.to,f.useMax=!1);if(d<=b)return n(b,d,f,0,0,0,a);e||(e=d-b);e=Math.floor(Math.log(e)/Math.LN10);e=c&&"majorTickStep"in c?c.majorTickStep:Math.pow(10,e);var k=0,l=0;if(c&&"minorTickStep"in c)k=c.minorTickStep;else{do{k=e/10;if(!f.natural||.9<k){var h=n(b,d,f,e,k,0,a);if(h.bounds.scale*h.minor.tick>g)break}k=e/5;if(!f.natural||.9<k)if(h=n(b,d,f,e,k,0,a),h.bounds.scale*
h.minor.tick>g)break;k=e/2;if(!f.natural||.9<k)if(h=n(b,d,f,e,k,0,a),h.bounds.scale*h.minor.tick>g)break;return n(b,d,f,e,0,0,a)}while(0)}if(c&&"microTickStep"in c)l=c.microTickStep,h=n(b,d,f,e,k,l,a);else{do{l=k/10;if(!f.natural||.9<l)if(h=n(b,d,f,e,k,l,a),3<h.bounds.scale*h.micro.tick)break;l=k/5;if(!f.natural||.9<l)if(h=n(b,d,f,e,k,l,a),3<h.bounds.scale*h.micro.tick)break;l=k/2;if(!f.natural||.9<l)if(h=n(b,d,f,e,k,l,a),3<h.bounds.scale*h.micro.tick)break;l=0}while(0)}return l?h:n(b,d,f,e,k,0,a)},
buildTicks:function(b,d){var a=b.major.start,c=b.minor.start,e=b.micro.start;if(d.microTicks&&b.micro.tick){var g=b.micro.tick;var f=e}else if(d.minorTicks&&b.minor.tick)g=b.minor.tick,f=c;else if(b.major.tick)g=b.major.tick,f=a;else return null;var k=1/b.bounds.scale;if(b.bounds.to<=b.bounds.from||isNaN(k)||!isFinite(k)||0>=g||isNaN(g)||!isFinite(g))return null;for(var l=[],h=[],q=[];f<=b.bounds.to+k;){if(Math.abs(a-f)<g/2){var p={value:a};d.majorLabels&&(p.label=v(a,b.major.prec,d));l.push(p);a+=
b.major.tick;c+=b.minor.tick}else Math.abs(c-f)<g/2?(d.minorTicks&&(p={value:c},d.minorLabels&&b.minMinorStep<=b.minor.tick*b.bounds.scale&&(p.label=v(c,b.minor.prec,d)),h.push(p)),c+=b.minor.tick):d.microTicks&&q.push({value:e});e+=b.micro.tick;f+=g}return{major:l,minor:h,micro:q}},getTransformerFromModel:function(b){var d=b.bounds.from,a=b.bounds.scale;return function(c){return(c-d)*a}},getTransformerFromPlot:function(b){var d=b.bounds.from,a=b.bounds.scale;return function(c){return c/a+d}}})});