"use strict";var efsaPesticideDatavizConfig={colors:["#31b7d2","#71c17c","#e7799e","#f8c25e","#8a428c","#acc25d","#7a7c7f"],donut:{color_1:"#00a690",color_2:"#4cc4a9",color_3:"#de4a7a"},gray:"#a8a8a8",all_foods:"#85746c"},mobile=q.mobilecheck(),RESIZE_TOLERANCE=70;function efsaPesticideDataviz(t){var e=!1,a=["en","it","fr","de"],r=function(){var t=window.location.search;if(t&&(t=t.split("?")).length&&(t=t[1]))for(var e in t=t.split("&")){var r=t[e].split("=");if("lang"===r[0])return r[1]}var i=window.location.href;for(var e in a){var n=a[e];if(i.indexOf("/"+n+"/")>0)return n}return null}()||t.lang||navigator.language&&navigator.language.split("-")[0]||"en";a.indexOf(r)<0&&(r="en"),window.efsaPesticideDatavizLang=r;var i=t.time||(mobile?200:320),n=t.donut.color_1||"#30807c",s=t.donut.color_2||"#4cbf85",c=t.donut.color_3||"#c34a2d",o=t.colors||["#00aac0","#7baa52","#f27f89","#e8b469","#8e3392","#98935c","#7a7c7f"],l=t.gray||"#a8a8a8",d="#00626d",p="white",f=i18n(r);q.fastclick();var u,x,y,m,h,v,g,b,w,k,A,z,T,C,P,L,B,O,D=q.speedtest(),E=q.ceil(D/10),M=1,U=2,F=3,R=null,W=d3.select("#efsa-pesticide-dataviz-svg"),N=W.node().clientWidth||parseInt(window.getComputedStyle(W.node()).width),S=W.node().clientHeight||parseInt(window.getComputedStyle(W.node()).height);W.attr("viewBox","0 0 "+N+" "+S),W.selectAll("*").remove();var I,Q=q.round(N/18.776),Z=0,H=31,j=q.round(S/H),X=mobile?1:2,Y=q.round(N/4.8),J=null,V=!1,G=!1,K=-1,$=-1,tt=!1,et=!1,at=!1,rt=!1,it=!1,nt=0,st=-1,ct=null,ot=!1,lt=S/3.85-j,dt=.15,pt=null,ft=S/3.75;N>1500&&(ft+=20);var ut=null,xt=.25,yt="#a0a0a0",mt=!1,ht=0,vt=["Domestic","EU","TC","UN"],gt=Math.min(q.round(S/45),q.round(N/70));gt<6&&(gt=6);var bt=q.round(.8*gt);gt>16.5&&(gt=16.5),bt>13&&(bt=13);var _t=navigator.userAgent.indexOf("Trident")>-1,wt=navigator.userAgent.indexOf("Firefox")>-1,kt=navigator.userAgent.indexOf("Safari")>-1&&navigator.userAgent.indexOf("Chrome")<0,qt=q.getDecimalSeparator(r),At="."===qt?",":".",zt=[],Tt=[],Ct=[];function Pt(t,e){d3.request(t).mimeType("text/plain").response(function(t){return d3.dsvFormat(";").parse(t.responseText)}).get(function(t){e(t)})}function Lt(){j=q.round(S/H),R=null,d3.select("#efsa-pesticide-loading").style("display","block").style("background-color","rgba(245,245,245,.5)"),Pt("//www.efsa.europa.eu/sites/default/files/interactive_tools/pesticides_2017/data/food.csv",function(t){var e=[],a=[],r=[],i={},n=0;_.each(t,function(t){var s=t.Category,c=t.SubCategory,o=+t.Samples;e.push({name:s,subcategory:null}),a[s]=a[s]?a[s]:[],a[s].indexOf(c)<0&&a[s].push(c),i["cat-"+s]=i["cat-"+s]?i["cat-"+s]:0,i["subcat-"+c]=i["subcat-"+c]?i["subcat-"+c]:0,i["cat-"+s]+=o,i["subcat-"+c]+=o,r.push({name:t.Food,subcategory:c,category:s,value:o,value_below_loq_as_samples:t["Below LOQ"],value_below_mrl_as_samples:t["Below MRL"],value_above_mrl_as_samples:t["Above MRL"],value_below_loq:t["% Below LOQ"],value_below_mrl:t["% Below MRL"],value_above_mrl:t["% Above MRL"]}),c.length>n&&(n=c.length)}),Y=n*bt/1.7,Y=Math.max(Z+30,Y),Ot(e=_.uniq(_.map(e,function(t){return t.name})),a,r,i,"food")})}function Bt(){var t;R=null,j=q.round(S/H),j*=1.3,d3.select("#efsa-pesticide-loading").style("display","block").style("background-color","rgba(245,245,245,.5)"),t=function(t){var e,a=[],r=[],i={},n=[],s={};_.each(t,function(t){var e=t.country;n[e]||(n[e]={name:e,countrycode:t.code,inhabitants:t.inhabitants,samples:0}),n[e].samples+=+t.samples,s[t.country]=s[t.country]?s[t.country]:[],s[t.country].push({country:t.refcountry,type:t.type,samples:+t.samples})}),e=["countries"],a.countries=[];var c=0;for(var o in n){var l=n[o],d=l.name,p=+l.samples;a.countries.push(d),r.push({name:d,countrycode:l.countrycode,subcategory:d,category:"countries",value:p,value_below_loq:zt[d].value_below_loq,value_below_mrl:zt[d].value_below_mrl,value_above_mrl:zt[d].value_above_mrl,samples:p,inhabitants:+l.inhabitants}),d.length>c&&(c=d.length),i["cat-countries"]=i["cat-countries"]?i["cat-countries"]:0,i["subcat-"+d]=i["subcat-"+d]?i["subcat-"+d]:0,i["cat-countries"]+=p,i["subcat-"+d]+=p,i["subcat-"+d+"-inhabitants"]=+l.inhabitants}Y=c*bt/2+30,Y=Math.max(Z+30,Y),i.composition=s,Ot(e,a,r,i,"country")},Pt("//www.efsa.europa.eu/sites/default/files/interactive_tools/pesticides_2017/data/results-by-country.csv",function(e){for(var a in e){var r=e[a];r.name&&(zt[r.name]={value_below_loq:+r["%below LOQ"],value_below_mrl:+r["%betweenLOQ_MRL"],value_above_mrl:+r["%aboveLOQ"]})}Pt("//www.efsa.europa.eu/sites/default/files/interactive_tools/pesticides_2017/data/results-by-origin.csv",function(e){for(var a in e){var r=e[a];r.name&&(Tt[r.name]={value_below_loq:+r["%belowLOQ"],value_below_mrl:+r["%betweenLOQ_MRL"],value_above_mrl:+r["%aboveLOQ"]})}Pt("//www.efsa.europa.eu/sites/default/files/interactive_tools/pesticides_2017/data/origin-of-sample.csv",function(e){for(var a in e){var r=e[a];r.name&&(Ct[r.name]={dom:+r.dom,eu:+r.eu,tc:+r.tc,un:+r.un})}Pt("//www.efsa.europa.eu/sites/default/files/interactive_tools/pesticides_2017/data/country.csv",t)})})})}function Ot(a,r,D,H,Ct){var Pt=0;_.each(D,function(t,e){Pt=Math.max(Pt,t.value)}),pt="food"===Ct?90:110,ut="food"===Ct?6:1,W.selectAll("*").remove(),b=W.append("g").attr("opacity","0"),w=W.append("g").style("display","none"),k=W.append("g").style("display","none"),A=W.append("g"),z=W.append("g"),T=W.append("g"),C=k.append("g"),P=k.append("g"),L=k.append("g").style("display","none"),B=k.append("g").style("display","none"),O=k.append("g").style("display","none"),ve(!1),_.each(a,function(t,e){o[t]=o[e]});var Lt=function(t){return o[t]},Bt=new Array(ut),Ot=[],Et=[],Mt=0;function Ut(t){q.d3stopPropagation(),V||et||(mobile&&d3.selectAll(".efsa-pesticide-subtab").transition().duration(i/5).attr("fill",function(t,e){return e===st?d3.select(this).attr("fill-default"):d3.select(this).attr("fill-brighter")}),ot=!1,b.attr("opacity","1"),E<2&&!mobile?(u.style("cursor",function(e){return e.category===t?"pointer":"default"}).transition().duration(i).attr("opacity",function(e){return e.category===t?1:dt}),setTimeout(function(){ot=!0},i)):(u.attr("opacity",function(e){return e.category===t?1:dt}).style("cursor",function(e){return e.category===t?"pointer":"default"}),ot=!0))}function Ft(t){st!==t&&d3.select(this).transition().duration(i/5).attr("fill",d3.select(this).attr("fill-brighter"))}function Rt(t){q.d3stopPropagation(),V||(this&&this!==window&&(mobile&&d3.selectAll(".efsa-pesticide-subtab").transition().duration(i/5).attr("fill",function(t,e){return e===st?d3.select(this).attr("fill-default"):d3.select(this).attr("fill-brighter")}),d3.select(this).transition().duration(i/5).attr("fill",d3.select(this).attr("fill-default"))),et||(ot=!1,b.attr("opacity","1"),E<2&&!mobile?(u.style("cursor",function(e){return e.subcategory===t?"pointer":"default"}).transition().duration(i/3).attr("opacity",function(e){return e.subcategory===t?1:dt}),setTimeout(function(){ot=!0},i)):(u.attr("opacity",function(e){return e.subcategory===t?1:dt}).style("cursor",function(e){return e.subcategory===t?"pointer":"default"}),ot=!0)))}function Wt(){u.attr("opacity","1"),b.attr("opacity","1")}function Nt(t){t.style("display","block")}function St(t){t.style("display","none")}function It(t,e,a){if(q.d3stopPropagation(),I=null,Et&&0!==Et.length&&-1!==$){tt=!0,$=-1;var r=u;r.attr("stroke-width",0).attr("fill",function(t,e){return d3.select(this).attr("fill-val")}),"country"===Ct&&r.attr("stroke-width",xt).attr("stroke",yt);var n=0;r.transition().duration(.7*i).ease(q.qeaseElastic).attr("cx",function(t,e){return n++,Et[e].x}).attr("cy",function(t,e){return Et[e].y}).attr("r",function(t,e){return d3.select(this).attr("r-val")}).on("end",function(){if(!--n){for(var t=0;te&&(i.pop(),l.text(i.join(" ")),i=[d],l=t.append("tspan").attr("x",s).attr("y",c).attr("dy",1*++n+o+"em").text(d),a++),d=r.pop()}),a}(y,2*(pt-pt/4));jt=i;var n=-y._groups[0][0].getBBox().height;"country"===Ct?n/=2:n-=i>2?bt/2:i>1?bt:2*bt;var s=G?-N/5:0;q.d3attr(y,{transform:"translate("+s+","+n+")"}),"food"===Ct&&(q.d3attr(m,{transform:"translate("+s+","+(pt-pt/1.8)+")"}),q.d3attr(h,{transform:"translate("+s+","+(pt-pt/1.8)+")"}))}(o.x,o.y,n,s),function(t,e,a,r,i){"food"===Ct?(ae(v,ht,r,"",0,4,function(){-1===$&&v.text("")}),ht=+r,g.text(i),e+=gt,q.d3attr(v,{fill:a,x:t,y:e}),q.d3attr(g,{fill:a,x:t,y:e+gt})):(v.empty(),q.d3attr(v,{fill:a,x:t,y:e}));var n=G?-N/5:0,e=0;1===jt?e=-bt:2===jt&&(e=-bt/2);q.d3attr(v,{transform:"translate("+n+","+e+")"}),q.d3attr(g,{transform:"translate("+n+","+e+")"})}(o.x,o.y,n,c,f.global.samples))},"food"===Ct?i/2:0)}}function Ht(){Nt(k),Nt(x)}_.each(D,function(t,e){var r,i=Pt;if("food"===Ct)r=10+40/i*t.value;else{var n=1e3+3e4/i*t.value;r=Math.sqrt(n/Math.PI)}var s=a.indexOf(t.category),c=0,d=0;R&&(c=R[e].x,d=R[e].y);var p={cluster:s,radius:r,inhabitants:+t.inhabitants,samples:+t.value,value:+t.value,value_below_loq:t.value_below_loq,value_below_mrl:t.value_below_mrl,value_above_mrl:t.value_above_mrl,countrycode:t.countrycode,food:t.name,subcategory:t.subcategory,category:t.category,color:"food"===Ct?o[s]:l,x:c,y:d};Ot.push(p),Mt++,(!Bt[s]||r>Bt[s].radius)&&(Bt[s]=p)}),et=!1,st=null,ct=null,G=!1,J=null;var jt=0;function Xt(t){if(!V){q.d3stopPropagation();var e=a.indexOf(t);if(null!==J)return J===e?void 0:void Yt();Vt(),Jt(!1),_e(!1),Gt(e),ge(function(){Ut(t)})}}function Yt(){null!==J&&(d3.selectAll(".efsa-pesticide-tab-title").transition().duration(i/2).attr("transform","translate("+-(Y-(Z+30))+",0)"),d3.select("#efsa-pesticide-subtabs-group-"+J).transition().duration(i/3).attr("transform","translate("+-Y+", 0)"),St(d3.selectAll(".efsa-pesticide-tab-text")),J=null)}function Jt(t){x.attr("pointer-events","none"),t?x.transition().duration(i).attr("stroke-width",0).attr("r",10).on("end",function(){St(x)}):St(x)}function Vt(){y.text(""),v.text(""),g.text(""),"food"===Ct&&(m.style("display","none"),h.style("display","none"))}function Gt(t){var e;J=t,e=t,d3.select("#efsa-pesticide-subtabs-group-"+e).transition().duration(i/3).attr("transform","translate(0, 0)"),ot=!1,setTimeout(function(){d3.select(d3.selectAll(".efsa-pesticide-tab-title")._groups[0][t]).transition().duration(i).attr("transform","translate(0, 0)").on("end",function(){setTimeout(function(){ot=!0},2*i)})},10)}var Kt,$t=-1;function te(t,e,a,r,i){$t=i,T.style("display","block"),d3.select("#efsa-pesticide-tooltip-text").text(a);var n=Math.ceil(d3.select("#efsa-pesticide-tooltip-text").node().getBBox().width);d3.select("#efsa-pesticide-tooltip-text").text("");var s=50+n;d3.select("#efsa-pesticide-tooltip").attr("d",function(t,e,a,r,i){return"M"+t+" "+e+" L"+t+" "+(e-r-i)+" L"+(t-a)+" "+(e-r-i)+" L"+(t-a)+" "+(e-i)+"L "+(t-i/2)+" "+(e-i)+" Z"}(t,e,s,26,14)).attr("width",s).style("stroke",r),d3.select("#efsa-pesticide-tooltip-text").attr("x",t-s/2).attr("y",e-14-26/3).text(a)}function ee(t){setTimeout(function(){$t!==t&&-999!==t||T.style("display","none")},100)}function ae(t,e,a,r,i,n,s){mobile&&(n/=2);var c=0,o=setInterval(function(){(e=q.round((e+a)/2))<100?(l=(l=(l=e.toFixed(i)).replace(".",qt)).replace(",",qt),t.text(l+r)):t.text(q.numberWithCommas(e.toFixed(i),At)+r);if(++c>n){var l;if(clearInterval(o),a<100)l=(l=(l=a.toFixed(i)).replace(".",qt)).replace(",",qt),t.text(l+r);else t.text(q.numberWithCommas(a.toFixed(i),At)+r);s&&s()}},40)}function re(t,e,n,s,c,o,l,d,p){ee(-1);var y=!et;et=!0,x.attr("pointer-events","inherit"),u.style("cursor","default"),q.d3stopPropagation(),q.d3attr(x,{transform:"translate(0,0)"}),x.attr("stroke",t),t&&d3.selectAll(".efsa-pesticide-expanded-circle-rect").attr("fill",t),Vt(),setTimeout(function(){"food"===Ct?(Nt(L),Nt(P)):"country"===Ct&&Nt(O),Vt()},i);var m=a.indexOf(e),h=-1;n&&""!==n&&(h=r[e].indexOf(n)),st=n||e,ct=p,"food"===Ct&&Gt(m),d3.selectAll(".efsa-pesticide-subtab-"+m).attr("transform","translate(0,0)"),d3.selectAll(".efsa-pesticide-subtab-space-"+m).attr("transform","translate(0,0)"),d3.selectAll(".efsa-pesticide-subtab-text-"+m).attr("transform","translate(0,0)");var v=null;(v=h>-1&&m<4?d3.select("#efsa-pesticide-subtabs-group-"+m).selectAll(".efsa-pesticide-subtab-rect")._groups.length?d3.select("#efsa-pesticide-subtabs-group-"+m).selectAll(".efsa-pesticide-subtab-rect")._groups[0][h]:d3.selectAll(".efsa-pesticide-tab-title")._groups[0][h]:(d3.selectAll(".efsa-pesticide-tab-title")._groups.length,d3.selectAll(".efsa-pesticide-tab-title")._groups[0][m]))&&(mobile?d3.selectAll(".efsa-pesticide-subtab").attr("fill",function(t,e){return d3.select(this).attr("fill-brighter")}):d3.selectAll(".efsa-pesticide-subtab").transition().duration(i/5).attr("fill",function(t,e){return d3.select(this).attr("fill-brighter")}),h>-1&&(mobile?d3.select(v).attr("fill",d3.select(v).attr("fill-default")):d3.select(v).transition().duration(i/5).attr("fill",d3.select(v).attr("fill-default")))),"food"===Ct?setTimeout(function(){y&&d3.selectAll(".efsa-pesticide-expanded-circle-rect-text").attr("x",0),function(t,e,a,r){var n=[],s=d3.select("#efsa-pesticide-expanded-circle-rect-text-1"),c=s.text();u.attr("opacity",dt),d3.selectAll(".efsa-pesticide-expanded-circle-rect-text").style("display","block").attr("text-anchor","end").text(function(a,i){if(0===i)return t;if(1===i)return q.numberWithCommas(e,At)+" "+f.global.samples;if(2===i){if(r===F)return f.global.all_products;if(r===U)return f.global.back_to_subcategory;if(r===M)return f.global.back_to_category}return 3===i?"":void 0}).transition().duration(i).delay(function(t,e){return e*i}).attr("x",function(t,e){var a=d3.selectAll(".efsa-pesticide-expanded-circle-rect-text")._groups[0][e].getBBox().width+ft+ft/9*e;return n.push(a),+n[e]}),c=parseInt(c),isNaN(c)&&(c=0),ae(s,c,e," "+f.global.samples,0,4),a&&(a.attr("fill",a.attr("fill-default")),d3.selectAll(".efsa-pesticide-expanded-circle-rect").attr("fill",a.attr("fill-default")),x.attr("stroke",a.attr("fill-default"))),d3.select("#efsa-pesticide-expanded-circle-rect-3").attr("y",a.attr("y")-S/2).attr("x",-(N/2-Y+2)).attr("fill",a.attr("fill-default")).attr("width",0),d3.selectAll(".efsa-pesticide-expanded-circle-rect").attr("transform","translate(0,0)").style("display","block").style("cursor",function(t,e){return 2===e?"pointer":"default"}).transition().duration(i).delay(function(t,e){return 3===e?0:e*i}).attr("x",function(t,e){return 3===e?-(N/2-Y+2):0}).attr("width",function(t,e){return 3===e?N/2-(Y+Q/2)+2:+n[e]+10}).on("end",function(t,e){"food"===Ct&&0===e&&(k.select("#efsa-pesticide-expanded-circle-rect-close-food-name").remove(),k.append("rect").attr("id","efsa-pesticide-expanded-circle-rect-close-food-name").attr("x",+d3.select("#efsa-pesticide-expanded-circle-rect-0").attr("width")+2).attr("y",ft/10-ft).attr("width",j).attr("height",j).attr("fill",a.attr("fill-default")).attr("cursor","pointer").on("click",function(){pe(),k.select("#efsa-pesticide-expanded-circle-rect-close-food-name").remove(),k.select("#efsa-pesticide-expanded-circle-rect-close-food-name-text").remove()}).on("mouseover",function(){d3.select("#efsa-pesticide-expanded-circle-rect-close-food-name-text").style("text-decoration","underline")}).on("mouseout",function(){d3.select("#efsa-pesticide-expanded-circle-rect-close-food-name-text").style("text-decoration","none")}),k.select("#efsa-pesticide-expanded-circle-rect-close-food-name-text").remove(),k.append("text").attr("id","efsa-pesticide-expanded-circle-rect-close-food-name-text").attr("x",+d3.select("#efsa-pesticide-expanded-circle-rect-0").attr("width")+2+j/2).attr("y",ft/10-ft+2+j/2+bt/2.5).attr("text-anchor","middle").attr("fill","white").style("font-size",1.25*gt+"px").text("x"))}),r===F?(St(d3.select("#efsa-pesticide-expanded-circle-rect-2")),St(d3.select("#efsa-pesticide-expanded-circle-rect-text-2"))):(Nt(d3.select("#efsa-pesticide-expanded-circle-rect-2")),Nt(d3.select("#efsa-pesticide-expanded-circle-rect-text-2"))),setTimeout(function(){r===U?(d3.select("#efsa-pesticide-expanded-circle-rect-icon-sub-category").attr("xlink:href","/sites/default/files/interactive_tools/pesticides_2017/assets/sub-category.png"),d3.select("#efsa-pesticide-expanded-circle-rect-icon-sub-category").style("display","block")):r===M&&(d3.select("#efsa-pesticide-expanded-circle-rect-icon-sub-category").attr("xlink:href","/sites/default/files/interactive_tools/pesticides_2017/assets/category.png"),d3.select("#efsa-pesticide-expanded-circle-rect-icon-sub-category").style("display","block"))},2.5*i)}(f.foods[s],c,d3.select(v),p)},y&&"food"===Ct?i:0):"country"===Ct&&setTimeout(function(){!function(t,e,a){d3.selectAll(".efsa-pesticide-expanded-circle-text-for-country").text(function(r,i){if(0===i)return f.countries[t].toUpperCase();if(1===i)return q.numberWithCommas(e,At);if(2===i)return f.global.samples.toUpperCase();if(3===i){var n=e/(a/1e5),s=n.toFixed(1),c=(s=(s=s.replace(",","x")).replace(".","x")).split("x")[1];return s=(s=(s=q.numberWithCommas(q.floor(n),At)).replace(",",At)).replace(".",At),s+=qt+c}return 4===i?f.global.samples_100000.toUpperCase():5===i?f.global.inhabitants.toUpperCase():""}),ae(d3.select(d3.selectAll(".efsa-pesticide-expanded-circle-text-for-country")._groups[0][1]),0,e,"",0,4),ae(d3.select(d3.selectAll(".efsa-pesticide-expanded-circle-text-for-country")._groups[0][3]),0,e/(a/1e5),"",1,4);var r=[];d3.selectAll(".efsa-pesticide-expanded-circle-rect-text").attr("transform","translate(0,0)").style("display",function(t,e){return e>0&&e<3?"block":"none"}).style("font-weight","300").text(function(e,a){if(0===a){if("food"===Ct)return t.toUpperCase();if("country"===Ct)return f.countries[t].toUpperCase()}return 1===a?f.global.overall_results:2===a?f.global.origin_of_samples:3===a?"":void 0}).attr("x",0).transition().duration(i).delay(function(t,e){return i+e*i/4}).attr("x",function(t,e){d3.selectAll(".efsa-pesticide-expanded-circle-rect-text").style("display","block");var a=+d3.selectAll(".efsa-pesticide-expanded-circle-rect-text")._groups[0][e].getBBox().width+ft+ft/9*e;return"country"===Ct&&0===e&&(a-=ft/9),r.push(a),0===e?-a:ft+ft/9*e}),d3.selectAll(".efsa-pesticide-expanded-circle-rect").attr("transform","translate(0,0)").style("display",function(t,e){return e>=0&&e<3?"block":"none"}).style("cursor",function(t,e){return e>0&&e<3?"pointer":"default"}).attr("x",function(t,e){return 0}).transition().duration(i).delay(function(t,e){return e*i/4}).attr("x",function(t,e){return 0===e?-r[e]-10:0}).attr("width",function(t,e){return+r[e]+10}).on("end",function(t,e){"country"===Ct&&0===e&&(k.select("#efsa-pesticide-expanded-circle-rect-close-all").remove(),k.append("rect").attr("id","efsa-pesticide-expanded-circle-rect-close-all").attr("x",-d3.select("#efsa-pesticide-expanded-circle-rect-0").attr("width")-j-2).attr("y",ft/10-ft).attr("width",j).attr("height",j).attr("fill","#a8a8a8").attr("cursor","pointer").on("click",function(){pe()}).on("mouseover",function(){d3.select("#efsa-pesticide-expanded-circle-rect-close-all-text").style("text-decoration","underline")}).on("mouseout",function(){d3.select("#efsa-pesticide-expanded-circle-rect-close-all-text").style("text-decoration","none")}),k.select("#efsa-pesticide-expanded-circle-rect-close-all-text").remove(),k.append("text").attr("id","efsa-pesticide-expanded-circle-rect-close-all-text").attr("x",-d3.select("#efsa-pesticide-expanded-circle-rect-0").attr("width")-j-2+j/2).attr("y",ft/10-ft+j/2+bt/2.5).attr("text-anchor","middle").attr("fill","white").style("font-size",1.25*gt+"px").text("x"))}),setTimeout(function(){d3.select("#efsa-pesticide-expanded-circle-rect-icon-pie-chart").attr("transform","translate(0,0)").style("display","block"),d3.select("#efsa-pesticide-expanded-circle-rect-icon-map-marker").attr("transform","translate(0,0)").style("display","block")},2*i)}(s,c[0],c[1])},y?i:0),Nt(k),Nt(x),x.attr("cx",0).attr("cy",0),"food"===Ct?de(o,l,d):x.attr("stroke-width",ft/10).transition().duration(i).attr("r",ft)}function ie(t,e,a,n,s){d3.selectAll(".efsa-pesticide-expanded-circle-pie").selectAll("*").remove();var c=it?0:i;it=!0,x.attr("stroke-width",ft/10).transition().duration(c).attr("r",ft).on("end",function(){var o=["#e8e8e8","#e8e8e8","#e8e8e8","#e8e8e8","#3186d3","#dd6c31","#ac56c1","#33b53c"],l=["#e8e8e8","#e8e8e8","#e8e8e8","#e8e8e8","#1166b3","#bd4c11","#8c36a1","#13951c"],d=[t,e,a,n],p=t+e+a+n,u=1/p*d[0],x=1/p*d[1],y=1/p*d[2],m=1/p*d[3],h=" "+(100*u).toFixed(1).replace(".",qt).replace(",",qt)+"%",v=" "+(100*x).toFixed(1).replace(".",qt).replace(",",qt)+"%",g=" "+(100*y).toFixed(1).replace(".",qt).replace(",",qt)+"%",b=" "+(100*m).toFixed(1).replace(".",qt).replace(",",qt)+"%",_=[f.composition_chart.domestic_samples+h,f.composition_chart.eea_countries+v,f.composition_chart.third_countries+g,f.composition_chart.unknown_origin+b],w=c;d=d.sort(function(t,e){return t>e?-1:t3&&(ee(-1),4==e?ga("send","event",{eventCategory:"Pesticides origin chart",eventAction:"EEA",eventLabel:"EEA"}):5==e?ga("send","event",{eventCategory:"Pesticides origin chart",eventAction:"Domestic",eventLabel:"Domestic"}):6==e?ga("send","event",{eventCategory:"Pesticides origin chart",eventAction:"Third Countries",eventLabel:"Third Countries"}):7==e&&ga("send","event",{eventCategory:"Pesticides origin chart",eventAction:"Unknown origin",eventLabel:"Unknown origin"}),se(s,r,!1,!0,0,[vt[e-4]]))})});var A=mobile?70:80;d3.select(".efsa-pesticide-expanded-circle-pie").append("image").attr("xlink:href","/sites/default/files/interactive_tools/pesticides_2017/assets/pie-chart-icon.png").style("cursor","pointer").attr("x",-A/2).attr("y",-A/2).attr("width",A).attr("height",A).on("mouseover",function(){d3.select(this).attr("xlink:href","/sites/default/files/interactive_tools/pesticides_2017/assets/pie-chart-icon-over.png")}).on("mouseout",function(){d3.select(this).attr("xlink:href","/sites/default/files/interactive_tools/pesticides_2017/assets/pie-chart-icon.png")}).on("click",function(t,e){q.d3stopPropagation(),ee(-1),ga("send","event",{eventCategory:"Pesticides origin chart",eventAction:"All",eventLabel:"All"}),se(s,r,!1,!0,0,null)})})}function ne(t){var e=d3.select(".efsa-composition-chart-legend-item-"+t+"-text").classed("efsa-pesticide-composition-chart-filter-inactive");d3.select(".efsa-composition-chart-legend-item-"+t+"-text").classed("efsa-pesticide-composition-chart-filter-inactive",!e)}function se(t,e,a,r,n,s){var c=r?i:0;(et||at)&&fe(),St(b),St(L),St(P);var o=vt,l=[f.composition_chart.domestic_samples,f.composition_chart.eea_countries,f.composition_chart.third_countries,f.composition_chart.unknown_origin],d=[];if(s)d=s;else for(var p=0;p<4;p++){var u=d3.select(".efsa-composition-chart-legend-item-"+p+"-text");u.node()&&u.classed("efsa-pesticide-composition-chart-filter-inactive")||d.push(o[p])}w.empty(),w.html(""),w.node().innerHTML="",w.selectAll("*").remove(),w.style("opacity","1"),w.append("rect").attr("x",0).attr("y",0).attr("width",N).attr("height",S).attr("fill","#f4f4f4"),w.append("rect").attr("x",N-70).attr("y",0).attr("width",50).attr("height",50).attr("fill","#f4f4f4").on("click",function(){qe()}),w.append("text").style("pointer-events","auto").style("cursor","pointer").attr("x",N-45).attr("y",4.6*gt).text("x").attr("font-size","36px").on("mouseover",function(){d3.select(this).style("text-decoration","underline")}).on("mouseout",function(){d3.select(this).style("text-decoration","none")}).on("click",function(){qe()});var y,m={Domestic:{normal:"#0b4e99",brighter:"#61a1db"},EU:{normal:"#dd6c31",brighter:"#e28e61"},TC:{normal:"#ac56c1",brighter:"#be7dcd"},UN:{normal:"#33b53c",brighter:"#63c46a"}};if(a)for(var h in y=[],H.composition){var v=H.composition[h];for(var g in v)v[g].country===t&&y.push({country:h,type:v[g].type,samples:v[g].samples})}else y=H.composition[t];var _=0;for(var A in y)_+=y[A].samples;y=y.filter(function(t){return d.indexOf(t.type)>-1});var z=0,T=0;for(var A in y)z=Math.max(z,y[A].samples),T+=y[A].samples;y=y.sort(function(t,e){return(t=Dt(f.countries[t.country]))<(e=Dt(f.countries[e.country]))?-1:t>e?1:0});var C=N/3.8,D=N/100,E=N/100,M=S/35,U=N/10,F=22;N<1111&&(F=10,M*=1.75);var R=6*M,W=d3.scaleLinear().domain([0,z]).range([0,C]),I=N-U-C-E;w.append("text").attr("x",N/2).attr("y",2*gt).attr("text-anchor","middle").attr("fill","#202020").attr("font-size",gt).attr("font-weight","400").text(f.composition_chart.title);var Q=N/70;for(p=0;p<4;p++)!function(r){var i=d.indexOf(o[r])<0?" efsa-pesticide-composition-chart-filter-inactive ":"",n=N/6*(r+1)+Q/2,s=m[o[r]].normal,c=n+Q,p=3.5*gt,f=p+N/70;if(N<1025&&(c+=2,f+=2),N<800&&(n-=3,p-=3),w.append("rect").attr("x",n).attr("width",c-n).attr("y",p).attr("height",f-p).attr("fill","transparent").style("cursor","pointer").on("click",function(){ne(r),setTimeout(function(){se(t,e,a,!0,0,null)},50)}).on("mouseover",function(){d3.selectAll(".efsa-composition-chart-legend-item-"+r+"-close").attr("opacity",.5)}).on("mouseout",function(){d3.selectAll(".efsa-composition-chart-legend-item-"+r+"-close").attr("opacity",1)}),w.append("text").attr("class","efsa-composition-chart-legend-item efsa-composition-chart-legend-item-"+r+"-text efsa-composition-chart-legend-item-"+r+i).attr("x",n+Q+5).attr("y",3.6*gt+Q-bt/2+(mobile?3:0)).attr("font-weight","400").attr("font-size",N<800?"10px":N<1025?"13px":"15px").attr("fill",s).text(l[r]),i){g="M"+(n+=u=2)+","+(p+=u)+" L"+(c-=u)+","+p+" L"+c+","+(f-=u)+" L"+n+","+f+" Z"}else{var u,x=(n+=u=2)+((c-=u)-n)/2,y=(p+=u)+((f-=u)-p)/2;g="M"+n+","+p+" L"+c+","+p+" L"+c+","+f+" L"+n+","+f+" Z M"+(x-3)+","+y+" L"+(x-1)+","+(y+3)+" L"+(x+4)+","+(y-3)}w.append("path").attr("class","efsa-composition-chart-legend-item efsa-composition-chart-legend-item-"+r+"-close efsa-composition-chart-legend-item-"+r).attr("d",g).attr("stroke",s).attr("fill","transparent").attr("stroke-width","2px").style("pointer-events","none")}(p);var Z=R-2*M;w.append("rect").attr("x",D).attr("y",Z).attr("width",N/2-D-1).attr("height",1.5*M).attr("fill","#dbdbdb"),w.append("rect").attr("x",N/2+1).attr("y",Z).attr("width",N/2-E-1).attr("height",1.5*M).attr("fill","#dbdbdb"),w.append("text").attr("x",D+15).attr("y",Z+1.5*gt).attr("fill","#202020").style("font-size",gt+"px").attr("font-weight","400").text(f.composition_chart.origin),w.append("text").attr("x",N-E-15).attr("y",Z+1.5*gt).attr("fill","#202020").text(f.composition_chart.analysing_countries).style("font-size",gt+"px").attr("font-weight","400").attr("text-anchor","end"),Nt(w);var Y=y.length50?nt.substr(0,48)+"..":nt)+" ("+q.numberWithCommas(y[p].samples,At)+")"),w.append("rect").attr("x",G).attr("width",K).attr("y",$).attr("height",tt).style("pointer-events","none").attr("fill",m[y[p].type].normal).attr("opacity",0).transition().delay(r?20*p:0).duration(c).attr("opacity",1);g=a?"M"+V+","+$+" L"+(U+C+D)+","+(tt/2+R)+" L"+V+","+($+tt)+" Z":"M"+(G+K)+","+$+" L"+I+","+(tt/2+R)+" L"+(G+K)+","+($+tt)+" Z";w.append("path").attr("d",g).attr("fill",m[y[p].type].brighter).attr("opacity",0).transition().delay(r?20*p:0).duration(c).attr("opacity",1)}n0&&w.append("image").attr("xlink:href","/sites/default/files/interactive_tools/pesticides_2017/assets/menu arrow up b.png").attr("x",a?N-J/1.5+25:J/1.5+25).attr("y",S-1.5*M).attr("height",M/1.3).attr("width",M/1.3).style("cursor","pointer").on("click",function(){q.d3stopPropagation(),se(t,e,a,!1,n-1,null)}),w.on("mousewheel",null),w.on("wheel",null);var st,ct=y.length-F+1,ot=kt?"mousewheel":"wheel";if(function(t,e,a,r,i){w.on(ot,function(n,s){var c=d3.event.wheelDelta||d3.event.deltaY;(wt||_t)&&(c=-c),c<0&&r0&&r>0&&se(t,e,a,!1,r-1,null)})}(t,e,a,n,ct),w.append("rect").attr("x",a?E:I).attr("width",U+C).attr("y",0+R).attr("height",M).attr("fill","#0b4e99"),w.append("text").attr("x",a?E+5:I+5).attr("y",0+1.3*bt+R).attr("fill","#ffffff").style("font-size",bt+"px").text(f.countries[t]?f.countries[t]+" ("+q.numberWithCommas(T,At)+")":t+" ("+q.numberWithCommas(T,At)+")"),w.append("image").attr("xlink:href","/sites/default/files/interactive_tools/pesticides_2017/assets/menu arrow down.png").attr("x",a?U+C-M/2-10:I+U+C-M/2-10).attr("y",0+R+M/2-M/4).attr("height",M/2).attr("width",M/2).style("cursor","pointer").on("click",function(){q.d3stopPropagation(),Nt(d3.selectAll(".composition-chart-dropdown-analysing"))}),w.append("image").attr("xlink:href","/sites/default/files/interactive_tools/pesticides_2017/assets/pie chart.png").attr("x",a?U+C-3*M/2-10:I+U+C-3*M/2-10).attr("y",0+R+M/2-M/4).attr("height",M/2).attr("width",M/2).style("cursor","pointer").on("click",function(){q.d3stopPropagation();var e=a?Tt[t].value_below_loq:zt[t].value_below_loq,r=a?Tt[t].value_below_mrl:zt[t].value_below_mrl,n=a?Tt[t].value_above_mrl:zt[t].value_above_mrl;!function(t,e,a,r,n,s,c){q.d3stopPropagation(),d3.selectAll(".efsa-pesticide-expanded-circle-text").style("display","none"),at=!0,Nt(d3.select("#composition-chart-cover")),Nt(x),Nt(k),St(O),St(B),Nt(L),Nt(P),x.attr("stroke-width",ft/10).transition().duration(i).attr("r",ft).on("end",function(){de(e,a,r);var n=f.countries[t];n=n||t,d3.select("#efsa-pesticide-expanded-circle-rect-text-0").style("display","block").text(f.global.all_countries),d3.select("#efsa-pesticide-expanded-circle-rect-text-1").style("display","block").text(n+" | "+q.numberWithCommas(c,At)+" "+f.global.samples).attr("transform","translate("+-ft/10+",0)"),d3.select("#efsa-pesticide-expanded-circle-rect-0").attr("x",0).attr("width",0).attr("transform","translate(0,0)").style("display","block").style("cursor","pointer"),d3.select("#efsa-pesticide-expanded-circle-rect-1").attr("x",0).attr("width",0).attr("transform","translate(0,0)").style("display","block").style("cursor","default"),d3.select("#efsa-pesticide-expanded-circle-rect-text-0").attr("x",0).attr("width",0).attr("transform","translate(0,0)").style("display","block"),d3.select("#efsa-pesticide-expanded-circle-rect-text-1").attr("x",0).attr("width",0).attr("transform","translate(0,0)").style("display","block");var o=d3.select("#efsa-pesticide-expanded-circle-rect-text-0")._groups[0][0].getBBox().width,l=d3.select("#efsa-pesticide-expanded-circle-rect-text-1")._groups[0][0].getBBox().width;if(s){var d=ft+ft/9+o,p=j+X+X;d3.select("#efsa-pesticide-expanded-circle-rect-0").attr("transform","translate(0,"+p+")"),d3.select("#efsa-pesticide-expanded-circle-rect-0").transition().duration(i).attr("width",d).attr("transform","translate(0,"+p+")"),d3.select("#efsa-pesticide-expanded-circle-rect-text-0").attr("transform","translate(0,"+p+")"),d3.select("#efsa-pesticide-expanded-circle-rect-text-0").transition().duration(i).attr("transform","translate("+(d-o-15)+","+p+")");var u=ft+ft/9+l;d3.select("#efsa-pesticide-expanded-circle-rect-1").transition().duration(i).attr("width",u).attr("transform","translate("+-u+",0)"),d3.select("#efsa-pesticide-expanded-circle-rect-text-1").transition().duration(i).attr("transform","translate("+-(u-15)+",0)")}else{var d=ft+ft/9+o,p=j+X+X;d3.select("#efsa-pesticide-expanded-circle-rect-0").attr("transform","translate(0,"+p+")"),d3.select("#efsa-pesticide-expanded-circle-rect-0").transition().duration(i).attr("width",d).attr("transform","translate("+-d+","+p+")"),d3.select("#efsa-pesticide-expanded-circle-rect-text-0").attr("transform","translate(0,"+p+")"),d3.select("#efsa-pesticide-expanded-circle-rect-text-0").transition().duration(i).attr("transform","translate("+-(d-15)+","+p+")");var u=ft+ft/9+l;d3.select("#efsa-pesticide-expanded-circle-rect-1").transition().duration(i).attr("width",u),d3.select("#efsa-pesticide-expanded-circle-rect-text-1").transition().duration(i).attr("transform","translate("+(u-l-15)+",0)")}k.select("#efsa-pesticide-expanded-circle-rect-close-composition-donut").remove(),k.select("#efsa-pesticide-expanded-circle-rect-close-composition-donut-text").remove(),setTimeout(function(){if(k.append("rect").attr("id","efsa-pesticide-expanded-circle-rect-close-composition-donut").attr("x",u+2).attr("y",ft/10-ft+j+5+(s?X:0)).attr("width",j).attr("height",j).attr("fill","#a8a8a8").attr("cursor","pointer").on("click",function(){q.d3stopPropagation(),St(L),St(P),P.selectAll("*").remove(),d3.select(this).remove(),pe()}).on("mouseover",function(){d3.select("#efsa-pesticide-expanded-circle-rect-close-composition-donut-text").style("text-decoration","underline")}).on("mouseout",function(){d3.select("#efsa-pesticide-expanded-circle-rect-close-composition-donut-text").style("text-decoration","none")}),k.append("text").attr("id","efsa-pesticide-expanded-circle-rect-close-composition-donut-text").attr("x",u+2+j/2).attr("y",ft/10-ft+j+5+j/2+bt/2.5+(s?X:0)).attr("text-anchor","middle").attr("fill","white").style("font-size",1.25*gt+"px").text("x"),s){var t=k.select("#efsa-pesticide-expanded-circle-rect-close-composition-donut"),e=+t.attr("x"),a=+t.attr("width");t.attr("transform","translate("+-(2*e+a)+","+-X+")");var t=k.select("#efsa-pesticide-expanded-circle-rect-close-composition-donut-text"),e=+t.attr("x"),a=+t.attr("width");t.attr("transform","translate("+-(2*e+a)+","+-X+")")}},i)})}(t,e,r,n,0,a,_)}),a){for(var lt in st=[],Tt)st.push(lt);st=st.sort(function(t,e){return(t=Dt(f.countries[t]))>(e=Dt(f.countries[e]))?1:t(e=Dt(f.countries[e]))?1:t800?32:20,st,a,D,I,R,M,U,C,!1),w.append("rect").attr("id","composition-chart-cover").attr("x",0).attr("y",R-5).attr("width",N).attr("height",S-R).attr("fill","#ffffff").attr("opacity",.85).style("display","none")}function ce(t,e,a,i,n,s,c,o,l,d,p){w.selectAll(".composition-chart-dropdown-analysing").remove();for(var u=1.4*bt,x=kt?"mousewheel":"wheel",y=0,m=t,h=a.length;m6&&(t-=7,e-=7),ce(t,e,a,v,n,s,c,o,l,d,!0))});var b=f.countries[m];b=b||m,w.append("text").attr("class","composition-chart-dropdown-analysing").style("display",p?"block":"none").attr("id","composition-chart-text-analysing-"+i).attr("x",v?n+5:s+5).attr("y",g+bt).attr("fill","#202020").attr("font-size",bt+"px").style("cursor","pointer").text(b)}(m,a[m],i);t0&&w.append("image").attr("class","composition-chart-dropdown-analysing").style("display",p?"block":"none").attr("xlink:href","/sites/default/files/interactive_tools/pesticides_2017/assets/menu arrow up b.png").attr("x",i?80:N-50).attr("y",y+o).attr("height",o/1.7).attr("width",o/1.7).style("cursor","pointer").on("click",function(){q.d3stopPropagation(),ce(t-=7,e-=7,a,i,n,s,c,o,l,d,!0)})}function oe(t,e){d3.select(t).attr("fill","#3878b2"),d3.select(e).attr("fill","#ffffff")}function le(t,e,a,r){d3.select(t).attr("fill",a),d3.select(e).attr("fill",r)}function de(t,e,a){var r=10;rt||(r=10,d3.selectAll(".efsa-pesticide-expanded-circle-text").style("display","none").transition().duration(0).delay(function(t,e){return 2*i+30*e}).style("display","block"),rt=!0),x.attr("stroke-width",ft/10).transition().duration(i).attr("r",ft).on("end",function(){var o=t,l=e,d=a,p=[o,l,d];o/=100,l/=100,d/=100;for(var f=d3.selectAll(".efsa-pesticide-expanded-circle-text-value"),u=0;u<3;u++){var x=d3.select(f._groups[0][u]),y=parseInt(x.text());isNaN(y)&&(y=0),ae(x,y,p[u],"%",1,r)}var m=i/2,h=ft-ft/10-ft/20-ft/10,v=ft-ft/10-ft/20;be(P,0,o,n,m*o,h,v,function(){be(P,o,o+l,s,m*l,h,v,function(){be(P,o+l,o+l+d,c,m*d,h,v)})}),setTimeout(function(){for(var t=1;t<=3;t++){var e=d3.select("#efsa-pesticide-expanded-circle-text-"+t)._groups[0][0].getBBox().width;d3.select("#efsa-pesticide-expanded-circle-text-"+t+"c").attr("cx",-e/2-5)}},3*i)})}function pe(){ot&&!V&&(mt||Yt(),Wt(),"food"===Ct&&G&&ve(!0),mt&&(mt=!1),(et||at)&&fe(),mobile&&-1!==$&&It(0,0,!1),u.style("cursor","pointer"),k.select("#efsa-pesticide-expanded-circle-rect-close-composition-donut").remove(),k.select("#efsa-pesticide-expanded-circle-rect-close-composition-donut-text").remove(),k.select("#efsa-pesticide-expanded-circle-rect-close-food-name").remove(),k.select("#efsa-pesticide-expanded-circle-rect-close-food-name-text").remove(),St(d3.selectAll(".composition-chart-dropdown-analysing")),K=-1,at&&setTimeout(function(){St(d3.select("#composition-chart-cover"))},2*i))}function fe(){we(),Vt(),St(L),St(P),St(B),St(O),function(t){d3.selectAll(".efsa-pesticide-expanded-circle-rect-text").attr("x","0"),d3.selectAll(".efsa-pesticide-expanded-circle-rect-text").text(""),d3.selectAll(".efsa-pesticide-expanded-circle-rect-text-for-country").text("");var e=!1;d3.selectAll(".efsa-pesticide-expanded-circle-rect").transition().duration(i).attr("width",0).attr("transform",function(t,e){var a=d3.select(this).attr("x"),r=0;return d3.select(this).attr("transform")&&(r=q.cssTransformTranslateValues(d3.select(this).attr("transform")).y),a<0?"translate("+-a+","+r+")":"translate(0,"+r+")"}).on("end",function(){e||(e=!0,t())})}(function(){_e(!0),Wt(),Jt(!0),et=!1,st=null,ct=null,at=!1,tt=!1,rt=!1,it=!1})}function ue(){tt||("country"===Ct&&d3.selectAll(".country-code").each(function(t,e){d3.select(this).attr("x",d3.select("#efsa-pesticide-food-"+e).attr("cx")).attr("y",+d3.select("#efsa-pesticide-food-"+e).attr("cy")+bt/2)}),u.attr("cx",function(t){return t.x}).attr("cy",function(t){return t.y}).attr("index",function(t){return t.index}))}function xe(t){for(var e,a,r=0,i=Mt,n=1*t;r-1)&&!tt&&!V&&ot){var a="food"===Ct?d3.select(this).attr("fill-val"):"gray",r=+d3.select(this).attr("opacity");if(1===r){var i=t.food;i="food"===Ct?f.foods[i]:f.countries[i],te(+d3.select(this).attr("cx")+N/2-t.radius/3,+d3.select(this).attr("cy")+S/2-t.radius/3,i,a,d3.select(this).attr("index"))}}}),u.on("mousemove",function(t,e){et||$>-1||tt||V||!ot||K>-1||function(t,e){K=e;for(var a=0;a-1){n=s;break}var c=0,o=0,l=0;_.each(D,function(e){e.subcategory===t&&(c+=+e.value_below_loq_as_samples,o+=+e.value_below_mrl_as_samples,l+=+e.value_above_mrl_as_samples,0)}),re(e,n,i,i,a,c*=100/a,o*=100/a,l*=100/a,U)}function ze(t,e){q.d3stopPropagation();var a=H["cat-"+t],r=t,i=0,n=0,s=0;_.each(D,function(e){e.category===t&&(i+=+e.value_below_loq_as_samples,n+=+e.value_below_mrl_as_samples,s+=+e.value_above_mrl_as_samples,0)}),re(e,r,"",r,a,i*=100/a,n*=100/a,s*=100/a,M)}!function(){u=b.selectAll(".efsa-pesticide-food").data(Ot).enter().append("circle").attr("id",function(t,e){return"efsa-pesticide-food-"+e}).attr("class","efsa-pesticide-food").attr("stroke-width",0).attr("r",function(t){return t.radius}).attr("r-val",function(t){return t.radius}).attr("data-category",function(t){return t.category}).attr("data-subcategory",function(t){return t.subcategory}).attr("data-food",function(t){return t.food}).attr("fill-val",function(t){return"food"===Ct?Lt(t.cluster):d}).attr("fill",function(t){return"food"===Ct?Lt(t.cluster):d}).attr("cx",function(t){return t.x}).attr("cy",function(t){return t.y}).attr("cx-val",function(t){return t.x}).attr("cy-val",function(t){return t.y}).style("cursor","pointer"),"country"===Ct&&u.each(function(t,e){var a=d3.select(this);b.append("text").style("opacity","0").attr("class","country-code").attr("text-anchor","middle").attr("x",a.attr("cx")).attr("y",+a.attr("cy")).text(t.countrycode).attr("fill",p).attr("font-weight","700").attr("font-size",bt).transition().duration(500).delay(function(){return 1e3+30*e}).style("opacity","1")}),"country"===Ct&&u.attr("stroke",yt).attr("stroke-width",xt);var t,e,a=[1,2,3,4];if(C.selectAll(".efsa-pesticide-expanded-circle-rect").data(a).enter().append("rect").attr("class","efsa-pesticide-expanded-circle-rect").attr("id",function(t,e){return"efsa-pesticide-expanded-circle-rect-"+e}).attr("y",function(t,e){return ft/10-ft+e*(j+5)}).attr("height",j).style("display","none"),C.selectAll(".efsa-pesticide-expanded-circle-rect-text").data(a).enter().append("text").style("font-size",function(t,e){return(0===e?gt:(gt+bt)/2)+"px"}).attr("class","efsa-pesticide-expanded-circle-rect-text").attr("id",function(t,e){return"efsa-pesticide-expanded-circle-rect-text-"+e}).attr("y",function(t,e){return ft/10-ft+e*(j+5)+j/2+(0===e?gt:(gt+bt)/2)/2.5}),"food"===Ct&&C.append("image").attr("xlink:href","/sites/default/files/interactive_tools/pesticides_2017/assets/sub-category.png").style("display","none").style("pointer-events","none").attr("height",.7*j).attr("width",.7*j).attr("x",ft+ft/10+2).attr("y",function(t,e){return ft/10-ft+2*(j+5)+3}).attr("id","efsa-pesticide-expanded-circle-rect-icon-sub-category"),"country"===Ct&&(C.append("image").attr("xlink:href","/sites/default/files/interactive_tools/pesticides_2017/assets/pie chart.png").style("display","none").style("pointer-events","none").attr("height",.7*j).attr("width",.7*j).attr("class","efsa-pesticide-expanded-circle-rect-icon").attr("id","efsa-pesticide-expanded-circle-rect-icon-pie-chart").attr("y",function(){return ft/10-ft+1*(j+5)+.15*j}).attr("x",ft+ft/9*1-j),C.append("image").attr("xlink:href","/sites/default/files/interactive_tools/pesticides_2017/assets/map marker.png").style("display","none").style("pointer-events","none").attr("height",.7*j).attr("width",.7*j).attr("class","efsa-pesticide-expanded-circle-rect-icon").attr("id","efsa-pesticide-expanded-circle-rect-icon-map-marker").attr("y",function(){return ft/10-ft+2*(j+5)+.15*j}).attr("x",ft+ft/9*2-j)),x=C.append("circle").attr("r",0).attr("fill","white").attr("stroke-width",0).attr("pointer-events","none"),y=C.append("text").attr("class","efsa-pesticide-clicked-circle-text").style("font-size",bt+"px"),v=C.append("text").attr("class","efsa-pesticide-clicked-circle-text").style("font-weight","700").style("font-size",gt+"px"),g=C.append("text").attr("class","efsa-pesticide-clicked-circle-text").style("font-weight","300").style("font-size",bt+"px"),"food"===Ct){m=C.append("rect").attr("rx",10).attr("ry",10).attr("width",94).attr("height",20).attr("pointer-events","none").style("display","none"),h=C.append("text").attr("fill","white").attr("font-size","10px").text(f.global.see_results).attr("pointer-events","none").attr("text-anchor","middle").style("font-weight","400").style("display","none");var r=0;_t||wt||kt?r=5*h.text().length:(h.style("display","block"),r=h._groups[0][0].getBBox().width,h.style("display","none")),r>85&&h.attr("font-size","9px")}"food"===Ct?me():"country"===Ct&&(me(),St(L),St(P),P.selectAll("*").remove(),B.append("g").attr("class","efsa-pesticide-expanded-circle-pie"),St(B),t=-ft/2.2+3*gt,e=-ft/2.2+10*gt,O.append("text").attr("class","efsa-pesticide-expanded-circle-text-for-country").attr("x",0).attr("y",-ft/1.5).style("font-size",gt+"px").text(""),O.append("text").attr("class","efsa-pesticide-expanded-circle-text-for-country").attr("x",0).attr("y",t).style("font-size",2*gt+"px").text(""),O.append("text").attr("class","efsa-pesticide-expanded-circle-text-for-country").attr("x",0).attr("y",-ft/2.2+5*gt).style("font-size",gt+"px").text(""),O.append("text").attr("class","efsa-pesticide-expanded-circle-text-for-country").attr("x",0).attr("y",e).style("font-size",2*gt+"px").text(""),O.append("text").attr("class","efsa-pesticide-expanded-circle-text-for-country").attr("x",0).attr("y",-ft/2.2+12*gt).style("font-size",gt+"px").text(""),O.append("text").attr("class","efsa-pesticide-expanded-circle-text-for-country").attr("x",0).attr("y",-ft/2.2+13*gt).style("font-size",gt+"px").text(""),O.append("line").attr("class","efsa-pesticide-expanded-circle-line").attr("x1",-ft/2).attr("y1",-ft/2).attr("x2",+ft/2).attr("y2",-ft/2),O.append("line").attr("class","efsa-pesticide-expanded-circle-line").attr("x1",-ft/2).attr("y1",(e+t)/2).attr("x2",+ft/2).attr("y2",(e+t)/2))}(),setTimeout(function(){!function(e){"food"===Ct&&(A.selectAll(".efsa-pesticide-tab-title").data(e).enter().append("rect").attr("class","efsa-pesticide-tab-title"),A.selectAll(".efsa-pesticide-tab-title-text").data(e).enter().append("text").style("font-size",(gt+bt)/2+"px").attr("class","efsa-pesticide-tab-title-text").attr("x",-300).attr("y",function(t,e){return lt+e*(j+X)+j/2+6}).text(function(t){return f.foods[t]}).transition().duration(2*i).ease(q.qeaseElastic).delay(function(t,e){return i+(e+1)*i/2}).attr("x",10),Z=0,A.selectAll(".efsa-pesticide-tab-title-text").each(function(t,e){Z=q.max(Z,d3.select(this).node().getBBox().width)}),Y=Math.max(Z+30,Y),A.selectAll(".efsa-pesticide-tab-title").attr("x",0).attr("y",function(t,e){return lt+e*(j+X)}).attr("width",Y).attr("height",j).attr("opacity","1").attr("fill",function(t,e){return Lt(t)}).attr("fill-default",function(t,e){return Lt(t)}).attr("transform","translate("+-Y+",0)").transition().duration(2*i).delay(function(t,e){return(e+1)*i/2}).attr("transform","translate("+-(Y-(Z+30))+",0)"),A.append("rect").attr("class","efsa-pesticide-tab-title").attr("x",0).attr("y",function(t,e){return lt+-1*(j+X)}).attr("width",Y).attr("height",j).attr("opacity","1").attr("fill",t.all_foods).attr("fill-default",t.all_foods).attr("transform","translate("+-Y+",0)").transition().duration(2*i).delay(function(t,e){return e*i/2}).attr("transform","translate("+-(Y-(Z+30))+",0)"),A.append("text").style("font-size",(gt+bt)/2+"px").attr("class","efsa-pesticide-tab-title-text").attr("x",-300).attr("y",function(t,e){return lt+-1*(j+X)+j/2+6}).text(f.global.all_products).transition().duration(2*i).ease(q.qeaseElastic).delay(function(t,e){return i/2+i/2}).attr("x",10))}(a),_.each(a,function(t,e){!function(t){var e=Lt(t),i=d3.color(e).brighter(.25),n=[a[t]].concat(r[a[t]]);if(!((n=r[a[t]]).length<2)){var s=z.append("g");s.attr("id","efsa-pesticide-subtabs-group-"+t).attr("transform","translate("+-Y+", 0)"),s.selectAll(".efsa-pesticide-subtab-space-"+t).data(n).enter().append("rect").attr("class","efsa-pesticide-subtab efsa-pesticide-subtab-space-"+t).attr("x",-1).attr("y",function(e,a){return lt+(a+2)*(j+X)+t*(j+X)-X-5}).attr("width",Y).attr("height",X+5).attr("fill-default","#f4f4f4").attr("fill-brighter","#f4f4f4").attr("fill","#f4f4f4"),s.selectAll(".efsa-pesticide-subtab-"+t).data(n).enter().append("rect").attr("class","efsa-pesticide-subtab efsa-pesticide-subtab-rect efsa-pesticide-subtab-"+t).attr("x",0).attr("y",function(e,a){return lt+(a+1)*(j+X)+t*(j+X)}).attr("width",Y).attr("height",j).attr("fill-default",e).attr("fill-brighter",i).attr("fill",i),s.selectAll(".efsa-pesticide-subtab-text-"+t).data(n).enter().append("text").style("font-size",(gt+bt)/2+"px").attr("class","efsa-pesticide-subtab-text efsa-pesticide-subtab-text-"+t).attr("x",10).attr("y",function(e,a){return lt+(a+1)*(j+X)+t*(j+X)+j/2+5}).text(function(t,e){return f.foods[t]})}}(e)}),T.append("path").attr("id","efsa-pesticide-tooltip").attr("width",0),T.append("text").attr("id","efsa-pesticide-tooltip-text")},200),e?(ye(),b.attr("opacity","1"),setTimeout(he,15e3)):d3.text("/sites/default/files/interactive_tools/pesticides_2017/"+Ct+"-nodes.dat",function(t,e){if(t)throw t;var a=JSON.parse(e);R=a.data,ye()})}function Dt(t){return"Ö"===t[0]?t=t.replace("Ö","O"):"Ä"===t[0]&&(t=t.replace("Ä","A")),"é"===t[1]?t=t.replace("é","e"):"ü"===t[1]&&(t=t.replace("ü","u")),t}window.doFoods=function(){Lt()},window.doCountries=function(){Bt()};var Et=[function(){},Lt,Bt];window.location.search.indexOf("do=foods")>-1?Et[1]():window.location.search.indexOf("do=countries")>-1?Et[2]():Et[1]()}efsaPesticideDataviz(efsaPesticideDatavizConfig);var resize_w=window.innerWidth,resize_h=window.innerHeight;window.addEventListener("resize",function(){if(mobile){var t=window.innerWidth;if(t-resize_w)return resize_w=t,void efsaPesticideDataviz(efsaPesticideDatavizConfig);var e=window.innerHeight,a=e-resize_h;return Math.abs(a)>RESIZE_TOLERANCE?(resize_w=t,resize_h=e,d3.select("#efsa-pesticide-dataviz-svg").attr("viewBox",[0,0,resize_w,resize_h].join(" ")),void efsaPesticideDataviz(efsaPesticideDatavizConfig)):void setTimeout(function(){var t=window.innerHeight,e=t-resize_h,a=t/resize_w,r=d3.select("#efsa-pesticide-dataviz-svg").attr("viewBox").split(" ");-e/a>=0&&(r[0]=-e/a,r[2]=resize_w+e/a,d3.select("#efsa-pesticide-dataviz-svg").attr("viewBox",r.join(" ")))},500)}efsaPesticideDataviz(efsaPesticideDatavizConfig)});