// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://js.arcgis.com/3.23/esri/copyright.txt for details.
//>>built
define("esri/dijit/geoenrichment/ReportPlayer/core/charts/chartUtils/builder/_RoundChartBuilder","dojo/_base/declare dojo/_base/lang ../ThemeCalculator ../ChartTypes ../ChartSorting ../../../supportClasses/conditionalStyling/ConditionalStyleUtil ../plots/Pie ../plots/Donut ../plots/Gauge ../plots/Ring ./_ChartDataUtil ./_TooltipInfoBuilder ./_ChartDataLabelBuilder ./ChartPlots dojo/i18n!../../../../../../../nls/jsapi".split(" "),function(K,l,x,d,y,z,p,E,F,G,A,H,I,J,k){k=k.geoenrichment.dijit.ReportPlayer.ReportPlayer;
var D={configureChart:function(a){a.chart.addPlot(J.PRIMARY,this._createPiePlot(a.visualProperties,a.themeSettings,a.viewModel,a.chartType))},_createPiePlot:function(a,h,e,m){var k=-1!==a.dataLabels.indexOf("Label"),g=-1!==a.dataLabels.indexOf("Value"),q=-1!==a.dataLabels.indexOf("Percent");h=l.mixin({},h.dataLabelsStyle,a.dataLabelsStyle);a=(k||g||q)&&m!==d.GAUGE?{labelStyle:a.dataLabelsStackedInColumns?"columns":a.dataLabelsInside?"inside":"outside",htmlLabels:!0,font:x.combineFontString(h),fontColor:h.color,
omitLabels:!a.dataLabelsStackedInColumns}:{labels:!1};e=e.dynamicReportInfo&&e.chartAnimationAllowed?{animate:!0}:null;var b;switch(m){case d.PIE:b=p;break;case d.DONUT:b=E;break;case d.GAUGE:b=F;break;case d.RING:b=G}return b?l.mixin({type:b,fontColor:"black"},a,e):null},calcSeries:function(a){var h=a.seriesItems,e=a.chartType,m=a.themeSettings,l=a.viewModel,g=a.visualProperties,q=a.previewFeatureIndex,b=a.sorting;a=[];var r=h[0],t={name:"data",data:[]},u=[],n=0,v=1E6,w=-1E6,B,c=r.points;e===d.GAUGE&&
1===c.length&&(c=c.slice(),c.push({label:k.gaugeOthers}));if(this.supportConditionalStyling(e)&&g.conditionalStyling){var C=z.getStatistics(g.conditionalStyling);C&&r&&(B=A.getChartData(C,c.length))}c.forEach(function(a,b){var f;f=e===d.GAUGE&&1===b?Math.max(0,100-u[0]):A.getPreviewValue(a,b,0,!1,l,q,B);f=(u[b]=f)||0;n+=f;v=Math.min(v,f);w=Math.max(w,f)});var p=n/c.length;c.forEach(function(a,b){var f=u[b],d=f||0,c;D.supportConditionalStyling(e)&&g.conditionalStyling&&(c=(c=z.getConditionalStyle(d,
g.conditionalStyling))&&c.backgroundColor);c=c||x.calcColorForPoint(a,r,b,0,h.length,e,m);t.data.push({x:1,y:Math.max(1E-4,d),isUnavailableData:isNaN(f),valueProp:"y",unsortedIndex:b,name:a.label,point:a,fill:c,text:I.formatDataLabel(d,a.label,n,g,e),tooltip:H.getTooltipInfo(f,a.label,null,v,w,n,p,g,e,c,g.conditionalStyling),stroke:{width:0}})});this.supportsSorting(e)&&b&&b!==y.NONE&&t.data.sort(function(a,c){return(a.y-c.y)*(b===y.DESC?-1:1)});a.push(t);return a},supportConditionalStyling:function(a){return d.isConditionalStylingEnabled(a)},
supportsSorting:function(a){return d.isSortingEnabled(a)},getFullSeriesItems:function(a){return a.seriesItems}};return D});