// 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/InterestingFacts","../../declare ./BaseWidget dojo/_base/lang dojo/on require dojo/dom-construct dojo/dom-attr dojo/dom-class dojo/query dojo/string dijit/Tooltip dojo/i18n!../../nls/jsapi ./dom ./utils ./formatVariable".split(" "),function(p,q,r,t,u,v,w,x,y,z,A,B,C,D,E){return p("esri.dijit.geoenrichment.InterestingFacts",[q],{_chartNode:null,_varNode:null,_table:null,_selectedFact:0,_lastSelectedTag:null,_updateTable:function(){var d=this.metadata.name,c=(this._selectedFact+
1).toString(),h="FACT"+c+"VALUE";d3.select(this._varNode).text(this.getValueByName(0,"FACT"+c+"ALIAS"));var c=this.data.features,k=-Infinity,l=Infinity,f,m;c.forEach(function(a){var b=a.attributes[h];b<l&&(l=b,f=a);b>k&&(k=b,m=a)});var n=d3.scale.linear().domain([0,1.4*k]).nice().range([0,100]),g=[{width:"50%",cl:"OneVarMultiComparison_TextColumn"},{width:"20%",cl:"OneVarMultiComparison_ValueColumn"},{cl:"OneVarMultiComparison_ChartColumn"}],c=d3.select(this._table).selectAll("tr").data(c);c.enter().append("tr").classed("OneVarMultiComparison_Row",
!0).classed("AlternatingRow",function(a,b){return 1===b%2});c.exit().remove();c=c.selectAll("td").data(function(a){var b=a.attributes;return[{v:b[d],f:a},{v:b[h],f:a},{v:b[h],f:a}]});c.enter().append("td");c.each(function(a,b){var e=d3.select(this);g[b].width&&(e=e.style("width",g[b].width));e=e.classed(g[b].cl,!0);2>b?e.text(a.v):(e=e.selectAll("div").data([1]),e.enter().append("div").style("height","9px"),e.transition().style("background-color",function(){return a.f===f?"#43D3FF":a.f===m?"#66F45B":
"#b5b5b5"}).style("width",n(a.v)+"%"))})},updateUIExpanded:function(){var d=this;d.inherited(arguments);d._updateTable();var c=d._chartNode;c.innerHTML="";for(var h=c.clientWidth,k=c.clientHeight,l=Number.NEGATIVE_INFINITY,f=Number.POSITIVE_INFINITY,m=[],n=0;30>n;n++){var g="FACT"+(n+1).toString();if(!d.getValueByName(0,g+"ALIAS"))break;var a=d.getValueByName(0,g+"DIFF"),b;0<a?b="#66F45B":(a=-a,b="#43D3FF");a>l&&(l=a);a<f&&(f=a);m.push({text:d.getValueByName(0,g+"TAG"),absDiff:a,color:b})}d3.layout.cloud().size([h,
k]).words(m.map(function(a,b){a.size=Math.ceil(8+30*(a.absDiff-f)/(l-f));a.tagIndex=b;return a})).padding(5).rotate(function(){return 0}).font("Verdana").fontSize(function(a){return a.size}).on("end",function(a){function b(a){d._selectedFact=a;e.classed("selected",function(b){return b.tagIndex===a})}var e=d3.select(c).selectAll("div").data(a).enter().append("div").style("font-size",function(a){return a.size+"px"}).style("color",function(a){return a.color}).style("left",function(a){return a.x+a.x0+
h/2+"px"}).style("top",function(a){return a.y+a.y0+k/2+"px"}).style("margin",function(a){return a.padding+"px"}).text(function(a){return a.text}).on("click",function(a){b(a.tagIndex);d._updateTable()});b(0)}).start()},createUIExpanded:function(d){this.inherited(arguments);this._chartNode=d.addContent("div",{"class":"InterestingFacts_Chart"});this._varNode=d.addFooter("div",{"class":"OneVarMultiComparison_TextColumnHeader"});this._table=d.addFooter("table",{"class":"OneVarMultiComparison_Table"})}})});