(function(n){"use strict";function t(n,t,i,r,u,f,e,o){function c(){s.getCommodityGroups();s.getReportingPeriods()}function l(){s.queryParam.reportingPeriod=s.reportingPeriod.value;s.queryParam.commodityCode=s.commodity.value;s.queryParam.regionCode=s.region.value;s.queryParam.countryCode=s.country.value;s.queryParam.attributeId=s.attributeId}function h(n){p(n);w(n);b(n);k(n);d(n);g(n)}function a(){s.attributeId=s.queryParam.attributeId;o.getAllAttributeData(s.queryParam).then(function(n){s.allAttributeData=n;s.dataTracker[0]=!0;v();s.attributeId=s.queryParam.attributeId;h(s.queryParam.attributeId)},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);s.message="Failed to get Reporting Periods due to:"+t.join(" ")})}function v(){var n=s.queryParam.attributeId||s.attributeId;$.each(s.allAttributeData.attributeValues,function(n,t){if(t.publicAccess)return s.queryParam.attributeId=t.attributeId,!1});$.each(s.allAttributeData.attributeValues,function(t,i){if(i.attributeId===n)return s.queryParam.attributeId=n,!1})}function y(){s.singleAttribAllYearsData=null;s.singleAttribMonthlyChangeData=null;s.singleAttribYearlyChangeData=null;s.singleAttribWindowedData=null;s.singleAttributeRankedData=null;s.singleAttributeStackedData=null}function p(n){s.queryParam.attributeId=n;o.getSingleAttributeAllYearsData(s.queryParam).then(function(n){s.singleAttribAllYearsData=n;s.dataTracker[0]=s.singleAttribAllYearsData.dataSeries.length>0;$("#allYearChart").highcharts({credits:{enabled:!0,text:"Source: FAS USDA",href:"http://www.fas.usda.gov"},chart:{type:"column"},title:{text:s.singleAttribAllYearsData.titleText},subtitle:{text:"Forecast Data reported on: "+s.singleAttribAllYearsData.reportedOn},xAxis:{categories:s.singleAttribAllYearsData.categories,title:{text:null}},yAxis:{min:0,title:{text:s.singleAttribAllYearsData.yAxisLabel,align:"middle"},labels:{overflow:"justify"}},tooltip:{valueSuffix:s.singleAttribAllYearsData.yAxisLabel},plotOptions:{column:{dataLabels:{enabled:!1}}},legend:{enabled:!1,layout:"vertical",align:"right",verticalAlign:"top",x:-40,y:80,floating:!0,borderWidth:1,backgroundColor:Highcharts.theme&&Highcharts.theme.legendBackgroundColor||"#FFFFFF",shadow:!0},series:[{name:"Yearly forecast data",data:s.singleAttribAllYearsData.dataSeries,color:"#3882AB"}]});setTimeout(function(){$("#allYearChart").highcharts().reflow()},500)},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);s.message="Failed to get Reporting Periods due to:"+t.join(" ")})}function w(n){(s.dataTracker[1]=!1,s.queryParam.countryCode=="00")&&(s.queryParam.attributeId=n,o.getSingleAttributeMonthlyChangeData(s.queryParam).then(function(n){s.singleAttribMonthlyChangeData=n;s.dataTracker[1]=s.singleAttribMonthlyChangeData.dataSeries.length>0;$("#monthlyChangeChart").highcharts({credits:{enabled:!0,text:"Source: FAS USDA",href:"http://www.fas.usda.gov"},chart:{type:"column"},title:{text:s.singleAttribMonthlyChangeData.titleText},subtitle:{text:"Forecast Data reported on: "+s.singleAttribMonthlyChangeData.reportedOn},xAxis:{categories:s.singleAttribMonthlyChangeData.categories,title:{text:null}},yAxis:{title:{text:s.singleAttribMonthlyChangeData.yAxisLabel,align:"middle"},labels:{overflow:"justify"}},tooltip:{valueSuffix:s.singleAttribMonthlyChangeData.yAxisLabel},plotOptions:{column:{dataLabels:{enabled:!0}}},legend:{enabled:!1,layout:"vertical",align:"right",verticalAlign:"top",x:-40,y:80,floating:!0,borderWidth:1,backgroundColor:Highcharts.theme&&Highcharts.theme.legendBackgroundColor||"#FFFFFF",shadow:!0},series:[{name:"Monthly Change",data:s.singleAttribMonthlyChangeData.dataSeries,color:"#3882AB",negativeColor:"orangered"}]});setTimeout(function(){$("#monthlyChangeChart").highcharts().reflow()},500)},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);s.message="Failed to get Reporting Periods due to:"+t.join(" ")}))}function b(n){(s.queryParam.attributeId=n,s.dataTracker[2]=!1,s.queryParam.countryCode=="00")&&o.getSingleAttributeYearlyChangeData(s.queryParam).then(function(n){s.singleAttribYearlyChangeData=n;s.dataTracker[2]=s.singleAttribYearlyChangeData.dataSeries.length>0&&s.country.value=="00";$("#yearlyChangeChart").highcharts({credits:{enabled:!0,text:"Source: FAS USDA",href:"http://www.fas.usda.gov"},chart:{type:"column"},title:{text:s.singleAttribYearlyChangeData.titleText},subtitle:{text:"Forecast Data reported on: "+s.singleAttribYearlyChangeData.reportedOn},xAxis:{categories:s.singleAttribYearlyChangeData.categories,title:{text:null}},yAxis:{title:{text:s.singleAttribYearlyChangeData.yAxisLabel,align:"middle"},labels:{overflow:"justify"}},tooltip:{valueSuffix:s.singleAttribYearlyChangeData.yAxisLabel},plotOptions:{column:{dataLabels:{enabled:!0}}},legend:{enabled:!1,layout:"vertical",align:"right",verticalAlign:"top",x:-40,y:80,floating:!0,borderWidth:1,backgroundColor:Highcharts.theme&&Highcharts.theme.legendBackgroundColor||"#FFFFFF",shadow:!0},series:[{name:"Yearly Change",data:s.singleAttribYearlyChangeData.dataSeries,color:"#3882AB",negativeColor:"orangered"}]});setTimeout(function(){$("#yearlyChangeChart").highcharts().reflow()},500)},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);s.message="Failed to get Reporting Periods due to:"+t.join(" ")})}function k(){o.getSingleAttributeWindowedChangeData(s.queryParam).then(function(n){var t,i;if(s.singleAttribWindowedData=n,s.dataTracker[3]=s.singleAttribWindowedData.dataSeries.length>0,!!s.dataTracker[3])for(t=0;t<s.singleAttribWindowedData.dataSeries[2].data.length;t++)i=s.singleAttribWindowedData.dataSeries[2].data[t],i===0&&(s.singleAttribWindowedData.dataSeries[2].data[t]=null);$("#windowedChangeChart").highcharts({credits:{enabled:!0,text:"Source: FAS USDA",href:"http://www.fas.usda.gov"},title:{text:s.singleAttribWindowedData.titleText,x:-20},subtitle:{text:"Forecast Data reported on: "+s.singleAttribWindowedData.reportedOn,x:-20},xAxis:{categories:s.singleAttribWindowedData.categories,title:{text:"Data Release"}},yAxis:{title:{text:s.singleAttribWindowedData.yAxisLabel},plotLines:[{value:0,width:1,color:"#808080"}]},tooltip:{valueSuffix:s.singleAttribWindowedData.yAxisLabel},legend:{layout:"vertical",align:"right",verticalAlign:"middle",borderWidth:0},series:s.singleAttribWindowedData.dataSeries});setTimeout(function(){$("#windowedChangeChart").highcharts().reflow()},500)},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);s.message="Failed to get Reporting Periods due to:"+t.join(" ")})}function d(){(s.dataTracker[4]=!1,s.queryParam.countryCode=="00")&&o.getTopRankedAttributeData(s.queryParam).then(function(n){s.singleAttributeRankedData=n;s.singleAttributeRankedData.attributeType==="SIMPLE"?(s.dataTracker[4]=s.singleAttributeRankedData.dataSeries.length>0,$("#rankedDataChart").highcharts({credits:{enabled:!0,text:"Source: FAS USDA",href:"http://www.fas.usda.gov"},chart:{type:"pie",options3d:{enabled:!0,alpha:45}},title:{text:s.singleAttributeRankedData.titleText},subtitle:{text:"Forecast Data reported on: "+s.singleAttributeRankedData.reportedOn},tooltip:{valueSuffix:s.singleAttributeRankedData.yAxisLabel},plotOptions:{pie:{innerSize:30,depth:5,showInLegend:!0,dataLabels:{enabled:!0,format:"{point.percentage:.1f} %",style:{color:Highcharts.theme&&Highcharts.theme.contrastTextColor||"black"}}}},series:[{name:"Region Composition by countries",data:s.singleAttributeRankedData.dataSeries}]})):s.singleAttributeRankedData.attributeType==="COMPOSITE"&&(s.dataTracker[4]=s.singleAttributeRankedData.compositeDataSeries.length>0,$("#rankedDataChart").highcharts({credits:{enabled:!0,text:"Source: FAS USDA",href:"http://www.fas.usda.gov"},chart:{type:"column"},title:{text:s.singleAttributeRankedData.titleText},subtitle:{text:"Forecast Data reported on: "+s.singleAttributeRankedData.reportedOn},tooltip:{valueSuffix:s.singleAttributeRankedData.yAxisLabel},legend:{align:"right",verticalAlign:"middle",layout:"vertical"},xAxis:{categories:s.singleAttributeRankedData.categories,labels:{x:-10}},yAxis:{title:{text:s.singleAttributeRankedData.yAxisLabel}},series:s.singleAttributeRankedData.compositeDataSeries}));setTimeout(function(){$("#rankedDataChart").highcharts().reflow()},500)},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);s.message="Failed to get Reporting Periods due to:"+t.join(" ")})}function g(){(s.dataTracker[5]=!1,s.queryParam.countryCode=="00")&&o.getTopStackedAttributeData(s.queryParam).then(function(n){s.singleAttributeStackedData=n;s.dataTracker[5]=s.singleAttributeStackedData.dataSeries.length>0;var t="{series.name}: {point.y} "+s.singleAttributeStackedData.yAxisLabel+"<br/>Total: {point.stackTotal} "+s.singleAttributeStackedData.yAxisLabel;s.singleAttributeStackedData.attributeType==="COMPOSITE"&&(t="{series.name}: {point.y} "+s.singleAttributeStackedData.yAxisLabel);$("#stackedDataChart").highcharts({credits:{enabled:!0,text:"Source: FAS USDA",href:"http://www.fas.usda.gov"},chart:{type:"column"},title:{text:s.singleAttributeStackedData.titleText},subtitle:{text:"Forecast Data reported on: "+s.singleAttributeStackedData.reportedOn},xAxis:{categories:s.singleAttributeStackedData.categories},yAxis:{min:0,title:{text:s.singleAttributeStackedData.yAxisLabel},stackLabels:{enabled:s.singleAttributeStackedData.attributeType==="COMPOSITE"?!1:!0,style:{fontWeight:"normal",fontSize:"8px",color:Highcharts.theme&&Highcharts.theme.textColor||"gray"}}},legend:{align:"center",verticalAlign:"bottom",backgroundColor:Highcharts.theme&&Highcharts.theme.background2||"white",borderColor:"#CCC",borderWidth:1,shadow:!1},tooltip:{headerFormat:"<b>{point.x}<\/b><br/>",pointFormat:t},plotOptions:{column:{stacking:"normal",dataLabels:{enabled:!1,color:Highcharts.theme&&Highcharts.theme.dataLabelsColor||"white"}}},series:s.singleAttributeStackedData.dataSeries});setTimeout(function(){$("#stackedDataChart").highcharts().reflow()},500)},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);s.message="Failed to get Reporting Periods due to:"+t.join(" ")})}var s=this;s.dataTracker=[];s.autoran=!1;s.attributeId=28;s.commodityGroup=null;s.commodityGroups=null;s.commodity=null;s.commodities=null;s.region=null;s.regions=null;s.country=null;s.countries=null;s.reportingPeriod=null;s.reportingPeriods=null;s.singleAttribAllYearsData=null;s.singleAttribMonthlyChangeData=null;s.singleAttribYearlyChangeData=null;s.singleAttribWindowedData=null;s.singleAttributeRankedData=null;s.singleAttributeStackedData=null;s.queryParam={reportingPeriod:null,reportingCutoffPeriod:null,commodityCode:null,regionCode:null,countryCode:null,attributeId:null};s.getReportingPeriods=function(){o.getReportingPeriods().then(function(n){s.reportingPeriods=n;s.reportingPeriod=s.reportingPeriods[0]},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);s.message="Failed to get Reporting Periods due to:"+t.join(" ")})};s.getCommodityGroups=function(){s.commodity=null;o.getCommodityGroups().then(function(n){s.commodityGroups=n;s.commodityGroup=s.commodityGroups[0]},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);s.message="Failed to get Commodity Groups due to:"+t.join(" ")})};s.getCommodities=function(n){s.region=null;o.getCommodities(n.value).then(function(n){s.commodities=n;s.commodity=s.commodities[0]},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);s.message="Failed to get Commodities due to:"+t.join(" ")})};s.getRegions=function(n){s.country=null;s.regions=null;o.getRegions(n.value).then(function(n){s.regions=n;s.region=s.regions[0]},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);s.message="Failed to get REgions due to:"+t.join(" ")})};s.getCountries=function(n,t){return o.getCountries(n.value,t.value).then(function(n){s.countries=n;s.country=s.countries[0];s.autoran||(s.autoran=!0,s.getData())},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);s.message="Failed to get Countries due to:"+t.join(" ")})};s.getData=function(){y();l();a()};s.captureData=function(n){s.attributeId=n.attributeId;h(s.attributeId)};s.getFormattedData=function(n){return isFinite(n)?i("passthruNumber")(n,0):n};s.saveTableAsImage=function(n){e.download({payload:$(n)[0].innerHTML,payloadtype:"html",imageName:"topCommodities"}).then(function(n){try{var t=new Blob([n],{type:"octet/stream"});f.download(t,"AllAttribs.png",{type:"octet/stream"})}catch(i){u.error({title:"Error",body:"Save as Image not supported on this browser version"})}},function(){u.error({title:"Error",body:"Save as Image not supported on this browser version"})})};c();n.$watch(angular.bind(s,function(){return s.commodityGroup}),function(n,t){!n||t&&n.value===t.value||s.getCommodities(n)});n.$watch(angular.bind(s,function(){return s.commodity}),function(n,t){!n||t&&n.value===t.value||s.getRegions(n)});n.$watch(angular.bind(s,function(){return s.region}),function(n,t){!n||t&&n.value===t.value||s.getCountries(n,s.commodity)})}n.controller("compositeVizCtrl",["$scope","$timeout","$filter","$window","toaster","SaveAs","imageConversionService","compositeVizService",t])})(angular.module("common")),function(n){"use strict";var t=function(){var n=this;n.showInstructions=!0;n.geographicRegions=[];n.indexArray=[];n.showRegion=function(t){n.indexArray[t]=!0;n.showInstructions=!1};n.hideRegion=function(t){n.indexArray[t]=!1;n.showInstructions=!0;$.each(n.indexArray,function(t,i){if(i)return n.showInstructions=!1,!1})}};n.controller("statsByCommodity",["$scope",t])}(angular.module("common")),function(n){"use strict";var t=function(n,t){var i=function(i,r){var u=n.open({animation:i.animationsEnabled,templateUrl:"vizByCommodity/countrySpecificRecords.html",backdrop:"static",controller:"countrySpecificRecordsCtrl",controllerAs:"vm",size:"lg",resolve:{countrySpecificRecords:function(){return t.getCountrySpecificData(r.queryParams).then(function(n){return{dto:r,countrySpecificData:n}},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);vm.message="Failed to get Country specific Records due to:"+t.join(" ")})}}})};return{showAllCommodities:i}};n.factory("countrySpecificPopupService",["$uibModal","commodityStatsService",t])}(angular.module("common")),function(n){"use strict";var t=function(n,t,i,r,u,f,e){var o=this;o.dataAvailability="";o.predicate=null;o.reverse=!1;o.order=function(n){o.reverse=o.predicate===n?!o.reverse:!1;o.predicate=n};o.countrySpecificData=r.countrySpecificData;o.attribute=r.dto.attributeName;o.countryName=r.dto.countryName;o.countryCode=r.dto.queryParams.countryCode;t.cancel=function(){i.dismiss("cancel")};o.getData=function(n){i.dismiss("cancel");var u=r.dto;o.countryCode=n.topCountryCode;u.queryParams.countryCode=n.topCountryCode;u.countryName=n.topCountry;f.showAllCommodities(t,u)};o.showCommoditySpecificCountries=function(n){i.dismiss("cancel");var u=r.dto;u.queryParams.commodityCode=n.commodityCode;u.queryParams.commodityName=n.commodityName;u.queryParams.commodityId=n.commodityId;u.queryParams.commodityGroupId=n.commodityGroupId;u.commodityName=n.commodityName;e.showAllCountries(t,u)};o.getDataAvailability=function(t){var i=o.countryCode,r=n.getDataAvailability(t,i).then(function(n){o.dataAvailability=n},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);o.message="Failed to get Data Availability due to:"+t.join(" ")})};o.download=function(){var t="AllCmdty_"+o.countryName+"_"+o.attribute+".xls",n=angular.element(".downloadable >table")[0].outerHTML;n='<html><head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><\/head><body>'+n+"<\/body><\/html>";u.download(n,t,{type:"application/vnd.ms-excel;charset=utf-8"})}};n.controller("countrySpecificRecordsCtrl",["commodityStatsService","$scope","$uibModalInstance","countrySpecificRecords","SaveAs","countrySpecificPopupService","commoditySpecificPopupService",t])}(angular.module("common")),function(n){"use strict";var t=function(n,t){var i=function(){var n=this,i;n.checkedStatusArray=[];n.trackChange=function(t,i){var r=n.checkedStatusArray[t];r?n.showRegion()(t,i):n.hideRegion()(t,i)};n.regionCodeArray=[];i=t.getGeographicRegions().then(function(t){n.geographicRegions=t},function(t){var i=[],r;for(r in t.modelState)i.push(t.modelState[r]);n.message="Failed to get Geographic Regions due to:"+i.join(" ")})},r=function(t,i,r,u){t.manageRegionStats=function(i,r){if(u.trackChange(i,r),u.checkedStatusArray[i]===!1)$("#regionStat"+i).slideUp(500);else if(u.checkedStatusArray[i]===!0)if($("#regionStat"+i).length===1)$("#regionStat"+i).slideDown(500,function(){$("html, body").animate({scrollTop:$("#regionStat"+i).offset().top},1e3)});else{var f=n(' <div id="regionStat'+i+'"><region-stats regioncode="'+r+'"><\/region-stats>')(t);$("#statsContainer").append(f);f.css("display","none");f.slideDown(500,function(){$("html, body").animate({scrollTop:f.offset().top},1e3)})}}};return{controller:i,link:r,scope:{showRegion:"&",hideRegion:"&"},controllerAs:"vm",bindToController:!0,templateUrl:"vizByCommodity/directives/geographicRegions.html"}};n.directive("geographicRegions",["$compile","commodityStatsService",t])}(angular.module("common")),function(n){"use strict";var t=function(n,t){function r(i,r,u,f,e,o,s){function c(){if(!e.commodityGroup){h.commodityGroup=h.commodityGroups[0];return}$.each(h.commodityGroups,function(n,t){if(t.groupId===e.commodityGroup.groupId)return h.commodityGroup=t,!1})}function l(){if(!e.commodity){h.commodity=h.commodities[0];return}h.commodity=h.commodities[0];$.each(h.commodities,function(n,t){if(t.commodityId===e.commodity.commodityId)return h.commodity=t,!1})}function a(){if(!e.groupAttribute){h.groupAttribute=h.groupAttributes[0];return}h.groupAttribute=h.groupAttributes[0];$.each(h.groupAttributes,function(n,t){if(t.groupAttributeId===e.groupAttribute.groupAttributeId)return h.groupAttribute=t,!1})}function v(){h.groupResultsHeader=h.commodityGroup.groupName+" - "+h.commodity.commodityName+" : "+h.groupAttribute.text;h.groupResultsHeader+=" Reported On: "+h.commodityGroup.lastReportedPeriod.reportingPeriodForDisplay}function y(){h.chartTitle=h.commodity.commodityName+" : "+h.groupAttribute.text+" for "+h.region.regionName}function p(){h.uom=h.groupAttribute.unitOfMeasure}function w(n,t){var i="regionAttribSeries"+h.regionCode;Highcharts.chart(i,{credits:{enabled:!0,text:"Source: FAS USDA",href:"http://www.fas.usda.gov"},title:{text:h.chartTitle,x:-20},subtitle:{text:"Forecast Data. Reported On:"+t,x:-20},xAxis:{categories:n.categories,title:{text:"Market Years"}},yAxis:{min:0,title:{text:h.uom},plotLines:[{value:0,width:1,color:"#808080"}]},tooltip:{valueSuffix:h.uom},legend:{layout:"vertical",align:"right",verticalAlign:"middle",borderWidth:0},series:n.dataSeries})}function b(n,t,i){$("#regionCompositionSeries"+h.regionCode).highcharts({credits:{enabled:!0,text:"Source: FAS USDA",href:"http://www.fas.usda.gov"},chart:{type:"pie",options3d:{enabled:!0,alpha:45}},legend:{align:"right",layout:"vertical",verticalAlign:"middle"},title:{text:h.chartTitle},subtitle:{text:"Forecast Data. Reported On:"+t},plotOptions:{series:{point:{events:{mouseOver:function(){h.active=this.options.name.trim();i.$apply()},mouseOut:function(){h.active="";i.$apply()}}}},pie:{innerSize:30,depth:5,showInLegend:!0,dataLabels:{enabled:!0,format:"{point.percentage:.1f} %",style:{color:Highcharts.theme&&Highcharts.theme.contrastTextColor||"black"}}}},tooltip:{headerFormat:"<b>{point.key}<\/b><br/>",pointFormat:"{series.name}: {point.y}"+h.uom},series:[{name:h.commodity.commodityName+": "+h.groupAttribute.displayName,data:n.dataSeries}]});$("#regionCompositionSeries"+h.regionCode).on("mouseenter",".highcharts-legend-item",function(){h.active=$(this).text().trim();i.$apply()}).on("mouseleave",".highcharts-legend-item",function(){h.active="";i.$apply()})}function k(n,t){$("#regionShareSeries"+h.regionCode).highcharts({credits:{enabled:!0,text:"Source: FAS USDA",href:"http://www.fas.usda.gov"},chart:{type:"column"},title:{text:h.chartTitle},subtitle:{text:"Forecast Data. Reported On:"+t},xAxis:{categories:n.categories,title:{text:null}},yAxis:{min:0,title:{text:h.uom,align:"middle"},labels:{overflow:"justify"}},tooltip:{valueSuffix:h.uom},plotOptions:{column:{dataLabels:{enabled:!0}}},legend:{enabled:!1,layout:"vertical",align:"right",verticalAlign:"top",x:-40,y:80,floating:!0,borderWidth:1,backgroundColor:Highcharts.theme&&Highcharts.theme.legendBackgroundColor||"#FFFFFF",shadow:!0},series:[{name:h.commodity.commodityName+": "+h.groupAttribute.displayName,data:n.dataSeries}]})}var h=this;h.chartTitle=null;h.groupResultsHeader=null;h.uom=null;h.commodityGroups=null;h.commodities=null;h.groupAttributes=null;h.commodityGroup=null;h.commodity=null;h.groupAttribute=null;h.region=null;h.regionCode=null;h.regionStats=null;h.countrySpecificRecords=null;h.saveAsPngSupported=f.isExportToPngSupported();h.queryParams={commodityGroupId:"",regionCode:"",countryCode:"",commodityCode:"",groupAttributeId:""};h.active="";h.setRegionCode=function(n){h.regionCode=n;h.getRegion(n)};h.getRegion=function(t){var i=n.getRegion(t).then(function(n){h.region=n},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);h.message="Failed to get Region due to:"+t.join(" ")})};h.getCommodityGroups=function(){var t=n.getCommodityGroups().then(function(n){h.commodityGroups=n;c()},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);h.message="Failed to get Commodity Groups due to:"+t.join(" ")})};h.getCommodities=function(t){var i=n.getCommodities(t).then(function(n){h.commodities=n;l()},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);h.message="Failed to get Commodities due to:"+t.join(" ")})};h.getGroupAttributes=function(t){var i=n.getGroupAttributes(t).then(function(n){h.groupAttributes=n;a()},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);h.message="Failed to get Group attributes due to:"+t.join(" ")})};h.getStats=function(){h.queryParams.commodityGroupId=h.commodityGroup.groupId;h.queryParams.regionCode=h.regionCode;h.queryParams.commodityCode=h.commodity.commodityCode;h.queryParams.groupAttributeId=h.groupAttribute.value;var t=n.getRegionStatistics(h.queryParams).then(function(n){e.commodityGroup=h.commodityGroup;e.commodity=h.commodity;e.groupAttribute=h.groupAttribute;h.regionStats=n;v();y();p();w(h.regionStats.regionAttribSeries,h.regionStats.reportedOn);b(h.regionStats.regionCompositionSeries,h.regionStats.reportedOn,i);k(h.regionStats.regionShareSeries,h.regionStats.reportedOn)},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);h.message="Failed to get Group Stats due to:"+t.join(" ")})};h.showAllCommodities=function(n){h.queryParams.countryCode=n.countryCode;var r={countryCode:n.countryCode,countryName:n.countryName,attributeName:h.regionStats.attributeName,queryParams:h.queryParams};t.showAllCommodities(i,r)};h.saveTableAsImage=function(n){o.download({payload:$(n)[0].innerHTML,payloadtype:"html",imageName:"topCommodities"}).then(function(n){try{var t=new Blob([n],{type:"octet/stream"});s.download(t,"countryStats.png",{type:"octet/stream"})}catch(i){toaster.error({title:"Error",body:"Save as Image not supported on this browser version"})}},function(){toaster.error({title:"Error",body:"Save as Image not supported on this browser version"})})};i.$watch(angular.bind(h,function(){return h.commodityGroup}),function(n,t){!n||t&&n.groupId===t.groupId||(h.getCommodities(n.groupId),h.getGroupAttributes(n.groupId))});i.reflowChart=function(n){h.regionCode&&(n="#"+n+h.regionCode,setTimeout(function(){var t=$(n).highcharts();!t||t.reflow()},100))}}var i=["$scope","$uibModal","$window","browserDetector","regionQueryCache","imageConversionService","SaveAs",r],u=function(n,t,i,r){r.setRegionCode(n.vm.regioncode);r.getCommodityGroups()};return{restrict:"E",controller:i,controllerAs:"vm",bindToController:!0,link:u,scope:{regioncode:"@"},templateUrl:"vizByCommodity/directives/regionStats.html"}};n.directive("regionStats",["commodityStatsService","countrySpecificPopupService",t])}(angular.module("common")),function(n){"use strict";n.value("regionQueryCache",{commodityGroup:null,commodity:null,groupAttribute:null})}(angular.module("common")),function(n){"use strict";var t=function(){var n=this;n.showInstructions=!0;n.commodityGroups=[];n.indexArray=[];n.showGroup=function(t){n.indexArray[t]=!0;n.showInstructions=!1};n.hideGroup=function(t){n.indexArray[t]=!1;n.showInstructions=!0;$.each(n.indexArray,function(t,i){if(i)return n.showInstructions=!1,!1})}};n.controller("statsByCountry",["$scope",t])}(angular.module("common")),function(n){"use strict";var t=function(n,t,i,r,u){var f=this;f.predicate=null;f.reverse=!1;f.order=function(n){f.reverse=f.predicate===n?!f.reverse:!1;f.predicate=n};f.commoditySpecificData=i.commoditySpecificData;f.dto=i.dto;f.attribute=f.dto.attributeName;f.commodityName=f.dto.commodityName;f.currentForecastPeriod=f.commoditySpecificData[0].currentForecastPeriod;f.previousForecastPeriod=f.commoditySpecificData[0].previousForecastPeriod;n.cancel=function(){t.dismiss("cancel")};f.showCountrySpecificCommodities=function(i){t.dismiss("cancel");f.dto.countryName=i.countryName;f.dto.countryCode=i.countryCode;f.dto.queryParams.countryCode=i.countryCode;u.showAllCommodities(n,f.dto)};f.download=function(){var t="AllCtry_"+f.commodityName+"_"+f.attribute+".xls",n=angular.element(".downloadable >table")[0].outerHTML;n='<html><head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><\/head><body>'+n+"<\/body><\/html>";r.download(n,t,{type:"application/vnd.ms-excel;charset=utf-8"})}};n.controller("commoditySpecificRecordsCtrl",["$scope","$uibModalInstance","commoditySpecificRecords","SaveAs","countrySpecificPopupService",t])}(angular.module("common")),function(n){"use strict";var t=function(n,t){var i=function(i,r){var u=n.open({animation:i.animationsEnabled,templateUrl:"vizByCountry/commoditySpecificRecords.html",backdrop:"static",controller:"commoditySpecificRecordsCtrl",controllerAs:"vm",size:"lg",resolve:{commoditySpecificRecords:function(){return t.getCommoditySpecificData(r.queryParams).then(function(n){return{dto:r,commoditySpecificData:n}},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);return"Failed to get Commodity specific Records due to:"+t.join(" ")})}}})};return{showAllCountries:i}};n.factory("commoditySpecificPopupService",["$uibModal","countryStatsService",t])}(angular.module("common")),function(n){"use strict";var t=function(n,t){var i=function(){var n=this,i;n.checkedStatusArray=[];n.trackChange=function(t,i){var r=n.checkedStatusArray[t];r?n.showGroup()(t,i):n.hideGroup()(t,i)};n.groupIdArray=[];i=t.getCommodityGroups().then(function(t){n.commodityGroups=t},function(t){var i=[],r;for(r in t.modelState)i.push(t.modelState[r]);n.message="Failed to get Commodity Groups due to:"+i.join(" ")})},r=function(t,i,r,u){t.manageGroupStats=function(i,r){if(u.trackChange(i,r),u.checkedStatusArray[i]===!1)$("#groupStat"+i).slideUp(500);else if(u.checkedStatusArray[i]===!0)if($("#groupStat"+i).length===1)$("#groupStat"+i).slideDown(500,function(){$("html, body").animate({scrollTop:$("#groupStat"+i).offset().top},1e3)});else{var f=n(' <div id="groupStat'+i+'"><group-stats groupid="'+r+'"><\/group-stats>')(t);$("#statsContainer").append(f);f.css("display","none");f.slideDown(500,function(){$("html, body").animate({scrollTop:f.offset().top},1e3)})}}};return{controller:i,link:r,scope:{showGroup:"&",hideGroup:"&"},controllerAs:"vm",bindToController:!0,templateUrl:"vizByCountry/directives/commodityGroups.html"}};n.directive("commodityGroups",["$compile","countryStatsService",t])}(angular.module("common")),function(n){"use strict";var t=function(n,t){function r(i,r,u,f,e,o,s){function a(){if(!e.region){h.region=h.regions[0];return}$.each(h.regions,function(n,t){if(t.value===e.region.value)return h.region=t,!1})}function v(){if(!e.country&&!!h.countries){h.country=h.countries[0];return}h.country=h.countries[0];$.each(h.countries,function(n,t){if(t.value===e.country.value)return h.country=t,!1});h.country||!h.countries||(h.country=h.countries[0])}function y(){if(!e.groupAttribute){h.groupAttribute=h.groupAttributes[0];return}$.each(h.groupAttributes,function(n,t){if(t.attributeId===e.groupAttribute.attributeId)return h.groupAttribute=t,!1});h.groupAttribute||!h.groupAttributes||(h.groupAttribute=h.groupAttributes[0])}function p(){h.groupResultsHeader=h.region.text+"  >> "+h.country.text;h.groupResultsHeader+=" >> "+h.commodityGroup.groupName+" : "+h.groupAttribute.text;h.groupResultsHeader+=" Reported On: "+h.commodityGroup.lastReportedPeriod.reportingPeriodForDisplay}function w(){h.chartTitle=h.commodityGroup.groupName+" - "+h.groupAttribute.text+" for "+h.country.text}function b(){h.uom=h.groupAttribute.unitOfMeasure}function k(n,t){var i="groupAttribSeries"+h.commodityGroup.groupId;Highcharts.chart(i,{credits:{enabled:!0,text:"Source: FAS USDA",href:"http://www.fas.usda.gov"},title:{text:h.chartTitle,x:-20},subtitle:{text:"Forecast for last 5 Years. Reported On:"+t,x:-20},xAxis:{categories:n.categories,title:{text:"Market Years"}},yAxis:{min:0,title:{text:h.uom},plotLines:[{value:0,width:1,color:"#808080"}]},tooltip:{valueSuffix:h.uom},legend:{layout:"vertical",align:"right",verticalAlign:"middle",borderWidth:0},series:n.dataSeries})}function d(n,t,i){$("#compositionSeries"+h.commodityGroup.groupId).highcharts({credits:{enabled:!0,text:"Source: FAS USDA",href:"http://www.fas.usda.gov"},chart:{type:"pie",options3d:{enabled:!0,alpha:45}},legend:{align:"right",layout:"vertical",verticalAlign:"middle"},title:{text:h.chartTitle},subtitle:{text:"Forecast Data. Reported On:"+t},plotOptions:{series:{point:{events:{mouseOver:function(){h.active=this.options.name.trim();i.$apply()},mouseOut:function(){h.active="";i.$apply()}}}},pie:{innerSize:30,depth:5,showInLegend:!0,dataLabels:{enabled:!0,format:"{point.percentage:.1f} %",style:{color:Highcharts.theme&&Highcharts.theme.contrastTextColor||"black"}}}},tooltip:{headerFormat:"<b>{point.key}<\/b><br/>",pointFormat:"{series.name}: {point.y}"+h.uom},series:[{name:h.groupAttribute.displayName,data:n.dataSeries}]});$("#compositionSeries"+h.commodityGroup.groupId).on("mouseenter",".highcharts-legend-item",function(){h.active=$(this).text().trim();i.$apply()}).on("mouseleave",".highcharts-legend-item",function(){h.active="";i.$apply()})}function g(n,t){$("#shareSeries"+h.commodityGroup.groupId).highcharts({credits:{enabled:!0,text:"Source: FAS USDA",href:"http://www.fas.usda.gov"},chart:{type:"column"},title:{text:h.chartTitle},subtitle:{text:"Forecast Data. Reported On:"+t},xAxis:{categories:n.categories},yAxis:{min:0,title:{text:h.uom},stackLabels:{enabled:!0,style:{fontWeight:"normal",color:Highcharts.theme&&Highcharts.theme.textColor||"gray"}}},legend:{align:"center",verticalAlign:"bottom",backgroundColor:Highcharts.theme&&Highcharts.theme.background2||"white",borderColor:"#CCC",borderWidth:1,shadow:!1},tooltip:{headerFormat:"<b>{point.x}<\/b><br/>",pointFormat:"{series.name}: {point.y}"+h.uom+"<br/>Total: {point.stackTotal}"+h.uom},plotOptions:{column:{stacking:"normal",dataLabels:{enabled:!1,color:Highcharts.theme&&Highcharts.theme.dataLabelsColor||"white"}}},series:n.dataSeries})}var h=this,c,l;h.chartTitle=null;h.groupResultsHeader=null;h.uom=null;h.queryParams={commodityGroupId:"",commodityId:"",regionCode:"",countryCode:"",groupAttributeId:""};h.groupStats=null;h.commodityGroup=null;h.regions=null;h.countries=null;h.groupAttributes=null;h.region=null;h.country=null;h.groupAttribute=null;h.active="";h.getCommodityGroup=function(t){var i=n.getCommodityGroup(t).then(function(n){h.commodityGroup=n},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);h.message="Failed to get Commodity Groups due to:"+t.join(" ")})};h.getRegions=function(){var t=n.getRegions().then(function(n){h.regions=n;a()},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);h.message="Failed to get Regions due to:"+t.join(" ")})};h.getCountries=function(){var t=n.getCountries(h.commodityGroup.groupId,h.region.value).then(function(n){h.countries=n;v()},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);h.message="Failed to get Countries due to:"+t.join(" ")})};h.getGroupAttributes=function(t){var i=n.getGroupAttributes(t).then(function(n){h.groupAttributes=n;y()},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);h.message="Failed to get Group attributes due to:"+t.join(" ")})};h.getStats=function(){h.queryParams.commodityGroupId=h.commodityGroup.groupId;h.queryParams.regionCode=h.region.value;h.queryParams.countryCode=h.country.value;h.queryParams.groupAttributeId=h.groupAttribute.value;e.region=h.region;e.country=h.country;e.groupAttribute=h.groupAttribute;var t=n.getGroupStatistics(h.queryParams).then(function(n){p();w();b();h.groupStats=n;k(h.groupStats.groupAttribSeries,h.groupStats.reportedOn);d(h.groupStats.compositionSeries,h.groupStats.reportedOn,i);g(h.groupStats.groupShareSeries,h.groupStats.reportedOn)},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);h.message="Failed to get Group Stats due to:"+t.join(" ")})};h.showAllCountries=function(n){h.queryParams.commodityId=n.commodityId;h.queryParams.commodityGroupId=h.commodityGroup.groupId;var r={commodityName:n.commodityName,attributeName:h.groupStats.attributeName,queryParams:h.queryParams};t.showAllCountries(i,r)};c=i.$watch(angular.bind(h,function(){return h.commodityGroup}),function(n,t){!n||t&&n.groupId===t.groupId||(h.getCountries(),l(),c())});l=function(){i.$watch(angular.bind(h,function(){return h.region}),function(n,t){!n||t&&n.value===t.value||h.getCountries()})};h.saveTableAsImage=function(n){o.download({payload:$(n)[0].innerHTML,payloadtype:"html",imageName:"topCommodities"}).then(function(n){try{var t=new Blob([n],{type:"octet/stream"});s.download(t,"commodityStats.png",{type:"octet/stream"})}catch(i){f.error({title:"Error",body:"Save as Image not supported on this browser version"})}},function(){f.error({title:"Error",body:"Save as Image not supported on this browser version"})})};i.reflowChart=function(n){h.commodityGroup&&(n="#"+n+h.commodityGroup.groupId,setTimeout(function(){var t=$(n).highcharts();!t||t.reflow()},100))}}var i=["$scope","$uibModal","$window","toaster","commodityGroupQueryCache","imageConversionService","SaveAs",r],u=function(n,t,i,r){r.getCommodityGroup(n.vm.groupid);r.getGroupAttributes(n.vm.groupid);r.getRegions()};return{restrict:"E",controller:i,controllerAs:"vm",bindToController:!0,link:u,scope:{groupid:"@"},templateUrl:"vizByCountry/directives/groupStats.html"}};n.directive("groupStats",["countryStatsService","commoditySpecificPopupService",t])}(angular.module("common")),function(n){"use strict";n.value("commodityGroupQueryCache",{region:null,country:null,groupAttribute:null})}(angular.module("common")),function(n){"use strict";var t=function(n,t,i){var r=this;r.showInstructions=!0;r.showOptGroup=!1;r.selectedRegion=null;r.countries=null;r.selectedCountry=null;r.topCommoditiesByCountry=null;r.scaleType="bestfit";n.$on("regionChangedEvent",function(n,t){r.selectedRegion=t;r.showInstructions=!1;r.getCountries(t);console.log(t)});r.getCountries=function(n){r.showOptGroup=n.regionCode==="R05";console.log(n);var i=t.getCountries(0,r.selectedRegion.regionCode).then(function(n){r.countries=n;r.selectedCountry=r.countries[0]},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);r.message="Failed to get Countries due to:"+t.join(" ")})};r.getTopCommoditiesByCountry=function(){var n=i.getTopCommoditiesByCountry(r.selectedCountry.value).then(function(n){r.topCommoditiesByCountry=n},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);r.message="Failed to get Top Commodities due to:"+t.join(" ")})}};n.controller("topCommoditiesByCountry",["$scope","countryStatsService","commodityStatsService",t])}(angular.module("common")),function(n){"use strict";var t=function(n,t){var i=this,r;i.regionChanged=function(t){n.$emit("regionChangedEvent",t)};r=function(){t.getGeographicRegions().then(function(n){i.geographicRegions=n},function(n){var t=[],r;for(r in n.modelState)t.push(n.modelState[r]);i.message="Failed to get Geographic Regions due to:"+t.join(" ")})};i.$onInit=function(){r()}};n.component("singleSelectRegions",{templateUrl:"VizTopCommoditiesByCountry/directives/singleSelectRegions.html",bindings:{},controllerAs:"model",controller:["$scope","commodityStatsService",t]})}(angular.module("common")),function(n){"use strict";var t=function(n,t,i,r,u,f,e){var o=this,s,h,a,c,l;o.saveAsPngSupported=r.isExportToPngSupported();s=!1;o.key="";h=function(){o.key=o.vizData.yAxisLabelFragment+" % World "+o.vizData.attribute;var n=o.scaleType==="bestfit"?o.vizData.yAxisMaxValue:100;$("#chart"+o.vizData.attributeId).highcharts({credits:{enabled:!0,text:"Source: FAS USDA",href:"http://www.fas.usda.gov"},chart:{type:"bar"},title:{text:"Latest forecast on file: "+o.key},xAxis:{type:"category",categories:o.vizData.categories},yAxis:{min:0,title:{text:""},stackLabels:{enabled:!0,style:{fontWeight:"normal",color:Highcharts.theme&&Highcharts.theme.textColor||"gray"}}},legend:{align:"center",verticalAlign:"bottom",backgroundColor:Highcharts.theme&&Highcharts.theme.background2||"white",borderColor:"#CCC",borderWidth:1,shadow:!1},tooltip:{headerFormat:"<b>{point.x}<\/b><br/>",pointFormat:"{series.name}: {point.y} %<br/>"},plotOptions:{series:{borderWidth:0,dataLabels:{enabled:!0,format:"{point.y:.1f}%"}}},series:[{name:"% of World",color:"#3882AB",data:o.vizData.dataSeries}]})};a=function(){};n.$watch(angular.bind(o,function(){return o.vizData}),function(n,i){!n||i&&n===i||(s=!1,t(function(){h()},200))});n.$watch(angular.bind(o,function(){return o.scaleType}),function(n,i){!n||i&&n===i||t(function(){var n=o.scaleType==="bestfit"?o.vizData.yAxisMaxValue:100;$("#chart"+o.vizData.attributeId).highcharts().yAxis[0].setExtremes(0,n)},200)});o.saveAsImage=function(n){o.vizType==="chart"?c("#chart"+n):o.vizType==="table"&&l("#table"+n)};c=function(n){var t=angular.element(n)[0],r=t.childNodes[0];i.saveSvgAsPng(r,o.key+".png",{backgroundColor:"white",scale:2})};l=function(n){e.download({payload:$(n)[0].innerHTML,payloadtype:"html",imageName:"topCommodities"}).then(function(n){try{var t=new Blob([n],{type:"octet/stream"});u.download(t,o.key+".png",{type:"octet/stream"})}catch(i){f.error({title:"Error",body:"Save as Image not supported on this browser version"})}},function(){f.error({title:"Error",body:"Save as Image not supported on this browser version"})})};o.download=function(n){var i="#table"+n+" > table",t=angular.element(i)[0].outerHTML;t='<html><head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><\/head><body>'+t+"<\/body><\/html>";u.download(t,o.key+".xls",{type:"application/vnd.ms-excel;charset=utf-8"})}};n.component("topCommoditiesChart",{templateUrl:"VizTopCommoditiesByCountry/directives/topCommoditiesChart.html",bindings:{vizType:"<",scaleType:"<",vizData:"<"},controllerAs:"model",controller:["$scope","$timeout","$window","browserDetector","SaveAs","toaster","imageConversionService",t]})}(angular.module("common")),function(n){"use strict";var t=function(n,t,i){var r=this;r.showInstructions=!0;r.selectedcGroup=null;r.commodities=null;r.selectedCommodity=null;r.topCountriesByCommodity=null;r.scaleType="bestfit";n.$on("commodityGroupChangedEvent",function(n,t){r.selectedcGroup=t;r.showInstructions=!1;r.getCommodities(t);console.log(t)});r.getCommodities=function(n){var i=t.getCommodities(n.groupId).then(function(n){r.commodities=n;r.selectedCommodity=r.commodities[0]},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);r.message="Failed to get Commodities due to:"+t.join(" ")})};r.getTopCountriesByCommodity=function(){var n=i.getTopCountriesByCommodity(r.selectedCommodity.commodityCode).then(function(n){r.topCountriesByCommodity=n},function(n){var t=[],i;for(i in n.modelState)t.push(n.modelState[i]);r.message="Failed to get Top Commodities due to:"+t.join(" ")})}};n.controller("topCountriesByCommodity",["$scope","commodityStatsService","countryStatsService",t])}(angular.module("common")),function(n){"use strict";var t=function(n,t,i){var r=this;r.scaleType="bestfit";r.vizType="chart";r.xScaleChanged=function(n){r.scaleType=n};r.vizTypeChanged=function(n){r.vizType=n};r.scrollTo=function(n){var u=r.vizType+n;t.hash(u);i.scrollTo(u)}};n.component("vizPreferences",{templateUrl:"VizTopCountriesByCommodity/directives/vizPreferences.html",bindings:{scaleType:"=",vizType:"="},controllerAs:"model",controller:["$scope","$location","anchorSmoothScroll",t]})}(angular.module("common")),function(n){"use strict";var t=function(n,t,i,r,u,f,e){var o=this,s,h,c,l;o.saveAsPngSupported=r.isExportToPngSupported();o.key="";s=!1;h=function(){o.key=o.vizData.yAxisLabelFragment+" % World "+o.vizData.attribute;var n=o.scaleType==="bestfit"?o.vizData.yAxisMaxValue:100;$("#chart"+o.vizData.attributeId).highcharts({credits:{enabled:!0,text:"Source: FAS USDA",href:"http://www.fas.usda.gov"},chart:{type:"bar"},title:{text:"Latest forecast on file: "+o.key},xAxis:{type:"category",categories:o.vizData.categories},yAxis:{min:0,max:n,title:{text:""},stackLabels:{enabled:!0,style:{fontWeight:"normal",color:Highcharts.theme&&Highcharts.theme.textColor||"gray"}}},legend:{align:"center",verticalAlign:"bottom",backgroundColor:Highcharts.theme&&Highcharts.theme.background2||"white",borderColor:"#CCC",borderWidth:1,shadow:!1},tooltip:{headerFormat:"<b>{point.x}<\/b><br/>",pointFormat:"{series.name}: {point.y} %<br/>"},plotOptions:{series:{borderWidth:0,dataLabels:{enabled:!0,format:"{point.y:.1f}%"}}},series:[{name:"% of World",color:"#3882AB",data:o.vizData.dataSeries}]})};n.$watch(angular.bind(o,function(){return o.vizData}),function(n,i){!n||i&&n===i||(s=!1,t(function(){h()},200))});n.$watch(angular.bind(o,function(){return o.scaleType}),function(n,i){!n||i&&n===i||t(function(){var n=o.scaleType==="bestfit"?o.vizData.yAxisMaxValue:100;$("#chart"+o.vizData.attributeId).highcharts().yAxis[0].setExtremes(0,n)},200)});o.saveAsImage=function(n){o.vizType==="chart"?c("#chart"+n):o.vizType==="table"&&l("#table"+n)};c=function(n){var t=angular.element(n)[0],r=t.childNodes[0];i.saveSvgAsPng(r,o.key+".png",{backgroundColor:"white",scale:2})};l=function(n){e.download({payload:$(n)[0].innerHTML,payloadtype:"html",imageName:"topCommodities"}).then(function(n){try{var t=new Blob([n],{type:"octet/stream"});u.download(t,o.key+".png",{type:"octet/stream"})}catch(i){f.error({title:"Error",body:"Save as Image not supported on this browser version"})}},function(){f.error({title:"Error",body:"Save as Image not supported on this browser version"})})};o.download=function(n){var i="#table"+n+" > table",t=angular.element(i)[0].outerHTML;t='<html><head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><\/head><body>'+t+"<\/body><\/html>";u.download(t,o.key+".xls",{type:"application/vnd.ms-excel;charset=utf-8"})}};n.component("topCountriesChart",{templateUrl:"VizTopCountriesByCommodity/directives/topCountriesChart.html",bindings:{vizType:"<",scaleType:"<",vizData:"<",chartColor:"<"},controllerAs:"model",controller:["$scope","$timeout","$window","browserDetector","SaveAs","toaster","imageConversionService",t]})}(angular.module("common")),function(n){"use strict";var t=function(n,t){var i=this,r;i.commodityGroupChanged=function(t){n.$emit("commodityGroupChangedEvent",t)};r=function(){t.getCommodityGroups().then(function(n){i.commodityGroups=n},function(n){var t=[],r;for(r in n.modelState)t.push(n.modelState[r]);i.message="Failed to get Commodity Groups due to:"+t.join(" ")})};i.$onInit=function(){r()}};n.component("singleSelectCgroups",{templateUrl:"VizTopCountriesbyCommodity/directives/singleSelectCgroups.html",bindings:{},controllerAs:"model",controller:["$scope","countryStatsService",t]})}(angular.module("common"))