// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
define("esri/dijit/geoenrichment/ReportPlayer/core/charts/tooltips/ChartTooltip","dojo/_base/declare dojo/_base/lang dojo/string dojo/_base/window dojo/_base/connect dojo/sniff dojo/dom-class dojo/dom-construct dojo/dom-geometry dojo/dom-style dijit/Tooltip dojox/charting/action2d/Tooltip dojox/lang/functional dojox/gfx/matrix ../chartUtils/ChartTypes ../../supportClasses/conditionalStyling/ConditionalStyleLegendBuilder esri/dijit/geoenrichment/utils/DomUtil dojo/i18n!../../../../../../nls/jsapi".split(" "),
function(y,z,w,A,B,C,t,g,D,v,l,E,n,F,p,G,H,b){b=b.geoenrichment.dijit.ReportPlayer.ReportPlayer;var r=Math.PI/4,I=Math.PI/2,x={_nodeInLayoutCheckHandle:null,_rawNode:null,_node:null,show:function(a,b,f,k){b&&(this.hide(b),l.show(a,b,f),this._setClasses(!0),this._setListeners(b,k))},hide:function(a){l.hide(a);this._setClasses(!1);this._setListeners(null,null)},_setClasses:function(a){l._masterTT&&(t[a?"add":"remove"](l._masterTT.domNode,"esriGEChartContainer_chartTooltip_masterTooltip"),t[a?"add":
"remove"](l._masterTT.containerNode,"esriGEChartContainer_chartTooltip_containerNode"))},_setListeners:function(a,b){var f=this;clearInterval(this._nodeInLayoutCheckHandle);b&&(this._node=a,this._rawNode=b,this._nodeInLayoutCheckHandle=setInterval(function(){H.isNodeInLayout(f._rawNode)||f.hide(f._node)},500))}};return y(E,{showStatistics:!0,_chartType:null,constructor:function(){var a=this,b=this.text;this.text=function(f,k){var c;c=f.run&&f.run.data&&f.run.data[f.index];c=c.tooltip&&"object"===
typeof c.tooltip?a._renderTooltip(c.tooltip):void 0;return c||b(f,k)}},process:function(a){function b(){z.mixin(c,f())}function f(){var b=a.shape.rawNode.getBoundingClientRect(),c=D.position(k.chart.node,!0);return{x:b.left-c.x,y:b.top-c.y,w:b.width,h:b.height}}var k=this;if("onplotreset"===a.type||"onmouseout"===a.type)x.hide(this.aroundRect),this.aroundRect=null,"onplotreset"===a.type&&delete this.angles;else if(!(!a.shape||this.mouseOver&&"onmouseover"!==a.type||!this.mouseOver&&"onclick"!==a.type)){var c=
{type:"rect"},g=["after-centered","before-centered"];if(p.isPictureLike(this._chartType))b();else{switch(a.element){case "marker":case "circle":case "spider_circle":case "spider_plot":case "candlestick":b();break;case "column":g=["above-centered","below-centered"];case "bar":b();break;default:if(!this.angles){var d="number"===typeof a.run.data[0]?n.map(a.run.data,"x ? Math.max(x, 0) : 0"):n.map(a.run.data,"x ? Math.max(x.y, 0) : 0");this.angles=n.map(n.scanl(d,"+",0),"* 2 * Math.PI / this",n.foldl(d,
"+",0))}var d=F._degToRad(a.plot.opt.startAngle),h=(this.angles[a.index]+this.angles[a.index+1])/2+d;b();d&&(0>h||h>2*Math.PI)&&(h=Math.abs(2*Math.PI-Math.abs(h)));h<r||(h<I+r?g=["below-centered","above-centered"]:h<Math.PI+r?g=["before-centered","after-centered"]:h<2*Math.PI-r&&(g=["above-centered","below-centered"]))}C("dojo-bidi")&&this._recheckPosition(a,c,g)}d=this.chart.getCoords();c.x+=d.x;c.y+=d.y;c.x=Math.round(c.x);c.y=Math.round(c.y);c.w=Math.ceil(c.w);c.h=Math.ceil(c.h);this.aroundRect=
c;(d=this.text(a,this.plot))&&x.show(this._format(d),this.aroundRect,g,a.shape.rawNode);this.mouseOver||(this._handle=B.connect(A.doc,"onclick",this,"onClick"))}},setChartType:function(a){this._chartType=a},_renderTooltip:function(a){function l(a,b){var c=g.create("div",{"class":"chartTooltip_title esriGERowHigh"},m,"first");b&&f(b,c);k(a,c)}function f(a,b){var c=g.create("div",{"class":"chartTooltip_color dijitInline esriGESpaceAfterBig"},b);v.set(c,"backgroundColor",a||"transparent")}function k(a,
b){return g.create("div",{"class":"chartTooltip_label dijitInline esriGESpaceAfterBig",innerHTML:a},b)}function c(a,b){return g.create("div",{"class":"chartTooltip_value dijitInline esriGESpaceAfterBig",innerHTML:a},b)}function n(a){var b=0;a.forEach(function(a){b=Math.max(b,v.get(a,"width"))});a.forEach(function(a){v.set(a,"width",b+"px")})}function d(b,e,d,l){function h(b,e){if(a[b]){var d=g.create("div",{"class":"chartTooltip_row esriGERowHigh"},m);f(null,d);q.push(k(e,d));c(a[b],d)}}h("percentLabel",
b);h("minValueLabel",e);h("maxValueLabel",d);h("avgValueLabel",l)}function h(){var h=a.getGroup&&a.getGroup();h&&1!==h.length?(l(a.label),f(a.color,e),q.push(k(a.seriesLabel,e)),u?c(b.unavailableData,e):(c(a.valueLabel,e),d(b.weightInSeries,b.minValueInSeries,b.maxValueInSeries,b.avgValueInSeries)),a.getGroup().forEach(function(d){if(a!==d){var e=g.create("div",{"class":"chartTooltip_row esriGERowHigh"},m);f(d.color,e);q.push(k(d.seriesLabel,e));isNaN(d.value)?c(b.unavailableData,e):c(d.valueLabel,
e)}})):(f(a.color,e),q.push(k(a.label,e)),u?c(b.unavailableData,e):(c(a.valueLabel,e),d(b.weight,b.minValue,b.maxValue,b.avgValue)))}function r(){l(a.label);f(a.color,e);q.push(k(a.seriesLabel,e));c(a.valueLabel,e);d(b.weightInSeries,b.minValueInSeries,b.maxValueInSeries,b.avgValueInSeries);a.getGroup().forEach(function(b){if(a!==b){var d=g.create("div",{"class":"chartTooltip_row esriGERowHigh"},m);f(b.color,d);q.push(k(b.seriesLabel,d));c(b.valueLabel,d)}})}var q=[],u=isNaN(a.value),m=g.create("div",
{"class":"esriGEChartContainer_chartTooltip"},document.body);if(this.showStatistics){var e=g.create("div",{"class":"chartTooltip_row esriGERowHigh"},m);this._chartType===p.PIE||this._chartType===p.DONUT||this._chartType===p.RING?(l(a.label,a.color),f(null,e),u?k(b.unavailableData,e):(k(w.substitute(b.pieChartTooltip_label,{value:a.valueLabel,total:a.sumValueLabel}),e),d(b.weight,b.minValue,b.maxValue,b.avgValue))):this._chartType===p.GAUGE?(l(a.label,a.color),f(null,e),u?k(b.unavailableData,e):k(w.substitute(b.pieChartTooltip_label,
{value:a.valueLabel,total:a.sumValueLabel}),e)):p.isColumnBarLike(this._chartType)?h():this._chartType===p.LINE&&r();n(q)}else g.create("div",{"class":"chartTooltip_row esriGERowHigh",innerHTML:b.colorOfBackWillDependOnValue},m);a.conditionalStyling&&g.place(G.createLegendNode(a.conditionalStyling,"chart",a.value),m);var t=m.outerHTML;g.destroy(m);return t}})});