//>>built
define("dojox/charting/Chart","../main dojo/_base/lang dojo/_base/array dojo/_base/declare dojo/dom-style dojo/dom dojo/dom-geometry dojo/dom-construct dojo/_base/Color dojo/sniff ./Element ./SimpleTheme ./Series ./axis2d/common ./plot2d/common dojox/gfx/shape dojox/gfx dojo/has!dojo-bidi?./bidi/Chart dojox/lang/functional dojox/lang/functional/fold dojox/lang/functional/reversed".split(" "),function(t,B,k,C,u,J,q,D,E,r,m,K,L,M,v,F,n,N,g){function w(a){return a.clear()}function x(a){return a.destroy()}
function y(a){return a.dirty=!1}function z(a){return a.dirty=!0}function G(a){return a.name}function H(a,b){a&&b&&(a.min=Math.min(a.min,b.min),a.max=Math.max(a.max,b.max));return a||b}function A(a,b){var c={},e={};k.forEach(a,function(d){var f=c[d.name]=d.getSeriesStats();d.hAxis&&(e[d.hAxis]=H(e[d.hAxis],{min:f.hmin,max:f.hmax}));d.vAxis&&(e[d.vAxis]=H(e[d.vAxis],{min:f.vmin,max:f.vmax}))});k.forEach(a,function(d){var f=c[d.name];if(d.hAxis){var h=e[d.hAxis];f.hmin=h.min;f.hmax=h.max}d.vAxis&&(h=
e[d.vAxis],f.vmin=h.min,f.vmax=h.max);d.initializeScalers(b,f)})}var p=B.getObject("charting",!0,t),I={l:10,t:10,r:10,b:10};t=C(r("dojo-bidi")?"dojox.charting.NonBidiChart":"dojox.charting.Chart",null,{constructor:function(a,b){b||(b={});this.margins=b.margins||I;this._customMargins=!!b.margins;this.stroke=b.stroke;this.fill=b.fill;this.delayInMs=b.delayInMs||200;this.title=b.title;this.titleGap=b.titleGap;this.titlePos=b.titlePos;this.titleFont=b.titleFont;this.titleFontColor=b.titleFontColor;this.titleAlign=
b.titleAlign;this.chartTitle=null;this.htmlLabels=!0;"htmlLabels"in b&&(this.htmlLabels=b.htmlLabels);this.theme=null;this.axes={};this.stack=[];this.plots={};this.series=[];this.runs={};this.dirty=!0;this.node=J.byId(a);var c=q.getMarginBox(a);this.surface=n.createSurface(this.node,c.w||400,c.h||300);-1==this.surface.declaredClass.indexOf("vml")&&(this._nativeClip=!0)},destroy:function(){k.forEach(this.series,x);k.forEach(this.stack,x);g.forIn(this.axes,x);this.surface.destroy();this.chartTitle&&
this.chartTitle.tagName&&D.destroy(this.chartTitle)},getCoords:function(){var a=this.node,b=u.getComputedStyle(a);b=q.getMarginBox(a,b);a=q.position(a,!0);b.x=a.x;b.y=a.y;return b},setTheme:function(a){this.theme=a.clone();this._customMargins||(this.margins=this.theme.chart.margins||I);this.dirty=!0;return this},addAxis:function(a,b){var c=b&&b.type||"Default";if("string"==typeof c){if(!p.axis2d||!p.axis2d[c])throw Error("Can't find axis: "+c+" - Check require() dependencies.");c=new p.axis2d[c](this,
b)}else c=new c(this,b);c.name=a;c.dirty=!0;a in this.axes&&this.axes[a].destroy();this.axes[a]=c;this.dirty=!0;return this},getAxis:function(a){return this.axes[a]},removeAxis:function(a){a in this.axes&&(this.axes[a].destroy(),delete this.axes[a],this.dirty=!0);return this},addPlot:function(a,b){var c=b&&b.type||"Default";if("string"==typeof c){if(!p.plot2d||!p.plot2d[c])throw Error("Can't find plot: "+c+" - didn't you forget to dojo.require() it?");c=new p.plot2d[c](this,b)}else c=new c(this,b);
c.name=a;c.dirty=!0;a in this.plots?(this.stack[this.plots[a]].destroy(),this.stack[this.plots[a]]=c):(this.plots[a]=this.stack.length,this.stack.push(c));this.dirty=!0;return this},getPlot:function(a){return this.stack[this.plots[a]]},removePlot:function(a){if(a in this.plots){var b=this.plots[a];delete this.plots[a];this.stack[b].destroy();this.stack.splice(b,1);g.forIn(this.plots,function(e,d,f){e>b&&(f[d]=e-1)});var c=k.filter(this.series,function(e){return e.plot!=a});c.length<this.series.length&&
(k.forEach(this.series,function(e){e.plot==a&&e.destroy()}),this.runs={},k.forEach(c,function(e,d){this.runs[e.plot]=d},this),this.series=c);this.dirty=!0}return this},getPlotOrder:function(){return g.map(this.stack,G)},setPlotOrder:function(a){var b={},c=g.filter(a,function(e){if(!(e in this.plots)||e in b)return!1;b[e]=1;return!0},this);c.length<this.stack.length&&g.forEach(this.stack,function(e){e=e.name;e in b||c.push(e)});a=g.map(c,function(e){return this.stack[this.plots[e]]},this);g.forEach(a,
function(e,d){this.plots[e.name]=d},this);this.stack=a;this.dirty=!0;return this},movePlotToFront:function(a){if(a in this.plots){var b=this.plots[a];if(b){var c=this.getPlotOrder();c.splice(b,1);c.unshift(a);return this.setPlotOrder(c)}}return this},movePlotToBack:function(a){if(a in this.plots){var b=this.plots[a];if(b<this.stack.length-1){var c=this.getPlotOrder();c.splice(b,1);c.push(a);return this.setPlotOrder(c)}}return this},addSeries:function(a,b,c){b=new L(this,b,c);b.name=a;a in this.runs?
(this.series[this.runs[a]].destroy(),this.series[this.runs[a]]=b):(this.runs[a]=this.series.length,this.series.push(b));this.dirty=!0;!("ymin"in b)&&"min"in b&&(b.ymin=b.min);!("ymax"in b)&&"max"in b&&(b.ymax=b.max);return this},getSeries:function(a){return this.series[this.runs[a]]},removeSeries:function(a){if(a in this.runs){var b=this.runs[a];delete this.runs[a];this.series[b].destroy();this.series.splice(b,1);g.forIn(this.runs,function(c,e,d){c>b&&(d[e]=c-1)});this.dirty=!0}return this},updateSeries:function(a,
b,c){a in this.runs&&(a=this.series[this.runs[a]],a.update(b),c?this.dirty=!0:(this._invalidateDependentPlots(a.plot,!1),this._invalidateDependentPlots(a.plot,!0)));return this},getSeriesOrder:function(a){return g.map(g.filter(this.series,function(b){return b.plot==a}),G)},setSeriesOrder:function(a){var b,c={},e=g.filter(a,function(d){if(!(d in this.runs)||d in c)return!1;var f=this.series[this.runs[d]];if(b){if(f.plot!=b)return!1}else b=f.plot;c[d]=1;return!0},this);g.forEach(this.series,function(d){var f=
d.name;f in c||d.plot!=b||e.push(f)});this.series=g.map(e,function(d){return this.series[this.runs[d]]},this).concat(g.filter(this.series,function(d){return d.plot!=b}));g.forEach(this.series,function(d,f){this.runs[d.name]=f},this);this.dirty=!0;return this},moveSeriesToFront:function(a){if(a in this.runs){var b=this.runs[a],c=this.getSeriesOrder(this.series[b].plot);if(a!=c[0])return c.splice(b,1),c.unshift(a),this.setSeriesOrder(c)}return this},moveSeriesToBack:function(a){if(a in this.runs){var b=
this.runs[a],c=this.getSeriesOrder(this.series[b].plot);if(a!=c[c.length-1])return c.splice(b,1),c.push(a),this.setSeriesOrder(c)}return this},resize:function(a,b){switch(arguments.length){case 1:q.setMarginBox(this.node,a);break;case 2:q.setMarginBox(this.node,{w:a,h:b})}var c=q.getMarginBox(this.node),e=this.surface.getDimensions();return e.width!=c.w||e.height!=c.h?(this.surface.setDimensions(c.w,c.h),this.dirty=!0,this.render()):this},getGeometry:function(){var a={};g.forIn(this.axes,function(b){b.initialized()&&
(a[b.name]={name:b.name,vertical:b.vertical,scaler:b.scaler,ticks:b.ticks})});return a},setAxisWindow:function(a,b,c,e){var d=this.axes[a];d&&(d.setWindow(b,c),k.forEach(this.stack,function(f){if(f.hAxis==a||f.vAxis==a)f.zoom=e}));return this},setWindow:function(a,b,c,e,d){"plotArea"in this||this.calculateGeometry();g.forIn(this.axes,function(f){var h=f.getScaler().bounds;var l=h.span/(h.upper-h.lower);f.vertical?(h=b,l=e/l/h):(h=a,l=c/l/h);f.setWindow(h,l)});k.forEach(this.stack,function(f){f.zoom=
d});return this},zoomIn:function(a,b,c){var e=this.axes[a];if(e){e=e.getScaler().bounds;var d=Math.min(b[0],b[1]),f=Math.max(b[0],b[1]);d=b[0]<e.lower?e.lower:d;f=b[1]>e.upper?e.upper:f;this.setAxisWindow(a,(e.upper-e.lower)/(f-d),d-e.lower);c?this.delayedRender():this.render()}},calculateGeometry:function(){if(this.dirty)return this.fullGeometry();var a=k.filter(this.stack,function(b){return b.dirty||b.hAxis&&this.axes[b.hAxis].dirty||b.vAxis&&this.axes[b.vAxis].dirty},this);A(a,this.plotArea);return this},
fullGeometry:function(){this._makeDirty();k.forEach(this.stack,w);this.theme||this.setTheme(new K);k.forEach(this.series,function(d){if(!(d.plot in this.plots)){if(!p.plot2d||!p.plot2d.Default)throw Error("Can't find plot: Default - didn't you forget to dojo.require() it?");var f=new p.plot2d.Default(this,{});f.name=d.plot;this.plots[d.plot]=this.stack.length;this.stack.push(f)}this.stack[this.plots[d.plot]].addSeries(d)},this);k.forEach(this.stack,function(d){d.assignAxes&&d.assignAxes(this.axes)},
this);var a=this.dim=this.surface.getDimensions();a.width=n.normalizedLength(a.width);a.height=n.normalizedLength(a.height);g.forIn(this.axes,w);A(this.stack,a);var b=this.offsets={l:0,r:0,t:0,b:0},c=this;g.forIn(this.axes,function(d){r("dojo-bidi")&&c._resetLeftBottom(d);g.forIn(d.getOffsets(),function(f,h){b[h]=Math.max(f,b[h])})});if(this.title){this.titleGap=0==this.titleGap?0:this.titleGap||this.theme.chart.titleGap||20;this.titlePos=this.titlePos||this.theme.chart.titlePos||"top";this.titleFont=
this.titleFont||this.theme.chart.titleFont;this.titleFontColor=this.titleFontColor||this.theme.chart.titleFontColor||"black";this.titleAlign=this.titleAlign||this.theme&&this.theme.chart&&this.theme.chart.titleAlign||"middle";var e=n.normalizedLength(n.splitFontString(this.titleFont).size);b["top"==this.titlePos?"t":"b"]+=e+this.titleGap}g.forIn(this.margins,function(d,f){b[f]+=d});this.plotArea={width:a.width-b.l-b.r,height:a.height-b.t-b.b};g.forIn(this.axes,w);A(this.stack,this.plotArea);return this},
render:function(){this._delayedRenderHandle&&(clearTimeout(this._delayedRenderHandle),this._delayedRenderHandle=null);this.theme&&this.theme.clear();if(this.dirty)return this.fullRender();this.calculateGeometry();g.forEachRev(this.stack,function(a){a.render(this.dim,this.offsets)},this);g.forIn(this.axes,function(a){a.render(this.dim,this.offsets)},this);this._makeClean();return this},fullRender:function(){this.fullGeometry();var a=this.offsets,b=this.dim,c=Math.max(0,b.width-a.l-a.r),e=Math.max(0,
b.height-a.t-a.b);k.forEach(this.series,v.purgeGroup);g.forIn(this.axes,v.purgeGroup);k.forEach(this.stack,v.purgeGroup);var d=this.surface.children;if(F.dispose)for(var f=0;f<d.length;++f)F.dispose(d[f]);this.chartTitle&&this.chartTitle.tagName&&D.destroy(this.chartTitle);this.surface.clear();this.chartTitle=null;this._renderChartBackground(b,a);this._renderPlotBackground(b,a,c,e);g.foldr(this.stack,function(h,l){return l.render(b,a),0},0);this._nativeClip||this._renderChartBackground(b,a);this.title&&
this._renderTitle(b,a);g.forIn(this.axes,function(h){h.render(b,a)});this._makeClean();return this},_renderTitle:function(a,b){var c="canvas"==n.renderer&&this.htmlLabels||!r("ie")&&!r("opera")&&this.htmlLabels?"html":"gfx",e=n.normalizedLength(n.splitFontString(this.titleFont).size),d=n._base._getTextBox(this.title,{font:this.titleFont}),f=this.titleAlign,h=r("dojo-bidi")&&this.isRightToLeft(),l=a.width/2;"edge"===f?(f="left",l=h?a.width-(b.r+d.w):b.l):"middle"!=f&&(h&&(f="left"===f?"right":"left"),
"left"===f?l=this.margins.l:"right"===f&&(f="left",l=a.width-(this.margins.l+d.w)));this.chartTitle=M.createText[c](this,this.surface,l,"top"==this.titlePos?e+this.margins.t:a.height-this.margins.b,f,this.title,this.titleFont,this.titleFontColor)},_renderChartBackground:function(a,b){var c=this.theme,e=void 0!==this.fill?this.fill:c.chart&&c.chart.fill;c=void 0!==this.stroke?this.stroke:c.chart&&c.chart.stroke;if("inherit"==e){var d=this.node;for(e=new E(u.get(d,"backgroundColor"));0==e.a&&d!=document.documentElement;)e=
new E(u.get(d,"backgroundColor")),d=d.parentNode}e&&(this._nativeClip?(e=m.prototype._shapeFill(m.prototype._plotFill(e,a),{x:0,y:0,width:a.width+1,height:a.height+1}),this.surface.createRect({width:a.width+1,height:a.height+1}).setFill(e)):(e=m.prototype._plotFill(e,a,b),b.l&&(d={x:0,y:0,width:b.l,height:a.height+1},this.surface.createRect(d).setFill(m.prototype._shapeFill(e,d))),b.r&&(d={x:a.width-b.r,y:0,width:b.r+1,height:a.height+2},this.surface.createRect(d).setFill(m.prototype._shapeFill(e,
d))),b.t&&(d={x:0,y:0,width:a.width+1,height:b.t},this.surface.createRect(d).setFill(m.prototype._shapeFill(e,d))),b.b&&(d={x:0,y:a.height-b.b,width:a.width+1,height:b.b+2},this.surface.createRect(d).setFill(m.prototype._shapeFill(e,d)))));c&&this.surface.createRect({width:a.width-1,height:a.height-1}).setStroke(c)},_renderPlotBackground:function(a,b,c,e){var d=this.theme,f=d.plotarea&&d.plotarea.fill;d=d.plotarea&&d.plotarea.stroke;var h={x:b.l-1,y:b.t-1,width:c+2,height:e+2};f&&(f=m.prototype._shapeFill(m.prototype._plotFill(f,
a,b),h),this.surface.createRect(h).setFill(f));d&&this.surface.createRect({x:b.l,y:b.t,width:c+1,height:e+1}).setStroke(d)},delayedRender:function(){this._delayedRenderHandle||(this._delayedRenderHandle=setTimeout(B.hitch(this,function(){this.render()}),this.delayInMs));return this},connectToPlot:function(a,b,c){return a in this.plots?this.stack[this.plots[a]].connect(b,c):null},fireEvent:function(a,b,c){if(a in this.runs){var e=this.series[this.runs[a]].plot;e in this.plots&&(e=this.stack[this.plots[e]])&&
e.fireEvent(a,b,c)}return this},_makeClean:function(){k.forEach(this.axes,y);k.forEach(this.stack,y);k.forEach(this.series,y);this.dirty=!1},_makeDirty:function(){k.forEach(this.axes,z);k.forEach(this.stack,z);k.forEach(this.series,z);this.dirty=!0},_invalidateDependentPlots:function(a,b){if(a in this.plots){var c=this.stack[this.plots[a]],e,d=b?"vAxis":"hAxis";c[d]?(e=this.axes[c[d]])&&e.dependOnData()&&(e.dirty=!0,k.forEach(this.stack,function(f){f[d]&&f[d]==c[d]&&(f.dirty=!0)})):c.dirty=!0}},setDir:function(a){return this},
_resetLeftBottom:function(a){},formatTruncatedLabel:function(a,b,c){}});return r("dojo-bidi")?C("dojox.charting.Chart",[t,N]):t});