//>>built
define("dojox/charting/action2d/_IndicatorElement","dojo/_base/lang dojo/_base/array dojo/_base/declare ../plot2d/Indicator dojo/has ../plot2d/common ../axis2d/common dojox/gfx".split(" "),function(t,z,q,A,y){var u=function(b,a,c){var d,e=b?{x:a[0],y:c[0][0]}:{x:c[0][0],y:a[0]};1<a.length&&(d=b?{x:a[1],y:c[1][0]}:{x:c[1][0],y:a[1]});return[e,d]};q=q("dojox.charting.action2d._IndicatorElement",A,{constructor:function(b,a){a||(a={});this.inter=a.inter},_updateVisibility:function(b,a,c){var d="x"==c?
this._hAxis:this._vAxis,e=d.getWindowScale();this.chart.setAxisWindow(d.name,e,d.getWindowOffset()+(b[c]-a[c])/e);this._noDirty=!0;this.chart.render();this._noDirty=!1;this._initTrack()},_trackMove:function(){this._updateIndicator(this.pageCoord);this._tracker=setTimeout(t.hitch(this,this._trackMove),100)},_initTrack:function(){this._tracker||(this._tracker=setTimeout(t.hitch(this,this._trackMove),500))},stopTrack:function(){this._tracker&&(clearTimeout(this._tracker),this._tracker=null)},render:function(){if(this.isDirty()){var b=
this.inter,a=b.plot,c=b.opt.vertical;this.opt.offset=b.opt.offset||(c?{x:0,y:5}:{x:5,y:0});b.opt.labelFunc&&(this.opt.labelFunc=function(d,e,g,f,h){d=u(c,e,g);return b.opt.labelFunc(d[0],d[1],f,h)});b.opt.fillFunc&&(this.opt.fillFunc=function(d,e,g){d=u(c,e,g);return b.opt.fillFunc(d[0],d[1])});this.opt=t.delegate(b.opt,this.opt);this.pageCoord?(this.opt.values=[],this.opt.labels=this.secondCoord?"trend":"markers"):(this.opt.values=null,this.inter.onChange({}));this.hAxis=a.hAxis;this.vAxis=a.vAxis;
this.inherited(arguments)}},_updateIndicator:function(){var b=this._updateCoordinates(this.pageCoord,this.secondCoord);if(1<b.length){var a=this.opt.vertical;this._data=[];this.opt.values=[];z.forEach(b,function(c){c&&(this.opt.values.push(a?c.x:c.y),this._data.push([a?c.y:c.x]))},this);this.inherited(arguments)}else this.inter.onChange({})},_renderText:function(b,a,c,d,e,g,f,h){this.inter.opt.labels&&this.inherited(arguments);var k=u(this.opt.vertical,f,h);this.inter.onChange({start:k[0],end:k[1],
label:a})},_updateCoordinates:function(b,a){y("dojo-bidi")&&this._checkXCoords(b,a);var c=this.inter,d=c.plot,e=c.opt.vertical,g=this.chart.getAxis(d.hAxis),f=this.chart.getAxis(d.vAxis),h=g.name,k=f.name,v=g.getScaler().bounds,w=f.getScaler().bounds;f=e?"x":"y";g=e?h:k;var r=e?v:w;if(a)if(e){if(b.x>a.x){var m=a;a=b;b=m}}else b.y>a.y&&(m=a,a=b,b=m);var p=d.toData(b),l;a&&(l=d.toData(a));var n={};n[h]=v.from;n[k]=w.from;m=d.toPage(n);n[h]=v.to;n[k]=w.to;h=d.toPage(n);if(p[g]<r.from){if(l||!c.opt.autoScroll||
c.opt.mouseOver){if(c.opt.mouseOver)return[];b[f]=m[f]}else return this._updateVisibility(b,m,f),[];p=d.toData(b)}else if(p[g]>r.to){if(l||!c.opt.autoScroll||c.opt.mouseOver){if(c.opt.mouseOver)return[];b[f]=h[f]}else return this._updateVisibility(b,h,f),[];p=d.toData(b)}c=this._snapData(p,f,e);if(null==c.y)return[];if(a){l[g]<r.from?(a[f]=m[f],l=d.toData(a)):l[g]>r.to&&(a[f]=h[f],l=d.toData(a));var x=this._snapData(l,f,e);null==x.y&&(x=null)}return[c,x]},_snapData:function(b,a,c){var d=this.chart.getSeries(this.inter.opt.series).data,
e,g=d.length;for(e=0;e<g;++e){var f=d[e];if(null!=f)if("number"==typeof f){if(e+1>b[a])break}else if(f[a]>b[a])break}if("number"==typeof f){if(g=e+1,0<e){var h=e;var k=d[e-1]}}else g=f.x,f=f.y,0<e&&(h=d[e-1].x,k=d[e-1].y);0<e&&b[a]<=(c?(g+h)/2:(f+k)/2)&&(g=h,f=k);return{x:g,y:f}},cleanGroup:function(b){this.inherited(arguments);this.group.moveToFront();return this},isDirty:function(){return!this._noDirty&&(this.dirty||this.inter.plot.isDirty())}});y("dojo-bidi")&&q.extend({_checkXCoords:function(b,
a){if(this.chart.isRightToLeft()&&this.isDirty()){var c=this.chart.node.offsetLeft,d=function(e,g){return e.chart.dim.width+(e.chart.offsets.l-e.chart.offsets.r)-(g.x-c)+c};b&&(b.x=d(this,b));a&&(a.x=d(this,a))}}});return q});