UNPKG

561 kBJavaScriptView Raw
1!function(e){function t(a){if(i[a])return i[a].exports;var r=i[a]={exports:{},id:a,loaded:!1};return e[a].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var i={};return t.m=e,t.c=i,t.p="",t(0)}([function(e,t,i){e.exports=i(13)},,,,,,,,,,,,,function(e,t,i){function a(e){return e.keys().map(e)}window.jsCommon,window.powerbi,window.powerbitests,window.InJs,window.debug,window.jasmine,window.Microsoft;window.jsCommon=window.jsCommon||{},window.powerbi=window.powerbi||{},window.debug=window.debug||{},window.InJs=window.InJs||{},a(i(14)),i(37)},function(e,t,i){function a(e){return i(r(e))}function r(e){return s[e]||function(){throw new Error("Cannot find module '"+e+"'.")}()}var s={"./styles/styles.less":15,"./visuals/asterPlot/visual/styles/asterPlot.less":17,"./visuals/bulletChart/visual/styles/bulletChart.less":18,"./visuals/chicletSlicer/visual/styles/chicletSlicer.less":19,"./visuals/chordChart/visual/styles/chordChart.less":20,"./visuals/dotPlot/visual/styles/dotPlot.less":21,"./visuals/enhancedScatterChart/visual/styles/enhancedScatterChart.less":22,"./visuals/forceGraph/visual/styles/forceGraph.less":23,"./visuals/gantt/visual/styles/gantt.less":24,"./visuals/globeMap/visual/styles/globeMap.less":25,"./visuals/histogram/visual/styles/histogram.less":26,"./visuals/lineDotChart/visual/styles/lineDotChart.less":27,"./visuals/mekkoChart/visual/styles/mekkoChart.less":28,"./visuals/pulseChart/visual/styles/pulseChart.less":29,"./visuals/radarChart/visual/styles/radarChart.less":30,"./visuals/sankeyDiagram/visual/styles/sankeyDiagram.less":31,"./visuals/streamGraph/visual/styles/streamGraph.less":32,"./visuals/sunburst/visual/styles/sunburst.less":33,"./visuals/timeline/visual/styles/timeline.less":34,"./visuals/tornadoChart/visual/styles/tornadoChart.less":35,"./visuals/wordCloud/visual/styles/wordCloud.less":36};a.keys=function(){return Object.keys(s)},a.resolve=r,e.exports=a,a.id=14},function(e,t){},,function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t){},function(e,t,i){window.jsCommon,window.powerbi,window.powerbitests,window.InJs,window.debug,window.jasmine,window.Microsoft;i(38),i(39),i(40),i(41),i(42),i(43),i(44),i(45),i(46),i(47),i(48),i(49),i(50),i(51),i(52),i(53),i(54),i(55),i(56),i(57),i(58)},function(e,t){var i,a=window.jsCommon,i=window.powerbi;window.powerbitests,window.InJs,window.debug,window.jasmine,window.Microsoft;!function(e){var t;!function(t){var i;!function(i){var r=a.CssConstants.createClassAndSelector,s=a.PixelConverter,o=e.visuals.valueFormatter,n="asterPlot",l=.9,c=.9,u=function(){function e(){}return e.prototype.bindEvents=function(e,t){this.selection=e.selection,this.clearCatcher=e.clearCatcher,this.interactivityService=e.interactivityService,this.hasHighlights=e.hasHighlights,this.selection.on("click",function(e,i){t.handleSelection(e.data,d3.event.ctrlKey)}),this.clearCatcher.on("click",function(){t.handleClearSelection()}),this.renderSelection(this.interactivityService.hasSelection())},e.prototype.renderSelection=function(e){var i=this;this.selection.style("fill-opacity",function(a){return t.ColumnUtil.getFillOpacity(a.data.selected,a.data.highlight,e,i.hasHighlights)})},e}(),h=function(){function e(e){this.message=e}return Object.defineProperty(e.prototype,"code",{get:function(){return"AsterPlotWarning"},enumerable:!0,configurable:!0}),e.prototype.getMessages=function(e){return{message:this.message,title:e.get(""),detail:e.get("")}},e}();i.AsterPlotWarning=h;var p=function(){function e(e,t){this.defaultViewport=e||{width:0,height:0},this.defaultMargin=t||{top:0,bottom:0,right:0,left:0}}return Object.defineProperty(e.prototype,"viewport",{get:function(){return this.viewportValue||(this.viewportValue=this.defaultViewport)},set:function(t){var i=this;this.previousOriginalViewportValue=_.clone(this.originalViewportValue),this.originalViewportValue=_.clone(t),this.setUpdateObject(t,function(e){return i.viewportValue=e},function(t){return e.restrictToMinMax(t,i.minViewport)})},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"viewportCopy",{get:function(){return _.clone(this.viewport)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"viewportIn",{get:function(){return this.viewportInValue||this.viewport},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"minViewport",{get:function(){return this.minViewportValue||{width:0,height:0}},set:function(t){var i=this;this.setUpdateObject(t,function(e){return i.minViewportValue=e},e.restrictToMinMax)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"margin",{get:function(){return this.marginValue||(this.marginValue=this.defaultMargin)},set:function(t){var i=this;this.setUpdateObject(t,function(e){return i.marginValue=e},e.restrictToMinMax)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"viewportChanged",{get:function(){return!(!this.originalViewportValue||this.previousOriginalViewportValue&&this.previousOriginalViewportValue.height===this.originalViewportValue.height&&this.previousOriginalViewportValue.width===this.originalViewportValue.width)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"viewportInIsZero",{get:function(){return 0===this.viewportIn.width||0===this.viewportIn.height},enumerable:!0,configurable:!0}),e.prototype.resetMargin=function(){this.margin=this.defaultMargin},e.prototype.update=function(){this.viewportInValue=e.restrictToMinMax({width:this.viewport.width-(this.margin.left+this.margin.right),height:this.viewport.height-(this.margin.top+this.margin.bottom)},this.minViewportValue)},e.prototype.setUpdateObject=function(t,i,a){var r=this;t=_.clone(t),i(e.createNotifyChangedObject(t,function(e){a&&a(t),r.update()})),a&&a(t),this.update()},e.createNotifyChangedObject=function(e,t){var i={};return _.keys(e).forEach(function(a){return Object.defineProperty(i,a,{get:function(){return e[a]},set:function(i){e[a]=i,t(e,a)},enumerable:!0,configurable:!0})}),i},e.restrictToMinMax=function(e,t){return _.keys(e).forEach(function(i){return e[i]=Math.max(t&&t[i]||0,e[i])}),e},e}(),d=function(){function e(){}return e.setAttrThroughTransitionIfNotResized=function(e,t,i,a,r,s){s?e.attr(i,a):t(e.transition()).attrTween(i,r)},e.interpolateArc=function(e){return function(t){if(!this.oldData)return this.oldData=t,function(){return e(t)};var i=d3.interpolate(this.oldData,t);return this.oldData=i(0),function(t){return e(i(t))}}},e.addContext=function(e,t){return function(){return t.apply(e,[this].concat(_.toArray(arguments)))}},e}(),g=function(){function i(){this.legend={show:!1,position:t.LegendPosition[t.LegendPosition.Top],showTitle:!0,titleText:"",labelColor:t.LegendData.DefaultLegendLabelFillColor,fontSize:8},this.labels={show:!1,color:t.dataLabelUtils.defaultLabelColor,displayUnits:0,precision:t.dataLabelUtils.defaultLabelPrecision,fontSize:t.dataLabelUtils.DefaultFontSizeInPt},this.outerLine={show:!1,thickness:1}}return Object.defineProperty(i,"Default",{get:function(){return new this},enumerable:!0,configurable:!0}),i.parse=function(e,t){var i=new this;if(!e||!e.metadata||!e.metadata.objects)return i;var a=this.getProperties(t);for(var r in t.objects)for(var s in t.objects[r].properties)if(i[r]&&_.has(i[r],s)){var o=t.objects[r].properties[s].type,n=this.getValueFnByType(o);i[r][s]=n(e.metadata.objects,a[r][s],i[r][s])}return i},i.getProperties=function(e){var t=_.merge({general:{properties:{formatString:{}}}},e.objects),i={};for(var a in t){i[a]={};for(var r in t[a].properties)i[a][r]={objectName:a,propertyName:r}}return i},i.createEnumTypeFromEnum=function(t){var i=!1;return e.createEnumType(Object.keys(t).filter(function(e,a){return!!(a%2)===i&&t[e]===e&&!void(i=!i)||!!(a%2)!==i}).map(function(e){return{value:e,displayName:e}}))},i.getValueFnByType=function(t){switch(_.keys(t)[0]){case"fill":return e.DataViewObjects.getFillColor;default:return e.DataViewObjects.getValue}},i.enumerateObjectInstances=function(e,i,a){void 0===e&&(e=new this);var r=new t.ObjectEnumerationBuilder,s=e&&e[i.objectName];if(!s)return r;var o={objectName:i.objectName,selector:null,properties:{}};for(var n in s)_.has(s,n)&&(o.properties[n]=s[n]);return r.pushInstance(o),r},i.prototype.createOriginalSettings=function(){this.originalSettings=_.cloneDeep(this)},i}();i.AsterPlotSettings=g;var m=function(){function e(){this.Category=null,this.Y=null}return e.getColumnSources=function(e){return this.getColumnSourcesT(e)},e.getTableValues=function(e){var t=e&&e.table,i=this.getColumnSourcesT(e);return i&&t&&_.mapValues(i,function(e,i){return e&&t.rows.map(function(t){return t[e.index]})})},e.getTableRows=function(e){var t=e&&e.table,i=this.getColumnSourcesT(e);return i&&t&&t.rows.map(function(e){return _.mapValues(i,function(t,i){return t&&e[t.index]})})},e.getCategoricalValues=function(e){var t=e&&e.categorical,i=t&&t.categories||[],a=t&&t.values||[],r=t&&a.source&&this.getSeriesValues(e);return t&&_.mapValues(new this,function(e,t){return _.toArray(i).concat(_.toArray(a)).filter(function(e){return e.source.roles&&e.source.roles[t]}).map(function(e){return e.values})[0]||a.source&&a.source.roles&&a.source.roles[t]&&r})},e.getSeriesValues=function(e){return e&&e.categorical&&e.categorical.values&&e.categorical.values.map(function(e){return t.converterHelper.getSeriesName(e.source)})},e.getCategoricalColumns=function(e){var t=e&&e.categorical,i=t&&t.categories||[],a=t&&t.values||[];return t&&_.mapValues(new this,function(e,t){return i.filter(function(e){return e.source.roles&&e.source.roles[t]})[0]||a.source&&a.source.roles&&a.source.roles[t]||a.filter(function(e){return e.source.roles&&e.source.roles[t]})})},e.getColumnSourcesT=function(e){var t=e&&e.metadata&&e.metadata.columns;return t&&_.mapValues(new this,function(e,i){return t.filter(function(e){return e.roles&&e.roles[i]})[0]})},e.Roles=Object.freeze(_.mapValues(new e,function(e,t){return t})),e}();i.AsterPlotColumns=m;var y=function(){function i(){}return i.converter=function(e,a){var r=m.getCategoricalColumns(e),n=m.getCategoricalValues(e);if(r&&r.Category&&!_.isEmpty(r.Category.values)&&!_.isEmpty(r.Y)&&!_.isEmpty(r.Y[0].values)){for(var l=i.parseSettings(e,r.Category.source),c=g.getProperties(i.capabilities),u=[],h=[],p={dataPoints:[],title:null,fontSize:g.Default.legend.fontSize,labelColor:t.LegendData.DefaultLegendLabelFillColor},d=new t.ColorHelper(a),y=!!r.Y[0].highlights,f=Math.max(d3.min(r.Y[0].values)),v=Math.min(0,d3.min(r.Y[0].values)),x=o.create({format:o.getFormatString(r.Y[0].source,c.general.formatString),precision:l.labels.precision,value:0===l.labels.displayUnits&&null!=f?f:l.labels.displayUnits}),b=t.valueFormatter.getFormatString(r.Category.source,c.general.formatString),S=s.fromPoint(l.labels.fontSize),w=0;w<n.Category.length;w++){var C=t.valueFormatter.format(n.Category[w],b),P=r.Y[0].values[w],D=t.TooltipBuilder.createTooltipInfo(c.general.formatString,e.categorical,C,P,null,null,0);if(r.Y.length>1){var A=t.TooltipBuilder.createTooltipInfo(c.general.formatString,e.categorical,C,r.Y[1].values[w],null,null,1)[1];A&&D.push(A),P+=r.Y[1].values[w]}var T=r.Category.identity[w],V=d.getColorForMeasure(r.Category.objects&&r.Category.objects[w],T.key),N=t.SelectionId.createWithId(T),L=Math.max(0,r.Y.length>1?r.Y[1].values[w]:1);if(L>0&&u.push({sliceHeight:r.Y[0].values[w]-v,sliceWidth:L,label:x.format(P),color:V,identity:N,selected:!1,tooltipInfo:D,labelFontSize:S,highlight:!1}),l.legend.show&&p.dataPoints.push({label:C,color:V,icon:t.LegendIcon.Box,selected:!1,identity:N}),y){var M=t.SelectionId.createWithHighlight(N),k=null!=r.Y[0].highlights[w];if(P=k?r.Y[0].highlights[w]:0,D=t.TooltipBuilder.createTooltipInfo(c.general.formatString,e.categorical,C,P,null,null,0),r.Y.length>1){var A=t.TooltipBuilder.createTooltipInfo(c.general.formatString,e.categorical,C,r.Y[1].highlights[w],null,null,1)[1];A&&D.push(A),P+=null!==r.Y[1].highlights[w]?r.Y[1].highlights[w]:0}h.push({sliceHeight:k?r.Y[0].highlights[w]-v:null,sliceWidth:Math.max(0,r.Y.length>1&&null!==r.Y[1].highlights[w]?r.Y[1].highlights[w]:L),label:x.format(P),color:V,identity:M,selected:!1,tooltipInfo:D,labelFontSize:S,highlight:!0})}}return u.length&&{dataPoints:u,settings:l,hasHighlights:y,legendData:p,highlightedDataPoints:h,labelFormatter:x,centerText:r.Category.source.displayName}}},i.parseSettings=function(e,t){var a=g.parse(e,i.capabilities);return a.labels.precision=Math.min(17,Math.max(0,a.labels.precision)),a.outerLine.thickness=Math.min(300,Math.max(1,a.outerLine.thickness)),a.createOriginalSettings(),_.isEmpty(a.legend.titleText)&&(a.legend.titleText=t.displayName),a},Object.defineProperty(i.prototype,"settings",{get:function(){return this.data&&this.data.settings},enumerable:!0,configurable:!0}),i.prototype.init=function(e){this.hostServices=e.host,this.hostServices.canSelect=function(e){return!(e.data&&e.data.length>1&&e.data.some(function(e){return e&&e.data&&e.data.length>1}))},this.layout=new p(e.viewport,{top:10,right:10,bottom:15,left:10});var a=e.element,r=this.svg=d3.select(a.get(0)).append("svg").classed(n,!0).style("position","absolute");this.colors=e.style.colorPalette.dataColors,this.mainGroupElement=r.append("g"),this.mainLabelsElement=r.append("g"),this.behavior=new u,this.clearCatcher=t.appendClearCatcher(this.mainGroupElement),this.slicesElement=this.mainGroupElement.append("g").classed(i.AsterSlices["class"],!0);var s=e.interactivity;this.interactivityService=t.createInteractivityService(this.hostServices),this.legend=t.createLegend(a,s&&s.isInteractiveLegend,this.interactivityService,!0)},i.prototype.update=function(e){if(e&&e.dataViews&&e.dataViews[0]){this.layout.viewport=e.viewport;var a=e.suppressAnimations?0:t.AnimatorCommon.MinervaAnimationDuration,r=i.converter(e.dataViews[0],this.colors);if(!r)return void this.clear();this.data=r,this.interactivityService&&(this.interactivityService.applySelectionStateToData(this.data.dataPoints),this.interactivityService.applySelectionStateToData(this.data.highlightedDataPoints)),this.renderLegend(),this.updateViewPortAccordingToLegend(),this.svg.attr(this.layout.viewport);var s=(this.layout.viewportIn.width+this.layout.margin.right)/2,o=(this.layout.viewportIn.height+this.layout.margin.bottom)/2;if(this.mainGroupElement.attr("transform",t.SVGUtil.translate(s,o)),this.mainLabelsElement.attr("transform",t.SVGUtil.translate(s,o)),this.clearCatcher.attr("transform",t.SVGUtil.translate(-s,-o)),t.dataLabelUtils.cleanDataLabels(this.mainLabelsElement,!0),this.renderArcsAndLabels(a),this.data.hasHighlights?this.renderArcsAndLabels(a,!0):this.slicesElement.selectAll(i.AsterHighlightedSlice.selector).remove(),this.interactivityService){var n={selection:this.slicesElement.selectAll(i.AsterSlice.selector+", "+i.AsterHighlightedSlice.selector),clearCatcher:this.clearCatcher,interactivityService:this.interactivityService,hasHighlights:this.data.hasHighlights};this.interactivityService.bind(this.data.dataPoints.concat(this.data.highlightedDataPoints),this.behavior,n)}}},i.prototype.renderArcsAndLabels=function(e,a){var r=this;void 0===a&&(a=!1);var s=Math.min(this.layout.viewportIn.width,this.layout.viewportIn.height)/2,o=.3*(this.settings.labels.show?s*l:s),n=d3.max(this.data.dataPoints,function(e){return e.sliceHeight}),c=d3.sum(this.data.dataPoints,function(e){return e.sliceWidth}),u=d3.layout.pie().sort(null).value(function(e){return(e&&!isNaN(e.sliceWidth)?e.sliceWidth:0)/c}),h=d3.svg.arc().innerRadius(o).outerRadius(function(e){var t=(s-o)*(e&&e.data&&!isNaN(e.data.sliceHeight)?e.data.sliceHeight:1)/n,i=o+(r.settings.labels.show?t*l:t);return Math.max(i,o)}),p=u(a?this.data.highlightedDataPoints:this.data.dataPoints),g=a?i.AsterHighlightedSlice:i.AsterSlice,m=this.slicesElement.selectAll(g.selector).data(p,function(e,t){return e.data?e.data.identity.getKey():t});if(m.enter().append("path").classed(g["class"],!0).attr("stroke","#333"),m.attr("fill",function(e){return e.data.color}).call(function(t){return d.setAttrThroughTransitionIfNotResized(t,function(t){return t.duration(e)},"d",h,d.interpolateArc(h),r.layout.viewportChanged)}),m.exit().remove(),t.TooltipManager.addTooltip(m,function(e){return e.data.data.tooltipInfo}),this.settings.labels.show&&(!this.data.hasHighlights||this.data.hasHighlights&&a)){var y=function(e){var t=s*(e&&!isNaN(e.sliceHeight)?e.sliceHeight:1)/n+o;return Math.max(t,o)},f=d3.svg.arc().innerRadius(function(e){return y(e.data)}).outerRadius(function(e){return y(e.data)}),v=function(e){var t=(s-o)*(e&&!isNaN(e.sliceHeight)?e.sliceHeight:1)/n;return t=o+t*l,Math.max(t,o)},x=d3.svg.arc().innerRadius(function(e){return v(e.data)}).outerRadius(function(e){return v(e.data)}),b=this.getLabelLayout(f,this.layout.viewport);this.drawLabels(p.filter(function(e){return!a||null!==e.data.sliceHeight}),this.mainLabelsElement,b,this.layout.viewport,x,f)}else t.dataLabelUtils.cleanDataLabels(this.mainLabelsElement,!0);return a||(this.drawCenterText(o),this.drawOuterLine(o,_.max(p.map(function(e){return h.outerRadius()(e)})),p)),m},i.prototype.getLabelLayout=function(i,a){var r=function(e){return e.startAngle+(e.endAngle-e.startAngle)/2},o={fontFamily:t.dataLabelUtils.StandardFontFamily,fontSize:s.fromPoint(this.settings.labels.fontSize),text:""},n=function(t){var r=i.centroid(t);o.text=t.data.label;var s=e.TextMeasurementService.measureSvgTextWidth(o),n=a.width/2-Math.abs(r[0]),l=e.TextMeasurementService.estimateSvgTextHeight(o),c=a.height/2-Math.abs(r[1]);return t.isLabelHasConflict=s>n||l>c,t.isLabelHasConflict};return{labelText:function(t){o.text=t.data.label;var r=i.centroid(t),s=n(t)?r[0]*c:r[0],l=a.width/2-Math.abs(s);return e.TextMeasurementService.getTailoredTextOrDefault(o,l)},labelLayout:{x:function(e){var t=i.centroid(e);o.text=e.data.label;var a=e.isLabelHasConflict?t[0]*c:t[0];return a},y:function(e){var t=i.centroid(e),a=e.isLabelHasConflict?t[1]*c:t[1];return a}},filter:function(e){return null!=e&&!_.isEmpty(e.data.label)},style:{fill:this.settings.labels.color,"font-size":o.fontSize,"text-anchor":function(e){return r(e)<Math.PI?"start":"end"}}}},i.prototype.drawLabels=function(a,r,s,o,n,l){var c=this,u=new e.DataLabelManager,h=u.hideCollidedLabels(o,a,s,!0);if(0===h.length)return void t.dataLabelUtils.cleanDataLabels(r,!0);r.select(i.labelGraphicsContextClass.selector).empty()&&r.append("g").classed(i.labelGraphicsContextClass["class"],!0);var p=r.select(i.labelGraphicsContextClass.selector).selectAll(".data-labels").data(h,function(e){return e.data.identity.getKey()});if(p.enter().append("text").classed("data-labels",!0),p){p.attr({x:function(e){return e.labelX},y:function(e){return e.labelY},dy:".35em"}).text(function(e){return e.labeltext}).style(s.style),p.exit().remove(),r.select(i.linesGraphicsContextClass.selector).empty()&&r.append("g").classed(i.linesGraphicsContextClass["class"],!0),h=_.filter(h,function(e){return null!==e.data.sliceHeight&&0!==e.data.sliceHeight});var d=r.select(i.linesGraphicsContextClass.selector).selectAll("polyline").data(h,function(e){return e.data.identity.getKey()}),g=4,m=1.02,y=function(e){return e.startAngle+(e.endAngle-e.startAngle)/2};d.enter().append("polyline").classed("line-label",!0),d.attr("points",function(e){var t=[e.labelX,e.labelY];t[0]=t[0]+(y(e)<Math.PI?-1:1)*g;var i=n.centroid(e);return i[0]*=m,i[1]*=m,[i,t]}).style({opacity:.5,"fill-opacity":0,stroke:function(e){return c.settings.labels.color}}),d.exit().remove()}},i.prototype.renderLegend=function(){if(this.settings.legend.show){var e=_.clone(this.settings.legend);e.labelColor={solid:{color:e.labelColor}},t.LegendData.update(this.data.legendData,e),this.legend.changeOrientation(t.LegendPosition[this.settings.legend.position])}this.legend.drawLegend(this.data.legendData,this.layout.viewportCopy),t.Legend.positionChartArea(this.svg,this.legend)},i.prototype.updateViewPortAccordingToLegend=function(){if(this.settings.legend.show){var e=this.legend.getMargins(),i=t.LegendPosition[this.settings.legend.position];switch(i){case t.LegendPosition.Top:case t.LegendPosition.TopCenter:case t.LegendPosition.Bottom:case t.LegendPosition.BottomCenter:this.layout.viewport.height-=e.height;break;case t.LegendPosition.Left:case t.LegendPosition.LeftCenter:case t.LegendPosition.Right:case t.LegendPosition.RightCenter:this.layout.viewport.width-=e.width}}},i.prototype.drawOuterLine=function(e,t,a){var r=this.mainGroupElement,s=d3.svg.arc().innerRadius(e).outerRadius(t);if(this.settings.outerLine.show){var o=this.settings.outerLine.thickness+"px",n=r.selectAll(i.OuterLine.selector).data(a);n.enter().append("path"),n.attr("fill","none").attr({stroke:"#333","stroke-width":o,d:s}).style("opacity",1).classed(i.OuterLine["class"],!0),n.exit().remove()}else r.selectAll(i.OuterLine.selector).remove()},i.prototype.drawCenterText=function(a){if(_.isEmpty(this.data.centerText))return void this.mainGroupElement.select(i.CenterLabelClass.selector).remove();var r={fontFamily:t.dataLabelUtils.StandardFontFamily,fontWeight:"bold",fontSize:s.toString(a*i.CenterTextFontHeightCoefficient),text:this.data.centerText};this.mainGroupElement.select(i.CenterLabelClass.selector).empty()&&(this.centerText=this.mainGroupElement.append("text").classed(i.CenterLabelClass["class"],!0)),this.centerText.style({"line-height":1,"font-weight":r.fontWeight,"font-size":r.fontSize,fill:this.settings.labels.color}).attr({dy:"0.35em","text-anchor":"middle"}).text(e.TextMeasurementService.getTailoredTextOrDefault(r,a*i.CenterTextFontWidthCoefficient))},i.prototype.clear=function(){this.mainGroupElement.selectAll("path").remove(),this.mainGroupElement.select(i.CenterLabelClass.selector).remove(),t.dataLabelUtils.cleanDataLabels(this.mainLabelsElement,!0),this.legend.drawLegend({dataPoints:[]},this.layout.viewportCopy)},i.prototype.onClearSelection=function(){this.interactivityService&&this.interactivityService.clearSelection()},i.prototype.enumerateObjectInstances=function(e){var t=g.enumerateObjectInstances(this.settings&&this.settings.originalSettings,e,i.capabilities);return t.complete()},i.capabilities={dataRoles:[{displayName:"Category",name:m.Roles.Category,kind:e.VisualDataRoleKind.Grouping},{displayName:"Y Axis",name:m.Roles.Y,kind:e.VisualDataRoleKind.Measure}],dataViewMappings:[{conditions:[{Category:{max:1},Y:{max:2}}],categorical:{categories:{"for":{"in":"Category"},dataReductionAlgorithm:{top:{}}},values:{select:[{bind:{to:"Y"}}]}}}],objects:{general:{displayName:e.data.createDisplayNameGetter("Visual_General"),properties:{formatString:{type:{formatting:{formatString:!0}}}}},legend:{displayName:"Legend",description:"Display legend options",properties:{show:{displayName:"Show",type:{bool:!0}},position:{displayName:"Position",description:"Select the location for the legend",type:{enumeration:t.legendPosition.type}},showTitle:{displayName:"Title",description:"Display a title for legend symbols",type:{bool:!0}},titleText:{displayName:"Legend Name",description:"Title text",type:{text:!0},suppressFormatPainterCopy:!0},labelColor:{displayName:"Color",type:{fill:{solid:{color:!0}}}},fontSize:{displayName:"Text Size",type:{formatting:{fontSize:!0}}}}},label:{displayName:"Center Label",properties:{fill:{displayName:"Fill",type:{fill:{solid:{color:!0}}}}}},labels:{displayName:"Detail Labels",properties:{show:{type:{bool:!0}},color:{displayName:"Color",type:{fill:{solid:{color:!0}}}},displayUnits:{displayName:"Display Units",type:{formatting:{displayUnits:!0}}},precision:{displayName:"Decimal Places",placeHolderText:"Auto",type:{numeric:!0}},fontSize:{displayName:"Text Size",type:{formatting:{fontSize:!0}}}}},outerLine:{displayName:"Outer line",properties:{show:{displayName:"Show",type:{bool:!0}},thickness:{displayName:"Thickness",type:{numeric:!0}}}}},supportsHighlight:!0},i.AsterSlices=r("asterSlices"),i.AsterSlice=r("asterSlice"),i.AsterHighlightedSlice=r("asterHighlightedSlice"),i.OuterLine=r("outerLine"),i.labelGraphicsContextClass=r("labels"),i.linesGraphicsContextClass=r("lines"),i.CenterLabelClass=r("centerLabel"),i.CenterTextFontHeightCoefficient=.4,i.CenterTextFontWidthCoefficient=1.9,i}();i.AsterPlot=y}(i=t.samples||(t.samples={}))}(t=e.visuals||(e.visuals={}))}(i||(i={}))},function(e,t){var i,a=window.jsCommon,i=window.powerbi;window.powerbitests,window.InJs,window.debug,window.jasmine,window.Microsoft;!function(e){var t;!function(t){var i;!function(i){function r(){return new l}var s=a.PixelConverter,o=function(){function e(){}return e.prototype.bindEvents=function(e,t){this.columns=e.columns,this.clearCatcher=e.clearCatcher,this.interactivityService=e.interactivityService,this.columns.on("click",function(e,i){t.handleSelection(e,d3.event.ctrlKey)}),this.clearCatcher.on("click",function(){t.handleClearSelection()})},e.prototype.renderSelection=function(e){var i=this.interactivityService.hasSelection();this.columns.style("fill-opacity",function(a){return t.ColumnUtil.getFillOpacity(a.selected,a.highlight,!a.highlight&&e,!a.selected&&i)})},e}(),n=function(){function e(e,t,i,a,r){this.scrollYBrush=d3.svg.brush(),this.getRoot=e,this.getViewport=t,this.isScrollable=r,this.getPrefferedHeight=a}return Object.defineProperty(e.prototype,"scrollViewport",{get:function(){return{height:this.viewport.height,width:this.viewport.width-(this.isYScrollBarVisible&&this.isScrollable?c.ScrollBarWidth:0)}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"root",{get:function(){return this.getRoot()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"viewport",{get:function(){return this.getViewport()},enumerable:!0,configurable:!0}),e.prototype.renderY=function(e,t){var i=this;if(this.isYScrollBarVisible=this.isScrollable&&this.getPrefferedHeight()>this.viewport.height&&this.viewport.height>0&&this.viewport.width>0,this.brushGraphicsContextY=this.createOrRemoveScrollbar(this.isYScrollBarVisible,this.brushGraphicsContextY,"y brush"),!this.isYScrollBarVisible)return void t.call(this,jQuery.extend(!0,{},e),0,1);var a=this.viewport.height,r=this.getExtentData(this.getPrefferedHeight(),a),s=function(s){void 0===s&&(s=0);var o=i.scrollYBrush.extent();if(0!==s){var n=(o[1]-o[0])/2;if(o[0]+=s>0?n:-n,o[1]+=s>0?n:-n,o[0]<0){var l=0-o[0];o[0]+=l,o[1]+=l}if(o[1]>a){var l=o[1]-a;o[0]-=l,o[1]-=l}i.scrollYBrush.extent(o),i.brushGraphicsContextY.select(".extent").attr("y",o[0])}var c=r.toScrollPosition(o,a);t.call(i,jQuery.extend(!0,{},e),c[0],c[1]),i.setScrollBarSize(i.brushGraphicsContextY,r.value[1],!0)},o=d3.scale.ordinal().rangeBands([0,a]);this.scrollYBrush.y(o).extent(r.value),this.renderScrollbar(this.scrollYBrush,this.brushGraphicsContextY,this.viewport.width,s),s()},e.prototype.createOrRemoveScrollbar=function(e,t,i){return e&&this.isScrollable?t||this.root.append("g").classed(i,!0):t?void t.remove():void 0},e.prototype.renderScrollbar=function(e,i,a,r){var s=this;e.on("brush",function(){return window.requestAnimationFrame(function(){return r(0)})}),this.root.on("wheel",function(){if(s.isYScrollBarVisible){var e=d3.event;r(e.deltaY)}}),i.attr({transform:t.SVGUtil.translate(a,0),"drag-resize-disabled":"true"}),i.call(e),i.selectAll(".resize").remove(),i.select(".background").remove(),i.selectAll(".extent").style({"fill-opacity":.125,cursor:"default"})},e.prototype.setScrollBarSize=function(e,t,i){e.selectAll("rect").attr(i?"width":"height",c.ScrollBarWidth),e.selectAll("rect").attr(i?"height":"width",t)},e.prototype.getExtentData=function(t,i){var a=i*i/t,r=e.ScrollBarMinLength<=a?1:a/e.ScrollBarMinLength;a=Math.max(a,e.ScrollBarMinLength);var s=function(e,t){var i=e[1]-e[0],a=e[0]/(t-i);i*=r;var s=a*(t-i),o=s+i;return[s/t,o/t]};return{value:[0,a],toScrollPosition:s}},e.prototype.clearData=function(){this.brushGraphicsContextY&&this.brushGraphicsContextY.selectAll("*").remove()},e.ScrollBarMinLength=15,e}(),l=function(){function e(){}return Object.defineProperty(e.prototype,"code",{get:function(){return"TornadoChartWarning"},enumerable:!0,configurable:!0}),e.prototype.getMessages=function(e){var t,i="This visual requires two distinct values to be returned for the Legend field.",a="",r="";return t={message:i,title:e.get(a),detail:e.get(r)}},e}();i.TornadoChartWarning=l,i.getTornadoChartWarning=r;var c=function(){function i(e){this.textOptions={},this.columnPadding=5,this.leftLabelMargin=4,this.InnerTextHeightDelta=2,this.margin={top:10,right:5,bottom:10,left:10},this.heightColumn=0,e&&(this.svg=e.svg||this.svg,this.margin=e.margin||this.margin,this.columnPadding=e.columnPadding||this.columnPadding,this.animator=e.animator)}return i.getProperties=function(e){var t={};for(var i in e.objects){t[i]={};for(var a in e.objects[i].properties)t[i][a]={objectName:i,propertyName:a}}return t},i.converter=function(a,r,o){if(!(a&&a.categorical&&a.categorical.categories&&a.categorical.categories[0]&&a.categorical.categories[0].source&&a.categorical.values&&a.categorical.values[0]))return null;var n=a.categorical,l=n.categories||[],c=n.values,u=l[0],h=i.Properties.general.formatString,p=d3.max(c[0].values),d=i.parseSettings(a.metadata.objects,p,o),g=!!c.source,m=!!(c.length>0&&c[0].highlights),y=e.TextMeasurementService.estimateSvgTextHeight({fontFamily:t.dataLabelUtils.StandardFontFamily,fontSize:s.fromPoint(d.labelSettings.fontSize)}),f=[],v=[],x=[],b=t.valueFormatter.getFormatString(u.source,h),S=u.values.map(function(e){var a=t.valueFormatter.format(e,b);return i.getTextData(a,r,!0)}),w=c.grouped?c.grouped():null,C=Math.min(d3.min(c[0].values),0);c.length===i.MaxSeries&&(C=d3.min([C,d3.min(c[1].values)]),p=d3.max([p,d3.max(c[1].values)]));for(var P=0;P<c.length;P++){var D=w&&w.length>P&&w[P].values?w[P]:null,A=i.parseSeries(c,P,g,D,o);f.push(A);for(var T=c[P],V=T.source.queryName,N=0;N<u.values.length;N++){var L,M=null==T.values[N]||isNaN(T.values[N])?0:T.values[N],k=t.SelectionIdBuilder.builder().withCategory(u,N).withSeries(c,D).withMeasure(V).createSelectionId(),O=S[N].text;L=t.TooltipBuilder.createTooltipInfo(h,n,O,M,null,null,P,N,null);var I=A.categoryAxisEnd?Math.min(A.categoryAxisEnd,p):p,j=a.categorical.values[P].source.format;if(v.push({value:M,minValue:C,maxValue:I,formatString:j,color:A.fill,selected:!1,identity:k,tooltipData:L,categoryIndex:N}),m){var F=t.SelectionId.createWithHighlight(k),z=T.highlights[N],G=null!=z?z:0;L=t.TooltipBuilder.createTooltipInfo(h,n,O,M,null,null,P,N,G),x.push({value:G,minValue:C,maxValue:I,formatString:j,color:A.fill,selected:!1,identity:F,tooltipData:L,categoryIndex:N,highlight:!0})}}}return{categories:S,series:f,settings:d,legend:i.getLegendData(f,g),dataPoints:v,highlightedDataPoints:x,maxLabelsWidth:_.max(S.map(function(e){return e.width})),hasDynamicSeries:g,hasHighlights:m,labelHeight:y,legendObjectProperties:e.DataViewObjects.getObject(a.metadata.objects,"legend",{})}},i.parseSeries=function(e,a,r,s,o){var n,l,c=e?e[a]:null,u=c?c.source:null,h=s?s.identity:null,p=u?u.queryName:null,d=h?t.SelectionId.createWithId(h):t.SelectionIdBuilder.builder().withSeries(e,s).withMeasure(p).createSelectionId(),g=u?u.groupName?u.groupName:u.displayName:null;r&&s?(l=s.objects?s.objects.categoryAxis:null,n=s.objects):u&&(n=u.objects,l=n?n.categoryAxis:null);var m=i.getColor(i.Properties.dataPoint.fill,["purple","teal"][a],n,o),y=l?l.end:null;return{fill:m,name:g,selectionId:d,categoryAxisEnd:y}},i.getColor=function(e,i,a,r){var s=new t.ColorHelper(r,e,i);return s.getColorForMeasure(a,"")},i.getTextData=function(t,i,a,r,o){void 0===a&&(a=!1),void 0===r&&(r=!1);var n,l,c=0,u=0;return t=t||"",n=o?s.fromPoint(o):""+i.fontSize+i.sizeUnit,l={text:t,fontFamily:i.fontFamily,fontSize:n},a&&(c=e.TextMeasurementService.measureSvgTextWidth(l)),r&&(u=e.TextMeasurementService.estimateSvgTextHeight(l)),{text:t,width:c,height:u,textProperties:l}},Object.defineProperty(i.prototype,"allLabelsWidth",{get:function(){
2return(this.dataView.settings.showCategories?Math.min(this.dataView.maxLabelsWidth,this.scrolling.scrollViewport.width/2):3)+i.CategoryLabelMargin},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"allColumnsWidth",{get:function(){return this.scrolling.scrollViewport.width-this.allLabelsWidth},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"columnWidth",{get:function(){return this.dataView.series.length===i.MaxSeries?this.allColumnsWidth/2:this.allColumnsWidth},enumerable:!0,configurable:!0}),i.prototype.init=function(e){var a,r=this,s=e.style;this.hostService=e.host;var l=e.element;this.colors=s.colorPalette.dataColors;var c=e.interactivity;this.interactivityService=t.createInteractivityService(this.hostService);var u;this.svg?this.root=u=this.svg:this.root=u=d3.select(l.get(0)).append("svg"),u.classed(i.ClassName,!0).style("position","absolute"),a=u.style("font-size"),this.textOptions.sizeUnit=a.slice(a.length-2),this.textOptions.fontSize=Number(a.slice(0,a.length-2)),this.textOptions.fontFamily=u.style("font-family"),this.viewport=e.viewport,this.scrolling=new n(function(){return u},function(){return r.viewport},function(){return r.margin},function(){return r.dataView.categories.length*i.CategoryMinHeight},!0);var h=this.main=u.append("g");this.clearCatcher=t.appendClearCatcher(h),this.columns=h.append("g").classed(i.Columns["class"],!0),this.axes=h.append("g").classed(i.Axes["class"],!0),this.labels=h.append("g").classed(i.Labels["class"],!0),this.categories=h.append("g").classed(i.Categories["class"],!0),this.behavior=new o,this.legend=t.createLegend(l,c&&c.isInteractiveLegend,this.interactivityService,!0)},i.prototype.update=function(e){if(e&&e.dataViews&&e.dataViews[0]){if(this.viewport={height:Math.max(0,e.viewport.height-this.margin.top-this.margin.bottom),width:Math.max(0,e.viewport.width-this.margin.left-this.margin.right)},this.animator?this.durationAnimations=t.AnimatorCommon.GetAnimationDuration(this.animator,e.suppressAnimations):this.durationAnimations=e.suppressAnimations?0:250,this.dataView=i.converter(this.validateDataView(e.dataViews[0]),this.textOptions,this.colors),!this.dataView||this.scrolling.scrollViewport.height<i.CategoryMinHeight)return void this.clearData();this.dataView&&this.interactivityService&&(this.interactivityService.applySelectionStateToData(this.dataView.dataPoints),this.interactivityService.applySelectionStateToData(this.dataView.highlightedDataPoints)),this.render()}},i.prototype.validateDataView=function(e){return e&&e.categorical&&e.categorical.values?e.categorical.values.length>i.MaxSeries?(this.hostService.setWarnings([r()]),null):e:null},i.prototype.updateElements=function(){var e=t.SVGUtil.translate(this.allLabelsWidth,0);this.root.attr({height:this.viewport.height+this.margin.top+this.margin.bottom,width:this.viewport.width+this.margin.left+this.margin.right}),this.columns.attr("transform",e),this.labels.attr("transform",e),this.axes.attr("transform",e)},i.parseSettings=function(a,r,s){var o=i.getPrecision(a),n=e.DataViewObjects.getValue(a,i.Properties.labels.labelDisplayUnits,i.DefaultTornadoChartSettings.labelSettings.displayUnits),l=i.DefaultTornadoChartSettings.labelSettings,c=function(e){return t.valueFormatter.create({format:e,precision:o,value:0===n&&null!=r?r:n})};return{labelOutsideFillColor:i.getColor(i.Properties.labels.outsideFill,i.DefaultTornadoChartSettings.labelOutsideFillColor,a,s),labelSettings:{show:e.DataViewObjects.getValue(a,i.Properties.labels.show,l.show),precision:o,fontSize:e.DataViewObjects.getValue(a,i.Properties.labels.fontSize,l.fontSize),displayUnits:n,labelColor:i.getColor(i.Properties.labels.insideFill,l.labelColor,a,s)},showCategories:e.DataViewObjects.getValue(a,i.Properties.categories.show,i.DefaultTornadoChartSettings.showCategories),showLegend:e.DataViewObjects.getValue(a,i.Properties.legend.show,i.DefaultTornadoChartSettings.showLegend),legendFontSize:e.DataViewObjects.getValue(a,i.Properties.legend.fontSize,i.DefaultTornadoChartSettings.legendFontSize),legendColor:i.getColor(i.Properties.legend.labelColor,i.DefaultTornadoChartSettings.legendColor,a,s),categoriesFillColor:i.getColor(i.Properties.categories.fill,i.DefaultTornadoChartSettings.categoriesFillColor,a,s),getLabelValueFormatter:c}},i.getPrecision=function(t){var a=e.DataViewObjects.getValue(t,i.Properties.labels.labelPrecision,i.DefaultTornadoChartSettings.labelSettings.precision);return Math.min(Math.max(0,a),i.MaxPrecision)},i.getLegendData=function(e,i){var a=[];return i&&(a=e.map(function(e){return{label:e.name,color:e.fill,icon:t.LegendIcon.Box,selected:!1,identity:e.selectionId}})),{dataPoints:a}},i.prototype.render=function(){this.updateElements(),this.renderLegend(),this.scrolling.renderY(this.dataView,this.renderWithScrolling.bind(this))},i.prototype.clearData=function(){this.columns.selectAll("*").remove(),this.axes.selectAll("*").remove(),this.labels.selectAll("*").remove(),this.categories.selectAll("*").remove(),this.legend.drawLegend({dataPoints:[]},this.viewport),this.scrolling.clearData()},i.prototype.onClearSelection=function(){this.interactivityService&&this.interactivityService.clearSelection()},i.prototype.renderWithScrolling=function(e,t,a){if(this.dataView&&this.dataView.settings){var r=e.categories.length,s=t*r,o=a*r,n=Math.floor(s),l=Math.floor(o),c=Math.floor(this.scrolling.scrollViewport.height/i.CategoryMinHeight);1>a-t&&l-n>c&&(s-n>o-l?n++:o--),this.interactivityService&&(this.interactivityService.applySelectionStateToData(e.dataPoints),this.interactivityService.applySelectionStateToData(e.highlightedDataPoints)),e.categories=e.categories.slice(n,l),e.dataPoints=_.filter(e.dataPoints,function(e){return e.categoryIndex>=n&&e.categoryIndex<l}),e.highlightedDataPoints=_.filter(e.highlightedDataPoints,function(e){return e.categoryIndex>=n&&e.categoryIndex<l}),this.dataView=e,this.computeHeightColumn(),this.renderMiddleSection(),this.renderAxes(),this.renderCategories()}},i.prototype.updateViewport=function(){var e,i=this.legend.getMargins();switch(e=t.LegendPosition[this.dataView.legendObjectProperties[t.legendProps.position]]){case t.LegendPosition.Top:case t.LegendPosition.TopCenter:case t.LegendPosition.Bottom:case t.LegendPosition.BottomCenter:this.viewport.height-=i.height;break;case t.LegendPosition.Left:case t.LegendPosition.LeftCenter:case t.LegendPosition.Right:case t.LegendPosition.RightCenter:this.viewport.width-=i.width}},i.prototype.computeHeightColumn=function(){var e=this.dataView.categories.length;this.heightColumn=(this.scrolling.scrollViewport.height-(e-1)*this.columnPadding)/e},i.prototype.renderMiddleSection=function(){var e=this.dataView;this.calculateDataPoints(e.dataPoints),this.calculateDataPoints(e.highlightedDataPoints);var t=e.dataPoints.concat(e.highlightedDataPoints);this.renderColumns(t,2===e.series.length),this.renderLabels(this.dataView.hasHighlights?e.highlightedDataPoints:e.dataPoints,e.settings.labelSettings)},i.prototype.calculateDataPoints=function(e){for(var t=this.dataView.categories.length,a=this.dataView.settings,r=Math.max(this.heightColumn,0),s=r/2,o=r*i.HighlightedShapeFactor/2,n=this.dataView.series.length===i.MaxSeries,l=0;l<e.length;l++){var c=e[l],u=t>l&&n,h=l>t-1,p=this.getColumnWidth(c.value,c.minValue,c.maxValue,this.columnWidth),d=(this.columnWidth-p)*Number(u)+this.columnWidth*Number(h);d=Math.max(d,0);var g=this.dataView.hasHighlights&&c.highlight,m=g?r*(1-i.HighlightedShapeFactor)/2:0,y=(r+this.columnPadding)*(l%t)+m,f=this.getLabelData(c.value,d,p,u,c.formatString,a);c.dx=d,c.dy=y,c.px=p/2,c.py=g?o:s,c.angle=u?180:0,c.width=p,c.height=g?r*i.HighlightedShapeFactor:r,c.label=f}},i.prototype.renderColumns=function(e,a){var r=this;void 0===a&&(a=!1);var s=this.interactivityService&&this.interactivityService.hasSelection(),o=this.columns.selectAll(i.Column.selector).data(e);o.enter().append("svg:rect").classed(i.Column["class"],!0),o.style("fill",function(e){return e.color}).style("fill-opacity",function(e){return t.ColumnUtil.getFillOpacity(e.selected,e.highlight,s,r.dataView.hasHighlights)}).attr("transform",function(e){return t.SVGUtil.translateAndRotate(e.dx,e.dy,e.px,e.py,e.angle)}).attr("height",function(e){return e.height}).attr("width",function(e){return e.width}),o.exit().remove();var n=this.interactivityService;if(n){n.applySelectionStateToData(e);var l={columns:o,clearCatcher:this.clearCatcher,interactivityService:this.interactivityService};n.bind(e,this.behavior,l)}this.renderTooltip(o)},i.prototype.renderTooltip=function(e){t.TooltipManager.addTooltip(e,function(e){return e.data.tooltipData})},i.prototype.getColumnWidth=function(e,t,i,a){if(t===i)return a;var r=a*(e-t)/(i-t);return Math.max(0,Math.min(a,r))},i.prototype.getLabelData=function(a,r,o,n,l,c){var u,h=c?c:this.dataView.settings,p=h.labelSettings,d=p.fontSize,g=p.labelColor,m=n?r-this.leftLabelMargin:this.allColumnsWidth-(r+o+this.leftLabelMargin),y=Math.max(m,o-this.leftLabelMargin),f={fontFamily:t.dataLabelUtils.StandardFontFamily,fontSize:s.fromPoint(d),text:h.getLabelValueFormatter(l).format(a)},v=e.TextMeasurementService.getTailoredTextOrDefault(f,y),x=i.getTextData(v,this.textOptions,!0,!1,d);return o>x.width+i.LabelPadding?u=r+o/2-x.width/2:(u=n?r-this.leftLabelMargin-x.width:r+o+this.leftLabelMargin,g=h.labelOutsideFillColor),{dx:u,source:a,value:v,color:g}},i.prototype.renderAxes=function(){var e,t,a=this.main.select(i.Axes.selector).selectAll(i.Axis.selector);return this.dataView.series.length!==i.MaxSeries?void a.remove():(e=this.generateAxesData(),t=a.data(e),t.enter().append("svg:line").classed(i.Axis["class"],!0),t.attr("x1",function(e){return e.x1}).attr("y1",function(e){return e.y1}).attr("x2",function(e){return e.x2}).attr("y2",function(e){return e.y2}),void t.exit().remove())},i.prototype.generateAxesData=function(){var e,t,i;return e=this.allColumnsWidth/2,t=0,i=this.scrolling.scrollViewport.height,[{x1:e,y1:t,x2:e,y2:i}]},i.prototype.renderLabels=function(e,a){var r,o=this,n=this.main.select(i.Labels.selector).selectAll(i.Label.selector).data(_.filter(e,function(e){return e.label.dx>=0}));if(!a.show||this.dataView.labelHeight>=this.heightColumn)return void this.labels.selectAll("*").remove();var l=s.fromPoint(a.fontSize),c=this.heightColumn/2+this.dataView.labelHeight/2-this.InnerTextHeightDelta,u=this.dataView.categories.length;r=n.enter().append("g"),r.append("svg:title").classed(i.LabelTitle["class"],!0),r.append("svg:text").attr("dy",t.dataLabelUtils.DefaultDy).classed(i.LabelText["class"],!0),n.attr("pointer-events","none").classed(i.Label["class"],!0),n.select(i.LabelTitle.selector).text(function(e){return e.label.source}),n.attr("transform",function(e,i){var a=(o.heightColumn+o.columnPadding)*(i%u);return t.SVGUtil.translate(e.label.dx,a+c)}),n.select(i.LabelText.selector).attr("fill",function(e){return e.label.color}).attr("font-size",function(e){return l}).text(function(e){return e.label.value}),n.exit().remove()},i.prototype.renderCategories=function(){var a,r,s=this,o=this.dataView.settings,n=o.categoriesFillColor,l=this.main.select(i.Categories.selector).selectAll(i.Category.selector);return o.showCategories?(r=l.data(this.dataView.categories),a=r.enter().append("g"),a.append("svg:title").classed(i.CategoryTitle["class"],!0),a.append("svg:text").classed(i.CategoryText["class"],!0),r.attr("transform",function(e,a){var r=(s.heightColumn+s.columnPadding)*a+s.heightColumn/2,o=i.getTextData(e,s.textOptions,!1,!0);return r=r+o.height/2-s.InnerTextHeightDelta,t.SVGUtil.translate(0,r)}).classed(i.Category["class"],!0),r.select(i.CategoryTitle.selector).text(function(e){return e.text}),r.select(i.CategoryText.selector).attr("fill",n).text(function(t){return s.dataView.settings.showCategories?e.TextMeasurementService.getTailoredTextOrDefault(i.getTextData(t.text,s.textOptions).textProperties,s.allLabelsWidth):""}),void r.exit().remove()):void l.remove()},i.prototype.renderLegend=function(){var e=this.dataView.legend;if(e){var i=this.dataView.settings,a={title:e.title,dataPoints:e.dataPoints,fontSize:i.legendFontSize,labelColor:i.legendColor};if(this.dataView.legendObjectProperties){var r;t.LegendData.update(a,this.dataView.legendObjectProperties),r=this.dataView.legendObjectProperties[t.legendProps.position],r&&this.legend.changeOrientation(t.LegendPosition[r])}var s={height:this.viewport.height+this.margin.top+this.margin.bottom,width:this.viewport.width+this.margin.left+this.margin.right};this.legend.drawLegend(a,s),t.Legend.positionChartArea(this.root,this.legend),a.dataPoints.length>0&&i.showLegend&&this.updateViewport()}},i.prototype.enumerateObjectInstances=function(i){var a,r=new t.ObjectEnumerationBuilder;if(!this.dataView||!this.dataView.settings)return[];switch(a=this.dataView.settings,i.objectName){case"dataPoint":this.enumerateDataPoint(r);break;case"categoryAxis":this.enumerateCategoryAxis(r);break;case"labels":var s=a.labelSettings,o={objectName:"labels",displayName:"Labels",selector:null,properties:{show:s.show,fontSize:s.fontSize,labelPrecision:s.precision,labelDisplayUnits:s.displayUnits,insideFill:s.labelColor,outsideFill:a.labelOutsideFillColor}};r.pushInstance(o);break;case"legend":if(!this.dataView.hasDynamicSeries)return;var n,l=!0,c="";l=e.DataViewObject.getValue(this.dataView.legendObjectProperties,t.legendProps.showTitle,l),c=e.DataViewObject.getValue(this.dataView.legendObjectProperties,t.legendProps.titleText,c),n={objectName:"legend",displayName:"Legend",selector:null,properties:{show:a.showLegend,position:t.LegendPosition[this.legend.getOrientation()],showTitle:l,titleText:c,fontSize:a.legendFontSize,labelColor:a.legendColor}},r.pushInstance(n);break;case"categories":var u={objectName:"categories",displayName:"Categories",selector:null,properties:{show:a.showCategories,fill:a.categoriesFillColor}};r.pushInstance(u)}return r.complete()},i.prototype.enumerateDataPoint=function(e){if(this.dataView&&this.dataView.series)for(var i=this.dataView.series,a=0,r=i.length;r>a;a++)e.pushInstance({objectName:"dataPoint",displayName:i[a].name,selector:t.ColorHelper.normalizeSelector(i[a].selectionId.getSelector(),!1),properties:{fill:{solid:{color:i[a].fill}}}})},i.prototype.enumerateCategoryAxis=function(e){if(this.dataView&&this.dataView.series)for(var t=this.dataView.series,i=0,a=t.length;a>i;i++)e.pushInstance({objectName:"categoryAxis",displayName:t[i].name,selector:t[i].selectionId?t[i].selectionId.getSelector():null,properties:{end:t[i].categoryAxisEnd}})},i.prototype.destroy=function(){this.root=null},i.ClassName="tornado-chart",i.capabilities={dataRoles:[{name:"Category",kind:e.VisualDataRoleKind.Grouping,displayName:e.data.createDisplayNameGetter("Role_DisplayName_Group")},{name:"Series",kind:e.VisualDataRoleKind.Grouping,displayName:e.data.createDisplayNameGetter("Role_DisplayName_Legend")},{name:"Values",kind:e.VisualDataRoleKind.Measure,displayName:e.data.createDisplayNameGetter("Role_DisplayName_Values")}],dataViewMappings:[{conditions:[{Category:{max:1},Values:{min:0,max:1},Series:{min:0,max:1}},{Category:{max:1},Values:{min:2,max:2},Series:{max:0}}],categorical:{categories:{"for":{"in":"Category"}},values:{group:{by:"Series",select:[{"for":{"in":"Values"}}],dataReductionAlgorithm:{top:{}}}}}}],objects:{general:{displayName:"General",properties:{formatString:{type:{formatting:{formatString:!0}}}}},dataPoint:{displayName:"Data Colors",properties:{fill:{displayName:e.data.createDisplayNameGetter("Visual_Fill"),type:{fill:{solid:{color:!0}}}}}},categoryAxis:{displayName:"X-Axis",properties:{end:{displayName:"End",type:{numeric:!0},suppressFormatPainterCopy:!0}}},labels:{displayName:"Data Labels",properties:{show:{displayName:"Show",type:{bool:!0}},labelPrecision:{displayName:"Decimal Places",placeHolderText:"Auto",type:{numeric:!0}},fontSize:{displayName:e.data.createDisplayNameGetter("Visual_TextSize"),type:{formatting:{fontSize:!0}}},labelDisplayUnits:{displayName:"Display Units",type:{formatting:{labelDisplayUnits:!0}}},insideFill:{displayName:"Inside fill",type:{fill:{solid:{color:!0}}}},outsideFill:{displayName:"Outside fill",type:{fill:{solid:{color:!0}}}}}},legend:{displayName:"Legend",properties:{show:{displayName:"Show",type:{bool:!0}},position:{displayName:"Position",description:e.data.createDisplayNameGetter("Visual_LegendPositionDescription"),type:{enumeration:t.legendPosition.type}},showTitle:{displayName:"Title",description:e.data.createDisplayNameGetter("Visual_LegendShowTitleDescription"),type:{bool:!0}},titleText:{displayName:"Legend Name",description:e.data.createDisplayNameGetter("Visual_LegendNameDescription"),type:{text:!0}},labelColor:{displayName:"Color",type:{fill:{solid:{color:!0}}}},fontSize:{displayName:"TextSize",type:{formatting:{fontSize:!0}}}}},categories:{displayName:"Group",properties:{show:{displayName:"Show",type:{bool:!0}},fill:{displayName:"Color",type:{fill:{solid:{color:!0}}}}}}},supportsHighlight:!0},i.Properties=i.getProperties(i.capabilities),i.Columns={"class":"columns",selector:".columns"},i.Column={"class":"column",selector:".column"},i.Axes={"class":"axes",selector:".axes"},i.Axis={"class":"axis",selector:".axis"},i.Labels={"class":"labels",selector:".labels"},i.Label={"class":"label",selector:".label"},i.LabelTitle={"class":"label-title",selector:".label-title"},i.LabelText={"class":"label-text",selector:".label-text"},i.Categories={"class":"categories",selector:".categories"},i.Category={"class":"category",selector:".category"},i.CategoryTitle={"class":"category-title",selector:".category-title"},i.CategoryText={"class":"category-text",selector:".category-text"},i.MaxSeries=2,i.MaxPrecision=17,i.LabelPadding=2.5,i.CategoryMinHeight=25,i.DefaultFontSize=9,i.DefaultLegendFontSize=8,i.HighlightedShapeFactor=.5,i.CategoryLabelMargin=10,i.ScrollBarWidth=22,i.DefaultTornadoChartSettings={labelOutsideFillColor:t.dataLabelUtils.defaultLabelColor,labelSettings:{show:!0,precision:null,fontSize:i.DefaultFontSize,displayUnits:0,labelColor:t.dataLabelUtils.defaultInsideLabelColor},showCategories:!0,showLegend:!0,legendFontSize:i.DefaultLegendFontSize,legendColor:t.LegendData.DefaultLegendLabelFillColor,categoriesFillColor:"#777"},i}();i.TornadoChart=c}(i=t.samples||(t.samples={}))}(t=e.visuals||(e.visuals={}))}(i||(i={}))},function(e,t){var i,a=window.jsCommon,i=window.powerbi;window.powerbitests,window.InJs,window.debug,window.jasmine,window.Microsoft;!function(e){var t;!function(t){var i;!function(i){function r(e,i,r,s,o,n,l,c,u,h,p,d,g,m,y){var f=35,v=o.x,x=o.y1,b=o.y2,S=v.values,w=x.values,C=0,P=0,D=0,A=0,T=0,V=v.categoryThickness?v.categoryThickness/2:0,N=t.AxisHelper.isOrdinalScale(v.scale),L=0;if(void 0!==v.outerPadding?L=v.outerPadding:void 0!==v.xLabelMaxWidth&&(L=Math.max(0,(e.width-v.xLabelMaxWidth*S.length)/2)),0!==t.AxisHelper.getRecommendedNumberOfTicksForXAxis(e.width)||0!==t.AxisHelper.getRecommendedNumberOfTicksForYAxis(e.height)){var M;if(M=p?t.AxisHelper.LabelLayoutStrategy.DefaultRotationWithScrollbar:t.AxisHelper.LabelLayoutStrategy.DefaultRotation,m)for(var k=0,O=w.length;O>k;k++)c.text=w[k],D=Math.max(D,r(c));if(b&&y)for(var I=b.values,k=0,O=I.length;O>k;k++)u.text=I[k],A=Math.max(A,r(u));var j=s(l),F=Math.floor(n/j),z=v.scale,G=z.domain();if(g&&S.length>0){for(var k=0,O=S.length;O>k;k++){var R;l.text=S[k];var H=r(l);if(v.willLabelsWordBreak){var B=a.WordBreaker.splitByWidth(l.text,l,r,v.xLabelMaxWidth,F);R=B.length*j,H=v.xLabelMaxWidth}else!v.willLabelsFit&&N?(R=H*M.sine,H*=M.cosine):R=j;if(0===k){if(N)C=v.willLabelsFit?H/2-V-L:H-V-L,C=Math.max(C,0);else if(G.length>1){var U=z(G[0]);C=H/2-U,C=Math.max(C,0)}}else if(k===O-1)if(N)(v.willLabelsFit||v.willLabelsWordBreak)&&(P=H/2-V-L,P=Math.max(P,0));else if(G.length>1){var U=z(G[1]);P=H/2-(e.width-U),P=Math.max(P,0)}T=Math.max(T,R)}C=h?Math.min(C,f):0,P=h?Math.min(P,f):0}}var E=0,W=0,_=Math.min(Math.ceil(T),n);return d?(W=Math.min(Math.max(C,A),i),E=Math.min(Math.max(P,D),i)):(W=Math.min(Math.max(C,D),i),E=Math.min(Math.max(P,A),i)),{xMax:Math.ceil(_),yLeft:Math.ceil(W),yRight:Math.ceil(E)}}function s(e,t,i){return i>1?e&&e.length>t?[e[t]]:[]:e}function o(e,t,i){return 0===e&&!!t&&!!t.showAxisTitle||1===e&&!i&&!!t&&!!t.secShowAxisTitle}function n(e,i,a,r,s,n,l){var c={viewport:i,margin:a,forcedXDomain:[r?r.start:null,r?r.end:null],forceMerge:s&&s.secShow===!1,showCategoryAxisLabel:!1,showValueAxisLabel:!1,categoryAxisScaleType:r&&null!=r.axisScale?r.axisScale:t.axisScale.linear,valueAxisScaleType:s&&null!=s.axisScale?s.axisScale:t.axisScale.linear,trimOrdinalDataOnOverflow:!1},u=!1;s&&(c.forcedYDomain=t.AxisHelper.applyCustomizedDomain([s.start,s.end],c.forcedYDomain));for(var h,p=0,d=e.length;d>p;p++){var g=e[p];c.showCategoryAxisLabel=!!r&&!!r.showAxisTitle,c.showValueAxisLabel=o(p,s,u);var m=g.calculateAxesProperties(c);0===p&&(h={x:m[0],y1:m[1]}),h.x.willLabelsFit=!1,h.x.willLabelsWordBreak=!1}return h}function l(e,i,a,r,s){void 0===s&&(s=!0);var o=[],n={isScrollable:s,animator:r,interactivityService:a};return o.push(c(t.ColumnChartType.hundredPercentStackedColumn,n)),o}function c(e,t){var i={animator:t.animator,interactivityService:t.interactivityService,isScrollable:t.isScrollable,chartType:e};return new b(i)}var u=a.CssConstants.createClassAndSelector,h=e.visuals.NewDataLabelUtils,p=function(){function e(e,t){this.data=e,this.isScalar=t}return e.prototype.lookupXValue=function(e,i){var a=t.AxisHelper.isDateTime(i);if(a&&this.isScalar)return new Date(e);var r=this.data;if(i.text)return r.categories[e];var s=r.series[0];if(s){var o=s.data;if(o){this.data.hasHighlights&&(e=2*e);var n=o[e];if(n)return a?new Date(n.categoryValue):n.categoryValue}}return e},e}();i.MekkoDataWrapper=p;var d=function(){function i(){}return i.prototype.setupVisualProps=function(e){this.graphicsContext=e,this.margin=e.margin,this.width=this.graphicsContext.width,this.height=this.graphicsContext.height,this.categoryLayout=e.layout,this.animator=e.animator,this.interactivityService=e.interactivityService,this.viewportHeight=e.viewportHeight,this.viewportWidth=e.viewportWidth},i.prototype.setData=function(e){this.data=e},i.createFormatter=function(e,i,a,r,s,o,n,l,c){void 0===c&&(c=!1);var u;if(a.dateTime)if(r){var h=new Date(e[0]),p=new Date(e[1]);1===o&&(h=p=new Date(i[0])),u=t.valueFormatter.create({format:s,value:h,value2:p,tickCount:o})}else{var d=l(0,a),g=l(e.length-1,a);u=t.valueFormatter.create({format:s,value:d,value2:g,tickCount:o})}else if(c&&r&&n.length>1){var m=n[1]-n[0],y=0;u=t.valueFormatter.create({format:s,value:m,value2:y,allowFormatBeautification:!0})}else u=t.valueFormatter.createDefaultFormatter(s,!0);return u},i.formatAxisTickValues=function(e,t,i,a,r,s){var o=[];return i?!s||a.numeric&&r?(e.tickFormat(function(e){return i.format(e)}),o=t.map(function(e){return i.format(e)})):(e.tickFormat(function(e){return i.format(s(e,a))}),o=t.map(function(e){return i.format(s(e,a))})):o=t.map(function(e){return s(e,a)}),o},i.prototype.createAxis=function(e){var a=e.pixelSpan,r=e.dataDomain,s=e.metaDataColumn,o=e.formatStringProp,n=e.outerPadding||0,l=!!e.isCategoryAxis,c=!!e.isScalar,u=!!e.isVertical,h=!!e.useTickIntervalForDisplayUnits,p=e.getValueFn,d=e.categoryThickness,m=t.valueFormatter.getFormatString(s,o),y=t.AxisHelper.getCategoryValueType(s,c),f=t.AxisHelper.isLogScalePossible(r,y),v=d3.scale.linear(),x=[0,1],S=r.length||1,w=b.getBorderWidth(e.borderSettings),C=a-w*(S-1);C<g.MinOrdinalRectThickness&&(C=g.MinOrdinalRectThickness),v.domain(x).range([0,C]);var P=r,D=i.createFormatter(x,r,y,c,m,S,P,p,h),A=d3.svg.axis().scale(v).tickSize(6,0).orient(u?"left":"bottom").ticks(S).tickValues(r),T=[];s&&(T=i.formatAxisTickValues(A,P,D,y,c,p));var V;if(!c&&d)V=Math.max(1,d-2*t.CartesianChart.TickLabelPadding);else{var N=P.length>1?P.length+1:P.length;V=N>1?a/N:a,V=Math.max(1,V-2*t.CartesianChart.TickLabelPadding)}return{scale:v,axis:A,formatter:D,values:T,axisType:y,axisLabel:null,isCategoryAxis:l,xLabelMaxWidth:V,categoryThickness:d,outerPadding:n,usingDefaultDomain:!1,isLogScaleAllowed:f}},i.prototype.getCategoryAxis=function(e,i,a,r,s,o,n){var l=a.categoryThickness,c=a.isScalar,u=a.outerPaddingRatio,h=new p(e,c),d=[];if(e.series&&e.series.length>0&&e.series[0].data&&e.series[0].data.length>0){var g=e.series[0].data.map(function(e){return e.originalPosition+e.value/2});d=g.filter(function(e,t){return g.indexOf(e)===t})}var m=this.createAxis({pixelSpan:i,dataDomain:d,metaDataColumn:e.categoryMetadata,formatStringProp:t.columnChartProps.general.formatString,outerPadding:l*u,isCategoryAxis:!0,isScalar:c,isVertical:r,categoryThickness:l,useTickIntervalForDisplayUnits:!0,getValueFn:function(e,t){var i=d.indexOf(e),a=h.lookupXValue(i,t);return a},scaleType:n,borderSettings:e.borderSettings});return a.categoryThickness=m.categoryThickness,m},i.prototype.setXScale=function(e,t,i,a){var r,s,o=this.width;i&&2===i.length&&(r=i[0],s=i[1]);var n=this.xProps=this.getCategoryAxis(this.data,o,this.categoryLayout,!1,r,s,a);return n},i.prototype.setYScale=function(e,i,a,r){var s=this.viewportHeight,o=t.StackedUtil.calcValueDomain(this.data.series,e),n=[o.min,o.max],l=t.AxisHelper.combineDomain(a,n),c=t.AxisHelper.scaleShouldClamp(l,n),u=this.data.valuesMetadata[0],h=e?this.graphicsContext.hostService.getLocalizedString("Percentage"):t.valueFormatter.getFormatString(u,t.columnChartProps.general.formatString),p={pixelSpan:s,dataDomain:l,metaDataColumn:u,formatString:h,outerPadding:0,isScalar:!0,isVertical:!0,forcedTickCount:i,useTickIntervalForDisplayUnits:!0,isCategoryAxis:!1,scaleType:r,axisDisplayUnits:0,axisPrecision:0,is100Pct:e,shouldClamp:c,formatStringProp:void 0};return this.yProps=t.AxisHelper.createAxis(p),this.yProps},i.prototype.drawColumns=function(e){var a=this.data;this.columnsCenters=null;var r,s,o={columnWidth:0,xScale:this.xProps.scale,yScale:this.yProps.scale,isScalar:this.categoryLayout.isScalar,margin:this.margin},n=this.layout=i.getLayout(a,o),l=this.createMekkoLabelDataPoints(),c=t.ColumnUtil.drawSeries(a,this.graphicsContext.mainGraphicsContext,o);return this.animator&&e&&(r=this.animator.animate({viewModel:a,series:c,layout:n,itemCS:i.classes.item,interactivityService:this.interactivityService,mainGraphicsContext:this.graphicsContext.mainGraphicsContext,viewPort:{height:this.height,width:this.width}}),s=r.shapes),this.animator&&e&&!r.failed||(s=i.drawDefaultShapes(a,c,n,i.classes.item,!this.animator,this.interactivityService&&this.interactivityService.hasSelection())),t.ColumnUtil.applyInteractivity(s,this.graphicsContext.onDragStart),{shapesSelection:s,viewport:{height:this.height,width:this.width},axisOptions:o,labelDataPoints:l}},i.drawDefaultShapes=function(e,i,a,r,s,o){var n="rect";s=!1;var l;l=s?function(e){var t=_.filter(e.data,function(e){return!!e.value});return t}:function(e){return e.data};var c=i.selectAll(r.selector),u=c.data(l,function(e){return e.key});u.enter().append(n).attr("class",function(e){return r["class"].concat(e.highlight?" highlight":"")}),u.style("fill",function(e){return e.color}).style("fill-opacity",function(i){return t.ColumnUtil.getFillOpacity(i.selected,i.highlight,o,e.hasHighlights)}).attr(a.shapeLayout),u.exit().remove();var h=i.selectAll(b.BorderClass.selector),p=h.data(l,function(e){return e.key}),d=b.getBorderColor(e.borderSettings);return p.enter().append(n).classed(b.BorderClass["class"],!0),p.style("fill",function(e){return d}).style("fill-opacity",function(i){return e.hasHighlights?t.ColumnUtil.DimmedOpacity:t.ColumnUtil.DefaultOpacity}).attr(a.shapeBorder),p.exit().remove(),u},i.prototype.selectColumn=function(e,a){t.ColumnUtil.setChosenColumnOpacity(this.graphicsContext.mainGraphicsContext,i.classes.item.selector,e,a),this.moveHandle(e)},i.prototype.getClosestColumnIndex=function(e,i){return t.ColumnUtil.getClosestColumnIndex(e,this.getColumnsCenters())},i.prototype.getColumnsCenters=function(){var e=this;if(!this.columnsCenters){var i=this.categoryLayout.categoryThickness*(1-t.CartesianChart.InnerPaddingRatio);if(this.data.series.length>0){var a=0;this.categoryLayout.isScalar||(a=i/2);var r=this.data.series[0];r&&r.data&&(this.columnsCenters=r.data.map(function(t){return e.xProps.scale(e.categoryLayout.isScalar?t.categoryValue:t.categoryIndex)+a}))}}return this.columnsCenters},i.prototype.moveHandle=function(e){var t=this.getColumnsCenters(),i=t[e];if(this.columnSelectionLineHandle){var a=this.columnSelectionLineHandle;a.select("line").attr({x1:i,x2:i}),a.select("circle").attr({cx:i})}else{var a=this.columnSelectionLineHandle=this.graphicsContext.mainGraphicsContext.append("g");a.append("line").classed("interactive-hover-line",!0).attr({x1:i,x2:i,y1:0,y2:this.height}),a.append("circle").attr({cx:i,cy:this.height,r:"6px"}).classed("drag-handle",!0)}},i.getLayout=function(e,i){var a=i.xScale,r=i.yScale,s=r(0),o=a(0),n=b.getBorderWidth(e.borderSettings),l=function(e){var i=t.AxisHelper.diffScaled(a,e.value,0);return i},c=function(e){var i=o+t.AxisHelper.diffScaled(a,e.originalPosition,0)+n*e.categoryIndex;return i},u=function(e){var i=o+t.AxisHelper.diffScaled(a,e.originalPosition,0)+t.AxisHelper.diffScaled(a,e.value,0)+n*e.categoryIndex;return i};return{shapeLayout:{width:l,x:c,y:function(e){return s+t.AxisHelper.diffScaled(r,e.position,0)},height:function(e){return t.StackedUtil.getSize(r,e.valueAbsolute)}},shapeBorder:{width:function(e){return n},x:u,y:function(e){return s+t.AxisHelper.diffScaled(r,e.position,0)},height:function(e){return t.StackedUtil.getSize(r,e.valueAbsolute)}},shapeLayoutWithoutHighlights:{width:l,x:c,y:function(e){return s+t.AxisHelper.diffScaled(r,e.position,0)},height:function(e){return t.StackedUtil.getSize(r,e.originalValueAbsolute)}},zeroShapeLayout:{width:l,x:c,y:function(e){return s+t.AxisHelper.diffScaled(r,e.position,0)+t.StackedUtil.getSize(r,e.valueAbsolute)},height:function(e){return 0}},shapeXAxis:{width:l,x:c,y:function(e){return s+t.AxisHelper.diffScaled(r,e.position,0)},height:function(e){return t.StackedUtil.getSize(r,e.valueAbsolute)}}}},i.prototype.createMekkoLabelDataPoints=function(){for(var t=[],a=this.data,r=a.series,s=h.createColumnFormatterCacheManager(),o=this.layout.shapeLayout,n=0,l=r.length;l>n;n++){var c=r[n],u=c.labelSettings?c.labelSettings:a.labelSettings;if(u.show&&c.data)for(var p=h.getDisplayUnitValueFromAxisFormatter(this.yProps.formatter,u),d=0;d<c.data.length;d++){var g=c.data[d];if((!a.hasHighlights||g.highlight)&&null!=g.value){var m={left:o.x(g),top:o.y(g),width:o.width(g),height:o.height(g)},y=null,f=g.valueOriginal;u.displayUnits||(y=h.hundredPercentFormat,f=g.valueAbsolute);var v=s.getOrCreate(y,u,p),x=h.getLabelFormattedText(v.format(f)),b={text:x,fontFamily:h.LabelTextProperties.fontFamily,fontSize:h.LabelTextProperties.fontSize,fontWeight:h.LabelTextProperties.fontWeight},S=e.TextMeasurementService.measureSvgTextWidth(b),w=e.TextMeasurementService.estimateSvgTextHeight(b);t.push({isPreferred:!0,text:x,textSize:{width:S,height:w},outsideFill:u.labelColor?u.labelColor:h.defaultLabelColor,insideFill:u.labelColor?u.labelColor:h.defaultInsideLabelColor,isParentRect:!0,parentShape:{rect:m,orientation:1,validPositions:i.validLabelPositions},identity:g.identity,parentType:1})}}}return t},i.classes={item:u("column"),highlightItem:u("highlightColumn")},i.validLabelPositions=[1],i}();i.MekkoColumnChartStrategy=d;var g=function(){function i(e){this.isScrollable=!1,e?(this.type=e.chartType,e.isScrollable&&(this.isScrollable=e.isScrollable),this.animator=e.animator,e.cartesianSmallViewPortProperties&&(this.cartesianSmallViewPortProperties=e.cartesianSmallViewPortProperties),e.behavior&&(this.behavior=e.behavior)):this.behavior=new w([new t.ColumnChartWebBehavior])}return i.getTextProperties=function(e){return void 0===e&&(e=i.FontSize),{fontFamily:"wf_segoe-ui_normal",fontSize:a.PixelConverter.toString(e)}},i.prototype.init=function(e){this.visualInitOptions=e,this.layers=[];var a=this.element=e.element,r=this.currentViewport=e.viewport;this.hostServices=e.host,this.brush=d3.svg.brush(),a.addClass(i.ClassName),
3this.margin={top:1,right:1,bottom:1,left:1},this.yAxisOrientation=t.yAxisPosition.left,this.adjustMargins(r),this.sharedColorPalette=new t.SharedColorPalette(e.style.colorPalette.dataColors);var s=!0,o=!0,n=this.svg=d3.select(a.get(0)).append("svg");n.style("position","absolute");var l=this.axisGraphicsContext=n.append("g").classed(i.AxisGraphicsContextClassName,!0);this.svgScrollable=n.append("svg").classed("svgScrollable",!0).style("overflow","hidden");var c=this.axisGraphicsContextScrollable=this.svgScrollable.append("g").classed(i.AxisGraphicsContextClassName,!0);this.labelGraphicsContextScrollable=this.svgScrollable.append("g").classed(h.labelGraphicsContextClass["class"],!0),this.behavior&&(this.clearCatcher=t.appendClearCatcher(this.axisGraphicsContextScrollable));var u=s?c:l;this.xAxisGraphicsContext=s?l.append("g").attr("class","x axis"):c.append("g").attr("class","x axis"),this.y1AxisGraphicsContext=u.append("g").attr("class","y axis"),this.y2AxisGraphicsContext=u.append("g").attr("class","y axis"),this.xAxisGraphicsContext.classed("showLinesOnAxis",s),this.y1AxisGraphicsContext.classed("showLinesOnAxis",o),this.y2AxisGraphicsContext.classed("showLinesOnAxis",o),this.xAxisGraphicsContext.classed("hideLinesOnAxis",!s),this.y1AxisGraphicsContext.classed("hideLinesOnAxis",!o),this.y2AxisGraphicsContext.classed("hideLinesOnAxis",!o),this.behavior&&(this.interactivityService=t.createInteractivityService(this.hostServices)),this.legend=t.createLegend(a,e.interactivity&&e.interactivity.isInteractiveLegend,this.interactivityService,!0)},i.prototype.renderAxesLabels=function(a){this.axisGraphicsContext.selectAll(".xAxisLabel").remove(),this.axisGraphicsContext.selectAll(".yAxisLabel").remove();var r=this.margin,s=a.viewport.width-(r.left+r.right),o=a.viewport.height,n=i.FontSize,l=n,c=this.yAxisOrientation===t.yAxisPosition.right;if(!a.hideXAxisTitle){var u=this.axisGraphicsContext.append("text").style("text-anchor","middle").text(a.axisLabels.x).call(function(e){e.each(function(){var e=d3.select(this);e.attr({"class":"xAxisLabel",transform:t.SVGUtil.translate(s/2,o-l)})})});u.style("fill",a.xLabelColor?a.xLabelColor.solid.color:null),u.call(t.AxisHelper.LabelLayoutStrategy.clip,s,e.TextMeasurementService.svgEllipsis)}if(!a.hideYAxisTitle){var h=this.axisGraphicsContext.append("text").style("text-anchor","middle").text(a.axisLabels.y).call(function(e){e.each(function(){var e=d3.select(this);e.attr({"class":"yAxisLabel",transform:"rotate(-90)",y:c?s+r.right-n:-r.left,x:-((o-r.top-a.legendMargin)/2),dy:"1em"})})});h.style("fill",a.yLabelColor?a.yLabelColor.solid.color:null),h.call(t.AxisHelper.LabelLayoutStrategy.clip,o-(r.bottom+r.top),e.TextMeasurementService.svgEllipsis)}if(!a.hideY2AxisTitle&&a.axisLabels.y2){var p=this.axisGraphicsContext.append("text").style("text-anchor","middle").text(a.axisLabels.y2).call(function(e){e.each(function(){var e=d3.select(this);e.attr({"class":"yAxisLabel",transform:"rotate(-90)",y:c?-r.left:s+r.right-n,x:-((o-r.top-a.legendMargin)/2),dy:"1em"})})});p.style("fill",a.y2LabelColor?a.y2LabelColor.solid.color:null),p.call(t.AxisHelper.LabelLayoutStrategy.clip,o-(r.bottom+r.top),e.TextMeasurementService.svgEllipsis)}},i.prototype.adjustMargins=function(e){var i=this.margin,a=e.width-(i.left+i.right),r=e.height-(i.top+i.bottom),s=this.element.find(".x.axis");0===t.AxisHelper.getRecommendedNumberOfTicksForXAxis(a)&&0===t.AxisHelper.getRecommendedNumberOfTicksForYAxis(r)?(this.margin={top:0,right:0,bottom:0,left:0},s.hide()):s.show()},i.prototype.translateAxes=function(e){this.adjustMargins(e);var a=this.margin,r=e.width-(a.left+a.right),s=e.height-(a.top+a.bottom),o=this.yAxisOrientation===t.yAxisPosition.right;this.xAxisGraphicsContext.attr("transform",t.SVGUtil.translate(0,s)),this.y1AxisGraphicsContext.attr("transform",t.SVGUtil.translate(o?r:0,0)),this.y2AxisGraphicsContext.attr("transform",t.SVGUtil.translate(o?0:r,0)),this.svg.attr({width:e.width,height:e.height}),this.svg.style("top",this.legend.isVisible()?this.legend.getMargins().height+"px":0),this.svgScrollable.attr({width:e.width,height:e.height}),this.svgScrollable.attr({x:0}),this.axisGraphicsContext.attr("transform",t.SVGUtil.translate(a.left,a.top)),this.axisGraphicsContextScrollable.attr("transform",t.SVGUtil.translate(a.left,a.top)),this.labelGraphicsContextScrollable.attr("transform",t.SVGUtil.translate(a.left,a.top)),this.isXScrollBarVisible?(this.svgScrollable.attr({x:this.margin.left}),this.axisGraphicsContextScrollable.attr("transform",t.SVGUtil.translate(0,a.top)),this.labelGraphicsContextScrollable.attr("transform",t.SVGUtil.translate(0,a.top)),this.svgScrollable.attr("width",r),this.svg.attr("width",e.width).attr("height",e.height+i.ScrollBarWidth)):this.isYScrollBarVisible&&(this.svgScrollable.attr("height",s+a.top),this.svg.attr("width",e.width+i.ScrollBarWidth).attr("height",e.height))},i.getIsScalar=function(i,a,r){var s=e.DataViewObjects.getValue(i,a);return i&&void 0!==s?s===t.axisType.scalar&&!t.AxisHelper.isOrdinal(r):!t.AxisHelper.isOrdinal(r)},i.prototype.populateObjectProperties=function(i){if(i&&i.length>0){var a=i[0].metadata;if(a?(this.legendObjectProperties=e.DataViewObjects.getObject(a.objects,"legend",{}),this.borderObjectProperties=e.DataViewObjects.getObject(a.objects,"columnBorder",{})):(this.legendObjectProperties={},this.borderObjectProperties={}),this.categoryAxisProperties=t.CartesianHelper.getCategoryAxisProperties(a),this.valueAxisProperties=t.CartesianHelper.getValueAxisProperties(a),a&&a.objects){var r=a.objects.categoryAxis,s=a.objects.valueAxis;r&&(this.categoryAxisProperties.showBorder=r.showBorder,this.categoryAxisProperties.fontSize=r.fontSize),s&&(this.valueAxisProperties.fontSize=s.fontSize)}var o=this.valueAxisProperties.position;this.yAxisOrientation=o?o.toString():t.yAxisPosition.left}},i.prototype.update=function(e){var a=this.dataViews=e.dataViews;if(this.currentViewport=e.viewport,!a)return void this.clearViewport();if(this.currentViewport.width<i.MinWidth||this.currentViewport.height<i.MinHeight)return void this.clearViewport();0===this.layers.length&&(this.layers=this.createAndInitLayers(a));var r=this.layers;if(a&&a.length>0){var o=t.getInvalidValueWarnings(a,!1,!1,!1);o&&o.length>0&&this.hostServices.setWarnings(o),this.populateObjectProperties(a)}this.sharedColorPalette.clearPreferredScale();for(var n=0,l=r.length;l>n;n++)r[n].setData(s(a,n,l)),l>1&&this.sharedColorPalette.rotateScale();this.visualInitOptions.interactivity&&this.visualInitOptions.interactivity.isInteractiveLegend||this.renderLegend(),this.render(!this.hasSetData||e.suppressAnimations),this.hasSetData=this.hasSetData||a&&a.length>0},i.prototype.clearViewport=function(){this.legend.reset(),this.setVisibility(!1)},i.prototype.setVisibility=function(e){void 0===e&&(e=!0),this.svg.style("display",e?"block":"none"),this.element.find(".legend").toggle(e)},i.parseLabelSettings=function(e){var a=t.dataLabelUtils.getDefaultColumnLabelSettings(!0),r=e.labels,s=i.DefaultSettings.labelSettings.minPrecision,o=i.DefaultSettings.labelSettings.maxPrecision;return t.dataLabelUtils.updateLabelSettingsFromLabelsObject(r,a),a.precision<s&&(a.precision=s),a.precision>o&&(a.precision=o),a},i.parseBorderSettings=function(t){var a=e.DataViewObjects.getValue(t,i.properties.columnBorder.show,i.DefaultSettings.columnBorder.show),r=e.DataViewObjects.getFillColor(t,i.properties.columnBorder.color,i.DefaultSettings.columnBorder.color),s=e.DataViewObjects.getValue(t,i.properties.columnBorder.width,i.DefaultSettings.columnBorder.width),o=i.DefaultSettings.columnBorder.maxWidth;return s>o?s=o:0>s&&(s=0),a||(s=0),{show:a,color:r,width:s}},i.prototype.enumerateBorder=function(t){var a={columnBorder:this.borderObjectProperties},r=e.DataViewObjects.getValue(a,i.properties.columnBorder.show,i.DefaultSettings.columnBorder.show),s=e.DataViewObjects.getFillColor(a,i.properties.columnBorder.color,i.DefaultSettings.columnBorder.color),o=e.DataViewObjects.getValue(a,i.properties.columnBorder.width,i.DefaultSettings.columnBorder.width),n=i.DefaultSettings.columnBorder.maxWidth;o>n?o=n:0>o&&(o=0);var l={objectName:"columnBorder",selector:null,properties:{show:r,color:s,width:o}};t.pushInstance(l)},i.prototype.enumerateObjectInstances=function(i){var a=new t.ObjectEnumerationBuilder,r=this.layers?this.layers.length:0;if("columnBorder"===i.objectName)this.enumerateBorder(a);else if("legend"===i.objectName){if(!this.shouldShowLegendCard())return;var s=e.DataViewObject.getValue(this.legendObjectProperties,t.legendProps.show,this.legend.isVisible()),o=e.DataViewObject.getValue(this.legendObjectProperties,t.legendProps.showTitle,!0),n=e.DataViewObject.getValue(this.legendObjectProperties,t.legendProps.titleText,this.layerLegendData&&this.layerLegendData.title?this.layerLegendData.title:""),l=e.DataViewObject.getValue(this.legendObjectProperties,t.legendProps.fontSize,this.layerLegendData&&this.layerLegendData.fontSize?this.layerLegendData.fontSize:h.DefaultLabelFontSizeInPt);a.pushInstance({selector:null,properties:{show:s,position:t.LegendPosition[this.legend.getOrientation()],showTitle:o,titleText:n,fontSize:l},objectName:i.objectName})}else"categoryAxis"===i.objectName&&this.hasCategoryAxis?this.getCategoryAxisValues(a):"valueAxis"===i.objectName&&this.getValueAxisValues(a);for(var c=0,u=r;u>c;c++){var p=this.layers[c];p.enumerateObjectInstances&&p.enumerateObjectInstances(a,i)}return a.complete()},i.prototype.shouldShowLegendCard=function(){var e=this.layers,t=this.dataViews;if(e&&t)for(var i=e.length,a=0,r=0;i>r;r++){if(e[r].hasLegend())return!0;var s=t[r];if(s&&s.categorical&&s.categorical.values&&s.categorical.values.length>0&&(a++,a>1))return!0}return!1},i.prototype.getCategoryAxisValues=function(e){var i=t.axisType.both,a=!1,r=!!this.axes.x.isLogScaleAllowed,s=[t.axisScale.log,t.axisScale.linear];this.layers&&this.layers[0].getSupportedCategoryAxisType&&(i=this.layers[0].getSupportedCategoryAxisType(),a=i===t.axisType.scalar?!0:t.CartesianHelper.isScalar(i===t.axisType.both,this.categoryAxisProperties)),a||this.categoryAxisProperties&&(this.categoryAxisProperties.start=null,this.categoryAxisProperties.end=null);var o={selector:null,properties:{},objectName:"categoryAxis",validValues:{axisScale:s}};o.properties.show=this.categoryAxisProperties&&null!=this.categoryAxisProperties.show?this.categoryAxisProperties.show:!0,this.yAxisIsCategorical&&(o.properties.position=this.valueAxisProperties&&null!=this.valueAxisProperties.position?this.valueAxisProperties.position:t.yAxisPosition.left),i===t.axisType.both&&(o.properties.axisType=a?t.axisType.scalar:t.axisType.categorical),a&&(o.properties.axisScale=this.categoryAxisProperties&&null!=this.categoryAxisProperties.axisScale&&r?this.categoryAxisProperties.axisScale:t.axisScale.linear,o.properties.start=this.categoryAxisProperties?this.categoryAxisProperties.start:null,o.properties.end=this.categoryAxisProperties?this.categoryAxisProperties.end:null),o.properties.showAxisTitle=this.categoryAxisProperties&&null!=this.categoryAxisProperties.showAxisTitle?this.categoryAxisProperties.showAxisTitle:!1,o.properties.showBorder=this.categoryAxisProperties&&null!=this.categoryAxisProperties.showBorder?this.categoryAxisProperties.showAxisTitle:!1,o.properties.fontSize=this.categoryAxisProperties&&null!=this.categoryAxisProperties.fontSize?this.categoryAxisProperties.fontSize:h.DefaultLabelFontSizeInPt,e.pushInstance(o).pushInstance({selector:null,properties:{axisStyle:this.categoryAxisProperties&&this.categoryAxisProperties.axisStyle?this.categoryAxisProperties.axisStyle:t.axisStyle.showTitleOnly,labelColor:this.categoryAxisProperties?this.categoryAxisProperties.labelColor:null,fontSize:this.categoryAxisProperties&&null!=this.categoryAxisProperties.fontSize?this.categoryAxisProperties.fontSize:h.DefaultLabelFontSizeInPt},objectName:"categoryAxis",validValues:{axisStyle:this.categoryAxisHasUnitType?[t.axisStyle.showTitleOnly,t.axisStyle.showUnitOnly,t.axisStyle.showBoth]:[t.axisStyle.showTitleOnly]}})},i.prototype.getValueAxisValues=function(e){var i=[t.axisScale.log,t.axisScale.linear],a=!!this.axes.y1.isLogScaleAllowed,r={selector:null,properties:{},objectName:"valueAxis",validValues:{axisScale:i,secAxisScale:i}};r.properties.show=this.valueAxisProperties&&null!=this.valueAxisProperties.show?this.valueAxisProperties.show:!0,this.yAxisIsCategorical||(r.properties.position=this.valueAxisProperties&&null!=this.valueAxisProperties.position?this.valueAxisProperties.position:t.yAxisPosition.left),r.properties.axisScale=this.valueAxisProperties&&null!=this.valueAxisProperties.axisScale&&a?this.valueAxisProperties.axisScale:t.axisScale.linear,r.properties.start=this.valueAxisProperties?this.valueAxisProperties.start:null,r.properties.end=this.valueAxisProperties?this.valueAxisProperties.end:null,r.properties.showAxisTitle=this.valueAxisProperties&&null!=this.valueAxisProperties.showAxisTitle?this.valueAxisProperties.showAxisTitle:!1,r.properties.fontSize=this.valueAxisProperties&&null!=this.valueAxisProperties.fontSize?this.valueAxisProperties.fontSize:h.DefaultLabelFontSizeInPt,e.pushInstance(r).pushInstance({selector:null,properties:{axisStyle:this.valueAxisProperties&&null!=this.valueAxisProperties.axisStyle?this.valueAxisProperties.axisStyle:t.axisStyle.showTitleOnly,labelColor:this.valueAxisProperties?this.valueAxisProperties.labelColor:null,fontSize:this.valueAxisProperties&&null!=this.valueAxisProperties.fontSize?this.valueAxisProperties.fontSize:h.DefaultLabelFontSizeInPt},objectName:"valueAxis",validValues:{axisStyle:this.valueAxisHasUnitType?[t.axisStyle.showTitleOnly,t.axisStyle.showUnitOnly,t.axisStyle.showBoth]:[t.axisStyle.showTitleOnly]}}),2===this.layers.length&&(r.properties.secShow=this.valueAxisProperties&&null!=this.valueAxisProperties.secShow?this.valueAxisProperties.secShow:this.y2AxisExists,r.properties.secShow&&(r.properties.axisLabel=""))},i.prototype.onClearSelection=function(){if(this.hasSetData)for(var e=0,t=this.layers.length;t>e;e++){var i=this.layers[e];i.onClearSelection(),i.render(!0)}},i.prototype.createAndInitLayers=function(t){var i,a=this;if(t&&t.length>0){var r=t[0].metadata;r&&(i=r.objects)}var s=l(this.type,i,this.interactivityService,this.animator,this.isScrollable),o=e.Prototype.inherit(this.visualInitOptions);o.svg=this.axisGraphicsContextScrollable,o.cartesianHost={updateLegend:function(e){return a.legend.drawLegend(e,a.currentViewport)},getSharedColors:function(){return a.sharedColorPalette},triggerRender:void 0};for(var n=0,c=s.length;c>n;n++)s[n].init(o);return s},i.prototype.renderLegend=function(){for(var e=this.layers,i={title:"",dataPoints:[]},a=0,r=e.length;r>a;a++)this.layerLegendData=e[a].calculateLegend(),this.layerLegendData&&(i.title=0===a?this.layerLegendData.title||"":i.title,i.dataPoints=i.dataPoints.concat(this.layerLegendData.dataPoints||[]),this.layerLegendData.grouped&&(i.grouped=!0));var s=this.legendObjectProperties;if(s){s.fontSize||(s.fontSize=h.DefaultLabelFontSizeInPt),t.LegendData.update(i,s);var o=s[t.legendProps.position];o&&this.legend.changeOrientation(t.LegendPosition[o])}else this.legend.changeOrientation(t.LegendPosition.Top);(1===i.dataPoints.length&&!i.grouped||this.hideLegends())&&(i.dataPoints=[]),this.legend.drawLegend(i,this.currentViewport)},i.prototype.hideLegends=function(){return!!(this.cartesianSmallViewPortProperties&&this.cartesianSmallViewPortProperties.hideLegendOnSmallViewPort&&this.currentViewport.height<this.cartesianSmallViewPortProperties.MinHeightLegendVisible)},i.prototype.addUnitTypeToAxisLabel=function(e){var a=i.getUnitType(e,function(e){return e.x});if(e.x.isCategoryAxis?this.categoryAxisHasUnitType=null!==a:this.valueAxisHasUnitType=null!==a,e.x.axisLabel&&a&&(e.x.isCategoryAxis?e.x.axisLabel=t.AxisHelper.createAxisLabel(this.categoryAxisProperties,e.x.axisLabel,a):e.x.axisLabel=t.AxisHelper.createAxisLabel(this.valueAxisProperties,e.x.axisLabel,a)),a=i.getUnitType(e,function(e){return e.y1}),e.y1.isCategoryAxis?this.categoryAxisHasUnitType=null!==a:this.valueAxisHasUnitType=null!==a,e.y1.axisLabel&&a&&(e.y1.isCategoryAxis?e.y1.axisLabel=t.AxisHelper.createAxisLabel(this.categoryAxisProperties,e.y1.axisLabel,a):e.y1.axisLabel=t.AxisHelper.createAxisLabel(this.valueAxisProperties,e.y1.axisLabel,a)),e.y2){var a=i.getUnitType(e,function(e){return e.y2});this.secValueAxisHasUnitType=null!==a,e.y2.axisLabel&&a&&this.valueAxisProperties&&this.valueAxisProperties.secAxisStyle&&(this.valueAxisProperties.secAxisStyle===t.axisStyle.showBoth?e.y2.axisLabel=e.y2.axisLabel+" ("+a+")":this.valueAxisProperties.secAxisStyle===t.axisStyle.showUnitOnly&&(e.y2.axisLabel=a))}},i.prototype.shouldRenderSecondaryAxis=function(e){return e&&(!this.valueAxisProperties||null==this.valueAxisProperties.secShow||this.valueAxisProperties.secShow)?e.values&&e.values.length>0:!1},i.prototype.shouldRenderAxis=function(e,t){return void 0===t&&(t="show"),e?(!e.isCategoryAxis||this.categoryAxisProperties&&null!=this.categoryAxisProperties[t]&&!this.categoryAxisProperties[t])&&(e.isCategoryAxis||this.valueAxisProperties&&null!=this.valueAxisProperties[t]&&!this.valueAxisProperties[t])?!1:e.values&&e.values.length>0:!1},i.prototype.render=function(a){this.setVisibility(!0);var s=this.legendMargins=this.legend.getMargins(),o={height:this.currentViewport.height-s.height,width:this.currentViewport.width-s.width},l=this.getMaxMarginFactor(),c=this.leftRightMarginLimit=o.width*l;this.bottomMarginLimit=Math.max(i.MinBottomMargin,Math.ceil(o.height*l));var u=i.getTextProperties(this.categoryAxisProperties&&parseFloat(this.categoryAxisProperties.fontSize)||void 0),h=i.getTextProperties(this.valueAxisProperties&&parseFloat(this.valueAxisProperties.fontSize)||void 0),p=this.margin;p.top=parseFloat(h.fontSize)/2,p.bottom=i.MinBottomMargin,p.right=0;var d=this.axes=n(this.layers,o,p,this.categoryAxisProperties,this.valueAxisProperties,this.isXScrollBarVisible||this.isYScrollBarVisible,null);this.yAxisIsCategorical=d.y1.isCategoryAxis,this.hasCategoryAxis=this.yAxisIsCategorical?d.y1&&d.y1.values.length>0:d.x&&d.x.values.length>0;var g,m,y=this.shouldRenderAxis(d.x),f=this.shouldRenderAxis(d.y1),v=this.shouldRenderSecondaryAxis(d.y2),x=o.width-(p.left+p.right),b=!1;this.isXScrollBarVisible=!1,this.isYScrollBarVisible=!1;var S=this.yAxisOrientation,w=S===t.yAxisPosition.right;if(this.layers&&(this.layers[0].getVisualCategoryAxisIsScalar&&(b=this.layers[0].getVisualCategoryAxisIsScalar()),!b&&this.isScrollable&&this.layers[0].getPreferredPlotArea)){var C=this.scrollX?d.x.categoryThickness:d.y1.categoryThickness,P=this.scrollX?d.x.values.length:d.y1.values.length;m=this.layers[0].getPreferredPlotArea(b,P,C),this.scrollX&&m&&m.width>o.width&&(this.isXScrollBarVisible=!0,o.height-=i.ScrollBarWidth),this.scrollY&&m&&m.height>o.height&&(this.isYScrollBarVisible=!0,o.width-=i.ScrollBarWidth,x=o.width-(p.left+p.right))}this.isXScrollBarVisible||this.isYScrollBarVisible?this.brushGraphicsContext||(this.brushGraphicsContext=this.svg.append("g").classed("x brush",!0)):(this.svg.selectAll(".brush").remove(),this.brushGraphicsContext=void 0),d=n(this.layers,o,p,this.categoryAxisProperties,this.valueAxisProperties,this.isXScrollBarVisible||this.isYScrollBarVisible,null);for(var D=!1,A=2,T=0,V=void 0,N=void 0,L=void 0;!D&&A>T;){T++,V=r({width:x,height:o.height},c,e.TextMeasurementService.measureSvgTextWidth,e.TextMeasurementService.estimateSvgTextHeight,d,this.bottomMarginLimit,u,h,null,!1,this.isXScrollBarVisible||this.isYScrollBarVisible,w,y,f,v);var M=w?V.yRight:V.yLeft,k=w?V.yLeft:V.yRight,O=y?V.xMax/1.8:0;M+=i.LeftPadding,k+=i.RightPadding,O+=i.BottomPadding,this.hideAxisLabels(s)&&(d.x.axisLabel=null,d.y1.axisLabel=null,d.y2&&(d.y2.axisLabel=null)),this.addUnitTypeToAxisLabel(d),L={x:d.x.axisLabel,y:d.y1.axisLabel,y2:d.y2?d.y2.axisLabel:null},N=null!=L.x||null!=L.y||null!=L.y2,null!=L.x&&(O+=i.XAxisLabelPadding),null!=L.y&&(M+=i.YAxisLabelPadding),null!=L.y2&&(k+=i.YAxisLabelPadding),p.left=w?k:M,p.right=w?M:k,p.bottom=O,this.margin=p,x=o.width-(p.left+p.right);var I=d.y1.values.length,j=d.y2&&d.y2.values.length;d=n(this.layers,o,p,this.categoryAxisProperties,this.valueAxisProperties,this.isXScrollBarVisible||this.isYScrollBarVisible,d),d.y1.values.length!==I||d.y2&&d.y2.values.length!==j||(D=!0)}this.renderChart(g,d,x,V,N,L,o,a)},i.prototype.hideAxisLabels=function(e){return!(!(this.cartesianSmallViewPortProperties&&this.cartesianSmallViewPortProperties.hideAxesOnSmallViewPort&&this.currentViewport.height+e.height<this.cartesianSmallViewPortProperties.MinHeightAxesVisible)||this.visualInitOptions.interactivity.isInteractiveLegend)},i.getUnitType=function(e,t){return t(e).formatter&&t(e).formatter.displayUnit&&t(e).formatter.displayUnit.value>1?t(e).formatter.displayUnit.title:null},i.prototype.getMaxMarginFactor=function(){return this.visualInitOptions.style.maxMarginFactor||i.MaxMarginFactor},i.getChartViewport=function(e,t){return{width:e.width-t.left-t.right,height:e.height-t.top-t.bottom}},i.wordBreak=function(t,i,a,r,s){t.each(function(t,s){var o,n,l=d3.select(this);a.length>=s?(o=a[s],n=i.scale(o)):n=i.xLabelMaxWidth,l.style("text-anchor","middle").attr({dx:"0em",dy:"1em",transform:"rotate(0)"}),e.TextMeasurementService.wordBreak(this,n,i.willLabelsWordBreak?r:0)})},i.prototype.renderChart=function(a,r,s,o,n,l,c,u,p,d){var g,m,y,f,v,x=this.bottomMarginLimit,b=this.leftRightMarginLimit,S=this.layers,w=t.AnimatorCommon.GetAnimationDuration(this.animator,u),C=i.getChartViewport(c,this.margin);if(this.shouldRenderAxis(r.x)){r.x.isCategoryAxis?(g=this.categoryAxisProperties&&this.categoryAxisProperties.labelColor?this.categoryAxisProperties.labelColor:null,f=this.categoryAxisProperties&&null!=this.categoryAxisProperties.fontSize?this.categoryAxisProperties.fontSize:h.DefaultLabelFontSizeInPt):(g=this.valueAxisProperties&&this.valueAxisProperties.labelColor?this.valueAxisProperties.labelColor:null,f=this.valueAxisProperties&&this.valueAxisProperties.fontSize?this.valueAxisProperties.fontSize:h.DefaultLabelFontSizeInPt),r.x.axis.orient("bottom"),r.x.willLabelsFit||r.x.axis.tickPadding(i.TickPaddingRotatedX);var P=this.xAxisGraphicsContext;w?P.transition().duration(w).call(r.x.axis):P.call(r.x.axis),P.call(i.darkenZeroLine).call(i.setAxisLabelColor,g).call(i.setAxisLabelFontSize,f);var D=P.selectAll("text"),A=[],T=0;this.layers&&this.layers.length&&(A=this.layers[0].getColumnsWidth(),T=this.layers[0].getBorderWidth()),P.call(i.moveBorder,r.x.scale,T,f/2-8),D.call(i.wordBreak,r.x,A,x,T)}else this.xAxisGraphicsContext.selectAll("*").remove();if(this.shouldRenderAxis(r.y1)){r.y1.isCategoryAxis?(m=this.categoryAxisProperties&&this.categoryAxisProperties.labelColor?this.categoryAxisProperties.labelColor:null,v=this.categoryAxisProperties&&null!=this.categoryAxisProperties.fontSize?this.categoryAxisProperties.fontSize:h.DefaultLabelFontSizeInPt):(m=this.valueAxisProperties&&this.valueAxisProperties.labelColor?this.valueAxisProperties.labelColor:null,v=this.valueAxisProperties&&null!=this.valueAxisProperties.fontSize?this.valueAxisProperties.fontSize:h.DefaultLabelFontSizeInPt);var V=this.yAxisOrientation,N=V===t.yAxisPosition.right;r.y1.axis.tickSize(-s).tickPadding(i.TickPaddingY).orient(V.toLowerCase());var L=this.y1AxisGraphicsContext;w?L.transition().duration(w).call(r.y1.axis):L.call(r.y1.axis),L.call(i.darkenZeroLine).call(i.setAxisLabelColor,m).call(i.setAxisLabelFontSize,v),o.yLeft>=b&&L.selectAll("text").call(t.AxisHelper.LabelLayoutStrategy.clip,b-i.LeftPadding,e.TextMeasurementService.svgEllipsis),!r.y2||this.valueAxisProperties&&null!=this.valueAxisProperties.secShow&&!this.valueAxisProperties.secShow?this.y2AxisGraphicsContext.selectAll("*").remove():(y=this.valueAxisProperties&&this.valueAxisProperties.secLabelColor?this.valueAxisProperties.secLabelColor:null,r.y2.axis.tickPadding(i.TickPaddingY).orient(N?t.yAxisPosition.left.toLowerCase():t.yAxisPosition.right.toLowerCase()),w?this.y2AxisGraphicsContext.transition().duration(w).call(r.y2.axis):this.y2AxisGraphicsContext.call(r.y2.axis),this.y2AxisGraphicsContext.call(i.darkenZeroLine).call(i.setAxisLabelColor,y),o.yRight>=b&&this.y2AxisGraphicsContext.selectAll("text").call(t.AxisHelper.LabelLayoutStrategy.clip,b-i.RightPadding,e.TextMeasurementService.svgEllipsis))}else this.y1AxisGraphicsContext.selectAll("*").remove(),this.y2AxisGraphicsContext.selectAll("*").remove();if(n){var M=!this.shouldRenderAxis(r.x,"showAxisTitle"),k=!this.shouldRenderAxis(r.y1,"showAxisTitle"),O=this.valueAxisProperties&&null!=this.valueAxisProperties.secShowAxisTitle&&this.valueAxisProperties.secShowAxisTitle===!1,I={axisLabels:l,legendMargin:this.legendMargins.height,viewport:c,hideXAxisTitle:M,hideYAxisTitle:k,hideY2AxisTitle:O,xLabelColor:g,yLabelColor:m,y2LabelColor:y,margin:void 0};this.renderAxesLabels(I)}else this.axisGraphicsContext.selectAll(".xAxisLabel").remove(),this.axisGraphicsContext.selectAll(".yAxisLabel").remove();this.translateAxes(c);var j=[],F=[],z=[];if(this.behavior){for(var G=0,R=S.length;R>G;G++){var H=S[G].render(u);if(H)if(j=j.concat(H.dataPoints),F.push(H.behaviorOptions),H.labelDataPointGroups)for(var B=H.labelDataPointGroups,U=0,E=B.length;E>U;U++){var W=B[U];z.push({labelDataPoints:W.labelDataPoints,maxNumberOfLabels:W.maxNumberOfLabels})}else{var _=H.labelDataPoints,Y=_;z.push({labelDataPoints:Y,maxNumberOfLabels:Y.length})}}var X={maximumOffset:h.maxLabelOffset,startingOffset:h.startingLabelOffset},q=new e.LabelLayout(X),K=q.layout(z,C);if(S.length>1&&h.drawLabelBackground(this.labelGraphicsContextScrollable,K,"#FFFFFF",.7),this.animator&&!u?h.animateDefaultLabels(this.labelGraphicsContextScrollable,K,this.animator.getDuration()):h.drawDefaultLabels(this.labelGraphicsContextScrollable,K),this.labelGraphicsContextScrollable.selectAll("text.label").style("pointer-events","none"),this.interactivityService){var Z={layerOptions:F,clearCatcher:this.clearCatcher};this.interactivityService.bind(j,this.behavior,Z)}}},i.darkenZeroLine=function(e){var t=e.selectAll("g.tick").filter(function(e){return 0===e}).node();t&&d3.select(t).select("line").classed("zero-line",!0)},i.setAxisLabelColor=function(e,t){e.selectAll("g.tick text").style("fill",t?t.solid.color:null)},i.setAxisLabelFontSize=function(e,t){var i=a.PixelConverter.toString(t);e.selectAll("g.tick text").attr("font-size",i)},i.moveBorder=function(e,i,a,r){void 0===r&&(r=0),e.selectAll("g.tick").attr("transform",function(e,s){return t.SVGUtil.translate(i(e)+a*s,r)})},i.capabilities={dataRoles:[{name:"Category",kind:e.VisualDataRoleKind.Grouping,displayName:"Category"},{name:"Series",kind:e.VisualDataRoleKind.Grouping,displayName:"Series"},{name:"Y",kind:e.VisualDataRoleKind.Measure,displayName:"Y Axis"},{name:"Width",kind:e.VisualDataRoleKind.Measure,displayName:"Axis width"}],objects:{columnBorder:{displayName:"Column Border",properties:{show:{displayName:e.data.createDisplayNameGetter("Visual_Show"),type:{bool:!0}},color:{displayName:e.data.createDisplayNameGetter("Visual_LabelsFill"),description:e.data.createDisplayNameGetter("Visual_LabelsFillDescription"),type:{fill:{solid:{color:!0}}}},width:{displayName:"Width",type:{numeric:!0}}}},labels:{displayName:e.data.createDisplayNameGetter("Visual_DataPointsLabels"),description:e.data.createDisplayNameGetter("Visual_DataPointsLabelsDescription"),properties:{show:{displayName:e.data.createDisplayNameGetter("Visual_Show"),type:{bool:!0}},showSeries:{displayName:e.data.createDisplayNameGetter("Visual_Show"),type:{bool:!0}},color:{displayName:e.data.createDisplayNameGetter("Visual_LabelsFill"),description:e.data.createDisplayNameGetter("Visual_LabelsFillDescription"),type:{fill:{solid:{color:!0}}}},labelDisplayUnits:{displayName:e.data.createDisplayNameGetter("Visual_DisplayUnits"),description:e.data.createDisplayNameGetter("Visual_DisplayUnitsDescription"),type:{formatting:{labelDisplayUnits:!0}},suppressFormatPainterCopy:!0},labelPrecision:{displayName:e.data.createDisplayNameGetter("Visual_Precision"),description:e.data.createDisplayNameGetter("Visual_PrecisionDescription"),placeHolderText:e.data.createDisplayNameGetter("Visual_Precision_Auto"),type:{numeric:!0},suppressFormatPainterCopy:!0},showAll:{displayName:e.data.createDisplayNameGetter("Visual_ShowAll"),type:{bool:!0}},fontSize:{displayName:e.data.createDisplayNameGetter("Visual_TextSize"),type:{formatting:{fontSize:!0}}}}},legend:{displayName:e.data.createDisplayNameGetter("Visual_Legend"),properties:{show:{displayName:e.data.createDisplayNameGetter("Visual_Show"),type:{bool:!0}},position:{displayName:e.data.createDisplayNameGetter("Visual_LegendPosition"),type:{formatting:{legendPosition:!0}}},showTitle:{displayName:e.data.createDisplayNameGetter("Visual_LegendShowTitle"),type:{bool:!0}},titleText:{displayName:"Title text",type:{text:!0}},fontSize:{displayName:"Text size",type:{formatting:{fontSize:!0}}}}},categoryAxis:{displayName:e.data.createDisplayNameGetter("Visual_XAxis"),properties:{show:{displayName:e.data.createDisplayNameGetter("Visual_Show"),type:{bool:!0}},position:{displayName:e.data.createDisplayNameGetter("Visual_YAxis_Position"),type:{formatting:{yAxisPosition:!0}}},axisScale:{displayName:e.data.createDisplayNameGetter("Visual_Axis_Scale"),type:{formatting:{axisScale:!0}}},axisType:{displayName:e.data.createDisplayNameGetter("Visual_Axis_Type"),type:{formatting:{axisType:!0}}},showAxisTitle:{displayName:e.data.createDisplayNameGetter("Visual_Axis_Title"),type:{bool:!0}},axisStyle:{displayName:e.data.createDisplayNameGetter("Visual_Axis_Style"),type:{formatting:{axisStyle:!0}}},labelColor:{displayName:e.data.createDisplayNameGetter("Visual_Axis_LabelColor"),type:{fill:{solid:{color:!0}}}},fontSize:{displayName:e.data.createDisplayNameGetter("Visual_TextSize"),type:{formatting:{fontSize:!0}}}}},valueAxis:{displayName:e.data.createDisplayNameGetter("Visual_YAxis"),properties:{show:{displayName:e.data.createDisplayNameGetter("Visual_Show"),type:{bool:!0}},position:{displayName:e.data.createDisplayNameGetter("Visual_YAxis_Position"),type:{formatting:{yAxisPosition:!0}}},axisScale:{displayName:e.data.createDisplayNameGetter("Visual_Axis_Scale"),type:{formatting:{axisScale:!0}}},intersection:{displayName:e.data.createDisplayNameGetter("Visual_Axis_Intersection"),type:{numeric:!0}},showAxisTitle:{displayName:e.data.createDisplayNameGetter("Visual_Axis_Title"),type:{bool:!0}},axisStyle:{displayName:e.data.createDisplayNameGetter("Visual_Axis_Style"),type:{formatting:{axisStyle:!0}}},labelColor:{displayName:e.data.createDisplayNameGetter("Visual_Axis_LabelColor"),type:{fill:{solid:{color:!0}}}},fontSize:{displayName:e.data.createDisplayNameGetter("Visual_TextSize"),type:{formatting:{fontSize:!0}}}}},dataPoint:{displayName:e.data.createDisplayNameGetter("Visual_DataPoint"),properties:{defaultColor:{displayName:e.data.createDisplayNameGetter("Visual_DefaultColor"),type:{fill:{solid:{color:!0}}}},showAllDataPoints:{displayName:e.data.createDisplayNameGetter("Visual_DataPoint_Show_All"),type:{bool:!0}},fill:{displayName:e.data.createDisplayNameGetter("Visual_Fill"),type:{fill:{solid:{color:!0}}}},fillRule:{displayName:e.data.createDisplayNameGetter("Visual_Gradient"),type:{fillRule:{}},rule:{inputRole:"Gradient",output:{property:"fill",selector:["Category"]}}}}}},dataViewMappings:[{conditions:[{Category:{min:0,max:1},Series:{min:0,max:1},Y:{min:0,max:1},Width:{min:0,max:1}}],categorical:{categories:{"for":{"in":"Category"},dataReductionAlgorithm:{top:{}}},values:{group:{by:"Series",select:[{"for":{"in":"Y"}},{"for":{"in":"Width"}}],dataReductionAlgorithm:{top:{}}}},rowCount:{preferred:{min:1,max:1},supported:{min:0}}}}],supportsHighlight:!0,sorting:{"default":{}},drilldown:{roles:["Category"]}},i.properties={general:{formatString:{objectName:"general",propertyName:"formatString"}},columnBorder:{show:{objectName:"columnBorder",propertyName:"show"},color:{objectName:"columnBorder",propertyName:"color"},width:{objectName:"columnBorder",
4propertyName:"width"}}},i.DefaultSettings={columnBorder:{show:!0,color:"#fff",width:2,maxWidth:5},labelSettings:{maxPrecision:4,minPrecision:0}},i.MinOrdinalRectThickness=20,i.MinScalarRectThickness=2,i.OuterPaddingRatio=.4,i.InnerPaddingRatio=.2,i.TickLabelPadding=2,i.ClassName="cartesianChart",i.AxisGraphicsContextClassName="axisGraphicsContext",i.MaxMarginFactor=.25,i.MinBottomMargin=50,i.LeftPadding=10,i.RightPadding=10,i.BottomPadding=16,i.YAxisLabelPadding=20,i.XAxisLabelPadding=20,i.TickPaddingY=10,i.TickPaddingRotatedX=5,i.FontSize=11,i.MaxNumberOfLabels=100,i.MinWidth=100,i.MinHeight=100,i.ScrollBarWidth=10,i}();i.MekkoChart=g,i.createLayers=l;var m=a.EnumExtensions,y=a.ArrayExtensions,f=2,v=16,x={category:"Category",series:"Series",y:"Y",width:"Width"},b=function(){function i(e){var t=e.chartType;this.chartType=t,this.categoryAxisType=null,this.animator=e.animator,this.isScrollable=e.isScrollable,this.interactivityService=e.interactivityService}return i.prototype.init=function(e){this.svg=e.svg,this.unclippedGraphicsContext=this.svg.append("g").classed("columnChartUnclippedGraphicsContext",!0),this.mainGraphicsContext=this.unclippedGraphicsContext.append("svg").classed("columnChartMainGraphicsContext",!0),this.labelGraphicsContext=this.svg.append("g").classed(h.labelGraphicsContextClass["class"],!0),this.style=e.style,this.currentViewport=e.viewport,this.hostService=e.host,this.interactivity=e.interactivity,this.colors=this.style.colorPalette.dataColors,this.cartesianVisualHost=e.cartesianHost,this.options=e,this.supportsOverflow=!m.hasFlag(this.chartType,v);var t=this.element=e.element;t.addClass(i.ColumnChartClassName),this.columnChart=new d},i.prototype.getCategoryLayout=function(e,i){var a=this.currentViewport.width-(this.margin.left+this.margin.right),r=this.data?this.data.categoryMetadata:void 0,s=t.AxisHelper.getCategoryValueType(r),o=this.data?this.data.scalarCategoryAxis:!1,n=t.AxisHelper.createDomain(this.data.series,s,o,i.forcedXDomain);return t.CartesianChart.getLayout(this.data,{availableWidth:a,categoryCount:e,domain:n,isScalar:o,isScrollable:this.isScrollable,trimOrdinalDataOnOverflow:!1})},i.getBorderWidth=function(e){if(!e||!e.show||!e.width)return 0;var t=e.width;return 0>t?0:t>e.maxWidth?e.maxWidth:t},i.getBorderColor=function(e){return e?e.color:g.DefaultSettings.columnBorder.color},i.converter=function(a,r,s,o,n,l,c){void 0===s&&(s=!1),void 0===o&&(o=!1),void 0===n&&(n=!1),void 0===l&&(l=null);var u=t.CartesianHelper.getCategoryAxisProperties(l),h=t.CartesianHelper.getValueAxisProperties(l);o=t.CartesianHelper.isScalar(o,u),a=t.ColumnUtil.applyUserMinMax(o,a,u);var p=new S(a),d=t.converterHelper.getPivotedCategories(a,t.columnChartProps.general.formatString),m=d.categories,y=d.categoryFormatter,f=d.categoryIdentities,v=a.categories&&a.categories.length>0?a.categories[0].source:void 0,b=g.DefaultSettings.columnBorder,w=t.dataLabelUtils.getDefaultColumnLabelSettings(!0),C=void 0,P=void 0;if(l&&l.objects){var D=l.objects;C=e.DataViewObjects.getFillColor(D,t.columnChartProps.dataPoint.defaultColor),P=e.DataViewObjects.getValue(D,t.columnChartProps.dataPoint.showAllDataPoints),w=g.parseLabelSettings(D),b=g.parseBorderSettings(D)}for(var A=p.getLegend(r,C),T=A.legend.dataPoints,V=A.seriesSources,N=i.createDataPoints(a,m,f,T,A.seriesObjects,p,w,s,o,n,t.converterHelper.categoryIsAlsoSeriesRole(a,x.series,x.category),d.categoryObjects,C,c,v),L=N.series,M=[],k=0,O=T.length;O>k;k++)M.push(V[k]);var I=t.converterHelper.createAxesLabels(u,h,v,M);return{categories:m,categoriesWidth:N.categoriesWidth,categoryFormatter:y,series:L,valuesMetadata:M,legendData:A.legend,hasHighlights:N.hasHighlights,categoryMetadata:v,scalarCategoryAxis:o,borderSettings:b,labelSettings:w,axesLabels:{x:I.xAxisLabel,y:I.yAxisLabel},hasDynamicSeries:N.hasDynamicSeries,defaultDataPointColor:C,showAllDataPoints:P,isMultiMeasure:!1}},i.getStackedMultiplier=function(e,i,a,r){for(var s=0,o=0,n=0;a>n;n++){var l=e[n][i];l=t.AxisHelper.normalizeNonFiniteNumber(l),l>0?s+=l:0>l&&(o-=l)}var c=s+o;return{pos:s?s/c/s:1,neg:o?o/c/o:1}},i.createDataPoints=function(a,r,s,o,n,l,c,u,h,p,d,g,y,f,b){void 0===u&&(u=!1),void 0===h&&(h=!1),void 0===p&&(p=!1);var S=a&&a.values?a.values.grouped():void 0,w=r.length,C=o.length,P=[];if(1>C||1>w||null===r[0])return{series:P,hasHighlights:!1,hasDynamicSeries:!1,categoriesWidth:[]};var D=a.categories;b=D&&D.length>0?D[0].source:null;var A=t.AxisHelper.getCategoryValueType(b),T=t.AxisHelper.isDateTime(A),V=[],N=[],L=[],M=[],k=!(!a.values||!a.values.source),O=[],I=-1,j=0,F=!1,z=l.hasHighlightValues(0);for(j=0;j<a.values.length;j++)if(a.values[j].source.roles&&a.values[j].source.roles[x.width]&&!a.values[j].source.roles[x.y]){I=j;for(var G=a.values[j].values,R=0,H=G.length;H>R;R++)O[R]=d3.sum([0,O[R],G[R]])}else{for(var B=[],U=[],E=0;w>E;E++){var W=l.getValueBySeriesAndCategory(j,E);if(B[E]=W,z){var _=l.getHighlightBySeriesAndCategory(j,E);U[E]=_,W>=0&&_>=0&&W>=_||0>=W&&0>=_&&_>=W||(F=!0)}}L.push(B),z&&M.push(U)}if(F&&!p&&(F=!1,z=!1,L=M),O.length<1)for(j=0;j<a.values.length;j++)if(a.values[j].source.roles&&a.values[j].source.roles[x.width]){I=j;for(var G=a.values[j].values,R=0,H=G.length;H>R;R++)O[R]=d3.sum([0,O[R],G[R]])}else;if(O.length<1)for(j=0;w>j;j++)O.push(1);var Y=d3.sum(O),X=d3.scale.linear().domain([0,Y]).range([0,1]),q=[0],K=[];for(j=0;w-1>j;j++){var Z=q[q.length-1]+(O[j]||0);q.push(Z)}for(j=0;w>j;j++)q[j]=X(q[j]),K[j]=X(O[j]);var J=g,Q=t.columnChartProps.general.formatString;for(j=0;C>j;j++){var $,ee=[],te=o[j];if(!k){var ie=S&&S.length>0&&S[0].values?S[0].values[j]:null,ae=ie&&ie.source&&ie.source.objects?ie.source.objects.labels:null;ae&&($=e.Prototype.inherit(c),t.dataLabelUtils.updateLabelSettingsFromLabelsObject(ae,$))}var re={displayName:te.label,key:"series"+j,index:j,data:ee,identity:te.identity,color:te.color,labelSettings:$};C>1&&(J=n[j]);for(var se=a.values[j].source,E=0;w>E;E++){0===j&&(V.push(0),N.push(0));var W=t.AxisHelper.normalizeNonFiniteNumber(L[j][E]);if(!(null==W&&j>0)){var oe=W,ne=r[E];if(T&&ne&&(ne=ne.getTime()),!h||null!=ne&&!isNaN(ne)){var le;u&&(le=i.getStackedMultiplier(L,E,C,w));var ce=W,ue=0>W;le&&(W*=ue?le.neg:le.pos);var he,pe=Math.abs(W);ue?(he=N[E],isNaN(pe)||(N[E]-=pe)):(isNaN(pe)||(V[E]+=pe),he=V[E]);var de=S&&S.length>j&&S[j].values?S[j]:null,ge=a.categories&&a.categories.length>0?a.categories[0]:null,me=t.SelectionIdBuilder.builder().withCategory(ge,E).withSeries(a.values,de).withMeasure(l.getMeasureNameByIndex(j)).createSelectionId(),ye=r[E],fe=i.getDataPointColor(te,E,J),ve=[];if(de){var xe={values:[],source:a.values.source};ve.push({value:de.name,metadata:xe});for(var be=0;be<de.values.length;be++){var Se=de.values[be];ve.push({value:Se.values[E],metadata:Se})}}var we=t.TooltipBuilder.createTooltipInfo(Q,null,ye,oe,[ge],ve,null,E),Ce=re&&re.labelSettings?re.labelSettings:c,Pe=Ce.labelColor,De=void 0;m.hasFlag(f,v)&&(De=this.getStackedLabelColor(ue,j,C,E,L),Pe=De||j===C-1&&!ue?Pe:t.dataLabelUtils.defaultInsideLabelColor),W=K[E];var Ae=q[E],Te={categoryValue:ne,value:W,position:he,valueAbsolute:pe,valueOriginal:ce,seriesIndex:j,labelSettings:Ce,categoryIndex:E,color:fe,selected:!1,originalValue:W,originalPosition:Ae,originalValueAbsolute:pe,identity:me,key:me.getKey(),tooltipInfo:we,labelFill:Pe,labelFormatString:se.format,lastSeries:De,chartType:f};if(ee.push(Te),z){var Ve=M[j][E],Ne=Ve,Le=!0;null===Ve&&(Ve=0,Le=!1),u&&(Ve*=le.pos);var Me=Math.abs(Ve),ke=he;Ve>0?ke-=pe-Me:0===Ve&&W>0&&(ke-=pe);var Oe=t.SelectionId.createWithHighlight(me),ye=r[E];Le&&(Te.tooltipInfo=we);var Ie={categoryValue:ne,value:W,position:ke,valueAbsolute:Me,valueOriginal:Ne,seriesIndex:j,labelSettings:Ce,categoryIndex:E,color:fe,selected:!1,highlight:!0,originalValue:W,originalPosition:Ae,originalValueAbsolute:pe,drawThinner:F,identity:Oe,key:Oe.getKey(),tooltipInfo:we,labelFormatString:se.format,labelFill:Pe,lastSeries:De,chartType:f};ee.push(Ie)}}}}P.push(re)}return{series:P,categoriesWidth:K,hasHighlights:z,hasDynamicSeries:k}},i.getDataPointColor=function(i,a,r){if(r){var s=e.DataViewObjects.getFillColor(r[a],t.columnChartProps.dataPoint.fill);if(s)return s}return i.color},i.getStackedLabelColor=function(e,i,a,r,s){for(var o=!(e&&i===a-1&&1!==a),n=i+1;a>n;n++){var l=t.AxisHelper.normalizeNonFiniteNumber(s[n][r]);if(null!==l&&((!e||e&&0===i)&&l>0||e&&0!==i)){o=!1;break}}return o},i.sliceSeries=function(t,i,a){void 0===a&&(a=0);var r=[];if(t&&t.length>0)for(var s=0,o=t.length;o>s;s++){var n=r[s]=e.Prototype.inherit(t[s]);n.data=t[s].data.filter(function(e){return e.categoryIndex>=a&&e.categoryIndex<i})}return r},i.getInteractiveColumnChartDomElement=function(e){return e.children("svg").get(0)},i.prototype.getColumnsWidth=function(){var e=this.data;return e&&e.series&&e.series[0]&&e.series[0].data?e.categoriesWidth:[]},i.prototype.getBorderWidth=function(){return i.getBorderWidth(this.data.borderSettings)},i.prototype.setData=function(e){var a=!0;if(this.data={categories:[],categoriesWidth:[],categoryFormatter:null,series:[],valuesMetadata:[],legendData:null,hasHighlights:!1,categoryMetadata:null,scalarCategoryAxis:!1,borderSettings:null,labelSettings:t.dataLabelUtils.getDefaultColumnLabelSettings(a),axesLabels:{x:null,y:null},hasDynamicSeries:!1,defaultDataPointColor:null,isMultiMeasure:!1},e.length>0){var r=e[0];if(r&&r.categorical){var s=this.dataViewCat=r.categorical;this.data=i.converter(s,this.cartesianVisualHost.getSharedColors(),!0,!1,this.supportsOverflow,r.metadata,this.chartType);for(var o=this.data.series,n=0,l=o.length;l>n;n++){var c=o[n];this.interactivityService&&this.interactivityService.applySelectionStateToData(c.data)}}}},i.prototype.calculateLegend=function(){if(this.interactivity&&this.interactivity.isInteractiveLegend)return this.createInteractiveMekkoLegendDataPoints(0);var e=this.data?this.data.legendData:null,t=e?e.dataPoints:[];return y.isUndefinedOrEmpty(t)?null:e},i.prototype.hasLegend=function(){return this.data&&(this.data.hasDynamicSeries||this.data.series&&this.data.series.length>1)},i.prototype.enumerateObjectInstances=function(e,i){switch(i.objectName){case"dataPoint":t.GradientUtils.hasGradientRole(this.dataViewCat)||this.enumerateDataPoints(e);break;case"labels":this.enumerateDataLabels(e)}},i.prototype.enumerateDataLabels=function(e){var i=this.data,a=this.data.labelSettings,r=i.series.length;if(t.dataLabelUtils.enumerateDataLabels(this.getLabelSettingsOptions(e,a,!1)),0!==r&&!i.hasDynamicSeries&&(r>1||!i.categoryMetadata))for(var s=0;r>s;s++){var o=i.series[s],a=o.labelSettings?o.labelSettings:this.data.labelSettings;t.dataLabelUtils.enumerateDataLabels(this.getLabelSettingsOptions(e,a,!0,o))}},i.prototype.getLabelSettingsOptions=function(e,t,i,a){var r=!0;return{enumeration:e,dataLabelsSettings:t,show:!i,displayUnits:r,precision:!0,selector:a&&a.identity?a.identity.getSelector():null}},i.prototype.enumerateDataPoints=function(e){var i=this.data;if(i&&i.series){var a=i.series.length;if(0!==a)if(i.hasDynamicSeries||a>1||!i.categoryMetadata)for(var r=0;a>r;r++){var s=i.series[r];e.pushInstance({objectName:"dataPoint",displayName:s.displayName,selector:t.ColorHelper.normalizeSelector(s.identity.getSelector()),properties:{fill:{solid:{color:s.color}}}})}else{var o=i.series[0].data,n=i.categoryFormatter;e.pushInstance({objectName:"dataPoint",selector:null,properties:{defaultColor:{solid:{color:i.defaultDataPointColor||this.colors.getColorByIndex(0).value}}}}).pushInstance({objectName:"dataPoint",selector:null,properties:{showAllDataPoints:!!i.showAllDataPoints}});for(var r=0;r<o.length;r++){var l=o[r],c=i.categories[r];e.pushInstance({objectName:"dataPoint",displayName:n?n.format(c):c,selector:t.ColorHelper.normalizeSelector(l.identity.getSelector(),!0),properties:{fill:{solid:{color:l.color}}}})}}}},i.prototype.calculateAxesProperties=function(e){var i=this.data;this.currentViewport=e.viewport;var a=this.margin=e.margin,r=i&&i.categories?i.categories.length:0,s=i?this.getCategoryLayout(r,e):{categoryCount:0,categoryThickness:t.CartesianChart.MinOrdinalRectThickness,outerPaddingRatio:t.CartesianChart.OuterPaddingRatio,isScalar:!1};this.categoryAxisType=s.isScalar?t.axisType.scalar:null,this.columnChart.setData(i);var o=this.getPreferredPlotArea(s.isScalar,s.categoryCount,s.categoryThickness);o.width===this.currentViewport.width&&(o.width-=a.left+a.right),o.height-=a.top+a.bottom;var n=!0,l={height:o.height,width:o.width,duration:0,hostService:this.hostService,unclippedGraphicsContext:this.unclippedGraphicsContext,mainGraphicsContext:this.mainGraphicsContext,labelGraphicsContext:this.labelGraphicsContext,margin:this.margin,layout:s,animator:this.animator,interactivityService:this.interactivityService,viewportHeight:this.currentViewport.height-(a.top+a.bottom),viewportWidth:this.currentViewport.width-(a.left+a.right),is100Pct:n,isComboChart:!0};this.ApplyInteractivity(l),this.columnChart.setupVisualProps(l);var c=m.hasFlag(this.chartType,f);if(c){var u=e.forcedXDomain;e.forcedXDomain=e.forcedYDomain,e.forcedYDomain=u}return this.xAxisProperties=this.columnChart.setXScale(n,e.forcedTickCount,e.forcedXDomain,c?e.valueAxisScaleType:e.categoryAxisScaleType),this.yAxisProperties=this.columnChart.setYScale(n,e.forcedTickCount,e.forcedYDomain,c?e.categoryAxisScaleType:e.valueAxisScaleType),e.showCategoryAxisLabel&&this.xAxisProperties.isCategoryAxis||e.showValueAxisLabel&&!this.xAxisProperties.isCategoryAxis?this.xAxisProperties.axisLabel=i.axesLabels.x:this.xAxisProperties.axisLabel=null,e.showValueAxisLabel&&!this.yAxisProperties.isCategoryAxis||e.showCategoryAxisLabel&&this.yAxisProperties.isCategoryAxis?this.yAxisProperties.axisLabel=i.axesLabels.y:this.yAxisProperties.axisLabel=null,[this.xAxisProperties,this.yAxisProperties]},i.prototype.getPreferredPlotArea=function(e,i,a){var r={height:this.currentViewport.height,width:this.currentViewport.width};if(this.isScrollable&&!e){var s=t.CartesianChart.getPreferredCategorySpan(i,a);m.hasFlag(this.chartType,f)?r.height=Math.max(s,r.height):r.width=Math.max(s,r.width)}return r},i.prototype.ApplyInteractivity=function(e){var i=this,a=this.interactivity;if(a&&(a.dragDataPoint&&(e.onDragStart=function(e){e.identity&&i.hostService.onDragStart({event:d3.event,data:{data:e.identity.getSelector()}})}),a.isInteractiveLegend)){var r=function(){var e=d3.mouse(i.mainGraphicsContext[0][0]),t=e[0],a=e[1],r=i.columnChart.getClosestColumnIndex(t,a);i.selectColumn(r)},s=t.ColumnChart.getInteractiveColumnChartDomElement(this.element);this.svg.on("click",r),d3.select(s).on("click",r);var o=d3.behavior.drag().origin(Object).on("drag",r);this.svg.call(o),d3.select(s).call(o)}},i.prototype.selectColumn=function(e,t){if(void 0===t&&(t=!1),t||this.lastInteractiveSelectedColumnIndex!==e){var i=this.createInteractiveMekkoLegendDataPoints(e),a=i.dataPoints;this.cartesianVisualHost.updateLegend(i),a.length>0&&this.columnChart.selectColumn(e,this.lastInteractiveSelectedColumnIndex),this.lastInteractiveSelectedColumnIndex=e}},i.prototype.createInteractiveMekkoLegendDataPoints=function(e){var i=this.data;if(!i||y.isUndefinedOrEmpty(i.series))return{dataPoints:[]};for(var a=t.columnChartProps.general.formatString,r=[],s=i.categories&&i.categories[e],o=i.series,n=i.legendData&&i.legendData.dataPoints,l=new S(this.dataViewCat),c=0,u=o.length;u>c;c++){var h,p=l.getValueBySeriesAndCategory(c,e),d=i.valuesMetadata[c],g=t.converterHelper.getFormattedLegendLabel(d,this.dataViewCat.values,a);if(1===o.length){var m=o[0];h=m.data.length>e&&m.data[e].color}else h=n.length>c&&n[c].color;r.push({color:h,icon:t.LegendIcon.Box,label:g,category:i.categoryFormatter?i.categoryFormatter.format(s):s,measure:t.valueFormatter.format(p,t.valueFormatter.getFormatString(d,a)),identity:t.SelectionId.createNull(),selected:!1})}return{dataPoints:r}},i.prototype.overrideXScale=function(e){this.xAxisProperties=e},i.prototype.render=function(e){var i=this.columnChart.drawColumns(!e),a=this.data,r=this.margin,s=this.currentViewport,o=s.height-(r.top+r.bottom),n=s.width-(r.left+r.right);this.mainGraphicsContext.attr("height",o).attr("width",n),t.TooltipManager.addTooltip(i.shapesSelection,function(e){return e.data.tooltipInfo});var l=[],c=void 0;if(this.interactivityService){for(var u=0,h=a.series.length;h>u;u++)l=l.concat(a.series[u].data);c={datapoints:l,bars:i.shapesSelection,hasHighlights:a.hasHighlights,eventGroup:this.mainGraphicsContext,mainGraphicsContext:this.mainGraphicsContext,viewport:i.viewport,axisOptions:i.axisOptions,showLabel:a.labelSettings.show}}return this.interactivity&&this.interactivity.isInteractiveLegend&&this.data.series.length>0&&this.selectColumn(0,!0),t.SVGUtil.flushAllD3TransitionsIfNeeded(this.options),{dataPoints:l,behaviorOptions:c,labelDataPoints:i.labelDataPoints,labelsAreNumeric:!0}},i.prototype.onClearSelection=function(){this.interactivityService&&this.interactivityService.clearSelection()},i.prototype.getVisualCategoryAxisIsScalar=function(){return this.data?this.data.scalarCategoryAxis:!1},i.prototype.getSupportedCategoryAxisType=function(){var e=this.data?this.data.categoryMetadata:void 0,i=t.AxisHelper.getCategoryValueType(e),a=t.AxisHelper.isOrdinal(i);return a?t.axisType.categorical:t.axisType.both},i.prototype.setFilteredData=function(i,a){var r=e.Prototype.inherit(this.data);return r.series=t.ColumnChart.sliceSeries(r.series,a,i),r.categories=r.categories.slice(i,a),this.columnChart.setData(r),r},i.ColumnChartClassName="columnChart",i.SeriesClasses=u("series"),i.BorderClass=u("mekkoborder"),i}();i.MekkoColumnChart=b;var S=function(){function e(e){this.dataView=e}return e.hasRole=function(e,t){var i=e.roles;return i&&i[t]},e.prototype.getLegend=function(i,a){var r=[],s=[],o=[],n=!1,l=new t.ColorHelper(i,t.columnChartProps.dataPoint.fill,a),c=void 0;if(this.dataView&&this.dataView.values){for(var u=this.dataView.values,h=u.grouped(),p=!(!u||!u.source),d=t.columnChartProps.general.formatString,g=0,m=h.length;m>g;g++)for(var y=h[g],f=y.objects,v=y.values,x=0,b=v.length;b>x;x++){var S=v[x],w=S.source;if(!e.hasRole(w,"Width")||e.hasRole(w,"Y")){s.push(w),o.push(S.objects);var C=S.identity?t.SelectionId.createWithIdAndMeasure(S.identity,w.queryName):t.SelectionId.createWithMeasure(this.getMeasureNameByIndex(x)),P=t.converterHelper.getFormattedLegendLabel(w,u,d),D=p?l.getColorForSeriesValue(f||w.objects,u.identityFields,w.groupName):l.getColorForMeasure(f||w.objects,w.queryName);r.push({icon:t.LegendIcon.Box,color:D,label:P,identity:C,selected:!1}),S.identity&&void 0!==w.groupName&&(n=!0)}}var A=this.dataView.values;c=A&&A.source?A.source.displayName:""}var T={title:c,dataPoints:r,grouped:n};return{legend:T,seriesSources:s,seriesObjects:o}},e.prototype.getValueBySeriesAndCategory=function(e,t){return this.dataView.values[e].values[t]},e.prototype.getMeasureNameByIndex=function(e){return this.dataView.values[e].source.queryName},e.prototype.hasHighlightValues=function(e){var t=this.dataView&&this.dataView.values?this.dataView.values[e]:void 0;return t&&!!t.highlights},e.prototype.getHighlightBySeriesAndCategory=function(e,t){return this.dataView.values[e].highlights[t]},e}(),w=function(){function e(e){this.behaviors=e}return e.prototype.bindEvents=function(e,t){for(var i=this.behaviors,a=0,r=i.length;r>a;a++)i[a].bindEvents(e.layerOptions[a],t);e.clearCatcher.on("click",function(){t.handleClearSelection()})},e.prototype.renderSelection=function(e){for(var t=0;t<this.behaviors.length;t++)this.behaviors[t].renderSelection(e)},e}();i.MekkoChartBehavior=w}(i=t.samples||(t.samples={}))}(t=e.visuals||(e.visuals={}))}(i||(i={}))},function(e,t){var i,a=window.jsCommon,i=window.powerbi;window.powerbitests,window.InJs,window.debug,window.jasmine,window.Microsoft;!function(e){var t;!function(t){var i;!function(i){var r=t.utility.SelectionManager,s=e.visuals.valueFormatter,o=a.PixelConverter.fromPoint,n=function(){function i(e){this.margin={top:10,right:10,bottom:10,left:10},this.nodeWidth=21.5,this.curvatureOfLinks=.5,e&&(this.svg=e.svg,this.margin=e.margin||this.margin,this.curvatureOfLinks=e.curvatureOfLinks||this.curvatureOfLinks)}return i.getProperties=function(e){var t={};for(var i in e.objects){t[i]={};for(var a in e.objects[i].properties)t[i][a]={objectName:i,propertyName:a}}return t},Object.defineProperty(i.prototype,"textProperties",{get:function(){return{fontFamily:this.root.style("font-family"),fontSize:o(this.dataView?this.dataView.settings.fontSize:i.DefaultSettings.fontSize)}},enumerable:!0,configurable:!0}),i.prototype.init=function(e){this.svg?this.root=this.svg:this.root=d3.select(e.element.get(0)).append("svg"),this.selectionManager=new r({hostServices:e.host});var a=e.style;this.colours=a&&a.colorPalette?a.colorPalette.dataColors:new t.DataColorPalette,this.root.classed(i.ClassName,!0),this.main=this.root.append("g"),this.links=this.main.append("g").classed(i.Links["class"],!0),this.nodes=this.main.append("g").classed(i.Nodes["class"],!0)},i.prototype.update=function(e){if(e&&e.dataViews){var t,i=e.dataViews[0];this.updateViewport(e.viewport),t=this.converter(i),this.computePositions(t),this.dataView=t,this.render(t)}},i.prototype.updateViewport=function(e){var t,i;t=this.getPositiveNumber(e.height),i=this.getPositiveNumber(e.width),this.viewport={height:this.getPositiveNumber(t-this.margin.top-this.margin.bottom),width:this.getPositiveNumber(i-this.margin.left-this.margin.right)},this.updateElements(t,i)},i.prototype.getPositiveNumber=function(e){return 0>e||isNaN(e)||null===e||e===1/0||e===-(1/0)?0:e},i.prototype.updateElements=function(e,i){this.root.attr({height:e,width:i}),this.main.attr("transform",t.SVGUtil.translate(this.margin.left,this.margin.top))},i.prototype.converter=function(a){var r=this;if(!(a&&a.categorical&&a.categorical.categories&&a.categorical.categories[0]&&a.categorical.categories[1]&&a.categorical.categories[0].values&&a.categorical.categories[1].values))return{nodes:[],links:[],columns:[],settings:{scale:{x:1,y:1},colourOfLabels:i.DefaultSettings.colourOfLabels,fontSize:i.DefaultSettings.fontSize}};var o,n,l,c,u,h,p,d=[],g=[],m=[],y=a.categorical.categories[0].values,f=a.categorical.categories[1].values,v=a.categorical.values&&a.categorical.values[0],x=[],b="g",S=a.categorical.categories[0].objects||[],w=[];return v&&v.values&&v.values.map&&(x=v.values.map(function(e){return e?e:0})),a.categorical.categories[0].identity&&(w=w.concat(a.categorical.categories[0].identity)),a.categorical.categories[1].identity&&(w=w.concat(a.categorical.categories[1].identity)),c=this.getObjectsFromDataView(a),u=this.getColour(i.Properties.labels.fill,i.DefaultSettings.colourOfLabels,c),v&&v.source&&(b=s.getFormatString(v.source,i.Properties.general.formatString)),m=y.map(function(e,t){return{source:e,destination:f[t],weigth:v?Math.max(x[t]||0,0):1}}),o=y.concat(f),n=s.create({format:s.getFormatString(a.categorical.categories[0].source,i.Properties.general.formatString),value:o[0],value2:o[o.length-1]}),l=s.create({format:b,value:Math.max(d3.max(x)||1,1)}),o.forEach(function(a,s){if(!d.some(function(e){return a===e.label.name?(e.selectionIds.push(t.SelectionId.createWithId(w[s])),!0):!1})){var o,l,c=n.format(a),h={text:c,fontFamily:r.textProperties.fontFamily,fontSize:r.textProperties.fontSize};o={name:a,formattedName:n.format(a),width:e.TextMeasurementService.measureSvgTextWidth(h),height:e.TextMeasurementService.estimateSvgTextHeight(h),colour:u},l=t.SelectionId.createWithId(w[s]),d.push({label:o,links:[],inputWeight:0,outputWeight:0,width:r.nodeWidth,height:0,colour:i.DefaultColourOfNode,tooltipData:[],selectionIds:[l]})}}),p=this.colours.getAllColors().length/d.length,d.forEach(function(e,t){e.colour=r.colours.getColorByIndex(Math.floor(t*p)).value}),m.forEach(function(e,a){var s,o,n,c;e.source!==e.destination&&(d.forEach(function(t){t.label.name===e.source&&(s=t),t.label.name===e.destination&&(o=t)}),c=r.getColour(i.Properties.links.fill,i.DefaultColourOfLink,S[a]),n={source:s,destination:o,weigth:e.weigth,height:e.weigth,colour:c,tooltipData:r.getTooltipDataForLink(l,s.label.formattedName,o.label.formattedName,e.weigth),selectionId:t.SelectionId.createWithId(w[a])},g.push(n),s.links.push(n),o.links.push(n),r.updateValueOfNode(s),r.updateValueOfNode(o),s.tooltipData=r.getTooltipForNode(l,s.label.formattedName,s.inputWeight?s.inputWeight:s.outputWeight),o.tooltipData=r.getTooltipForNode(l,o.label.formattedName,o.inputWeight?o.inputWeight:o.outputWeight))}),h=this.parseSettings(c),h.colourOfLabels=u,{nodes:d,links:g,settings:h,columns:[]}},i.prototype.getObjectsFromDataView=function(e){return e&&e.metadata&&e.metadata.columns&&e.metadata.objects?e.metadata.objects:null},i.prototype.getColour=function(e,i,a){var r;return r=new t.ColorHelper(this.colours,e,i),r.getColorForMeasure(a,"")},i.prototype.getTooltipDataForLink=function(e,t,a,r){var s;return s=e&&e.format?e.format(r):r.toString(),[{displayName:i.RoleNames.rows,value:t},{displayName:i.RoleNames.columns,value:a},{displayName:i.RoleNames.values,value:s}]},i.prototype.updateValueOfNode=function(e){e.inputWeight=e.links.reduce(function(t,i){return t+(i.destination===e?i.weigth:0)},0),e.outputWeight=e.links.reduce(function(t,i){return t+(i.source===e?i.weigth:0)},0)},i.prototype.getTooltipForNode=function(e,t,a){var r;return r=e&&e.format?e.format(a):a.toString(),[{displayName:"Name",value:t},{displayName:i.RoleNames.values,value:r}]},i.prototype.parseSettings=function(t){var a=!1;return a=e.DataViewObjects.getValue(t,i.Properties.labels.show,i.DefaultSettings.isVisibleLabels),{isVisibleLabels:a,scale:{x:i.DefaultSettings.scale.x,y:i.DefaultSettings.scale.y},colourOfLabels:i.DefaultSettings.colourOfLabels,fontSize:e.DataViewObjects.getValue(t,i.Properties.labels.fontSize,i.DefaultSettings.fontSize)}},i.prototype.computePositions=function(e){var t,i,a;t=this.computeXPositions(e),this.sortNodesByX(e.nodes),a=this.getColumns(e.nodes),i=this.getMaxColumn(a),e.settings.scale.x=this.getScaleByAxisX(t),e.settings.scale.y=this.getScaleByAxisY(i.sumValueOfNodes),this.scalePositionsByAxes(e.nodes,a,e.settings.scale,this.viewport.height),this.computeYPosition(e.nodes,e.settings.scale.y)},i.prototype.computeXPositions=function(e){for(var t=e.nodes,i=[],a=[],r=0,s=!1;t.length>0;)i=[],t.forEach(function(e){e.x=r,e.links.forEach(function(t){e===t.source&&e!==t.destination&&i.every(function(e){return e!==t.destination})&&i.push(t.destination)})}),s=i.length===a.length&&a.every(function(e){return i.some(function(t){return t===e})}),s?(a.forEach(function(e){e.x=r,r++}),t=[]):(t=i,a=t,r++);return r-1},i.prototype.getScaleByAxisX=function(e){return void 0===e&&(e=1),this.getPositiveNumber((this.viewport.width-this.nodeWidth)/e)},i.prototype.sortNodesByX=function(e){return e.sort(function(e,t){return e.x-t.x})},i.prototype.getColumns=function(e){var t=[],i=-Number.MAX_VALUE;return e.forEach(function(e,a){i!==e.x&&(t.push({countOfNodes:0,sumValueOfNodes:0}),i=e.x),t[e.x]&&(t[e.x].sumValueOfNodes+=Math.max(e.inputWeight,e.outputWeight),t[e.x].countOfNodes++)}),t},i.prototype.getMaxColumn=function(e){void 0===e&&(e=[]);var t={sumValueOfNodes:0,countOfNodes:0};return e.forEach(function(e){e&&e.sumValueOfNodes>t.sumValueOfNodes&&(t=e)}),t},i.prototype.getScaleByAxisY=function(e){return this.getPositiveNumber((this.viewport.height-this.getAvailableSumNodeMarginByY())/e)},i.prototype.getAvailableSumNodeMarginByY=function(){return this.viewport?this.viewport.height*i.NodeBottomMargin/100:0},i.prototype.scalePositionsByAxes=function(e,t,i,a){var r=0,s=0,o=0;e.forEach(function(e){var n=0,l=0;s!==e.x&&(s=e.x,r=0,o=0),t[s]&&(l=a-t[s].sumValueOfNodes*i.y,n=l/t[s].countOfNodes),e.x*=i.x,e.height=Math.max(e.inputWeight,e.outputWeight)*i.y,e.y=r+n*o,r+=e.height,o++})},i.prototype.computeYPosition=function(e,t){e.forEach(function(e){e.links=e.links.sort(function(t,i){var a,r;return a=t.source===e?t.destination.y:t.source.y,r=i.source===e?i.destination.y:i.source.y,a-r});var i=0,a=0;e.links.forEach(function(r){var s=0;r.height=r.weigth*t,r.source.x<e.x||r.destination.x<e.x?(s=i,i+=r.height):(r.source.x>e.x||r.destination.x>e.x)&&(s=a,a+=r.height),r.source===e?r.dySource=s:r.destination===e&&(r.dyDestination=s)})})},i.prototype.render=function(e){var t,i;i=this.renderLinks(e),this.renderTooltip(i),t=this.renderNodes(e),this.renderTooltip(t),this.bindSelectionHandler(e,t,i)},i.prototype.renderNodes=function(a){var r,s,o,n=this;return o=this.main.select(i.Nodes.selector).selectAll(i.Node.selector),s=o.data(a.nodes.filter(function(e){return e.height>0})),r=s.enter().append("g"),s.attr("transform",function(e){return t.SVGUtil.translate(e.x,e.y)}).classed(i.Node["class"],!0),r.append("rect").classed(i.NodeRect["class"],!0),r.append("text").classed(i.NodeLabel["class"],!0),s.select(i.NodeRect.selector).style({fill:function(e){return e.colour},stroke:function(e){return d3.rgb(e.colour).darker(1.5)}}).attr({x:0,y:0,height:function(e){return e.height},width:function(e){return e.width}}),s.select(i.NodeLabel.selector).attr({x:function(e){return n.getLabelPositionByAxisX(e)},y:function(e){return e.height/2},dy:"0.35em"}).style("fill",function(e){return e.label.colour}).style("font-size",this.textProperties.fontSize).style("display",function(e){var t=!1,r=n.getCurrentPositionOfLabelByAxisX(e);return t=r>=n.viewport.width||0>=r||e.height+i.NodeMargin<e.label.height,t||!a.settings.isVisibleLabels||a.settings.scale.x/2<i.MinWidthOfLabel?"none":null}).style("text-anchor",function(e){return n.isLabelLargerThanWidth(e)?"end":null}).text(function(t){var r=a.settings.scale.x/2-t.width-i.NodeMargin;return n.getCurrentPositionOfLabelByAxisX(t)>r?e.TextMeasurementService.getTailoredTextOrDefault({text:t.label.formattedName,fontFamily:n.textProperties.fontFamily,fontSize:n.textProperties.fontSize},r):t.label.formattedName}),s.exit().remove(),s},i.prototype.getLabelPositionByAxisX=function(e){return this.isLabelLargerThanWidth(e)?-i.LabelMargin:e.width+i.LabelMargin},i.prototype.isLabelLargerThanWidth=function(e){var t=e.x+e.width+i.LabelMargin;return t+e.label.width>this.viewport.width},i.prototype.getCurrentPositionOfLabelByAxisX=function(e){var t=this.getLabelPositionByAxisX(e);return t=t>0?t+e.x+e.label.width+e.width:e.x+t-e.label.width-e.width},i.prototype.renderLinks=function(e){var t,a,r=this;return a=this.main.select(i.Links.selector).selectAll(i.Link.selector),t=a.data(e.links.filter(function(e){return e.height>0})),t.enter().append("path").classed(i.Link["class"],!0),t.attr("d",function(e){return r.getSvgPath(e)}).style({"stroke-width":function(e){return e.height},stroke:function(e){return e.colour}}),t.exit().remove(),t},i.prototype.getSvgPath=function(e){var t,i,a,r,s,o,n;return e.destination.x<e.source.x?(t=e.source.x,i=e.destination.x+e.destination.width):(t=e.source.x+e.source.width,i=e.destination.x),a=d3.interpolateNumber(t,i),r=a(this.curvatureOfLinks),s=a(1-this.curvatureOfLinks),o=e.source.y+e.dySource+e.height/2,n=e.destination.y+e.dyDestination+e.height/2,"M "+t+" "+o+" C "+r+" "+o+", "+s+" "+n+", "+i+" "+n},i.prototype.renderTooltip=function(e){t.TooltipManager.addTooltip(e,function(e){return e.data.tooltipData})},i.prototype.bindSelectionHandler=function(e,t,i){var a=this;t.on("click",function(e){var r=_.isEqual(e.selectionIds.map(function(e){return e.getKey()}),a.selectionManager.getSelectionIds().map(function(e){return e.getKey()}))?[]:e.selectionIds;a.selectMany(r,!0).then(function(){return a.setSelection(t,i)}),d3.event.stopPropagation()}),i.on("click",function(e){a.selectionManager.select(e.selectionId,d3.event.ctrlKey).then(function(){return a.setSelection(t,i)}),d3.event.stopPropagation()}),this.root.on("click",function(){a.selectionManager.clear().then(function(){return a.setSelection(t,i)})}),this.setSelection(t,i)},i.prototype.selectMany=function(e,t){var i=this;if(void 0===t&&(t=!1),t)return this.selectionManager.clear().then(function(){return i.selectMany(e,!1)});var a=e.map(function(e){return i.selectionManager.select(e,!0)});return $.when.apply(null,a)},i.prototype.setSelection=function(e,t){
5var i=this.selectionManager.getSelectionIds();if(e.classed("selected",i.length>0),t.classed("selected",!1),0!==i.length){var a=e.filter(function(e){return i.some(function(t){return e.selectionIds.some(function(e){return e.getKey()===t.getKey()})})}),r=t.filter(function(e){return i.some(function(t){return t.getKey()===e.selectionId.getKey()})});a.classed("selected",!1),r.classed("selected",!0)}},i.prototype.enumerateObjectInstances=function(e){var i=new t.ObjectEnumerationBuilder;if(!this.dataView)return[];switch(e.objectName){case"labels":this.enumerateLabels(i);break;case"links":this.enumerateLinks(i)}return i.complete()},i.prototype.enumerateLabels=function(e){var t,i=this.dataView.settings;i&&(t={objectName:"labels",displayName:"labels",selector:null,properties:{show:i.isVisibleLabels,fill:i.colourOfLabels,fontSize:i.fontSize}},e.pushInstance(t))},i.prototype.enumerateLinks=function(e){var i=this.dataView.links;i&&i.length>0&&i.forEach(function(i){e.pushInstance({objectName:"links",displayName:i.source.label.formattedName+" - "+i.destination.label.formattedName,selector:t.ColorHelper.normalizeSelector(i.selectionId.getSelector(),!1),properties:{fill:{solid:{color:i.colour}}}})})},i.ClassName="sankeyDiagram",i.Nodes={"class":"nodes",selector:".nodes"},i.Node={"class":"node",selector:".node"},i.NodeRect={"class":"nodeRect",selector:".nodeRect"},i.NodeLabel={"class":"nodeLabel",selector:".nodeLabel"},i.Links={"class":"links",selector:".links"},i.Link={"class":"link",selector:".link"},i.DefaultColourOfNode="rgb(62, 187, 162)",i.DefaultColourOfLink="black",i.DefaultSettings={isVisibleLabels:!0,scale:{x:1,y:1},colourOfLabels:"black",fontSize:12},i.MinWidthOfLabel=35,i.NodeBottomMargin=5,i.NodeMargin=5,i.LabelMargin=4,i.RoleNames={rows:"Source",columns:"Destination",values:"Weight"},i.capabilities={dataRoles:[{name:i.RoleNames.rows,kind:e.VisualDataRoleKind.Grouping,displayName:i.RoleNames.rows},{name:i.RoleNames.columns,kind:e.VisualDataRoleKind.Grouping,displayName:i.RoleNames.columns},{name:i.RoleNames.values,kind:e.VisualDataRoleKind.Measure,displayName:i.RoleNames.values}],dataViewMappings:[{conditions:[{Source:{min:0,max:1},Destination:{min:0,max:1},Weight:{min:0,max:0}},{Source:{min:0,max:1},Destination:{min:0,max:1},Weight:{min:1,max:1}}],categorical:{categories:{"for":{"in":i.RoleNames.rows},dataReductionAlgorithm:{top:{}}},values:{select:[{bind:{to:i.RoleNames.columns}},{bind:{to:i.RoleNames.values}}]}}}],objects:{general:{displayName:e.data.createDisplayNameGetter("Visual_General"),properties:{formatString:{type:{formatting:{formatString:!0}}}}},labels:{displayName:e.data.createDisplayNameGetter("Visual_DataPointsLabels"),properties:{show:{displayName:e.data.createDisplayNameGetter("Visual_Show"),type:{bool:!0}},fill:{displayName:e.data.createDisplayNameGetter("Visual_Fill"),type:{fill:{solid:{color:!0}}}},fontSize:{displayName:e.data.createDisplayNameGetter("Visual_TextSize"),type:{formatting:{fontSize:!0}}}}},links:{displayName:"Links",properties:{fill:{displayName:e.data.createDisplayNameGetter("Visual_Fill"),type:{fill:{solid:{color:!0}}}}}}}},i.Properties=i.getProperties(i.capabilities),i}();i.SankeyDiagram=n}(i=t.samples||(t.samples={}))}(t=e.visuals||(e.visuals={}))}(i||(i={}))},function(e,t){var i,a=window.jsCommon,i=window.powerbi;window.powerbitests,window.InJs,window.debug,window.jasmine,window.Microsoft;!function(e){var t;!function(t){var i;!function(i){var r=a.PixelConverter;i.bulletChartProps={values:{targetValue:{objectName:"values",propertyName:"targetValue"},minimumPercent:{objectName:"values",propertyName:"minimumPercent"},needsImprovementPercent:{objectName:"values",propertyName:"needsImprovementPercent"},satisfactoryPercent:{objectName:"values",propertyName:"satisfactoryPercent"},goodPercent:{objectName:"values",propertyName:"goodPercent"},veryGoodPercent:{objectName:"values",propertyName:"veryGoodPercent"},maximumPercent:{objectName:"values",propertyName:"maximumPercent"},targetValue2:{objectName:"values",propertyName:"targetValue2"},secondTargetVisibility:{objectName:"values",propertyName:"secondTargetVisibility"}},orientation:{orientation:{objectName:"orientation",propertyName:"orientation"}},colors:{badColor:{objectName:"colors",propertyName:"badColor"},needsImprovementColor:{objectName:"colors",propertyName:"needsImprovementColor"},satisfactoryColor:{objectName:"colors",propertyName:"satisfactoryColor"},goodColor:{objectName:"colors",propertyName:"goodColor"},veryGoodColor:{objectName:"colors",propertyName:"veryGoodColor"},bulletColor:{objectName:"colors",propertyName:"bulletColor"}},axis:{axis:{objectName:"axis",propertyName:"axis"},axisColor:{objectName:"axis",propertyName:"axisColor"},measureUnits:{objectName:"axis",propertyName:"measureUnits"},unitsColor:{objectName:"axis",propertyName:"unitsColor"}},formatString:{objectName:"general",propertyName:"formatString"},labels:{fontSize:{objectName:"labels",propertyName:"fontSize"},show:{objectName:"labels",propertyName:"show"},labelColor:{objectName:"labels",propertyName:"labelColor"}}},i.bulletChartRoleNames={value:"Value",targetValue:"TargetValue",minValue:"Minimum",needsImprovementValue:"NeedsImprovement",satisfactoryValue:"Satisfactory",goodValue:"Good",veryGoodValue:"VeryGood",maxValue:"Maximum",targetValue2:"TargetValue2"};var s;!function(t){t.HORIZONTALLEFT="Horizontal Left",t.HORIZONTALRIGHT="Horizontal Right",t.VERTICALTOP="Vertical Top",t.VERTICALBOTTOM="Vertical Bottom",t.type=e.createEnumType([{value:t.HORIZONTALLEFT,displayName:t.HORIZONTALLEFT},{value:t.HORIZONTALRIGHT,displayName:t.HORIZONTALRIGHT},{value:t.VERTICALTOP,displayName:t.VERTICALTOP},{value:t.VERTICALBOTTOM,displayName:t.VERTICALBOTTOM}])}(s||(s={}));var o=function(){function a(){this.baselineDelta=0}return Object.defineProperty(a.prototype,"reverse",{get:function(){return this.model.bulletChartSettings.orientation.reverse},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"vertical",{get:function(){return this.model.bulletChartSettings.orientation.vertical},enumerable:!0,configurable:!0}),a.DefaultStyleProperties=function(){return{values:{targetValue:0,targetValue2:0,minimumPercent:0,needsImprovementPercent:25,satisfactoryPercent:50,goodPercent:100,veryGoodPercent:125,maximumPercent:200,secondTargetVisibility:!1},orientation:{orientation:s.HORIZONTALLEFT,reverse:!1,vertical:!1},colors:{badColor:"Darkred",needsImprovementColor:"Red",satisfactoryColor:"Yellow",goodColor:"Green",veryGoodColor:"Darkgreen",bulletColor:"Black"},axis:{axis:!0,axisColor:"Grey",measureUnits:"",unitsColor:"Grey"},labelSettings:{fontSize:11,show:!0,labelColor:"Black"}}},Object.defineProperty(a.prototype,"viewportIn",{get:function(){return{width:this.viewport.width,height:this.viewport.height}},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"viewportScroll",{get:function(){var e=this.viewportIn;return{width:e.width-a.ScrollBarSize,height:e.height-a.ScrollBarSize}},enumerable:!0,configurable:!0}),a.getTextProperties=function(e,t){return{fontFamily:a.FontFamily,fontSize:r.fromPoint(t),text:e}},a.converter=function(o,n){var l=a.DefaultStyleProperties(),c={bulletValueFormatString:null,bulletChartSettings:l,bars:[],barRects:[],valueRects:[],targetValues:[],viewportLength:0};if(!(o&&o.categorical&&o.categorical.values&&0!==o.categorical.values.length&&o.metadata&&o.metadata.columns&&0!==o.metadata.columns.length))return c;var u=o.metadata.objects,h=c.bulletChartSettings;u&&(h.values.targetValue=e.DataViewObjects.getValue(u,i.bulletChartProps.values.targetValue,l.values.targetValue),h.values.targetValue2=e.DataViewObjects.getValue(u,i.bulletChartProps.values.targetValue2,l.values.targetValue2),h.values.secondTargetVisibility=e.DataViewObjects.getValue(u,i.bulletChartProps.values.secondTargetVisibility,l.values.secondTargetVisibility),h.values.minimumPercent=e.DataViewObjects.getValue(u,i.bulletChartProps.values.minimumPercent,l.values.minimumPercent),h.values.needsImprovementPercent=e.DataViewObjects.getValue(u,i.bulletChartProps.values.needsImprovementPercent,l.values.needsImprovementPercent),h.values.satisfactoryPercent=e.DataViewObjects.getValue(u,i.bulletChartProps.values.satisfactoryPercent,l.values.satisfactoryPercent),h.values.goodPercent=e.DataViewObjects.getValue(u,i.bulletChartProps.values.goodPercent,l.values.goodPercent),h.values.veryGoodPercent=e.DataViewObjects.getValue(u,i.bulletChartProps.values.veryGoodPercent,l.values.veryGoodPercent),h.values.maximumPercent=e.DataViewObjects.getValue(u,i.bulletChartProps.values.maximumPercent,l.values.maximumPercent),h.orientation.orientation=e.DataViewObjects.getValue(u,i.bulletChartProps.orientation.orientation,l.orientation.orientation),h.colors.badColor=e.DataViewObjects.getFillColor(u,i.bulletChartProps.colors.badColor,l.colors.badColor),h.colors.needsImprovementColor=e.DataViewObjects.getFillColor(u,i.bulletChartProps.colors.needsImprovementColor,l.colors.needsImprovementColor),h.colors.satisfactoryColor=e.DataViewObjects.getFillColor(u,i.bulletChartProps.colors.satisfactoryColor,l.colors.satisfactoryColor),h.colors.goodColor=e.DataViewObjects.getFillColor(u,i.bulletChartProps.colors.goodColor,l.colors.goodColor),h.colors.veryGoodColor=e.DataViewObjects.getFillColor(u,i.bulletChartProps.colors.veryGoodColor,l.colors.veryGoodColor),h.colors.bulletColor=e.DataViewObjects.getFillColor(u,i.bulletChartProps.colors.bulletColor,l.colors.bulletColor),h.axis.axis=e.DataViewObjects.getValue(u,i.bulletChartProps.axis.axis,l.axis.axis),h.axis.axisColor=e.DataViewObjects.getFillColor(u,i.bulletChartProps.axis.axisColor,l.axis.axisColor),h.axis.measureUnits=e.TextMeasurementService.getTailoredTextOrDefault(a.getTextProperties(e.DataViewObjects.getValue(u,i.bulletChartProps.axis.measureUnits,l.axis.measureUnits),a.DefaultSubtitleFontSizeInPt),a.MaxLabelWidth),h.axis.unitsColor=e.DataViewObjects.getFillColor(u,i.bulletChartProps.axis.unitsColor,l.axis.unitsColor),h.labelSettings.fontSize=e.DataViewObjects.getValue(u,i.bulletChartProps.labels.fontSize,l.labelSettings.fontSize),h.labelSettings.show=e.DataViewObjects.getValue(u,i.bulletChartProps.labels.show,l.labelSettings.show),h.labelSettings.labelColor=e.DataViewObjects.getFillColor(u,i.bulletChartProps.labels.labelColor,l.labelSettings.labelColor)),h.orientation.orientation!==s.HORIZONTALRIGHT&&h.orientation.orientation!==s.VERTICALBOTTOM||(h.orientation.reverse=!0),h.orientation.orientation!==s.VERTICALTOP&&h.orientation.orientation!==s.VERTICALBOTTOM||(h.orientation.vertical=!0);var p,d,g,m=1;o.categorical.categories&&(p=o.categorical.categories[0],d=p.values,m=d.length,g=t.valueFormatter.getFormatString(p.source,i.bulletChartProps.formatString)),c.labelHeight=(h.labelSettings.show||0)&&parseFloat(r.fromPoint(h.labelSettings.fontSize)),c.labelHeightTop=(h.labelSettings.show||0)&&parseFloat(r.fromPoint(h.labelSettings.fontSize))/1.4,c.spaceRequiredForBarHorizontally=Math.max(60,c.labelHeight+20),c.bulletValueFormatString=t.valueFormatter.getFormatString(o.categorical.values[0].source,i.bulletChartProps.formatString),c.viewportLength=(h.orientation.vertical?n.viewport.height-c.labelHeightTop-a.SubtitleMargin-20-2*a.YMarginVertical:n.viewport.width-a.MaxLabelWidth-3*a.XMarginHorizontal)-a.ScrollBarSize;for(var y=0;m>y;y++){var f=[],v=void 0,x=void 0,b=void 0,S=void 0,w=void 0,C=void 0,P=void 0,D=void 0,A=void 0,T=void 0,V=!1,N=void 0;if(d){var L=d[y];v=t.valueFormatter.format(L,g),N=p.identity?p.identity[y]:null;var M=a.getTextProperties(v,h.labelSettings.fontSize);v=e.TextMeasurementService.getTailoredTextOrDefault(M,a.MaxLabelWidth)}var k=o.categorical.values;b=h.values.targetValue,S=h.values.targetValue2,c.hasHighlights=!!(k.length>0&&k[0].highlights);for(var O=0;O<k.length;O++){var I=k[O].source,j=k[O].values[y]||0;I&&I.roles&&(I.roles[i.bulletChartRoleNames.value]?(k[O].highlights&&(V=null!==k[O].highlights[y]),f.push({value:j,metadata:k[O]}),x=j):I.roles[i.bulletChartRoleNames.targetValue]?(f.push({value:j,metadata:k[O]}),b=j):I.roles[i.bulletChartRoleNames.targetValue2]?(f.push({value:j,metadata:k[O]}),S=j):I.roles[i.bulletChartRoleNames.minValue]?w=j:I.roles[i.bulletChartRoleNames.needsImprovementValue]?A=j:I.roles[i.bulletChartRoleNames.satisfactoryValue]?C=j:I.roles[i.bulletChartRoleNames.goodValue]?P=j:I.roles[i.bulletChartRoleNames.veryGoodValue]?T=j:I.roles[i.bulletChartRoleNames.maxValue]&&(D=j))}w||(w=h.values.minimumPercent*b/100),A||(A=h.values.needsImprovementPercent*b/100),C||(C=h.values.satisfactoryPercent*b/100),P||(P=h.values.goodPercent*b/100),T||(T=h.values.veryGoodPercent*b/100),D||(D=h.values.maximumPercent*b/100);var F=[w,A,C,P,T,D].sort(d3.descending),z=d3.scale.linear().clamp(!0).domain([w,Math.max(F[0],b,x)]).range(h.orientation.vertical?[c.viewportLength,0]:[0,c.viewportLength]),G=z(w),R=z(A),H=z(C),B=z(P),U=z(T),E=z(D),W=z(x),_=h.colors.badColor,Y=h.colors.needsImprovementColor,X=h.colors.satisfactoryColor,q=h.colors.goodColor,K=h.colors.veryGoodColor;a.addItemToBarArray(c.barRects,y,G,R,_,f,N,V),a.addItemToBarArray(c.barRects,y,R,H,Y,f,N,V),a.addItemToBarArray(c.barRects,y,H,B,X,f,N,V),a.addItemToBarArray(c.barRects,y,B,U,q,f,N,V),a.addItemToBarArray(c.barRects,y,U,E,K,f,N,V),a.addItemToBarArray(c.valueRects,y,G,W,h.colors.bulletColor,f,N,V),c.targetValues.push({barIndex:y,value:z(b),fill:h.colors.bulletColor,key:t.SelectionId.createWithIdAndMeasure(N,z(b).toString()).getKey(),value2:z(S)});var Z=null;if(h.axis.axis){Z=d3.svg.axis(),Z.orient(h.orientation.vertical?"left":"bottom");var J=Math.round(Math.max(3,c.viewportLength/100)),Q=[x,b,P,C,D,w,A,T].filter(function(e){return!isNaN(e)});Z.tickFormat(t.valueFormatter.create({format:c.bulletValueFormatString,value:Q.length?Math.max.apply(null,Q):0}).format),Z.ticks(J),Z.scale(z)}var $={scale:z,barIndex:y,categoryLabel:v,x:h.orientation.vertical?a.XMarginVertical+a.SpaceRequiredForBarVertically*y:a.XMarginHorizontal,y:h.orientation.vertical?a.YMarginVertical:a.YMarginHorizontal+c.spaceRequiredForBarHorizontally*y,axis:Z,key:t.SelectionId.createWithIdAndMeasure(N,y.toString()).getKey()};c.bars.push($)}return c},a.addItemToBarArray=function(e,a,r,s,o,n,l,c){isNaN(r)||isNaN(s)||e.push({barIndex:a,start:r,end:s,fill:o,tooltipInfo:t.TooltipBuilder.createTooltipInfo(i.bulletChartProps.formatString,null,null,null,null,n),selected:!1,identity:t.SelectionId.createWithId(l),key:t.SelectionId.createWithIdAndMeasure(l,r+" "+s).getKey(),highlight:c})},a.prototype.init=function(e){var i=d3.select(e.element.get(0));this.hostService=e.host,this.bulletBody=i.append("div").classed("bulletChart",!0).attr("drag-resize-disabled",!0),this.scrollContainer=this.bulletBody.append("svg").classed("bullet-scroll-region",!0),this.clearCatcher=t.appendClearCatcher(this.scrollContainer),this.labelGraphicsContext=this.scrollContainer.append("g"),this.bulletGraphicsContext=this.scrollContainer.append("g"),this.behavior=new l,this.interactivityService=t.createInteractivityService(e.host)},a.prototype.update=function(e){if(e.dataViews&&e.dataViews[0]){var t=e.dataViews[0];this.viewport=e.viewport,this.model=a.converter(t,e),this.baselineDelta=n.estimateSvgTextBaselineDelta(a.getTextProperties("1",this.model.bulletChartSettings.labelSettings.fontSize)),this.ClearViewport(),this.model&&(this.interactivityService&&this.interactivityService.applySelectionStateToData(this.model.barRects),this.bulletBody.style({height:this.viewportIn.height+"px",width:this.viewportIn.width+"px"}),this.vertical?this.scrollContainer.attr({width:this.model.bars.length*a.SpaceRequiredForBarVertically+a.XMarginVertical+"px",height:this.viewportScroll.height+"px"}):this.scrollContainer.attr({height:this.model.bars.length*this.model.spaceRequiredForBarHorizontally+"px",width:this.viewportScroll.width+"px"}),this.vertical?this.setUpBulletsVertically(this.bulletBody,this.model,this.reverse):this.setUpBulletsHorizontally(this.bulletBody,this.model,this.reverse))}},a.prototype.ClearViewport=function(){this.labelGraphicsContext.selectAll("text").remove(),this.bulletGraphicsContext.selectAll("rect").remove(),this.bulletGraphicsContext.selectAll("text").remove(),this.bulletGraphicsContext.selectAll("axis").remove(),this.bulletGraphicsContext.selectAll("path").remove(),this.bulletGraphicsContext.selectAll("line").remove(),this.bulletGraphicsContext.selectAll("tick").remove(),this.bulletGraphicsContext.selectAll("g").remove()},a.prototype.onClearSelection=function(){this.interactivityService&&this.interactivityService.clearSelection()},a.prototype.calculateLabelWidth=function(e,t,i){return(i?0:e.x+a.MaxLabelWidth)+a.XMarginHorizontal+(t?t.start:0)},a.prototype.calculateLabelHeight=function(e,t,i){return a.YMarginVertical+(i?5:e.y+this.model.labelHeightTop+a.BarMargin+a.SubtitleMargin)+(t?t.end:0)},a.prototype.setUpBulletsHorizontally=function(i,s,o){var n=this,l=s.bars,c=s.barRects,u=s.valueRects,h=s.targetValues,p=this.labelGraphicsContext.selectAll("text").data(l,function(e){return e.key}),d=this.bulletGraphicsContext.selectAll("rect.range").data(c,function(e){return e.key}),g=this.interactivityService&&this.interactivityService.hasSelection(),m=s.hasHighlights,y=d.enter().append("rect").attr({x:function(e){return n.calculateLabelWidth(l[e.barIndex],e,o)},y:function(e){return l[e.barIndex].y-a.BulletSize/2},width:function(e){return e.end-e.start},height:a.BulletSize}).classed("range",!0).style({fill:function(e){return e.fill},opacity:function(e){return t.ColumnUtil.getFillOpacity(e.selected,e.highlight,g,m)}});d.exit();var f=this.bulletGraphicsContext.selectAll("rect").data(u,function(e){return e.key});f.enter().append("rect").attr({x:function(e){return n.calculateLabelWidth(l[e.barIndex],e,o)},y:function(e){return l[e.barIndex].y-a.BulletSize/8},width:function(e){return e.end-e.start},height:1*a.BulletSize/4}).classed("value",!0).style({fill:function(e){return e.fill},opacity:function(e){return t.ColumnUtil.getFillOpacity(e.selected,e.highlight,g,m)}}),f.exit();var v=this.bulletGraphicsContext.selectAll("values").data(h,function(e){return isNaN(e.value)||isNaN(e.value2)?void 0:e.key});if(v.enter().append("line").attr({x1:function(e){return n.calculateLabelWidth(l[e.barIndex],null,o)+e.value},x2:function(e){return n.calculateLabelWidth(l[e.barIndex],null,o)+e.value},y1:function(e){return l[e.barIndex].y-a.MarkerMarginHorizontal},y2:function(e){return l[e.barIndex].y+a.MarkerMarginHorizontal}}).style({stroke:function(e){return e.fill},"stroke-width":2}),s.bulletChartSettings.values.secondTargetVisibility&&this.drawSecondTarget(v.enter(),function(e){return n.calculateLabelWidth(l[e.barIndex],null,o)+e.value2},function(e){return l[e.barIndex].y}),v.exit(),s.bulletChartSettings.axis.axis)for(var x=0;x<l.length;x++){var b=l[x];this.bulletGraphicsContext.append("g").attr({transform:function(){var e=n.calculateLabelWidth(b,null,o),t=b.y+a.BulletSize/2;return"translate("+e+","+t+")"}}).classed("axis",!0).call(b.axis.scale(b.scale)).style({fill:s.bulletChartSettings.axis.axisColor,"font-size":r.fromPoint(a.AxisFontSizeInPt)}).selectAll("line").style({stroke:s.bulletChartSettings.axis.axisColor})}s.bulletChartSettings.labelSettings.show&&p.enter().append("text").classed("title",!0).attr({x:function(e){return o?2*a.XMarginHorizontal+s.viewportLength:e.x},y:function(e){return e.y+n.baselineDelta},fill:s.bulletChartSettings.labelSettings.labelColor,"font-size":r.fromPoint(s.bulletChartSettings.labelSettings.fontSize)}).text(function(e){return e.categoryLabel});var S=e.TextMeasurementService.getTailoredTextOrDefault(a.getTextProperties(s.bulletChartSettings.axis.measureUnits,a.DefaultSubtitleFontSizeInPt),a.MaxMeasureUnitWidth);if(s.bulletChartSettings.axis.measureUnits&&p.enter().append("text").attr({x:function(e){return o?2*a.XMarginHorizontal+s.viewportLength+a.SubtitleMargin:e.x-a.SubtitleMargin},y:function(e){return e.y+n.model.labelHeight/2+12},fill:s.bulletChartSettings.axis.unitsColor,"font-size":r.fromPoint(a.DefaultSubtitleFontSizeInPt)}).text(S),this.interactivityService){var w={rects:y,valueRects:f,clearCatcher:this.clearCatcher,interactivityService:this.interactivityService,bulletChartSettings:this.model.bulletChartSettings,hasHighlights:!1},C=this.model.barRects.concat(this.model.valueRects);this.interactivityService.bind(C,this.behavior,w)}p.exit(),t.TooltipManager.addTooltip(f,function(e){return e.data.tooltipInfo},!0),t.TooltipManager.addTooltip(d,function(e){return e.data.tooltipInfo},!0)},a.prototype.setUpBulletsVertically=function(i,s,o){var n=this,l=s.bars,c=s.barRects,u=s.valueRects,h=s.targetValues,p=this.labelGraphicsContext.selectAll("text").data(l,function(e){return e.key}),d=this.bulletGraphicsContext.selectAll("rect.range").data(c,function(e){return e.key}),g=this.interactivityService&&this.interactivityService.hasSelection(),m=s.hasHighlights,y=d.enter().append("rect").attr({x:function(e){return l[e.barIndex].x},y:function(e){return n.calculateLabelHeight(l[e.barIndex],e,o)},height:function(e){return e.start-e.end},width:a.BulletSize}).classed("range",!0).style({fill:function(e){return e.fill},opacity:function(e){return t.ColumnUtil.getFillOpacity(e.selected,e.highlight,g,m)}});d.exit();var f=this.bulletGraphicsContext.selectAll("rect").data(u,function(e){return e.key});f.enter().append("rect").attr({x:function(e){return l[e.barIndex].x+a.BulletSize/3},y:function(e){return n.calculateLabelHeight(l[e.barIndex],e,o)},height:function(e){return e.start-e.end},width:1*a.BulletSize/4}).classed("value",!0).style({fill:function(e){return e.fill},opacity:function(e){return t.ColumnUtil.getFillOpacity(e.selected,e.highlight,g,m)}}),f.exit();var v=this.bulletGraphicsContext.selectAll("values").data(h,function(e){return isNaN(e.value)||isNaN(e.value2)?void 0:e.key});if(v.enter().append("line").attr({x2:function(e){return l[e.barIndex].x+3*a.MarkerMarginVertical},x1:function(e){return l[e.barIndex].x+a.MarkerMarginVertical},y2:function(e){return n.calculateLabelHeight(l[e.barIndex],null,o)+e.value},y1:function(e){return n.calculateLabelHeight(l[e.barIndex],null,o)+e.value}}).style({stroke:function(e){return e.fill},"stroke-width":2}),s.bulletChartSettings.values.secondTargetVisibility&&this.drawSecondTarget(v.enter(),function(e){return l[e.barIndex].x+a.BulletSize/3+a.BulletSize/8},function(e){return n.calculateLabelHeight(l[e.barIndex],null,o)+e.value2}),v.exit(),s.bulletChartSettings.axis.axis)for(var x=0;x<l.length;x++){var b=l[x];this.bulletGraphicsContext.append("g").attr({transform:function(){var e=b.x,t=n.calculateLabelHeight(b,null,o);return"translate("+e+","+t+")"}}).classed("axis",!0).call(b.axis.scale(b.scale)).style({fill:s.bulletChartSettings.axis.axisColor,"font-size":r.fromPoint(a.AxisFontSizeInPt)}).selectAll("line").style({stroke:s.bulletChartSettings.axis.axisColor})}var S=a.YMarginVertical+(o?s.viewportLength+15:0)+this.model.labelHeightTop;s.bulletChartSettings.labelSettings.show&&p.enter().append("text").classed("title",!0).attr({x:function(e){return e.x},y:function(e){return S},fill:s.bulletChartSettings.labelSettings.labelColor,"font-size":r.fromPoint(s.bulletChartSettings.labelSettings.fontSize)}).text(function(e){return e.categoryLabel});var w=e.TextMeasurementService.getTailoredTextOrDefault(a.getTextProperties(s.bulletChartSettings.axis.measureUnits,a.DefaultSubtitleFontSizeInPt),a.MaxMeasureUnitWidth);if(s.bulletChartSettings.axis.measureUnits&&p.enter().append("text").attr({x:function(e){return e.x+a.BulletSize},y:function(e){return S+a.SubtitleMargin+12},fill:s.bulletChartSettings.axis.unitsColor,"font-size":r.fromPoint(a.DefaultSubtitleFontSizeInPt)}).text(w),this.interactivityService){var C={rects:y,valueRects:f,clearCatcher:this.clearCatcher,interactivityService:this.interactivityService,bulletChartSettings:this.model.bulletChartSettings,hasHighlights:!1},P=this.model.barRects.concat(this.model.valueRects);this.interactivityService.bind(P,this.behavior,C)}p.exit(),t.TooltipManager.addTooltip(f,function(e){return e.data.tooltipInfo},!0),t.TooltipManager.addTooltip(d,function(e){return e.data.tooltipInfo},!0)},a.prototype.drawSecondTarget=function(e,t,i){var r={stroke:function(e){return e.fill},"stroke-width":2};e.append("line").attr({x1:function(e){return t(e)-a.SecondTargetLineSize},y1:function(e){return i(e)-a.SecondTargetLineSize},x2:function(e){return t(e)+a.SecondTargetLineSize},y2:function(e){return i(e)+a.SecondTargetLineSize}}).style(r),e.append("line").attr({x1:function(e){return t(e)+a.SecondTargetLineSize},y1:function(e){return i(e)-a.SecondTargetLineSize},x2:function(e){return t(e)-a.SecondTargetLineSize},y2:function(e){return i(e)+a.SecondTargetLineSize}}).style(r)},a.prototype.destroy=function(){},a.prototype.enumerateObjectInstances=function(e){var t=this.model;if(t){var i=e.objectName;switch(i){case"labels":return this.enumerateLabels(t);case"values":return this.enumerateValues(t);case"orientation":return this.enumerateOrientation(t);case"axis":return this.enumerateAxis(t);case"colors":return this.enumerateColors(t)}}},a.prototype.enumerateLabels=function(e){return[{selector:null,objectName:"labels",properties:{show:this.model.bulletChartSettings.labelSettings.show,labelColor:this.model.bulletChartSettings.labelSettings.labelColor,fontSize:this.model.bulletChartSettings.labelSettings.fontSize}}]},a.prototype.enumerateValues=function(e){return[{selector:null,objectName:"values",properties:{targetValue:this.model.bulletChartSettings.values.targetValue,targetValue2:this.model.bulletChartSettings.values.targetValue2,secondTargetVisibility:this.model.bulletChartSettings.values.secondTargetVisibility,minimumPercent:this.model.bulletChartSettings.values.minimumPercent,needsImprovementPercent:this.model.bulletChartSettings.values.needsImprovementPercent,satisfactoryPercent:this.model.bulletChartSettings.values.satisfactoryPercent,goodPercent:this.model.bulletChartSettings.values.goodPercent,veryGoodPercent:this.model.bulletChartSettings.values.veryGoodPercent,maximumPercent:this.model.bulletChartSettings.values.maximumPercent}}]},a.prototype.enumerateOrientation=function(e){return[{selector:null,objectName:"orientation",properties:{orientation:this.model.bulletChartSettings.orientation.orientation}}]},a.prototype.enumerateAxis=function(e){return[{selector:null,objectName:"axis",properties:{axis:this.model.bulletChartSettings.axis.axis,axisColor:this.model.bulletChartSettings.axis.axisColor,measureUnits:this.model.bulletChartSettings.axis.measureUnits,unitsColor:this.model.bulletChartSettings.axis.unitsColor}}]},a.prototype.enumerateColors=function(e){return[{selector:null,objectName:"colors",properties:{badColor:this.model.bulletChartSettings.colors.badColor,needsImprovementColor:this.model.bulletChartSettings.colors.needsImprovementColor,satisfactoryColor:this.model.bulletChartSettings.colors.satisfactoryColor,goodColor:this.model.bulletChartSettings.colors.goodColor,veryGoodColor:this.model.bulletChartSettings.colors.veryGoodColor,bulletColor:this.model.bulletChartSettings.colors.bulletColor}}]},a.ScrollBarSize=22,a.SpaceRequiredForBarVertically=100,a.XMarginHorizontal=20,a.YMarginHorizontal=30,a.XMarginVertical=50,a.YMarginVertical=10,a.BulletSize=25,a.DefaultSubtitleFontSizeInPt=9,a.BarMargin=10,a.MaxLabelWidth=80,a.MaxMeasureUnitWidth=a.MaxLabelWidth-20,a.SubtitleMargin=10,a.AxisFontSizeInPt=8,a.SecondTargetLineSize=7,a.MarkerMarginHorizontal=a.BulletSize/3,a.MarkerMarginVertical=a.BulletSize/4,a.FontFamily="Segoe UI",a.capabilities={dataRoles:[{name:"Category",kind:e.VisualDataRoleKind.Grouping,displayName:"Category"},{name:"Value",kind:e.VisualDataRoleKind.Measure,displayName:"Value"},{name:"TargetValue",kind:e.VisualDataRoleKind.Measure,displayName:"Target Value"},{name:"Minimum",kind:e.VisualDataRoleKind.Measure,displayName:"Minimum"},{name:"NeedsImprovement",kind:e.VisualDataRoleKind.Measure,displayName:"Needs Improvement"},{name:"Satisfactory",kind:e.VisualDataRoleKind.Measure,displayName:"Satisfactory"},{name:"Good",kind:e.VisualDataRoleKind.Measure,displayName:"Good"},{name:"VeryGood",kind:e.VisualDataRoleKind.Measure,displayName:"Very Good"},{name:"Maximum",kind:e.VisualDataRoleKind.Measure,displayName:"Maximum"},{name:"TargetValue2",kind:e.VisualDataRoleKind.Measure,displayName:"Target Value 2"}],objects:{general:{displayName:e.data.createDisplayNameGetter("Visual_General"),properties:{formatString:{type:{formatting:{formatString:!0}}}}},values:{displayName:"Data values",properties:{targetValue:{displayName:"Target Value",type:{numeric:!0}},targetValue2:{displayName:"Target Value 2",type:{numeric:!0}},secondTargetVisibility:{displayName:"Second Target Visibility",type:{bool:!0}},minimumPercent:{displayName:"Minimum %",type:{numeric:!0}},needsImprovementPercent:{displayName:"Needs Improvement %",type:{numeric:!0}},satisfactoryPercent:{displayName:"Satisfactory %",type:{numeric:!0}},goodPercent:{displayName:"Good %",type:{numeric:!0}},veryGoodPercent:{displayName:"Very Good %",type:{numeric:!0}},maximumPercent:{displayName:"Maximum %",type:{numeric:!0}}}},labels:{displayName:"Category labels",properties:{show:{displayName:e.data.createDisplayNameGetter("Visual_Show"),type:{bool:!0}},labelColor:{displayName:e.data.createDisplayNameGetter("Visual_LabelsFill"),description:e.data.createDisplayNameGetter("Visual_LabelsFillDescription"),type:{fill:{solid:{color:!0}}}},fontSize:{displayName:e.data.createDisplayNameGetter("Visual_TextSize"),type:{formatting:{fontSize:!0}}}}},orientation:{displayName:"Orientation",properties:{orientation:{displayName:"Orientation",type:{enumeration:s.type}}}},colors:{displayName:"Colors",properties:{badColor:{type:{fill:{solid:{color:!0}}},displayName:"Bad Color"},needsImprovementColor:{type:{fill:{solid:{color:!0}}},displayName:"Needs Improvement Color"},satisfactoryColor:{type:{fill:{solid:{color:!0}}},displayName:"Satisfactory Color"},goodColor:{type:{fill:{solid:{color:!0}}},displayName:"Good Color"},veryGoodColor:{type:{fill:{solid:{color:!0}}},displayName:"Very Good Color"},bulletColor:{type:{fill:{solid:{color:!0}}},displayName:"Bullet Color"}}},axis:{displayName:"Axis",properties:{axis:{displayName:"Axis",type:{bool:!0}},axisColor:{type:{fill:{solid:{color:!0}}},displayName:"Axis Color"},measureUnits:{type:{text:!0},displayName:"Measure Units "},unitsColor:{type:{fill:{solid:{color:!0}}},displayName:"Units Color"}}}},dataViewMappings:[{conditions:[{Category:{max:1},Value:{max:1},TargetValue:{max:1},Minimum:{max:1},NeedsImprovement:{max:1},Satisfactory:{max:1},Good:{max:1},VeryGood:{max:1},Maximum:{max:1},TargetValue2:{max:1}}],categorical:{categories:{"for":{"in":"Category"},dataReductionAlgorithm:{top:{}}},values:{select:[{bind:{to:"Value"}},{bind:{to:"TargetValue"}},{bind:{to:"TargetValue2"}},{bind:{to:"Minimum"}},{bind:{to:"NeedsImprovement"}},{bind:{to:"Satisfactory"}},{bind:{to:"Good"}},{bind:{to:"VeryGood"}},{bind:{to:"Maximum"}}]}}}],supportsHighlight:!0,sorting:{"default":{}},drilldown:{roles:["Category"]}},a}();i.BulletChart=o;var n;!function(e){function t(e){var t=r(e);return t.y+t.height}function i(){s||(s=$("<span/>"),$("body").append(s),o=d3.select($("body").get(0)).append("svg").style({height:"0px",width:"0px",position:"absolute"}).append("text"),n=$("<canvas/>").get(0).getContext("2d"))}function a(e){return i(),o.style(null),o.text(e.text).attr({visibility:"hidden","font-family":e.fontFamily,"font-size":e.fontSize,"font-weight":e.fontWeight,"font-style":e.fontStyle,"white-space":e.whiteSpace||"nowrap"}),o.node().getBBox()}function r(e){var t={fontFamily:e.fontFamily,fontSize:e.fontSize,text:"M"},i=a(t);return i}var s,o,n;e.estimateSvgTextBaselineDelta=t}(n=i.TextMeasurementHelper||(i.TextMeasurementHelper={}));var l=function(){function e(){}return e.prototype.bindEvents=function(e,t){this.options=e;var i=e.clearCatcher;e.valueRects.on("click",function(e,i){d3.event.stopPropagation(),t.handleSelection(e,d3.event.ctrlKey)}),e.rects.on("click",function(e,i){d3.event.stopPropagation(),t.handleSelection(e,d3.event.ctrlKey)}),
6i.on("click",function(){t.handleClearSelection()})},e.prototype.renderSelection=function(e){var i=this.options,a=i.hasHighlights;i.valueRects.style("opacity",function(i){return t.ColumnUtil.getFillOpacity(i.selected,i.highlight,!i.highlight&&e,!i.selected&&a)}),i.rects.style("opacity",function(i){return t.ColumnUtil.getFillOpacity(i.selected,i.highlight,!i.highlight&&e,!i.selected&&a)})},e}();i.BulletWebBehavior=l}(i=t.samples||(t.samples={}))}(t=e.visuals||(e.visuals={}))}(i||(i={}))},function(e,t){var i,i=(window.jsCommon,window.powerbi);window.powerbitests,window.InJs,window.debug,window.jasmine,window.Microsoft;!function(e){var t;!function(t){var i;!function(i){var a=e.visuals.valueFormatter,r=t.AnimatorCommon.GetAnimationDuration;!function(e){e[e.logn=0]="logn",e[e.sqrt=1]="sqrt",e[e.value=2]="value"}(i.WordCloudScaleType||(i.WordCloudScaleType={}));var s=i.WordCloudScaleType,o=function(){function e(e){this.selectionIdsValue=[],this.hostServices=e}return Object.defineProperty(e.prototype,"selectionIds",{get:function(){return this.selectionIdsValue},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasSelection",{get:function(){return this.selectionIds.length>0},enumerable:!0,configurable:!0}),e.prototype.selectAndSendSelection=function(e,t){void 0===t&&(t=!1);var i=_.isArray(e)?e:[e];return this.hostServices.shouldRetainSelection()?this.sendSelectionToHost(i):(this.selectInternal(i,t),this.sendSelection())},e.prototype.select=function(e,t){void 0===t&&(t=!1);var i=_.isArray(e)?e:[e];this.selectInternal(i,t)},e.prototype.isSelected=function(e){var i=this,a=_.isArray(e)?e:[e];return a.every(function(e){return t.utility.SelectionManager.containsSelection(i.selectionIds,e)})},e.prototype.sendSelection=function(){return this.sendSelectionToHost(this.selectionIds)},e.prototype.clear=function(e){return void 0===e&&(e=!0),this.selectionIds.length=0,e?this.sendSelection():$.Deferred().resolve()},e.prototype.selectInternal=function(e,i){var a=this,r=[];r=e.every(function(e){return a.isSelected(e)})?i?this.selectionIds.filter(function(i){return!t.utility.SelectionManager.containsSelection(e,i)}):this.selectionIds.length===e.length?[]:e:i?e.filter(function(e){return!a.isSelected(e)}).concat(this.selectionIds):e,this.selectionIds.length=0,r.forEach(function(e){return a.selectionIds.push(e)})},e.prototype.sendSelectionToHost=function(e){var t=$.Deferred(),i={data:e.filter(function(e){return e.hasIdentity()}).map(function(e){return e.getSelector()})},a=this.getSelectorsByColumn(e);return _.isEmpty(a)||(i.data2=a),this.hostServices.onSelect(i),t.resolve(this.selectionIds),t},e.prototype.getSelectorsByColumn=function(e){return _(e).filter(function(e){return e.hasIdentity}).map(function(e){return e.getSelectorsByColumn()}).compact().value()},e}(),n=function(){function e(e,t){this.defaultViewport=e||{width:0,height:0},this.defaultMargin=t||{top:0,bottom:0,right:0,left:0}}return Object.defineProperty(e.prototype,"viewport",{get:function(){return this.viewportValue||(this.viewportValue=this.defaultViewport)},set:function(t){var i=this;this.previousOriginalViewportValue=_.clone(this.originalViewportValue),this.originalViewportValue=_.clone(t),this.setUpdateObject(t,function(e){return i.viewportValue=e},function(t){return e.restrictToMinMax(t,i.minViewport)})},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"viewportCopy",{get:function(){return _.clone(this.viewport)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"viewportIn",{get:function(){return this.viewportInValue||this.viewport},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"minViewport",{get:function(){return this.minViewportValue||{width:0,height:0}},set:function(t){var i=this;this.setUpdateObject(t,function(e){return i.minViewportValue=e},e.restrictToMinMax)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"margin",{get:function(){return this.marginValue||(this.marginValue=this.defaultMargin)},set:function(t){var i=this;this.setUpdateObject(t,function(e){return i.marginValue=e},e.restrictToMinMax)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"viewportChanged",{get:function(){return!(!this.originalViewportValue||this.previousOriginalViewportValue&&this.previousOriginalViewportValue.height===this.originalViewportValue.height&&this.previousOriginalViewportValue.width===this.originalViewportValue.width)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"viewportInIsZero",{get:function(){return 0===this.viewportIn.width||0===this.viewportIn.height},enumerable:!0,configurable:!0}),e.prototype.resetMargin=function(){this.margin=this.defaultMargin},e.prototype.update=function(){this.viewportInValue=e.restrictToMinMax({width:this.viewport.width-(this.margin.left+this.margin.right),height:this.viewport.height-(this.margin.top+this.margin.bottom)},this.minViewportValue)},e.prototype.setUpdateObject=function(t,i,a){var r=this;t=_.clone(t),i(e.createNotifyChangedObject(t,function(e){a&&a(t),r.update()})),a&&a(t),this.update()},e.createNotifyChangedObject=function(e,t){var i={};return _.keys(e).forEach(function(a){return Object.defineProperty(i,a,{get:function(){return e[a]},set:function(i){e[a]=i,t(e,a)},enumerable:!0,configurable:!0})}),i},e.restrictToMinMax=function(e,t){return _.keys(e).forEach(function(i){return e[i]=Math.max(t&&t[i]||0,e[i])}),e},e}(),l=function(){function i(){this.general={maxNumberOfWords:200,minFontSize:20/u.FontSizePercentageCoefficent,maxFontSize:100/u.FontSizePercentageCoefficent,isBrokenText:!0},this.stopWords={show:!0,isDefaultStopWords:!1,words:null},this.rotateText={show:!0,minAngle:-60,maxAngle:90,maxNumberOfOrientations:2}}return Object.defineProperty(i,"Default",{get:function(){return new this},enumerable:!0,configurable:!0}),i.parse=function(e,t){var i=new this;if(!e||!e.metadata||!e.metadata.objects)return i;var a=this.getProperties(t);for(var r in t.objects)for(var s in t.objects[r].properties)if(i[r]&&_.has(i[r],s)){var o=t.objects[r].properties[s].type,n=this.getValueFnByType(o);i[r][s]=n(e.metadata.objects,a[r][s],i[r][s])}return i},i.getProperties=function(e){var t=_.merge({general:{properties:{formatString:{}}}},e.objects),i={};for(var a in t){i[a]={};for(var r in t[a].properties)i[a][r]={objectName:a,propertyName:r}}return i},i.createEnumTypeFromEnum=function(t){var i=!1;return e.createEnumType(Object.keys(t).filter(function(e,a){return!!(a%2)===i&&t[e]===e&&!void(i=!i)||!!(a%2)!==i}).map(function(e){return{value:e,displayName:e}}))},i.getValueFnByType=function(t){switch(_.keys(t)[0]){case"fill":return e.DataViewObjects.getFillColor;default:return e.DataViewObjects.getValue}},i.enumerateObjectInstances=function(e,i,a){void 0===e&&(e=new this);var r=new t.ObjectEnumerationBuilder,s=e&&e[i.objectName];if(!s)return r;var o={objectName:i.objectName,selector:null,properties:{}};for(var n in s)_.has(s,n)&&(o.properties[n]=s[n]);return r.pushInstance(o),r},i.prototype.createOriginalSettings=function(){this.originalSettings=_.cloneDeep(this)},i}();i.WordCloudSettings=l;var c=function(){function e(){this.Category=null,this.Values=null}return e.getColumnSources=function(e){return this.getColumnSourcesT(e)},e.getTableValues=function(e){var t=e&&e.table,i=this.getColumnSourcesT(e);return i&&t&&_.mapValues(i,function(e,i){return e&&t.rows.map(function(t){return t[e.index]})})},e.getTableRows=function(e){var t=e&&e.table,i=this.getColumnSourcesT(e);return i&&t&&t.rows.map(function(e){return _.mapValues(i,function(t,i){return t&&e[t.index]})})},e.getCategoricalValues=function(e){var t=e&&e.categorical,i=t&&t.categories||[],a=t&&t.values||[],r=t&&a.source&&this.getSeriesValues(e);return t&&_.mapValues(new this,function(e,t){return _.toArray(i).concat(_.toArray(a)).filter(function(e){return e.source.roles&&e.source.roles[t]}).map(function(e){return e.values})[0]||a.source&&a.source.roles&&a.source.roles[t]&&r})},e.getSeriesValues=function(e){return e&&e.categorical&&e.categorical.values&&e.categorical.values.map(function(e){return t.converterHelper.getSeriesName(e.source)})},e.getCategoricalColumns=function(e){var t=e&&e.categorical,i=t&&t.categories||[],a=t&&t.values||[];return t&&_.mapValues(new this,function(e,t){return i.filter(function(e){return e.source.roles&&e.source.roles[t]})[0]||a.source&&a.source.roles&&a.source.roles[t]||a.filter(function(e){return e.source.roles&&e.source.roles[t]})})},e.getColumnSourcesT=function(e){var t=e&&e.metadata&&e.metadata.columns;return t&&_.mapValues(new this,function(e,i){return t.filter(function(e){return e.roles&&e.roles[i]})[0]})},e.Roles=Object.freeze(_.mapValues(new e,function(e,t){return t})),e}();i.WordCloudColumns=c;var u=function(){function i(e){this.durationAnimations=500,this.fakeViewport={width:1500,height:1e3},this.canvasViewport={width:128,height:2048},e&&(this.svg=e.svg||this.svg,this.layout=new n(null,e.margin||i.DefaultMargin),e.animator&&(this.animator=e.animator)),this.isUpdating=!1}return i.converter=function(e,r,s){var o=c.getCategoricalColumns(e);if(!o||!o.Category||_.isEmpty(o.Category.values))return null;var n=c.getCategoricalValues(e),u=l.getProperties(i.capabilities),p=i.parseSettings(e,s&&s.settings),d=a.create({format:a.getFormatString(o.Category.source,u.general.formatString),value:n.Category[0]}),g=_.isString(p.stopWords.words)?p.stopWords.words.split(i.StopWordsDelemiter):[];g=p.stopWords.isDefaultStopWords?g.concat(i.StopWords):g;var m=new t.ColorHelper(r,u.dataPoint.fill,h.util.getRandomColor()),y=n.Category.map(function(i,a){var r;return r=o.Category.objects&&o.Category.objects[a]?h.util.hexToRgb(m.getColorForMeasure(o.Category.objects[a],"")):s&&s.texts&&s.texts[a]?s.texts[a].color:h.util.getRandomColor(),{text:i,count:n.Values&&n.Values[a]&&!isNaN(n.Values[a])?n.Values[a]:1,index:a,selectionId:t.SelectionId.createWithId(e.categorical.categories[0].identity[a]),color:r,textGroup:i}}),f=i.getReducedText(y,g,p),v=i.getDataPoints(f,p,d);return{dataView:e,settings:p,texts:y,dataPoints:v}},i.parseSettings=function(e,t){var a=l.parse(e,i.capabilities);return a.general.minFontSize=Math.max(a.general.minFontSize,1),a.general.maxFontSize=Math.max(a.general.maxFontSize,1),a.general.maxFontSize=Math.max(a.general.maxFontSize,a.general.minFontSize),a.rotateText.minAngle=Math.max(Math.min(a.rotateText.minAngle,i.MaxAngle),i.MinAngle),a.rotateText.maxAngle=Math.max(Math.min(a.rotateText.maxAngle,i.MaxAngle),i.MinAngle),a.rotateText.maxAngle=Math.max(a.rotateText.maxAngle,a.rotateText.minAngle),a.general.maxNumberOfWords=Math.max(Math.min(a.general.maxNumberOfWords,i.MaxNumberOfWords),1),a.rotateText.maxNumberOfOrientations=Math.max(Math.min(a.rotateText.maxNumberOfOrientations,i.MaxNumberOfWords),1),a.createOriginalSettings(),a},i.getReducedText=function(e,t,a){var r=i.getBrokenWords(e,t,a),s=_.values(_.groupBy(r,function(e){return e.text}));return s=s.map(function(e){return _.sortBy(e,function(e){return e.textGroup.length})})},i.getBrokenWords=function(e,t,a){var r=[],s=/\s/,o=new RegExp("["+i.Punctuation.join("\\")+"]","gim");return a.general.isBrokenText?(e.forEach(function(e){if("string"==typeof e.text){var i=e.text.replace(o," ").split(s);a.stopWords.show&&(i=i.filter(function(e){return e.length>0&&!t.some(function(t){return e.toLocaleLowerCase()===t.toLocaleLowerCase()})})),i.forEach(function(t){t.length>0&&!s.test(t)&&r.push({text:t,textGroup:e.textGroup,count:e.count,index:e.index,selectionId:e.selectionId,color:e.color})})}else r.push(e)}),r):e},i.getDataPoints=function(e,t,a){if(_.isEmpty(e))return[];var r=e.map(function(e){return{text:a.format(e[0].text),x:0,y:0,rotate:i.getAngle(t),padding:1,width:0,height:0,xOff:0,yOff:0,x0:0,y0:0,x1:0,y1:0,color:e[0].color,selectionIds:e.map(function(e){return e.selectionId}),wordIndex:e[0].index,count:_.sum(e,function(e){return e.count})}}),s=_.min(r,function(e){return e.count}).count,o=_.max(r,function(e){return e.count}).count,n=e.map(function(e){return e[0]});return r.forEach(function(e){return e.size=i.getWordFontSize(n,t,e.count,s,o)}),r.sort(function(e,t){return t.count-e.count})},i.getWordFontSize=function(e,t,a,r,o,n){void 0===n&&(n=s.value);var l,c,u=t.general.minFontSize*i.FontSizePercentageCoefficent,h=t.general.maxFontSize*i.FontSizePercentageCoefficent;if(e.length<2)return h;switch(n){case s.logn:l=Math.log(a);case s.sqrt:l=Math.sqrt(a);case s.value:l=a}return c=l>r&&o-r!==0?h*(l-r)/(o-r):0,c=100*c/h,c=c*(h-u)/100+u},i.getAngle=function(e){if(!e.rotateText.show)return 0;var t=(e.rotateText.maxAngle-e.rotateText.minAngle)/e.rotateText.maxNumberOfOrientations*Math.floor(Math.random()*e.rotateText.maxNumberOfOrientations);return e.rotateText.minAngle+t},Object.defineProperty(i.prototype,"settings",{get:function(){return this.data&&this.data.settings},enumerable:!0,configurable:!0}),i.prototype.init=function(e){var t=this;this.svg?this.root=this.svg:this.root=d3.select(e.element.get(0)).append("svg"),this.colors=e.style.colorPalette.dataColors,this.hostService=e.host,this.selectionManager=new o(this.hostService),this.layout=new n(null,i.DefaultMargin),this.root.classed(i.ClassName,!0),this.root.on("click",function(){t.setSelection(null)}),this.fontFamily=this.root.style("font-family"),this.main=this.root.append("g"),this.wordsContainerSelection=this.main.append("g").classed(i.Words["class"],!0),this.canvas=document.createElement("canvas")},i.prototype.update=function(e){var t=this;if(e&&e.viewport&&e.dataViews&&e.dataViews[0]&&e.viewport&&e.viewport.height>=0&&e.viewport.width>=0&&(e!==this.visualUpdateOptions&&(this.incomingUpdateOptions=e),!this.isUpdating&&this.incomingUpdateOptions!==this.visualUpdateOptions)){this.visualUpdateOptions=this.incomingUpdateOptions,this.layout.viewport=this.visualUpdateOptions.viewport;var a=e.dataViews[0];if(this.layout.viewportInIsZero)return;this.durationAnimations=r(this.animator,e.suppressAnimations),this.UpdateSize();var s=i.converter(a,this.colors,this.data);if(!s)return;this.data=s,this.computePositions(function(e){return t.render(e)})}},i.prototype.computePositions=function(t){var a=this,r=this.data.dataPoints;return _.isEmpty(r)?null:void requestAnimationFrame(function(){var s=_.range(0,(a.specialViewport.width>>5)*a.specialViewport.height,0);r.length>a.settings.general.maxNumberOfWords&&(r=r.slice(0,a.settings.general.maxNumberOfWords)),r.forEach(function(t){t.widthOfWord=e.TextMeasurementService.measureSvgTextWidth({fontFamily:a.fontFamily,fontSize:t.size+1+i.Size,text:t.text})+2}),a.computeCycle(r,a.getCanvasContext(),s,null,t,[],0)})},i.prototype.computeCycle=function(e,t,i,a,r,s,o){void 0===s&&(s=[]),void 0===o&&(o=0);var n=e[o],l=1;e.length<=10?l=5:e.length<=25?l=3:e.length<=75?l=1.5:e.length<=100&&(l=1.25),n.x=this.specialViewport.width/l*(Math.random()+.5)>>1,n.y=this.specialViewport.height/l*(Math.random()+.5)>>1,n.sprite||this.generateSprites(t,e,o),n.sprite&&this.findPosition(i,n,a)&&(s.push(n),a=this.updateBorders(n,a),n.x-=this.specialViewport.width>>1,n.y-=this.specialViewport.height>>1),++o<e.length&&this.root?this.computeCycle(e,t,i,a,r,s,o):r({data:s,leftBorder:a&&a[0],rightBorder:a&&a[1]})},i.prototype.updateBorders=function(e,t){if(t&&2===t.length){var i=t[0],a=t[1];e.x+e.x0<i.x&&(i.x=e.x+e.x0),e.y+e.y0<i.y&&(i.y=e.y+e.y0),e.x+e.x1>a.x&&(a.x=e.x+e.x1),e.y+e.y1>a.y&&(a.y=e.y+e.y1)}else t=[{x:e.x+e.x0,y:e.y+e.y0},{x:e.x+e.x1,y:e.y+e.y1}];return t},i.prototype.generateSprites=function(e,t,a){e.clearRect(0,0,this.canvasViewport.width<<5,this.canvasViewport.height);for(var r=0,s=0,o=0,n=a,l=t.length;l>n;n++){var c=t[n],u=c.widthOfWord,h=c.size<<1;if(c.rotate){var p=Math.sin(c.rotate*i.Radians),d=Math.cos(c.rotate*i.Radians),g=u*d,m=u*p,y=h*d,f=h*p;u=Math.max(Math.abs(g+f),Math.abs(g-f))+31>>5<<5,h=Math.floor(Math.max(Math.abs(m+y),Math.abs(m-y)))}else u=u+31>>5<<5;h>o&&(o=h),r+u>=this.canvasViewport.width<<5&&(r=0,s+=o,o=0),e.save(),e.font="normal normal "+(c.size+1)+i.Size+" "+this.fontFamily,e.translate(r+(u>>1),s+(h>>1)),c.rotate&&e.rotate(c.rotate*i.Radians),e.fillText(c.text,0,0),c.padding&&(e.lineWidth=2*c.padding,e.strokeText(c.text,0,0)),e.restore(),c.width=u,c.height=h,c.xOff=r,c.yOff=s,c.x1=u>>1,c.y1=h>>1,c.x0=-c.x1,c.y0=-c.y1,r+=u}this.setSprites(e,t)},i.prototype.setSprites=function(e,t){for(var i=e.getImageData(0,0,this.canvasViewport.width<<5,this.canvasViewport.height).data,a=[],r=t.length-1;r>=0;r--){var s=t[r],o=s.width,n=o>>5,l=s.y1-s.y0,c=0,u=0,h=0,p=0;if(s.xOff+o>=this.canvasViewport.width<<5||s.yOff+l>=this.canvasViewport.height)s.sprite=null;else{for(var d=0;l*n>d;d++)a[d]=0;if(null===s.xOff)return;c=s.xOff,u=s.yOff,h=0,p=-1;for(var d=0;l>d;d++){for(var g=0;o>g;g++){var m=n*d+(g>>5),y=(u+d)*(this.canvasViewport.width<<5)+(c+g)<<2,f=i[y]?1<<31-g%32:0;a[m]|=f,h|=f}h?p=d:(s.y0++,l--,d--,u++)}s.y1=s.y0+p,s.sprite=a.slice(0,(s.y1-s.y0)*n)}}},i.prototype.findPosition=function(e,t,i){for(var a,r,s,o={x:t.x,y:t.y},n=Math.sqrt(this.specialViewport.width*this.specialViewport.width+this.specialViewport.height*this.specialViewport.height),l=Math.random()<.5?1:-1,c=-l;;){if(c+=l,a=this.archimedeanSpiral(c),r=Math.floor(a.x),s=Math.floor(a.y),Math.min(Math.abs(r),Math.abs(s))>=n)break;if(t.x=o.x+r,t.y=o.y+s,!(t.x+t.x0<0||t.y+t.y0<0||t.x+t.x1>this.specialViewport.width||t.y+t.y1>this.specialViewport.height)&&(!i||!this.checkIntersect(t,e))&&(!i||this.checkIntersectOfRectangles(t,i[0],i[1]))){for(var u=t.sprite,h=t.width>>5,p=this.specialViewport.width>>5,d=t.x-(h<<4),g=127&d,m=32-g,y=t.y1-t.y0,f=(t.y+t.y0)*p+(d>>5),v=0;y>v;v++){for(var x=0,b=0;h>=b;b++){var S,w=x<<m;h>b&&(x=u[v*h+b]),S=h>b?x>>>g:0,e[f+b]|=w|S}f+=p}return t.sprite=null,!0}}return!1},i.prototype.archimedeanSpiral=function(e){var t=this.specialViewport.width/this.specialViewport.height;return e=.1*e,{x:t*e*Math.cos(e),y:e*Math.sin(e)}},i.prototype.checkIntersect=function(e,t){for(var i=this.specialViewport.width>>5,a=e.sprite,r=e.width>>5,s=e.x-(r<<4),o=127&s,n=32-o,l=e.y1-e.y0,c=(e.y+e.y0)*i+(s>>5),u=0;l>u;u++){for(var h=0,p=0;r>=p;p++){var d,g=0,m=0;if(d=h<<n,r>p&&(h=a[u*r+p]),g=r>p?h>>>o:0,m=(d|g)&t[c+p])return!0}c+=i}return!1},i.prototype.checkIntersectOfRectangles=function(e,t,i){return e.x+e.x1>t.x&&e.x+e.x0<i.x&&e.y+e.y1>t.y&&e.y+e.y0<i.y},i.prototype.getCanvasContext=function(){if(!this.canvasViewport)return null;this.canvas.width=1,this.canvas.height=1;var e=this.canvas.getContext("2d");return this.canvas.width=this.canvasViewport.width<<5,this.canvas.height=this.canvasViewport.height,e=this.canvas.getContext("2d"),e.fillStyle=e.strokeStyle="red",e.textAlign="center",e},i.prototype.UpdateSize=function(){var e,t,i;i=Math.sqrt(this.fakeViewport.width*this.fakeViewport.height/(this.layout.viewportIn.width*this.layout.viewportIn.height)),isNaN(i)?t=e=1:(t=this.layout.viewportIn.height*i,e=this.layout.viewportIn.width*i),this.specialViewport={height:t,width:e},this.root.attr({height:this.layout.viewport.height,width:this.layout.viewport.width})},i.prototype.render=function(e){var a=this;if(e&&e.data){this.scaleMainView(e),this.wordsGroupUpdateSelection=this.main.select(i.Words.selector).selectAll("g").data(e.data);var r=this.wordsGroupUpdateSelection.enter().append("svg:g").classed(i.WordGroup["class"],!0);r.append("svg:text").style("font-size","1px").attr("pointer-events","none"),r.append("svg:rect"),this.wordsGroupUpdateSelection.exit().remove(),this.wordsGroupUpdateSelection.attr("transform",function(e){return t.SVGUtil.translate(e.x,e.y)+" rotate("+e.rotate+")"}).sort(function(e,t){return t.height*t.width-e.height*e.width}),this.wordsTextUpdateSelection=this.wordsGroupUpdateSelection.selectAll("text").data(function(e){return[e]}),this.wordsTextUpdateSelection.text(function(e){return e.text}),this.animation(this.wordsTextUpdateSelection,this.durationAnimations).style({"font-size":function(e){return""+e.size+i.Size},fill:function(e){return e.color}}),this.wordsGroupUpdateSelection.selectAll("rect").data(function(e){return[e]}).attr({x:function(e){return.5*-e.widthOfWord},width:function(e){return e.widthOfWord},y:function(e){return.75*-e.size},height:function(e){return.85*e.size},fill:function(e){return"rgba(63, 191, 191, 0.0)"}}).on("click",function(e){a.setSelection(e),d3.event.stopPropagation()}),this.renderSelection(),this.isUpdating=!1,this.incomingUpdateOptions!==this.visualUpdateOptions&&this.update(this.incomingUpdateOptions)}},i.prototype.setSelection=function(e){var i=this;if(!e)return void this.selectionManager.clear().then(function(){return i.renderSelection()});var a=e.selectionIds;if(this.selectionManager.isSelected(a)&&d3.event.ctrlKey){var r=this.wordsGroupUpdateSelection.data().filter(function(t){return t.text!==e.text});a=a.filter(function(e){return!r.some(function(a){return i.selectionManager.isSelected(a.selectionIds)&&t.utility.SelectionManager.containsSelection(a.selectionIds,e)})})}this.selectionManager.selectAndSendSelection(a,d3.event.ctrlKey),this.renderSelection()},i.prototype.scaleMainView=function(e){var i=e.data.map(function(e){var t=e.width/2,i=e.height/2;return{left:e.x-t,top:e.y-i,right:e.x+t,bottom:e.y+i}}),a={left:_.min(i,function(e){return e.left}).left,top:_.min(i,function(e){return e.top}).top,right:_.max(i,function(e){return e.right}).right,bottom:_.max(i,function(e){return e.bottom}).bottom};a.width=a.right-a.left,a.height=a.bottom-a.top;var r=this.layout.viewportIn.width/a.width,s=this.layout.viewportIn.height/a.height,o=Math.min(r,s),n=-a.left*o+5,l=-a.top*o+5;this.main.style("line-height","5px"),this.main.attr("transform",t.SVGUtil.translate(n,l)+" scale("+o+")").style("line-height","10px")},i.prototype.renderSelection=function(){var e=this;if(this.selectionManager.selectionIds.some(function(t){return!e.wordsGroupUpdateSelection.data().some(function(e){return e.selectionIds.some(function(e){return e.getKey()===t.getKey()})})})&&this.selectionManager.clear(!1),!this.selectionManager.hasSelection)return void this.setOpacity(this.wordsTextUpdateSelection,i.MaxOpacity);var t=this.wordsTextUpdateSelection.filter(function(t){return e.selectionManager.isSelected(t.selectionIds[0])});this.setOpacity(this.wordsTextUpdateSelection,i.MinOpacity),this.setOpacity(t,i.MaxOpacity)},i.prototype.setOpacity=function(e,t){e.style("fill-opacity",t),this.main&&(this.main.style("line-height","14px"),this.animation(this.main,0,this.durationAnimations).style("line-height","15px"))},i.prototype.enumerateObjectInstances=function(e){var a=this,r=l.enumerateObjectInstances(this.settings&&this.settings.originalSettings,e,i.capabilities);switch(e.objectName){case"dataPoint":if(this.data&&this.data.dataPoints){var s=[];_.unique(this.data.dataPoints,function(e){return e.wordIndex}).forEach(function(i){-1===s.indexOf(i.wordIndex)&&(s.push(i.wordIndex),r.pushInstance({objectName:e.objectName,displayName:a.data.texts[i.wordIndex].text,selector:t.ColorHelper.normalizeSelector(i.selectionIds[0].getSelector(),!1),properties:{fill:{solid:{color:i.color}}}}))})}}return r.complete()},i.prototype.animation=function(e,t,i,a){return void 0===t&&(t=0),void 0===i&&(i=0),e.transition().delay(i).duration(t).each("end",a)},i.prototype.destroy=function(){this.root=null,this.canvas=null},i.ClassName="wordCloud",i.Words={"class":"words",selector:".words"},i.WordGroup={"class":"word",selector:".word"},i.Size="px",i.StopWordsDelemiter=" ",i.Radians=Math.PI/180,i.MinAngle=-180,i.MaxAngle=180,i.MaxNumberOfWords=2500,i.MinOpacity=.2,i.MaxOpacity=1,i.FontSizePercentageCoefficent=1,i.capabilities={dataRoles:[{name:c.Roles.Category,kind:e.VisualDataRoleKind.Grouping,displayName:"Category"},{name:c.Roles.Values,kind:e.VisualDataRoleKind.Measure,displayName:"Values"}],dataViewMappings:[{conditions:[{Category:{min:1,max:1},Values:{min:0,max:1}}],categorical:{categories:{"for":{"in":"Category"},dataReductionAlgorithm:{top:{count:i.MaxNumberOfWords}}},values:{"for":{"in":"Values"}}}}],sorting:{implicit:{clauses:[{role:"Values",direction:2}]}},objects:{general:{displayName:"General",properties:{formatString:{type:{formatting:{formatString:!0}}},maxNumberOfWords:{displayName:"Max number of words",type:{numeric:!0}},minFontSize:{displayName:"Min Font",type:{formatting:{fontSize:!0}}},maxFontSize:{displayName:"Max Font",type:{formatting:{fontSize:!0}}},isBrokenText:{displayName:"Word-breaking",type:{bool:!0}}}},dataPoint:{displayName:"Data colors",properties:{fill:{displayName:"Fill",type:{fill:{solid:{color:!0}}}}}},stopWords:{displayName:"Stop Words",properties:{show:{displayName:"Show",type:{bool:!0}},isDefaultStopWords:{displayName:"Default Stop Words",type:{bool:!0}},words:{displayName:"Words",type:{text:!0}}}},rotateText:{displayName:"Rotate Text",properties:{show:{displayName:"Show",type:{bool:!0}},minAngle:{displayName:"Min Angle",type:{numeric:!0}},maxAngle:{displayName:"Max Angle",type:{numeric:!0}},maxNumberOfOrientations:{displayName:"Max number of orientations",type:{numeric:!0}}}}}},i.Punctuation=["!",".",":","'",";",",","!","@","#","$","%","^","&","*","(",")","[","]",'"',"\\","/","-","_","+","="],i.StopWords=["a","able","about","across","after","all","almost","also","am","among","an","and","any","are","as","at","be","because","been","but","by","can","cannot","could","did","do","does","either","else","ever","every","for","from","get","got","had","has","have","he","her","hers","him","his","how","however","i","if","in","into","is","it","its","just","least","let","like","likely","may","me","might","most","must","my","neither","no","nor","not","of","off","often","on","only","or","other","our","own","rather","said","say","says","she","should","since","so","some","than","that","the","their","them","then","there","these","they","this","tis","to","too","twas","us","wants","was","we","were","what","when","where","which","while","who","whom","why","will","with","would","yet","you","your"],i.DefaultMargin={top:10,right:10,bottom:10,left:10},i}();i.WordCloud=u;var h;!function(e){var t;!function(e){function t(e){var t=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;e=e.replace(t,function(e,t,i,a){return t+t+i+i+a+a});var i=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return i?"rgb("+parseInt(i[1],16)+","+parseInt(i[2],16)+","+parseInt(i[3],16)+")":null}function i(){var e=Math.floor(255*Math.random()),t=Math.floor(255*Math.random()),i=Math.floor(255*Math.random());return"rgb("+e+","+t+","+i+")"}e.hexToRgb=t,e.getRandomColor=i}(t=e.util||(e.util={}))}(h||(h={}))}(i=t.samples||(t.samples={}))}(t=e.visuals||(e.visuals={}))}(i||(i={}))},function(e,t){var i,a=window.jsCommon,i=window.powerbi;window.powerbitests,window.InJs,window.debug,window.jasmine,window.Microsoft;!function(e){var t;!function(t){var i;!function(i){var r,s=a.CssConstants.createClassAndSelector,o=a.PixelConverter,n=e.data.SQExprConverter,l=e.visuals.SelectionIdBuilder;!function(e){function t(e){return new c(e)}e.createTableView=t}(r=i.TableViewFactory||(i.TableViewFactory={}));var c=function(){function e(t){this.options=$.extend(!0,{},t),this.options.baseContainer.style("overflow-y","auto").attr("drag-resize-disabled",!0),this.scrollContainer=t.baseContainer.append("div").attr("class","scrollRegion"),this.visibleGroupContainer=this.scrollContainer.append("div").attr("class","visibleGroup"),e.SetDefaultOptions(t)}return e.SetDefaultOptions=function(t){t.rowHeight=t.rowHeight||e.defaultRowHeight},e.prototype.rowHeight=function(e){return this.options.rowHeight=Math.ceil(e),this},e.prototype.columnWidth=function(e){return this.options.columnWidth=Math.ceil(e),this},e.prototype.orientation=function(e){return this.options.orientation=e,this},e.prototype.rows=function(e){return this.options.rows=Math.ceil(e),this},e.prototype.columns=function(e){return this.options.columns=Math.ceil(e),this},e.prototype.data=function(e,t,i){return void 0===i&&(i=!1),this._data=e,this.getDatumIndex=t,this.setTotalRows(),i&&$(this.options.baseContainer.node()).scrollTop(0),this},e.prototype.viewport=function(e){return this.options.viewport=e,this},e.prototype.empty=function(){this._data=[],this.render()},e.prototype.setTotalRows=function(){var t=this._data.length,i=Math.min(this.options.rows,t),a=Math.min(this.options.columns,t);a>0&&i>0?(this._totalColumns=a,this._totalRows=i):i>0?(this._totalRows=i,this._totalColumns=Math.ceil(t/i)):a>0?(this._totalColumns=a,this._totalRows=Math.ceil(t/a)):(this._totalColumns=e.defaultColumns,this._totalRows=Math.ceil(t/e.defaultColumns))},e.prototype.render=function(){var t=this.options,i=this.visibleGroupContainer,a=t.rowHeight||e.defaultRowHeight,r=[],s=t.rows,o=t.columns,n=this._data.length,s=t.rows>n?n:t.rows,o=t.columns>n?n:t.columns;if(0===o&&0===s?t.orientation===p.HORIZONTAL?(o=n,s=1):(o=1,s=n):0===o&&s>0?o=Math.ceil(n/s):o>0&&0===s&&(s=Math.ceil(n/o)),this.options.orientation===p.VERTICAL){var l=s;s=o,o=l}else this.options.orientation===p.HORIZONTAL&&(0===s&&(s=this._totalRows),0===o&&(o=this._totalColumns));for(var c=0,u=0,h=0;s>h;h++)if(this.options.orientation===p.VERTICAL&&0===t.rows&&n%t.columns>0&&t.columns<=n)n%t.columns>h?(c=h*Math.ceil(n/t.columns),u=c+Math.ceil(n/t.columns),r.push(this._data.slice(c,u))):(r.push(this._data.slice(u,u+Math.floor(n/t.columns))),u+=Math.floor(n/t.columns));else if(this.options.orientation===p.HORIZONTAL&&0===t.columns&&n%t.rows>0&&t.rows<=n)n%t.rows>h?(c=h*Math.ceil(n/t.rows),u=c+Math.ceil(n/t.rows),r.push(this._data.slice(c,u))):(r.push(this._data.slice(u,u+Math.floor(n/t.rows))),u+=Math.floor(n/t.rows));else{var u=h*o;r.push(this._data.slice(u,u+o))}i.selectAll(".row").remove();var d=i.selectAll(".row").data(r).enter().append("div").classed("row",!0).selectAll(".cell").data(function(e){return e});d.enter().append("div").classed("cell",!0).call(function(e){return t.enter(e)}),d.order();var g=i.selectAll(".cell:not(.transitioning)");if(g.call(function(e){return t.update(e)}),g.style({height:a>0?a+"px":"auto"}),this.options.orientation===p.VERTICAL){for(var m=0,h=0;h<r.length;h++)0!==r[h].length&&(m=h+1);g.style({width:"100%"});var y=i.selectAll("div.row");y.style({width:t.columnWidth>0?t.columnWidth+"px":100/m+"%"})}else g.style({width:t.columnWidth>0?t.columnWidth+"px":100/o+"%"});d.exit().call(function(e){return t.exit(e)}).remove()},e.defaultRowHeight=0,e.defaultColumns=1,e}();i.chicletSlicerProps={general:{orientation:{objectName:"general",propertyName:"orientation"},columns:{objectName:"general",propertyName:"columns"},rows:{objectName:"general",propertyName:"rows"},showDisabled:{objectName:"general",propertyName:"showDisabled"},multiselect:{objectName:"general",propertyName:"multiselect"},selection:{objectName:"general",propertyName:"selection"},selfFilterEnabled:{objectName:"general",propertyName:"selfFilterEnabled"}},header:{show:{objectName:"header",propertyName:"show"},title:{objectName:"header",propertyName:"title"},fontColor:{objectName:"header",propertyName:"fontColor"},background:{objectName:"header",propertyName:"background"},outline:{objectName:"header",propertyName:"outline"},textSize:{objectName:"header",propertyName:"textSize"},outlineColor:{objectName:"header",propertyName:"outlineColor"},outlineWeight:{objectName:"header",propertyName:"outlineWeight"}},rows:{fontColor:{objectName:"rows",propertyName:"fontColor"},textSize:{objectName:"rows",propertyName:"textSize"},height:{objectName:"rows",propertyName:"height"},width:{objectName:"rows",propertyName:"width"},background:{objectName:"rows",propertyName:"background"},transparency:{objectName:"rows",propertyName:"transparency"},selectedColor:{objectName:"rows",propertyName:"selectedColor"},hoverColor:{objectName:"rows",propertyName:"hoverColor"},unselectedColor:{objectName:"rows",propertyName:"unselectedColor"},disabledColor:{objectName:"rows",propertyName:"disabledColor"},outline:{objectName:"rows",propertyName:"outline"},outlineColor:{objectName:"rows",propertyName:"outlineColor"},outlineWeight:{objectName:"rows",propertyName:"outlineWeight"},borderStyle:{objectName:"rows",propertyName:"borderStyle"}},images:{imageSplit:{objectName:"images",propertyName:"imageSplit"},stretchImage:{objectName:"images",
7propertyName:"stretchImage"},bottomImage:{objectName:"images",propertyName:"bottomImage"}},selectedPropertyIdentifier:{objectName:"general",propertyName:"selected"},filterPropertyIdentifier:{objectName:"general",propertyName:"filter"},formatString:{objectName:"general",propertyName:"formatString"},hasSavedSelection:!0};var u;!function(t){t.ROUNDED="Rounded",t.CUT="Cut",t.SQUARE="Square",t.type=e.createEnumType([{value:t.ROUNDED,displayName:t.ROUNDED},{value:t.CUT,displayName:t.CUT},{value:t.SQUARE,displayName:t.SQUARE}])}(u||(u={}));var h;!function(t){t.INPLACE="Inplace",t.BOTTOM="Bottom",t.HIDE="Hide",t.type=e.createEnumType([{value:t.INPLACE,displayName:t.INPLACE},{value:t.BOTTOM,displayName:t.BOTTOM},{value:t.HIDE,displayName:t.HIDE}])}(h||(h={}));var p;!function(t){t.HORIZONTAL="Horizontal",t.VERTICAL="Vertical",t.type=e.createEnumType([{value:t.HORIZONTAL,displayName:t.HORIZONTAL},{value:t.VERTICAL,displayName:t.VERTICAL}])}(p||(p={}));var d=function(){function a(e){e&&e.behavior&&(this.behavior=e.behavior),this.behavior||(this.behavior=new y)}return a.DefaultStyleProperties=function(){return{general:{orientation:p.VERTICAL,columns:3,rows:0,multiselect:!0,showDisabled:h.INPLACE,selection:null,selfFilterEnabled:!1},margin:{top:50,bottom:50,right:50,left:50},header:{borderBottomWidth:1,show:!0,outline:"BottomOnly",fontColor:"#a6a6a6",background:null,textSize:10,outlineColor:"#a6a6a6",outlineWeight:1,title:""},headerText:{marginLeft:8,marginTop:0},slicerText:{textSize:10,height:0,width:0,fontColor:"#666666",hoverColor:"#212121",selectedColor:"#BDD7EE",unselectedColor:"#ffffff",disabledColor:"grey",marginLeft:8,outline:"Frame",background:null,transparency:0,outlineColor:"#000000",outlineWeight:1,borderStyle:"Cut"},slicerItemContainer:{marginTop:5,marginLeft:0},images:{imageSplit:50,stretchImage:!1,bottomImage:!1}}},a.converter=function(a,r,s,o){if(a&&a.categorical&&a.categorical.categories&&a.categorical.categories[0]&&a.categorical.categories[0].values&&a.categorical.categories[0].values.length>0){var n=new g.ChicletSlicerConverter(a,o);n.convert();var l,c=this.DefaultStyleProperties(),u=a.metadata.objects;u&&(c.general.orientation=e.DataViewObjects.getValue(u,i.chicletSlicerProps.general.orientation,c.general.orientation),c.general.columns=e.DataViewObjects.getValue(u,i.chicletSlicerProps.general.columns,c.general.columns),c.general.rows=e.DataViewObjects.getValue(u,i.chicletSlicerProps.general.rows,c.general.rows),c.general.multiselect=e.DataViewObjects.getValue(u,i.chicletSlicerProps.general.multiselect,c.general.multiselect),c.general.showDisabled=e.DataViewObjects.getValue(u,i.chicletSlicerProps.general.showDisabled,c.general.showDisabled),c.general.selection=e.DataViewObjects.getValue(a.metadata.objects,i.chicletSlicerProps.general.selection,c.general.selection),c.general.selfFilterEnabled=e.DataViewObjects.getValue(u,i.chicletSlicerProps.general.selfFilterEnabled,c.general.selfFilterEnabled),c.header.show=e.DataViewObjects.getValue(u,i.chicletSlicerProps.header.show,c.header.show),c.header.title=e.DataViewObjects.getValue(u,i.chicletSlicerProps.header.title,c.header.title),c.header.fontColor=e.DataViewObjects.getFillColor(u,i.chicletSlicerProps.header.fontColor,c.header.fontColor),c.header.background=e.DataViewObjects.getFillColor(u,i.chicletSlicerProps.header.background,c.header.background),c.header.textSize=e.DataViewObjects.getValue(u,i.chicletSlicerProps.header.textSize,c.header.textSize),c.header.outline=e.DataViewObjects.getValue(u,i.chicletSlicerProps.header.outline,c.header.outline),c.header.outlineColor=e.DataViewObjects.getFillColor(u,i.chicletSlicerProps.header.outlineColor,c.header.outlineColor),c.header.outlineWeight=e.DataViewObjects.getValue(u,i.chicletSlicerProps.header.outlineWeight,c.header.outlineWeight),c.slicerText.textSize=e.DataViewObjects.getValue(u,i.chicletSlicerProps.rows.textSize,c.slicerText.textSize),c.slicerText.height=e.DataViewObjects.getValue(u,i.chicletSlicerProps.rows.height,c.slicerText.height),c.slicerText.width=e.DataViewObjects.getValue(u,i.chicletSlicerProps.rows.width,c.slicerText.width),c.slicerText.selectedColor=e.DataViewObjects.getFillColor(u,i.chicletSlicerProps.rows.selectedColor,c.slicerText.selectedColor),c.slicerText.hoverColor=e.DataViewObjects.getFillColor(u,i.chicletSlicerProps.rows.hoverColor,c.slicerText.hoverColor),c.slicerText.unselectedColor=e.DataViewObjects.getFillColor(u,i.chicletSlicerProps.rows.unselectedColor,c.slicerText.unselectedColor),c.slicerText.disabledColor=e.DataViewObjects.getFillColor(u,i.chicletSlicerProps.rows.disabledColor,c.slicerText.disabledColor),c.slicerText.background=e.DataViewObjects.getFillColor(u,i.chicletSlicerProps.rows.background,c.slicerText.background),c.slicerText.transparency=e.DataViewObjects.getValue(u,i.chicletSlicerProps.rows.transparency,c.slicerText.transparency),c.slicerText.fontColor=e.DataViewObjects.getFillColor(u,i.chicletSlicerProps.rows.fontColor,c.slicerText.fontColor),c.slicerText.outline=e.DataViewObjects.getValue(u,i.chicletSlicerProps.rows.outline,c.slicerText.outline),c.slicerText.outlineColor=e.DataViewObjects.getFillColor(u,i.chicletSlicerProps.rows.outlineColor,c.slicerText.outlineColor),c.slicerText.outlineWeight=e.DataViewObjects.getValue(u,i.chicletSlicerProps.rows.outlineWeight,c.slicerText.outlineWeight),c.slicerText.borderStyle=e.DataViewObjects.getValue(u,i.chicletSlicerProps.rows.borderStyle,c.slicerText.borderStyle),c.images.imageSplit=e.DataViewObjects.getValue(u,i.chicletSlicerProps.images.imageSplit,c.images.imageSplit),c.images.stretchImage=e.DataViewObjects.getValue(u,i.chicletSlicerProps.images.stretchImage,c.images.stretchImage),c.images.bottomImage=e.DataViewObjects.getValue(u,i.chicletSlicerProps.images.bottomImage,c.images.bottomImage)),c.general.selfFilterEnabled&&s&&(s=s.toLowerCase(),n.dataPoints.forEach(function(e){return e.filtered=e.category.toLowerCase().indexOf(s)<0}));var h=a.categorical.categories[0];return l={categorySourceName:h.source.displayName,formatString:t.valueFormatter.getFormatString(h.source,i.chicletSlicerProps.formatString),slicerSettings:c,slicerDataPoints:n.dataPoints},l.hasSelectionOverride=n.hasSelectionOverride,l}},a.prototype.init=function(e){this.element=e.element,this.currentViewport=e.viewport,this.behavior&&(this.interactivityService=t.createInteractivityService(e.host)),this.hostServices=e.host,this.hostServices.canSelect=a.canSelect,this.settings=a.DefaultStyleProperties(),this.initContainer()},a.canSelect=function(e){var t=e.data;return!(t&&t.length>1&&t.some(function(e){return e&&e.data&&e.data.length>1}))},a.prototype.update=function(t){if(t&&t.dataViews&&t.dataViews[0]&&t.viewport){var i=this.dataView;this.dataView=t.dataViews[0];var a=!0;i&&(a=!e.DataViewAnalysis.hasSameCategoryIdentity(i,this.dataView)),t.viewport.height===this.currentViewport.height&&t.viewport.width===this.currentViewport.width?this.waitingForData=!1:this.currentViewport=t.viewport,this.updateInternal(a)}},a.prototype.onResizing=function(e){this.currentViewport=e,this.updateInternal(!1)},a.prototype.enumerateObjectInstances=function(e){var t=this.slicerData;if(t){var i=e.objectName;switch(i){case"rows":return this.enumerateRows(t);case"header":return this.enumerateHeader(t);case"general":return this.enumerateGeneral(t);case"images":return this.enumerateImages(t)}}},a.prototype.enumerateHeader=function(e){var t=this.settings;return[{selector:null,objectName:"header",properties:{show:t.header.show,title:t.header.title,fontColor:t.header.fontColor,background:t.header.background,textSize:t.header.textSize,outline:t.header.outline,outlineColor:t.header.outlineColor,outlineWeight:t.header.outlineWeight}}]},a.prototype.enumerateRows=function(e){var t=this.settings;return[{selector:null,objectName:"rows",properties:{textSize:t.slicerText.textSize,height:t.slicerText.height,width:t.slicerText.width,background:t.slicerText.background,transparency:t.slicerText.transparency,selectedColor:t.slicerText.selectedColor,hoverColor:t.slicerText.hoverColor,unselectedColor:t.slicerText.unselectedColor,disabledColor:t.slicerText.disabledColor,outline:t.slicerText.outline,outlineColor:t.slicerText.outlineColor,outlineWeight:t.slicerText.outlineWeight,fontColor:t.slicerText.fontColor,borderStyle:t.slicerText.borderStyle}}]},a.prototype.enumerateGeneral=function(e){var t=this.settings;return[{selector:null,objectName:"general",properties:{orientation:t.general.orientation,columns:t.general.columns,rows:t.general.rows,showDisabled:t.general.showDisabled,multiselect:t.general.multiselect,selfFilterEnabled:t.general.selfFilterEnabled}}]},a.prototype.enumerateImages=function(e){var t=this.settings;return[{selector:null,objectName:"images",properties:{imageSplit:t.images.imageSplit,stretchImage:t.images.stretchImage,bottomImage:t.images.bottomImage}}]},a.prototype.updateInternal=function(t){var i=this;this.updateSlicerBodyDimensions();var r="Select All",s=a.converter(this.dataView,r,this.searchInput.val(),this.interactivityService);if(!s)return void this.tableView.empty();this.interactivityService&&this.interactivityService.applySelectionStateToData(s.slicerDataPoints),s.slicerSettings.header.outlineWeight=s.slicerSettings.header.outlineWeight<0?0:s.slicerSettings.header.outlineWeight,s.slicerSettings.slicerText.outlineWeight=s.slicerSettings.slicerText.outlineWeight<0?0:s.slicerSettings.slicerText.outlineWeight,s.slicerSettings.slicerText.height=s.slicerSettings.slicerText.height<0?0:s.slicerSettings.slicerText.height,s.slicerSettings.slicerText.width=s.slicerSettings.slicerText.width<0?0:s.slicerSettings.slicerText.width,s.slicerSettings.images.imageSplit=s.slicerSettings.images.imageSplit<0?0:s.slicerSettings.images.imageSplit,s.slicerSettings.general.columns=s.slicerSettings.general.columns<0?0:s.slicerSettings.general.columns,s.slicerSettings.general.rows=s.slicerSettings.general.rows<0?0:s.slicerSettings.general.rows,s.slicerSettings.general.getSavedSelection=function(){try{return JSON.parse(i.slicerData.slicerSettings.general.selection)||[]}catch(e){return[]}},s.slicerSettings.general.setSavedSelection=function(e,t){i.isSelectionSaved=!0,i.hostServices.persistProperties({merge:[{objectName:"general",selector:null,properties:{filter:e,selection:t&&JSON.stringify(t)||""}}]})},this.slicerData?this.isSelectionSaved?this.isSelectionLoaded=!0:this.isSelectionLoaded=this.slicerData.slicerSettings.general.selection===s.slicerSettings.general.selection:this.isSelectionLoaded=!1,this.slicerData=s,this.settings=this.slicerData.slicerSettings,this.settings.general.showDisabled===h.BOTTOM?s.slicerDataPoints.sort(function(e,t){return e.selectable===t.selectable?0:e.selectable&&!t.selectable?-1:1}):this.settings.general.showDisabled===h.HIDE&&(s.slicerDataPoints=s.slicerDataPoints.filter(function(e){return e.selectable}));var o=this.settings.slicerText.height;if(0===o){var n=a.cellTotalInnerPaddings+a.cellTotalInnerBorders,l=a.getChicletTextProperties(this.settings.slicerText.textSize);o=e.TextMeasurementService.estimateSvgTextHeight(l)+e.TextMeasurementService.estimateSvgTextBaselineDelta(l)+n;var c=_.any(s.slicerDataPoints,function(e){return""!==e.imageURL&&"undefined"!=typeof e.imageURL});c&&(o+=100)}this.tableView.rowHeight(o).columnWidth(this.settings.slicerText.width).orientation(this.settings.general.orientation).rows(this.settings.general.rows).columns(this.settings.general.columns).data(s.slicerDataPoints.filter(function(e){return!e.filtered}),function(e){return $.inArray(e,s.slicerDataPoints)},t).viewport(this.getSlicerBodyViewport(this.currentViewport)).render(),this.updateSearchHeader()},a.prototype.initContainer=function(){var i=this,s=this.settings,n=this.getSlicerBodyViewport(this.currentViewport),l=d3.select(this.element.get(0)).append("div").classed(a.Container["class"],!0);this.slicerHeader=l.append("div").classed(a.Header["class"],!0),this.slicerHeader.append("span").classed(a.Clear["class"],!0).attr("title","Clear"),this.slicerHeader.append("div").classed(a.HeaderText["class"],!0).style({"margin-left":o.toString(s.headerText.marginLeft),"margin-top":o.toString(s.headerText.marginTop),"border-style":this.getBorderStyle(s.header.outline),"border-color":s.header.outlineColor,"border-width":this.getBorderWidth(s.header.outline,s.header.outlineWeight),"font-size":o.fromPoint(s.header.textSize)}),this.createSearchHeader($(l.node())),this.slicerBody=l.append("div").classed(a.Body["class"],!0).classed("slicerBody-horizontal",s.general.orientation===p.HORIZONTAL).classed("slicerBody-vertical",s.general.orientation===p.VERTICAL).style({height:o.toString(n.height),width:"100%"});var c=function(e){var t=i.settings,r=e.append("ul").append("li").classed(a.ItemContainer["class"],!0).style({"margin-left":o.toString(t.slicerItemContainer.marginLeft)});r.append("div").classed("slicer-img-wrapper",!0),r.append("div").classed("slicer-text-wrapper",!0).append("span").classed(a.LabelText["class"],!0).style({"font-size":o.fromPoint(t.slicerText.textSize)})},u=function(r){var s=i.settings,n=i.slicerData;if(n&&s){i.slicerHeader.classed("hidden",!s.header.show),i.slicerHeader.select(a.HeaderText.selector).text(""!==s.header.title.trim()?s.header.title.trim():i.slicerData.categorySourceName).style({"border-style":i.getBorderStyle(s.header.outline),"border-color":s.header.outlineColor,"border-width":i.getBorderWidth(s.header.outline,s.header.outlineWeight),color:s.header.fontColor,"background-color":s.header.background,"font-size":o.fromPoint(s.header.textSize)}),i.slicerBody.classed("slicerBody-horizontal",s.general.orientation===p.HORIZONTAL).classed("slicerBody-vertical",s.general.orientation===p.VERTICAL);var l=r.selectAll(a.LabelText.selector),c=a.getChicletTextProperties(s.slicerText.textSize),u=n.formatString;l.text(function(r){var o=t.valueFormatter.format(r.category,u);return c.text=o,0===i.settings.slicerText.width?e.TextMeasurementService.getTailoredTextOrDefault(c,i.currentViewport.width/i.settings.general.columns-a.chicletTotalInnerRightLeftPaddings-a.cellTotalInnerBorders-s.slicerText.outlineWeight):e.TextMeasurementService.getTailoredTextOrDefault(c,i.settings.slicerText.width-a.chicletTotalInnerRightLeftPaddings-a.cellTotalInnerBorders-s.slicerText.outlineWeight)});var h=r.selectAll(".slicer-img-wrapper");if(h.style("height",s.images.imageSplit+"%").classed("hidden",function(e){return e.imageURL?s.images.imageSplit<10?!0:void 0:!0}).style("display",function(e){return e.imageURL?"flex":"none"}).classed("stretchImage",s.images.stretchImage).classed("bottomImage",s.images.bottomImage).style("background-image",function(e){return e.imageURL?"url("+e.imageURL+")":""}),r.selectAll(".slicer-text-wrapper").style("height",function(e){return e.imageURL?100-s.images.imageSplit+"%":"100%"}).classed("hidden",function(e){return s.images.imageSplit>90?!0:void 0}),r.selectAll(".slicerItemContainer").style({color:s.slicerText.fontColor,"border-style":i.getBorderStyle(s.slicerText.outline),"border-color":s.slicerText.outlineColor,"border-width":i.getBorderWidth(s.slicerText.outline,s.slicerText.outlineWeight),"font-size":o.fromPoint(s.slicerText.textSize),"border-radius":i.getBorderRadius(s.slicerText.borderStyle)}),s.slicerText.background?i.slicerBody.style("background-color",f.util.hexToRGBString(s.slicerText.background,(100-s.slicerText.transparency)/100)):i.slicerBody.style("background-color",null),i.interactivityService&&i.slicerBody){i.interactivityService.applySelectionStateToData(n.slicerDataPoints);var d=i.slicerBody.attr("width",i.currentViewport.width),g=d.selectAll(a.ItemContainer.selector),m=d.selectAll(a.LabelText.selector),y=d.selectAll(a.Input.selector),v=i.slicerHeader.select(a.Clear.selector),x={dataPoints:n.slicerDataPoints,slicerItemContainers:g,slicerItemLabels:m,slicerItemInputs:y,slicerClear:v,interactivityService:i.interactivityService,slicerSettings:n.slicerSettings,isSelectionLoaded:i.isSelectionLoaded};i.interactivityService.bind(n.slicerDataPoints,i.behavior,x,{overrideSelectionFromData:!0,hasSelectionOverride:n.hasSelectionOverride}),i.behavior.styleSlicerInputs(r.select(a.ItemContainer.selector),i.interactivityService.hasSelection())}else i.behavior.styleSlicerInputs(r.select(a.ItemContainer.selector),!1)}},h=function(e){e.remove()},d={rowHeight:this.getRowHeight(),columnWidth:this.settings.slicerText.width,orientation:this.settings.general.orientation,rows:this.settings.general.rows,columns:this.settings.general.columns,enter:c,exit:h,update:u,loadMoreData:function(){return i.onLoadMoreData()},scrollEnabled:!0,viewport:this.getSlicerBodyViewport(this.currentViewport),baseContainer:this.slicerBody};this.tableView=r.createTableView(d)},a.prototype.createSearchHeader=function(e){var t=this;this.searchHeader=$("<div>").appendTo(e).addClass("searchHeader").addClass("collapsed"),$("<div>").appendTo(this.searchHeader).attr("title","Search").addClass("search");var i=0;this.searchInput=$("<input>").appendTo(this.searchHeader).attr("type","text").attr("drag-resize-disabled","true").addClass("searchInput").on("input",function(){return t.hostServices.persistProperties({merge:[{objectName:"general",selector:null,properties:{counter:i++}}]})})},a.prototype.updateSearchHeader=function(){this.searchHeader.toggleClass("show",this.slicerData.slicerSettings.general.selfFilterEnabled),this.searchHeader.toggleClass("collapsed",!this.slicerData.slicerSettings.general.selfFilterEnabled)},a.prototype.onLoadMoreData=function(){!this.waitingForData&&this.dataView.metadata&&this.dataView.metadata.segment&&(this.hostServices.loadMoreData(),this.waitingForData=!0)},a.prototype.getSlicerBodyViewport=function(e){var t=this.settings,i=t.header.show?this.getHeaderHeight():0,a=e.height-(i+t.header.borderBottomWidth);return{height:a,width:e.width}},a.prototype.updateSlicerBodyDimensions=function(){var e=this.getSlicerBodyViewport(this.currentViewport);this.slicerBody.style({height:o.toString(e.height),width:"100%"})},a.getChicletTextProperties=function(e){return{fontFamily:a.DefaultFontFamily,fontSize:o.fromPoint(e||a.DefaultFontSizeInPt)}},a.prototype.getHeaderHeight=function(){return e.TextMeasurementService.estimateSvgTextHeight(a.getChicletTextProperties(this.settings.header.textSize))},a.prototype.getRowHeight=function(){var t=this.settings.slicerText;return 0!==t.height?t.height:e.TextMeasurementService.estimateSvgTextHeight(a.getChicletTextProperties(t.textSize))},a.prototype.getBorderStyle=function(e){return"0px"===e?"none":"solid"},a.prototype.getBorderWidth=function(e,t){switch(e){case"None":return"0px";case"BottomOnly":return"0px 0px "+t+"px 0px";case"TopOnly":return t+"px 0px 0px 0px";case"TopBottom":return t+"px 0px "+t+"px 0px";case"LeftRight":return"0px "+t+"px 0px "+t+"px";case"Frame":return t+"px";default:return e.replace("1",t.toString())}},a.prototype.getBorderRadius=function(e){switch(e){case u.ROUNDED:return"10px";case u.SQUARE:return"0px";default:return"5px"}},a.capabilities={dataRoles:[{name:"Category",kind:e.VisualDataRoleKind.Grouping,displayName:"Category"},{name:"Values",kind:e.VisualDataRoleKind.Measure,displayName:"Values"},{name:"Image",kind:e.VisualDataRoleKind.Grouping,displayName:"Image"}],objects:{general:{displayName:e.data.createDisplayNameGetter("Visual_General"),properties:{selection:{displayName:"Selection",type:{text:!0}},orientation:{displayName:"Orientation",type:{enumeration:p.type}},columns:{displayName:"Columns",type:{numeric:!0}},rows:{displayName:"Rows",type:{numeric:!0}},showDisabled:{displayName:"Show Disabled",type:{enumeration:h.type}},multiselect:{displayName:"Multiple selection",type:{bool:!0}},selected:{type:{bool:!0}},filter:{type:{filter:{}}},selfFilter:{type:{filter:{selfFilter:!0}}},selfFilterEnabled:{type:{operations:{searchEnabled:!0}}},formatString:{type:{formatting:{formatString:!0}}}}},header:{displayName:e.data.createDisplayNameGetter("Visual_Header"),properties:{show:{displayName:e.data.createDisplayNameGetter("Visual_Show"),type:{bool:!0}},title:{displayName:"Title",type:{text:!0}},fontColor:{displayName:e.data.createDisplayNameGetter("Visual_FontColor"),type:{fill:{solid:{color:!0}}}},background:{displayName:e.data.createDisplayNameGetter("Visual_Background"),type:{fill:{solid:{color:!0}}}},outline:{displayName:e.data.createDisplayNameGetter("Visual_Outline"),type:{formatting:{outline:!0}}},textSize:{displayName:e.data.createDisplayNameGetter("Visual_TextSize"),type:{numeric:!0}},outlineColor:{displayName:"Outline Color",type:{fill:{solid:{color:!0}}}},outlineWeight:{displayName:"Outline Weight",type:{numeric:!0}}}},rows:{displayName:"Chiclets",properties:{fontColor:{displayName:"Text color",type:{fill:{solid:{color:!0}}}},textSize:{displayName:e.data.createDisplayNameGetter("Visual_TextSize"),type:{numeric:!0}},height:{displayName:"Height",type:{numeric:!0}},width:{displayName:"Width",type:{numeric:!0}},selectedColor:{displayName:"Selected Color",type:{fill:{solid:{color:!0}}}},hoverColor:{displayName:"Hover Color",type:{fill:{solid:{color:!0}}}},unselectedColor:{displayName:"Unselected Color",type:{fill:{solid:{color:!0}}}},disabledColor:{displayName:"Disabled Color",type:{fill:{solid:{color:!0}}}},background:{displayName:e.data.createDisplayNameGetter("Visual_Background"),type:{fill:{solid:{color:!0}}}},transparency:{displayName:"Transparency",description:"Set transparency for background color",type:{numeric:!0}},outline:{displayName:e.data.createDisplayNameGetter("Visual_Outline"),type:{formatting:{outline:!0}}},outlineColor:{displayName:"Outline Color",type:{fill:{solid:{color:!0}}}},outlineWeight:{displayName:"Outline Weight",type:{numeric:!0}},borderStyle:{displayName:"Outline Style",type:{enumeration:u.type}}}},images:{displayName:"Images",properties:{imageSplit:{displayName:"Image Split",type:{numeric:!0}},stretchImage:{displayName:"Stretch image",type:{bool:!0}},bottomImage:{displayName:"Bottom image",type:{bool:!0}}}}},dataViewMappings:[{conditions:[{Category:{max:1},Image:{min:0,max:1},Values:{min:0,max:1}}],categorical:{categories:{"for":{"in":"Category"},dataReductionAlgorithm:{top:{count:1e4}}},values:{group:{by:"Image",select:[{bind:{to:"Values"}}],dataReductionAlgorithm:{top:{count:1e4}}}},includeEmptyGroups:!0}}],supportsHighlight:!0,sorting:{"default":{}},suppressDefaultTitle:!0},a.DefaultFontFamily="Segoe UI, Tahoma, Verdana, Geneva, sans-serif",a.DefaultFontSizeInPt=11,a.cellTotalInnerPaddings=8,a.cellTotalInnerBorders=2,a.chicletTotalInnerRightLeftPaddings=14,a.ItemContainer=s("slicerItemContainer"),a.HeaderText=s("headerText"),a.Container=s("chicletSlicer"),a.LabelText=s("slicerText"),a.Header=s("slicerHeader"),a.Input=s("slicerCheckbox"),a.Clear=s("clear"),a.Body=s("slicerBody"),a}();i.ChicletSlicer=d;var g;!function(e){var a=function(){function e(e,a){var r=e.categorical;this.dataViewCategorical=r,this.dataViewMetadata=e.metadata,r.categories&&r.categories.length>0&&(this.category=r.categories[0],this.categoryIdentities=this.category.identity,this.categoryValues=this.category.values,this.categoryColumnRef=this.category.identityFields,this.categoryFormatString=t.valueFormatter.getFormatString(this.category.source,i.chicletSlicerProps.formatString)),this.dataPoints=[],this.interactivityService=a,this.hasSelectionOverride=!1}return e.prototype.convert=function(){if(this.dataPoints=[],this.numberOfCategoriesSelectedInData=0,this.categoryValues){var e,a=this.dataViewMetadata?this.dataViewMetadata.objects:void 0,r=void 0;if(a&&a.general&&a.general.filter){if(!this.categoryColumnRef)return;var s=a.general.filter,o=n.asScopeIdsContainer(s,this.categoryColumnRef);o?(r=o.isNot,e=o.scopeIds?o.scopeIds.length:0):r=!1}this.interactivityService&&(void 0===r?r=this.interactivityService.isSelectionModeInverted():this.interactivityService.setSelectionModeInverted(r));for(var c=void 0,u=0;u<this.categoryValues.length;u++){var h=t.isCategoryColumnSelected(i.chicletSlicerProps.selectedPropertyIdentifier,this.category,u);if(null!=h){c=h;break}}for(var p=this.dataViewCategorical,d=i.chicletSlicerProps.formatString,g=-(1/0),m="",y=0,f=this.categoryValues.length;f>y;y++){var v=t.isCategoryColumnSelected(i.chicletSlicerProps.selectedPropertyIdentifier,this.category,y),x=!0;null!=c&&(r?(null==this.category.objects&&(v=void 0),null!=v?v=c:null==v&&(v=!c)):null==v&&(v=!c)),v&&this.numberOfCategoriesSelectedInData++;var b=this.categoryValues[y],S=t.valueFormatter.format(b,this.categoryFormatString);if(this.dataViewCategorical.values)for(var w=0;w<this.dataViewCategorical.values.length;w++){var C=p.values[w];null!=C.values[y]&&(g=C.values[y],C.highlights&&(x=!(null===C.highlights[y])),C.source.groupName&&""!==C.source.groupName&&(m=t.converterHelper.getFormattedLegendLabel(C.source,p.values,d),/^(ftp|http|https):\/\/[^ "]+$/.test(m)||(m=void 0)))}var P=l.builder().withCategory(this.category,y).createSelectionId();this.dataPoints.push({identity:P,category:S,imageURL:m,value:g,selected:v,selectable:x})}null!=e&&e>this.numberOfCategoriesSelectedInData&&(this.hasSelectionOverride=!0)}},e}();e.ChicletSlicerConverter=a}(g||(g={}));var m;!function(e){function t(e){var t=r(e);return t.y+t.height}function i(){s||(s=$("<span/>"),$("body").append(s),o=d3.select($("body").get(0)).append("svg").style({height:"0px",width:"0px",position:"absolute"}).append("text"),n=$("<canvas/>").get(0).getContext("2d"))}function a(e){return i(),o.style(null),o.text(e.text).attr({visibility:"hidden","font-family":e.fontFamily,"font-size":e.fontSize,"font-weight":e.fontWeight,"font-style":e.fontStyle,"white-space":e.whiteSpace||"nowrap"}),o.node().getBBox()}function r(e){var t={fontFamily:e.fontFamily,fontSize:e.fontSize,text:"M"},i=a(t);return i}var s,o,n;e.estimateSvgTextBaselineDelta=t}(m=i.ChicletSlicerTextMeasurementHelper||(i.ChicletSlicerTextMeasurementHelper={}));var y=function(){function t(){}return t.prototype.bindEvents=function(e,t){var i=this,a=this.slicers=e.slicerItemContainers;this.slicerItemLabels=e.slicerItemLabels,this.slicerItemInputs=e.slicerItemInputs;var r=e.slicerClear;this.dataPoints=e.dataPoints,this.interactivityService=e.interactivityService,this.slicerSettings=e.slicerSettings,this.options=e,this.options.isSelectionLoaded||this.loadSelection(t),a.on("mouseover",function(e){e.selectable&&(e.mouseOver=!0,e.mouseOut=!1,i.renderMouseover())}),a.on("mouseout",function(e){e.selectable&&(e.mouseOver=!1,e.mouseOut=!0,i.renderMouseover())}),a.on("click",function(e,a){if(e.selectable){var r=i.slicerSettings;if(d3.event.preventDefault(),d3.event.altKey&&r.general.multiselect){var s=jQuery.map(i.dataPoints,function(e,t){return e.selected?t:void 0}),o=s.length>0?s[s.length-1]:0;if(o>a){var n=a;a=o,o=n}t.handleClearSelection();for(var l=o;a>=l;l++)t.handleSelection(i.dataPoints[l],!0)}else d3.event.ctrlKey&&r.general.multiselect?t.handleSelection(e,!0):t.handleSelection(e,!1);i.saveSelection(t)}}),r.on("click",function(e){t.handleClearSelection(),i.saveSelection(t)})},t.prototype.loadSelection=function(e){e.handleClearSelection();var t=this.slicerSettings.general.getSavedSelection();if(t.length){var a=this.dataPoints.filter(function(e){return t.some(function(t){return e.identity.getKey()===t})});a.forEach(function(t){return e.handleSelection(t,!0)}),e.persistSelectionFilter(i.chicletSlicerProps.filterPropertyIdentifier)}},t.getFilterFromSelectors=function(t,i){var a=[],r=t.selectedIds;r.length>0&&(a=_.chain(r).filter(function(e){return e.hasIdentity()}).map(function(e){return e.getSelector()}).value());var s=e.data.Selector.filterFromSelector(a,i);return s},t.prototype.saveSelection=function(e){var i=t.getFilterFromSelectors(e,this.interactivityService.isSelectionModeInverted()),a=e.selectedIds.map(function(e){return e.getKey()});this.slicerSettings.general.setSavedSelection(i,a)},t.prototype.renderSelection=function(e){e||this.interactivityService.isSelectionModeInverted()?this.styleSlicerInputs(this.slicers,e):this.slicers.style("background",this.slicerSettings.slicerText.unselectedColor)},t.prototype.renderMouseover=function(){var e=this;this.slicerItemLabels.style({color:function(t){return t.mouseOver?e.slicerSettings.slicerText.hoverColor:t.mouseOut?t.selected?e.slicerSettings.slicerText.fontColor:e.slicerSettings.slicerText.fontColor:void 0}})},t.prototype.styleSlicerInputs=function(e,t){var i=this.slicerSettings,a=[];e.each(function(e){e.selectable&&e.selected&&a.push(e),d3.select(this).style({background:e.selectable?e.selected?i.slicerText.selectedColor:i.slicerText.unselectedColor:i.slicerText.disabledColor}),d3.select(this).classed("slicerItem-disabled",!e.selectable)})},t}();i.ChicletSlicerWebBehavior=y;var f;!function(e){var t;!function(e){function t(e,t){var i=/^#?([a-f\d])([a-f\d])([a-f\d])$/i;e=e.replace(i,function(e,t,i,a){return t+t+i+i+a+a});var a=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e),r=a?{r:parseInt(a[1],16),g:parseInt(a[2],16),b:parseInt(a[3],16)}:null;return null===r?"":t||0===t?"rgba("+r.r+","+r.g+","+r.b+","+t+")":"rgb("+r.r+","+r.g+","+r.b+")"}e.hexToRGBString=t}(t=e.util||(e.util={}))}(f||(f={}))}(i=t.samples||(t.samples={}))}(t=e.visuals||(e.visuals={}))}(i||(i={}))},function(e,t){var i,a=window.jsCommon,i=window.powerbi;window.powerbitests,window.InJs,window.debug,window.jasmine,window.Microsoft;!function(e){var t;!function(t){var i;!function(i){var r=a.PixelConverter,s=function(){function e(e,t){this.defaultViewport=e||{width:0,height:0},this.defaultMargin=t||{top:0,bottom:0,right:0,left:0}}return Object.defineProperty(e.prototype,"margin",{get:function(){return this.marginValue||(this.margin=this.defaultMargin)},set:function(t){this.marginValue=e.restrictToMinMax(t),this.update()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"viewport",{get:function(){return this.viewportValue||(this.viewportValue=this.defaultViewport)},set:function(t){this.viewportValue=e.restrictToMinMax(t,this.minViewport),this.update()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"viewportIn",{get:function(){return this.viewportInValue||this.viewport},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"minViewport",{get:function(){return this.minViewportValue},set:function(e){this.minViewportValue=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"viewportInIsZero",{get:function(){return 0===this.viewportIn.width||0===this.viewportIn.height},enumerable:!0,configurable:!0}),e.prototype.resetMargin=function(){this.margin=this.defaultMargin},e.prototype.update=function(){this.viewportInValue=e.restrictToMinMax({width:this.viewport.width-(this.margin.left+this.margin.right),height:this.viewport.height-(this.margin.top+this.margin.bottom)},this.minViewportValue)},e.restrictToMinMax=function(e,t){var i=$.extend({},e);return _.keys(e).forEach(function(a){return i[a]=Math.max(t&&t[a]||0,e[a])}),i},e}(),o=function(){function e(){}return e.interpolateArc=function(e){return function(t){if(!this.oldData)return this.oldData=t,function(){return e(t)};var i=d3.interpolate(this.oldData,t);return this.oldData=i(0),function(t){return e(i(t))}}},e.addContext=function(e,t){return function(){return t.apply(e,[this].concat(_.toArray(arguments)))}},e}(),n=function(){function i(){this.dataPoint={defaultColor:null,showAllDataPoints:!1},this.axis={show:!0},this.labels={show:!0,color:t.dataLabelUtils.defaultLabelColor,fontSize:t.dataLabelUtils.DefaultFontSizeInPt}}return Object.defineProperty(i,"Default",{get:function(){return new this},enumerable:!0,configurable:!0}),i.parse=function(e,t){var i=new this;if(!e||!e.metadata||!e.metadata.objects)return i;var a=this.getProperties(t);for(var r in t.objects)for(var s in t.objects[r].properties)if(i[r]&&_.has(i[r],s)){var o=t.objects[r].properties[s].type,n=this.getValueFnByType(o);i[r][s]=n(e.metadata.objects,a[r][s],i[r][s])}return i},i.getProperties=function(e){var t=_.merge({general:{properties:{formatString:{}}}},e.objects),i={};for(var a in t){i[a]={};for(var r in t[a].properties)i[a][r]={objectName:a,propertyName:r}}return i;
8},i.createEnumTypeFromEnum=function(t){var i=!1;return e.createEnumType(Object.keys(t).filter(function(e,a){return!!(a%2)===i&&t[e]===e&&!void(i=!i)||!!(a%2)!==i}).map(function(e){return{value:e,displayName:e}}))},i.getValueFnByType=function(t){switch(_.keys(t)[0]){case"fill":return e.DataViewObjects.getFillColor;default:return e.DataViewObjects.getValue}},i.enumerateObjectInstances=function(e,i,a){var r=new t.ObjectEnumerationBuilder,s=e&&e[i.objectName];if(!s)return r;var o={objectName:i.objectName,selector:null,properties:{}};for(var n in s)_.has(s,n)&&(o.properties[n]=s[n]);return r.pushInstance(o),r},i}();i.ChordChartSettings=n;var l=function(){function e(){this.Category=null,this.Series=null,this.Y=null}return e.getColumnSources=function(e){return this.getColumnSourcesT(e)},e.getTableValues=function(e){var t=e&&e.table,i=this.getColumnSourcesT(e);return i&&t&&_.mapValues(i,function(e,i){return e&&t.rows.map(function(t){return t[e.index]})})},e.getTableRows=function(e){var t=e&&e.table,i=this.getColumnSourcesT(e);return i&&t&&t.rows.map(function(e){return _.mapValues(i,function(t,i){return t&&e[t.index]})})},e.getCategoricalValues=function(e){var t=e&&e.categorical,i=t&&t.categories||[],a=t&&t.values||[],r=t&&a.source&&this.getSeriesValues(e);return t&&_.mapValues(new this,function(e,t){return _.toArray(i).concat(_.toArray(a)).filter(function(e){return e.source.roles&&e.source.roles[t]}).map(function(e){return e.values})[0]||a.source&&a.source.roles&&a.source.roles[t]&&r})},e.getSeriesValues=function(e){return e&&e.categorical&&e.categorical.values&&e.categorical.values.map(function(e){return t.converterHelper.getSeriesName(e.source)})},e.getCategoricalColumns=function(e){var t=e&&e.categorical,i=t&&t.categories||[],a=t&&t.values||[];return t&&_.mapValues(new this,function(e,t){return i.filter(function(e){return e.source.roles&&e.source.roles[t]})[0]||a.source&&a.source.roles&&a.source.roles[t]||a.filter(function(e){return e.source.roles&&e.source.roles[t]})})},e.getColumnSourcesT=function(e){var t=e&&e.metadata&&e.metadata.columns;return t&&_.mapValues(new this,function(e,i){return t.filter(function(e){return e.roles&&e.roles[i]})[0]})},e.Roles=Object.freeze(_.mapValues(new e,function(e,t){return t})),e}();i.ChordChartColumns=l;var c=function(){function i(){}return Object.defineProperty(i.prototype,"settings",{get:function(){return this.data&&this.data.settings},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"innerRadius",{get:function(){return this.radius*i.InnerArcRadiusRatio},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"outerRadius",{get:function(){return this.radius*i.OuterArcRadiusRatio},enumerable:!0,configurable:!0}),i.converter=function(e,a,s){var o=n.getProperties(i.capabilities),c=i.parseSettings(e),u=l.getCategoricalColumns(e),h=l.getColumnSources(e),p=l.getCategoricalValues(e);if(!p||_.isEmpty(p.Category)||_.isEmpty(p.Y))return null;p.Series=p.Series||l.getSeriesValues(e);var d=[],g={dataPoints:[],title:h.Y.displayName||""},m=[],y=[],f=1e3,v=_.mapValues(_.invert(p.Series),parseFloat),x=_.mapValues(_.invert(p.Category),parseFloat),b=!1,S=[],w=new t.ColorHelper(a,o.dataPoint.fill,c.dataPoint.defaultColor),C=this.union_arrays(p.Category,p.Series).reverse();i.getValidArrayLength(C)===i.getValidArrayLength(p.Category)+i.getValidArrayLength(p.Series)&&(b=!0);for(var P=t.valueFormatter.create({format:t.valueFormatter.getFormatString(h.Category,o.general.formatString,!0)||h.Category.format}),D=t.valueFormatter.create({format:t.valueFormatter.getFormatString(h.Y,o.general.formatString,!0)||h.Y.format}),A=0,T=C.length;T>A;A++){var V=null,N="",L=!1;if(void 0!==x[C[A]]){var M=x[C[A]];V=t.SelectionIdBuilder.builder().withCategory(u.Category,x[C[A]]).createSelectionId(),L=!0;var k=u.Category.objects?u.Category.objects[M]:void 0;N=w.getColorForSeriesValue(k,void 0,p.Category[M])}else if(void 0!==v[C[A]]){var M=v[C[A]],O=u.Y[M],I=O&&O.objects&&O.objects[0],j=t.converterHelper.getSeriesName(O.source);V=t.SelectionId.createWithId(O.identity),L=!1,N=w.getColorForSeriesValue(I,void 0,j)}S.push({label:C[A],labelColor:c.labels.color,barColor:N,isCategory:L,identity:V,selected:!1,labelFontSize:r.fromPointToPixel(c.labels.fontSize)}),d.push([]),m.push([]);for(var F=0,z=C.length;z>F;F++){var G=0,R=[];if(void 0!==x[C[A]]&&void 0!==v[C[F]]){var H=x[C[A]],B=v[C[F]];null!==u.Y[B].values[H]&&(G=u.Y[B].values[H],G>f&&(f=G),R=t.TooltipBuilder.createTooltipInfo(o.general.formatString,e.categorical,P.format(p.Category[A]),D.format(G),null,null,B,H))}else if(b&&void 0!==x[C[F]]&&void 0!==v[C[A]]){var H=x[C[F]],B=v[C[A]];null!==u.Y[B].values[H]&&(G=u.Y[B].values[H])}d[A].push(G||0),m[A].push({tooltipInfo:R})}var U=d3.sum(d[A]);y.push({tooltipInfo:[{displayName:C[A],value:D.format(U)}]})}var E=d3.layout.chord().padding(.1).matrix(d),W=Math.round(f/5).toString().length-1;return{dataMatrix:d,dataView:e,settings:c,labelDataPoints:i.getChordArcDescriptors(E.groups(),S),legendData:g,tooltipData:m,sliceTooltipData:y,tickUnit:Math.pow(10,W),differentFromTo:b,prevAxisVisible:void 0===s?c.axis.show:s}},i.parseSettings=function(e){return n.parse(e,i.capabilities)},i.getValidArrayLength=function(e){for(var t=0,i=0,a=e.length;a>i;i++)void 0!==e[i]&&t++;return t},i.getChordArcDescriptors=function(e,t){var i=e;return i.forEach(function(e,i){return e.data=t[i]}),i},i.prototype.init=function(e){var a=this.element=e.element;this.selectionManager=new t.utility.SelectionManager({hostServices:e.host}),this.layout=new s(e.viewport,i.DefaultMargin),this.layout.minViewport={width:150,height:150},this.svg=d3.select(a.get(0)).append("svg").style("position","absolute").classed(i.VisualClassName,!0),this.mainGraphicsContext=this.svg.append("g"),this.mainGraphicsContext.append("g").classed("chords",!0),this.slices=this.mainGraphicsContext.append("g").classed("slices",!0),this.mainGraphicsContext.append("g").classed("ticks",!0),this.labels=this.mainGraphicsContext.append("g").classed(i.labelGraphicsContextClass["class"],!0),this.lines=this.mainGraphicsContext.append("g").classed(i.linesGraphicsContextClass["class"],!0),this.colors=e.style.colorPalette.dataColors},i.prototype.update=function(e){if(e.dataViews&&e.dataViews[0]){if(this.layout.viewport=e.viewport,this.duration=e.suppressAnimations?0:t.AnimatorCommon.MinervaAnimationDuration,this.data=i.converter(e.dataViews[0],this.colors,this.settings&&this.settings.axis.show),!this.data)return void this.clear();this.layout.resetMargin(),this.layout.margin.top=this.layout.margin.bottom=r.fromPointToPixel(this.settings.labels.fontSize)/2,this.render()}},i.prototype.enumerateObjectInstances=function(e){var a=n.enumerateObjectInstances(this.settings,e,i.capabilities);if(this.settings&&"dataPoint"===e.objectName&&!_.isEmpty(this.data.labelDataPoints)&&this.settings.dataPoint.showAllDataPoints)for(var r=0,s=this.data.labelDataPoints.length;s>r;r++){var o=this.data.labelDataPoints[r].data;if(o.isCategory){var l={objectName:"dataPoint",displayName:o.label,selector:t.ColorHelper.normalizeSelector(o.identity.getSelector()),properties:{fill:{solid:{color:o.barColor}}}};a.pushInstance(l)}}return a.complete()},i.prototype.calculateRadius=function(){if(this.settings.labels.show){var e=this.layout.viewportIn.height/this.layout.viewportIn.width,t=2+1/(1+Math.exp(-5*(e-1)));return Math.min(this.layout.viewportIn.height,this.layout.viewportIn.width)/t}return Math.min(this.layout.viewportIn.height,this.layout.viewportIn.width)/2},i.prototype.drawCategoryLabels=function(){var e=d3.svg.arc().innerRadius(0).outerRadius(this.innerRadius),i=d3.svg.arc().innerRadius(this.outerRadius).outerRadius(this.outerRadius);if(this.settings.labels.show){var a=this.getChordChartLabelLayout(i),r=this.getDataLabelManager().hideCollidedLabels(this.layout.viewportIn,this.data.labelDataPoints,a,!0);this.renderLabels(r,a,!0),this.renderLines(r,e,i)}else t.dataLabelUtils.cleanDataLabels(this.labels),t.dataLabelUtils.cleanDataLabels(this.lines,!0)},i.prototype.getDataLabelManager=function(){function i(i,a,r,s){if(i.hasConflict(r))return!0;var o={left:0,top:r.height/2,width:s.width,height:s.height};return o=t.shapes.Rect.inflate(o,{left:e.DataLabelManager.InflateAmount,top:0,right:e.DataLabelManager.InflateAmount,bottom:0}),o=t.shapes.Rect.intersect(o,r),t.shapes.Rect.isEmpty(o)?!0:e.Double.lessWithPrecision(o.height,r.height/2)}var a=new e.DataLabelManager;return a.hasCollisions=i.bind(a),a},i.prototype.render=function(){var e=this;this.chordLayout=d3.layout.chord().padding(.1).matrix(this.data.dataMatrix),this.radius=this.calculateRadius();var a=d3.svg.arc().innerRadius(this.radius).outerRadius(this.innerRadius);this.svg.attr({width:this.layout.viewport.width,height:this.layout.viewport.height}),this.mainGraphicsContext.attr("transform",t.SVGUtil.translate(this.layout.viewport.width/2,this.layout.viewport.height/2));var r=this.slices.selectAll("path"+i.sliceClass.selector).data(this.getChordTicksArcDescriptors());r.enter().insert("path").classed(i.sliceClass["class"],!0),r.style("fill",function(t,i){return e.data.labelDataPoints[i].data.barColor}).style("stroke",function(t,i){return e.data.labelDataPoints[i].data.barColor}).on("click",o.addContext(this,function(t,i,a){e.selectionManager.select(e.data.labelDataPoints[a].data.identity).then(function(i){i.length>0?(e.mainGraphicsContext.selectAll(".chords path.chord").style("opacity",1),e.slices.selectAll("path.slice").style("opacity",.3),e.mainGraphicsContext.selectAll(".chords path.chord").filter(function(e){return e.source.index!==a&&e.target.index!==a}).style("opacity",.3),d3.select(t).style("opacity",1)):(r.style("opacity",1),e.mainGraphicsContext.selectAll(".chords path.chord").filter(function(e){return e.source.index!==a&&e.target.index!==a}).style("opacity",1))}),d3.event.stopPropagation()})).transition().duration(this.duration).attrTween("d",o.interpolateArc(a)),r.exit().remove(),t.TooltipManager.addTooltip(r,function(t){return e.data.sliceTooltipData[t.data.index].tooltipInfo});var s=this.svg.select(".chords").selectAll("path"+i.chordClass.selector).data(this.chordLayout.chords);s.enter().insert("path").classed(i.chordClass["class"],!0),s.style("fill",function(t,i){return e.data.labelDataPoints[t.target.index].data.barColor}).style("opacity",1).transition().duration(this.duration).attr("d",d3.svg.chord().radius(this.radius)),s.exit().remove(),this.svg.on("click",function(){return e.selectionManager.clear().then(function(){r.style("opacity",1),s.style("opacity",1)})}),this.drawTicks(),this.drawCategoryLabels(),t.TooltipManager.addTooltip(s,function(t){var i=[];return e.data.differentFromTo?i=e.data.tooltipData[t.data.source.index][t.data.source.subindex].tooltipInfo:(i.push({displayName:e.data.labelDataPoints[t.data.source.index].data.label+"->"+e.data.labelDataPoints[t.data.source.subindex].data.label,value:e.data.dataMatrix[t.data.source.index][t.data.source.subindex].toString()}),i.push({displayName:e.data.labelDataPoints[t.data.target.index].data.label+"->"+e.data.labelDataPoints[t.data.target.subindex].data.label,value:e.data.dataMatrix[t.data.target.index][t.data.target.subindex].toString()})),i})},i.prototype.clear=function(){this.mainGraphicsContext.selectAll(i.sliceClass.selector).remove(),this.mainGraphicsContext.selectAll(i.sliceTicksClass.selector).remove(),this.mainGraphicsContext.selectAll(i.chordClass.selector).remove(),this.mainGraphicsContext.selectAll(i.labelsClass.selector).remove(),this.mainGraphicsContext.selectAll(i.lineClass.selector).remove()},i.prototype.clearTicks=function(){var e=[],t=this.mainGraphicsContext.selectAll(i.tickLineClass.selector).data(e);t.exit().remove();var a=this.mainGraphicsContext.selectAll(i.tickTextClass.selector).data(e);a.exit().remove(),this.mainGraphicsContext.selectAll(i.tickPairClass.selector).remove(),this.mainGraphicsContext.selectAll(i.sliceTicksClass.selector).remove()},i.prototype.getChordTicksArcDescriptors=function(){var e=this.chordLayout.groups(),a=!_.isEmpty(e)&&_.max(e,function(e){return e.value}).value||0,r=!_.isEmpty(e)&&_.min(e,function(e){return e.value}).value||0,s=this.radius/Math.abs(a-r)*1.25,o=t.valueFormatter.create({format:"0.##",value:a});return e.forEach(function(e){var t=(e.endAngle-e.startAngle)/e.value,a=Math.abs(e.value),r=d3.range(0,a,.15>a-1?.15:a-1);e.value<0&&(r=r.map(function(e){return-1*e}).reverse());for(var n=1;n<r.length;n++){var l=Math.abs(r[n]-r[n-1])*s;l<i.TicksFontSize&&(r.length>2&&n===r.length-1?r.splice(--n,1):r.splice(n--,1))}e.angleLabels=r.map(function(i,a){return{angle:i*t+e.startAngle,label:o.format(i)}})}),e},i.prototype.drawTicks=function(){var e=this;if(this.settings.axis.show){var t=this.mainGraphicsContext.select(".ticks").selectAll("g"+i.sliceTicksClass.selector).data(this.chordLayout.groups),a=this.data.prevAxisVisible===this.settings.axis.show?this.duration:0;t.enter().insert("g").classed(i.sliceTicksClass["class"],!0);var r=t.selectAll("g"+i.tickPairClass.selector).data(function(e){return e.angleLabels});r.enter().insert("g").classed(i.tickPairClass["class"],!0),r.transition().duration(a).attr("transform",function(t){return"rotate("+(180*t.angle/Math.PI-90)+")translate("+e.innerRadius+",0)"}),r.selectAll("line"+i.tickLineClass.selector).data(function(e){return[e]}).enter().insert("line").classed(i.tickLineClass["class"],!0).style("stroke","#000").attr("x1",1).attr("y1",0).attr("x2",5).attr("y2",0),r.selectAll("text"+i.tickTextClass.selector).data(function(e){return[e]}).enter().insert("text").classed(i.tickTextClass["class"],!0).style("pointer-events","none").attr("x",8).attr("dy",".35em"),r.selectAll("text"+i.tickTextClass.selector).text(function(e){return e.label}).style("text-anchor",function(e){return e.angle>Math.PI?"end":null}).attr("transform",function(e){return e.angle>Math.PI?"rotate(180)translate(-16)":null}),r.exit().remove(),t.exit().remove()}else this.clearTicks()},i.prototype.renderLabels=function(e,a,r,s){if(void 0===r&&(r=!1),void 0===s&&(s=!1),0===e.length)return t.dataLabelUtils.cleanDataLabels(this.labels,!0),null;var o=null!==e[0].key,n=null!==e[0].identity,l=o?function(e){return e.key}:n?function(e){return e.identity.getKey()}:void 0,c=r?this.labels.selectAll(i.labelsClass.selector).data(e,function(e){return e.data.identity.getKey()}):null!==l?this.labels.selectAll(i.labelsClass.selector).data(e,l):this.labels.selectAll(i.labelsClass.selector).data(e),u=c.enter().append("text").classed(i.labelsClass["class"],!0);s&&u.style("opacity",0),c.attr({x:function(e){return e.labelX},y:function(e){return e.labelY},dy:".35em"}).text(function(e){return e.labeltext}).style(a.style),c.exit().remove()},i.prototype.renderLines=function(e,t,a){var r=this,s=this.lines.selectAll("polyline").data(e,function(e){return e.data.identity.getKey()}),o=2.05,n=function(e){return e.startAngle+(e.endAngle-e.startAngle)/2};s.enter().append("polyline").classed(i.lineClass["class"],!0),s.attr("points",function(e){var s=a.centroid(e);s[0]=(r.radius+i.LabelMargin/2)*(n(e)<Math.PI?1:-1);var l=a.centroid(e),c=t.centroid(e);return c[0]*=o,c[1]*=o,[c,l,s]}).style({opacity:function(e){return i.PolylineOpacity},stroke:function(e){return e.data.labelColor},"pointer-events":"none"}),s.exit().remove()},i.prototype.getChordChartLabelLayout=function(e){var a=this,s=function(e){return e.startAngle+(e.endAngle-e.startAngle)/2},o=(this.layout.viewportIn.width-2*this.radius-2*i.LabelMargin)/1.6;return{labelText:function(e){return t.dataLabelUtils.getLabelFormattedText({label:e.data.label,maxWidth:o,fontSize:r.fromPointToPixel(a.settings.labels.fontSize)})},labelLayout:{x:function(e){return(a.radius+i.LabelMargin)*(s(e)<Math.PI?1:-1)},y:function(t){var i=e.centroid(t);return i[1]}},filter:function(e){return null!==e&&null!==e.data&&null!==e.data.label},style:{fill:function(e){return e.data.labelColor},"text-anchor":function(e){return s(e)<Math.PI?"start":"end"},"font-size":function(e){return r.fromPoint(a.settings.labels.fontSize)}}}},i.union_arrays=function(e,t){for(var i={},a=0;a<e.length;a++)i[e[a]]=e[a];for(var a=0;a<t.length;a++)i[t[a]]=t[a];var r=[];for(var s in i)i.hasOwnProperty(s)&&r.push(i[s]);return r},i.capabilities={dataRoles:[{name:l.Roles.Category,kind:e.VisualDataRoleKind.Grouping,displayName:"From"},{name:l.Roles.Series,kind:e.VisualDataRoleKind.Grouping,displayName:"To"},{name:l.Roles.Y,kind:e.VisualDataRoleKind.Measure,displayName:"Values"}],dataViewMappings:[{conditions:[{Category:{max:1},Series:{max:0}},{Category:{max:1},Series:{min:1,max:1},Y:{max:1}},{Category:{max:1},Series:{max:0},Y:{min:0,max:1}}],categorical:{categories:{"for":{"in":"Category"},dataReductionAlgorithm:{top:{}}},values:{group:{by:"Series",select:[{bind:{to:"Y"}}],dataReductionAlgorithm:{top:{}}}},rowCount:{preferred:{min:2},supported:{min:1}}}}],objects:{dataPoint:{displayName:e.data.createDisplayNameGetter("Visual_DataPoint"),properties:{defaultColor:{displayName:e.data.createDisplayNameGetter("Visual_DefaultColor"),type:{fill:{solid:{color:!0}}}},showAllDataPoints:{displayName:e.data.createDisplayNameGetter("Visual_DataPoint_Show_All"),type:{bool:!0}},fill:{displayName:e.data.createDisplayNameGetter("Visual_Fill"),type:{fill:{solid:{color:!0}}}}}},axis:{displayName:"Axis",properties:{show:{type:{bool:!0}}}},labels:{displayName:"Labels",properties:{show:{type:{bool:!0}},color:{displayName:e.data.createDisplayNameGetter("Visual_Reference_Line_Data_Label_Color"),description:e.data.createDisplayNameGetter("Visual_Reference_Line_Data_Label_Color_Description"),type:{fill:{solid:{color:!0}}}},fontSize:{displayName:e.data.createDisplayNameGetter("Visual_TextSize"),type:{formatting:{fontSize:!0}}}}}}},i.PolylineOpacity=.5,i.OuterArcRadiusRatio=.9,i.InnerArcRadiusRatio=.8,i.LabelMargin=10,i.DefaultMargin={left:10,right:10,top:10,bottom:10},i.VisualClassName="chordChart",i.TicksFontSize=12,i.sliceClass={"class":"slice",selector:".slice"},i.chordClass={"class":"chord",selector:".chord"},i.sliceTicksClass={"class":"slice-ticks",selector:".slice-ticks"},i.tickPairClass={"class":"tick-pair",selector:".tick-pair"},i.tickLineClass={"class":"tick-line",selector:".tick-line"},i.tickTextClass={"class":"tick-text",selector:".tick-text"},i.labelGraphicsContextClass={"class":"labels",selector:".labels"},i.labelsClass={"class":"data-labels",selector:".data-labels"},i.linesGraphicsContextClass={"class":"lines",selector:".lines"},i.lineClass={"class":"line-label",selector:".line-label"},i}();i.ChordChart=c}(i=t.samples||(t.samples={}))}(t=e.visuals||(e.visuals={}))}(i||(i={}))},function(e,t){var i,a=window.jsCommon,i=window.powerbi;window.powerbitests,window.InJs,window.debug,window.jasmine,window.Microsoft;!function(e){var t;!function(t){var i;!function(t){var i=a.PixelConverter,r=a.CssConstants.createClassAndSelector,s=e.data.DataRoleHelper.getCategoryIndexOfRole,o=e.data.DataRoleHelper.getMeasureIndexOfRole,n=e.visuals.InteractivityUtils.registerStandardInteractivityHandlers,l=e.data.createDisplayNameGetter,c=a.Lazy,u=e.TextMeasurementService.measureSvgTextWidth,h=e.TextMeasurementService.measureSvgTextHeight,p=e.TextMeasurementService.estimateSvgTextHeight,d=e.TextMeasurementService.svgEllipsis,g=e.visuals.TooltipManager.addTooltip,m=a.PixelConverter.fromPoint,y=e.visuals.dataLabelUtils.LabelTextProperties,f=e.visuals.dataLabelUtils.getLabelFormattedText,v=e.Double.equalWithPrecision,x=e.visuals.AnimatorCommon.GetAnimationDuration,b=e.TextMeasurementService.getTailoredTextOrDefault,S=e.visuals.LegendData,w=e.visuals.SelectionId,C=e.DataViewObject,P=e.VisualDataRoleKind,D=e.visuals.legendPosition,A=e.visuals.BaseAnimator,T=e.visuals.yAxisPosition,V=e.visuals.appendClearCatcher,N=e.visuals.createInteractivityService,L=e.visuals.createLegend,M=e.visuals.AxisHelper,k=e.DataViewObjects,O=e.visuals.valueFormatter,I=e.visuals.dataLabelUtils,j=e.visuals.ColorHelper,F=e.visuals.LegendIcon,z=e.visuals.SelectionIdBuilder,G=e.visuals.TooltipBuilder,R=e.visuals.getInvalidValueWarnings,H=e.visuals.legendProps,B=e.visuals.LegendPosition,U=e.visuals.Legend,E=e.visuals.SVGUtil,W=e.visuals.ObjectEnumerationBuilder,Y=e.visuals.GradientUtils,X=e.visuals.axisType,q=e.visuals.axisScale,K=e.visuals.axisStyle,Z=function(){function e(){this.ScrollBarWidth=10}return Object.defineProperty(e.prototype,"margin",{get:function(){return this._margin||{left:0,right:0,top:0,bottom:0}},set:function(t){this._margin=$.extend({},t),this._viewportIn=e.substractMargin(this.viewport,this.margin)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"viewport",{get:function(){return this._viewport||{width:0,height:0}},set:function(t){this._viewport=$.extend({},t),this._viewportIn=e.substractMargin(this.viewport,this.margin)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"viewportIn",{get:function(){return this._viewportIn||this.viewport},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"legendViewport",{get:function(){return this.legend.getMargins()},enumerable:!0,configurable:!0}),e.getPropertiesByCapabilities=function(e){var t={};if(!e)return t;for(var i in e.objects){var a=e.objects[i];if(t[i]={},a)for(var r in a.properties)t[i][r]={objectName:i,propertyName:r}}return t},e.substractMargin=function(e,t){return{width:Math.max(e.width-(t.left+t.right),0),height:Math.max(e.height-(t.top+t.bottom),0)}},e.getCustomSymbolType=function(e){var t=d3.map({circle:function(e){var t=Math.sqrt(e/Math.PI);return"M0,"+t+"A"+t+","+t+" 0 1,1 0,"+-t+"A"+t+","+t+" 0 1,1 0,"+t+"Z"},cross:function(e){var t=Math.sqrt(e/5)/2;return"M"+-3*t+","+-t+"H"+-t+"V"+-3*t+"H"+t+"V"+-t+"H"+3*t+"V"+t+"H"+t+"V"+3*t+"H"+-t+"V"+t+"H"+-3*t+"Z"},diamond:function(e){var t=Math.sqrt(e/(2*Math.tan(Math.PI/6))),i=t*Math.tan(Math.PI/6);return"M0,"+-t+"L"+i+",0 0,"+t+" "+-i+",0Z"},square:function(e){var t=Math.sqrt(e)/2;return"M"+-t+","+-t+"L"+t+","+-t+" "+t+","+t+" "+-t+","+t+"Z"},"triangle-up":function(e){var t=Math.sqrt(e/Math.sqrt(3)),i=t*Math.sqrt(3)/2;return"M0,"+-i+"L"+t+","+i+" "+-t+","+i+"Z"},"triangle-down":function(e){var t=Math.sqrt(e/Math.sqrt(3)),i=t*Math.sqrt(3)/2;return"M0,"+i+"L"+t+","+-i+" "+-t+","+-i+"Z"},star:function(e){for(var t=Math.sqrt(e/2),i=Math.sqrt(e/10),a="",r=Math.PI/5,s=0;10>s;s++){var o=0===(1&s)?t:i,n=Math.cos(s*r)*o,l=Math.sin(s*r)*o;0===s?a="M"+n+","+l+"L":a+=" "+n+","+l}return a+"Z"},hexagon:function(e){var t=Math.sqrt(e/(6*Math.sqrt(3))),i=Math.sqrt(e/(2*Math.sqrt(3)));return"M0,"+2*t+"L"+-i+","+t+" "+-i+","+-t+" 0,"+-2*t+" "+i+","+-t+" "+i+","+t+"Z"},x:function(e){var t=Math.sqrt(e/10);return"M0,"+t+"L"+-t+","+2*t+" "+-2*t+","+t+" "+-t+",0 "+-2*t+","+-t+" "+-t+","+-2*t+" 0,"+-t+" "+t+","+-2*t+" "+2*t+","+-t+" "+t+",0 "+2*t+","+t+" "+t+","+2*t+"Z"},uparrow:function(e){var t=Math.sqrt(e/12);return"M"+t+","+3*t+"L"+-t+","+3*t+" "+-t+","+-t+" "+-2*t+","+-t+" 0,"+-3*t+" "+2*t+","+-t+" "+t+","+-t+"Z"},downarrow:function(e){var t=Math.sqrt(e/12);return"M0,"+3*t+"L"+-2*t+","+t+" "+-t+","+t+" "+-t+","+-3*t+" "+t+","+-3*t+" "+t+","+t+" "+2*t+","+t+"Z"}}),i=t.entries()[0].value;if(e){if(isNaN(e))return t[e&&e.toString().toLowerCase()]||i;var a=t.entries()[Math.floor(e)];return a?a.value:i}return i},e.prototype.init=function(t){this.options=t,this.animator=new A,this.behavior=new J([new Q(e.DimmedBubbleOpacity,e.DefaultBubbleOpacity)]);var i=this.element=t.element;this.viewport=_.clone(t.viewport),this.style=t.style,this.hostServices=t.host,this.colors=this.style.colorPalette.dataColors,this.interactivity=t.interactivity,this.margin={top:1,right:1,bottom:1,left:1},this.yAxisOrientation=T.left,this.adjustMargins();var a=this.scrollY=!0,r=this.scrollX=!0,s=this.svg=d3.select(i.get(0)).append("svg").style("position","absolute").classed(e.ClassName,!0),o=this.axisGraphicsContext=s.append("g").classed(e.AxisGraphicsContextClassName,!0);this.svgScrollable=s.append("svg").classed("svgScrollable",!0).style("overflow","hidden");var n=this.axisGraphicsContextScrollable=this.svgScrollable.append("g").classed(e.AxisGraphicsContextClassName,!0);this.clearCatcher=V(this.axisGraphicsContextScrollable);var l=a?n:o;this.backgroundGraphicsContext=o.append("svg:image"),this.xAxisGraphicsContext=a?o.append("g").attr("class","x axis"):n.append("g").attr("class","x axis"),this.y1AxisGraphicsContext=l.append("g").attr("class","y axis"),this.xAxisGraphicsContext.classed("showLinesOnAxis",a),this.y1AxisGraphicsContext.classed("showLinesOnAxis",r),this.xAxisGraphicsContext.classed("hideLinesOnAxis",!a),this.y1AxisGraphicsContext.classed("hideLinesOnAxis",!r),this.interactivityService=N(this.hostServices),this.legend=L(i,this.interactivity&&this.interactivity.isInteractiveLegend,this.interactivityService,!0),this.mainGraphicsG=this.axisGraphicsContextScrollable.append("g").classed(e.MainGraphicsContextClassName,!0),this.mainGraphicsSVGSelection=this.mainGraphicsG.append("svg"),this.mainGraphicsContext=this.mainGraphicsSVGSelection.append("g"),this.svgDefaultImage="",this.keyArray=[]},e.prototype.adjustMargins=function(){var e=this.element.find(".x.axis");0===M.getRecommendedNumberOfTicksForXAxis(this.viewportIn.width)&&0===M.getRecommendedNumberOfTicksForYAxis(this.viewportIn.height)?(this.margin={top:0,right:0,bottom:0,left:0},e.hide()):e.show()},e.prototype.getValueAxisProperties=function(e,t){var i={};if(!e)return i;var a=e.objects;if(a){var r=a.valueAxis;r&&(i={show:r.show,position:r.position,axisScale:r.axisScale,start:r.start,end:r.end,showAxisTitle:null==r.showAxisTitle?t:r.showAxisTitle,axisStyle:r.axisStyle,axisColor:r.axisColor,secShow:r.secShow,secPosition:r.secPosition,secAxisScale:r.secAxisScale,secStart:r.secStart,secEnd:r.secEnd,secShowAxisTitle:r.secShowAxisTitle,secAxisStyle:r.secAxisStyle,labelDisplayUnits:r.labelDisplayUnits})}return i},e.prototype.getCategoryAxisProperties=function(e,t){var i={};if(!e)return i;var a=e.objects;if(a){var r=a.categoryAxis;r&&(i={show:r.show,axisType:r.axisType,axisScale:r.axisScale,axisColor:r.axisColor,start:r.start,end:r.end,showAxisTitle:null==r.showAxisTitle?t:r.showAxisTitle,axisStyle:r.axisStyle,labelDisplayUnits:r.labelDisplayUnits})}return i},e.converter=function(t,i,a,r,s){if(!t)return e.getDefaultData();var o,n,l,c,u,h=t.categorical,p=t.metadata,d=h.categories||[],g=h.values,m=!!g.source,y=g.grouped(),f=g.source,v=e.getMetadata(d,y,f),x=v.idx.category,b=v.idx.image>=0,S=v.idx.colorFill>=0;if(h.categories&&h.categories.length>0&&h.categories[x]){var w=h.categories[x];o=w.values,n=O.create({format:O.getFormatString(w.source,e.Properties.general.formatString),value:o[0],value2:o[o.length-1]}),c=w.identity,l=w.objects,u=w.source?w.source.queryName:null}else o=[null],n=O.createDefaultFormatter(null);var C=I.getDefaultPointLabelSettings(),P=!1,D={show:!1,url:""},A=!1,T=!1,V="",N=!0;if(p&&p.objects){var L=p.objects;V=k.getFillColor(L,e.Properties.dataPoint.defaultColor),N=k.getValue(L,e.Properties.dataPoint.showAllDataPoints);var M=L.categoryLabels;M&&(C.show=void 0!==M.show?M.show:C.show,C.fontSize=void 0!==M.fontSize?M.fontSize:C.fontSize,void 0!==M.color&&(C.labelColor=M.color.solid.color)),P=k.getValue(L,e.Properties.fillPoint.show,P);var j=L.backdrop;void 0!==j&&(D.show=j.show,D.show&&(D.url=j.url));var F=L.crosshair;void 0!==F&&(A=F.show);var z=L.outline;void 0!==z&&(T=z.show)}var G=e.createDataPoints(g,v,d,o,n,c,l,i,m,C,V,u);a&&a.applySelectionStateToData(G);var R=[];if(m){var H=O.getFormatString(f,e.Properties.general.formatString);R=e.createSeriesLegend(g,i,g,H,V)}var B=g&&f?f.displayName:"";B||(B=d&&d[x]&&d[x].source&&d[x].source.displayName?d[x].source.displayName:"");var U={title:B,dataPoints:R},E=e.getSizeRangeForGroups(y,v.idx.size);if(r&&null!==r.showAxisTitle&&r.showAxisTitle===!1&&(v.axesLabels.x=null),s&&null!==s.showAxisTitle&&s.showAxisTitle===!1&&(v.axesLabels.y=null),G&&G[0]){var W=G[0];null!=W.backdrop&&(D.show=!0,D.url=W.backdrop),null!=W.xStart&&(r.start=W.xStart),null!=W.xEnd&&(r.end=W.xEnd),null!=W.yStart&&(s.start=W.yStart),null!=W.yEnd&&(s.end=W.yEnd)}return{xCol:v.cols.x,yCol:v.cols.y,dataPoints:G,legendData:U,axesLabels:v.axesLabels,selectedIds:[],size:v.cols.size,sizeRange:E,dataLabelsSettings:C,defaultDataPointColor:V,hasDynamicSeries:m,showAllDataPoints:N,fillPoint:P,useShape:b,useCustomColor:S,backdrop:D,crosshair:A,outline:T}},e.createSeriesLegend=function(t,i,a,r,s){for(var o=[],n=t.grouped(),l=new j(i,e.Properties.dataPoint.fill,s),c=0,u=n.length;u>c;c++){var h,p,d=n[c];p=l.getColorForSeriesValue(d.objects,t.identityFields,d.name),h=d.identity?w.createWithId(d.identity):w.createNull(),o.push({color:p,icon:F.Circle,label:O.format(d.name,r),identity:h,selected:!1})}return o},e.getSizeRangeForGroups=function(t,i){var a={};return t&&t.forEach(function(t){var r=e.getMeasureValue(i,t.values),s=M.getRangeForColumn(r);(null==a.min||a.min>s.min)&&(a.min=s.min),(null==a.max||a.max<s.max)&&(a.max=s.max)}),a},e.getMetadata=function(t,i,a){var r,n,l,c=s(t,e.ColumnCategory),u=s(t,e.ColumnColorFill),h=s(t,e.ColumnImage),p=s(t,e.ColumnBackdrop),d=o(i,e.ColumnX),g=o(i,e.ColumnY),m=o(i,e.ColumnSize),y=o(i,e.ColumnShape),f=o(i,e.ColumnRotation),v=o(i,e.ColumnXStart),x=o(i,e.ColumnXEnd),b=o(i,e.ColumnYStart),S=o(i,e.ColumnYEnd),w="",C="";if(i&&i.length){var P=i[0];d>=0&&(r=P.values[d].source,w=P.values[d].source.displayName),g>=0&&(n=P.values[g].source,C=P.values[g].source.displayName),m>=0&&(l=P.values[m].source)}return{idx:{category:c,x:d,y:g,size:m,colorFill:u,shape:y,image:h,rotation:f,backdrop:p,xStart:v,xEnd:x,yStart:b,yEnd:S},cols:{x:r,y:n,size:l},axesLabels:{x:w,y:C}}},e.createLazyFormattedCategory=function(e,t){return new c(function(){return e.format(t)})},e.createDataPoints=function(t,a,r,s,o,n,l,c,u,h,p,d){var g,m,y=[],f=a.idx,v=t.source,x=t.grouped(),b=i.fromPoint(h.fontSize);m=e.Properties.general.formatString,g=new j(c,e.Properties.dataPoint.fill,p);for(var S=0,w=s.length;w>S;S++)for(var C=s[S],P=0,D=x.length;D>P;P++){var A=r[f.colorFill],T=r[f.image],V=r[f.backdrop],N=x[P],L=N.values,M=e.getMeasureValue(f.x,L),k=e.getMeasureValue(f.y,L),O=e.getMeasureValue(f.size,L),I=e.getMeasureValue(f.shape,L),F=e.getMeasureValue(f.rotation,L),R=e.getMeasureValue(f.xStart,L),H=e.getMeasureValue(f.xEnd,L),B=e.getMeasureValue(f.yStart,L),U=e.getMeasureValue(f.yEnd,L),E=M&&M.values&&!isNaN(M.values[S])?M.values[S]:null,W=k&&k.values&&!isNaN(k.values[S])?k.values[S]:0,_=null==E||null==W;if(!_){var Y,X,q,K,Z,J,Q,$,ee,te,ie;if(Y=e.getValueFromDataViewValueColumnById(O,S),X=e.getValueFromDataViewValueColumnById(A,S),q=e.getCustomSymbolType(e.getValueFromDataViewValueColumnById(I,S)),K=e.getValueFromDataViewValueColumnById(T,S),Z=e.getNumberFromDataViewValueColumnById(F,S),J=e.getValueFromDataViewValueColumnById(V,S),Q=e.getValueFromDataViewValueColumnById(R,S),$=e.getValueFromDataViewValueColumnById(H,S),ee=e.getValueFromDataViewValueColumnById(B,S),te=e.getValueFromDataViewValueColumnById(U,S),u)ie=g.getColorForSeriesValue(N.objects,t.identityFields,N.name);else{var ae=null!=O?O.source.queryName:"";ie=g.getColorForMeasure(l&&l[S],ae)}var re=r&&r.length>0?r[f.category]:null,se=z.builder().withCategory(re,S).withSeries(t,N).createSelectionId(),oe=[];v&&oe.push({value:N.name,metadata:{source:v,values:[]}}),M&&oe.push({value:E,metadata:M}),k&&oe.push({value:W,metadata:k}),O&&O.values&&O.values.length>0&&oe.push({value:O.values[S],metadata:O}),A&&A.values&&A.values.length>0&&oe.push({value:A.values[S],metadata:A}),I&&I.values&&I.values.length>0&&oe.push({value:I.values[S],metadata:I}),T&&T.values&&T.values.length>0&&oe.push({value:T.values[S],metadata:T}),F&&F.values&&F.values.length>0&&oe.push({value:F.values[S],metadata:F}),V&&V.values&&V.values.length>0&&oe.push({value:V.values[S],metadata:V}),R&&R.values&&R.values.length>0&&oe.push({value:R.values[S],metadata:R}),H&&H.values&&H.values.length>0&&oe.push({value:H.values[S],metadata:H}),B&&B.values&&B.values.length>0&&oe.push({value:B.values[S],metadata:B}),U&&U.values&&U.values.length>0&&oe.push({value:U.values[S],metadata:U});var ne=G.createTooltipInfo(m,void 0,C,null,re?[re]:void 0,oe,void 0),le={
9x:E,y:W,size:Y,radius:{sizeMeasure:O,index:S},fill:ie,formattedCategory:this.createLazyFormattedCategory(o,C),selected:!1,identity:se,tooltipInfo:ne,labelFill:h.labelColor,labelFontSize:b,contentPosition:8,colorFill:X,shapeSymbolType:q,svgurl:K,rotation:Z,backdrop:J,xStart:Q,xEnd:$,yStart:ee,yEnd:te};y.push(le)}}return y},e.getMeasureValue=function(e,t){return t&&e>=0?t[e]:null},e.getNumberFromDataViewValueColumnById=function(t,i){var a=e.getValueFromDataViewValueColumnById(t,i);return a&&!isNaN(a)?a:0},e.getValueFromDataViewValueColumnById=function(e,t){return e&&e.values?e.values[t]:null},e.getDefaultData=function(){return{xCol:void 0,yCol:void 0,dataPoints:[],legendData:{dataPoints:[]},axesLabels:{x:"",y:""},selectedIds:[],sizeRange:[],dataLabelsSettings:I.getDefaultPointLabelSettings(),defaultDataPointColor:null,hasDynamicSeries:!1,useShape:!1,useCustomColor:!1}},e.prototype.setData=function(t){if(this.data=e.getDefaultData(),t&&t.length>0){var i=t[0];i&&(this.categoryAxisProperties=this.getCategoryAxisProperties(i.metadata,!0),this.valueAxisProperties=this.getValueAxisProperties(i.metadata,!0),this.dataView=i,i.categorical&&i.categorical.values&&(this.data=e.converter(i,this.colors,this.interactivityService,this.categoryAxisProperties,this.valueAxisProperties)))}},e.prototype.update=function(e){var t=this.dataViews=e.dataViews;if(this.viewport=_.clone(e.viewport),t){if(t&&t.length>0){var i=R(t,!1,!1,!1);i&&i.length>0&&this.hostServices.setWarnings(i),this.populateObjectProperties(t)}this.setData(t),this.options.interactivity&&this.options.interactivity.isInteractiveLegend||this.renderLegend(),this.render(e.suppressAnimations)}},e.prototype.populateObjectProperties=function(e){if(e&&e.length>0){var t=e[0].metadata;t?this.legendObjectProperties=k.getObject(t.objects,"legend",{}):this.legendObjectProperties={},this.categoryAxisProperties=this.getCategoryAxisProperties(t),this.valueAxisProperties=this.getValueAxisProperties(t);var i=this.valueAxisProperties.position;this.yAxisOrientation=i?i.toString():T.left}},e.prototype.renderLegend=function(){var t={title:"",dataPoints:[]},i=this.legend;this.layerLegendData=this.data.legendData,this.layerLegendData&&(t.title=this.layerLegendData.title||"",t.dataPoints=t.dataPoints.concat(this.layerLegendData.dataPoints||[]),t.fontSize=this.legendLabelFontSize?this.legendLabelFontSize:e.LegendLabelFontSizeDefault,this.layerLegendData.grouped&&(t.grouped=!0));var a=this.legendObjectProperties;if(a){S.update(t,a);var r=a[H.position];r&&i.changeOrientation(B[r])}else i.changeOrientation(B.Top);1!==t.dataPoints.length||t.grouped||(t.dataPoints=[]);var s=this.viewport;i.drawLegend(t,{height:s.height,width:s.width}),U.positionChartArea(this.svg,i)},e.prototype.shouldRenderAxis=function(e,t){return void 0===t&&(t="show"),e?(!e.isCategoryAxis||this.categoryAxisProperties&&null!=this.categoryAxisProperties[t]&&!this.categoryAxisProperties[t])&&(e.isCategoryAxis||this.valueAxisProperties&&null!=this.valueAxisProperties[t]&&!this.valueAxisProperties[t])?!1:e.values&&e.values.length>0:!1},e.prototype.getMaxMarginFactor=function(){return this.options.style.maxMarginFactor||.25},e.prototype.adjustViewportbyBackdrop=function(){var e=new Image,t=this;if(e.src=this.data.backdrop.url,e.onload=function(){t.oldBackdrop!==this.src&&(t.render(!0),t.oldBackdrop=this.src)},e.width>0&&e.height>0)if(e.width*this.viewportIn.height<this.viewportIn.width*e.height){var i=this.viewportIn.width-this.viewportIn.height*e.width/e.height;this.viewport={width:this.viewport.width-i,height:this.viewport.height}}else{var a=this.viewportIn.height-this.viewportIn.width*e.height/e.width;this.viewport={width:this.viewport.width,height:this.viewport.height-a}}},e.prototype.render=function(t){if(this.viewport.height-=this.legendViewport.height,this.viewport.width-=this.legendViewport.width,0!==this.viewportIn.width&&0!==this.viewportIn.height){var i=this.getMaxMarginFactor();this.leftRightMarginLimit=this.viewport.width*i;var a=this.bottomMarginLimit=Math.max(25,Math.ceil(this.viewport.height*i));this.margin.top=8,this.margin.bottom=a,this.margin.right=0,this.calculateAxes(this.categoryAxisProperties,this.valueAxisProperties,e.TextProperties,!0),this.yAxisIsCategorical=this.yAxisProperties.isCategoryAxis,this.hasCategoryAxis=this.yAxisIsCategorical?this.yAxisProperties&&this.yAxisProperties.values.length>0:this.xAxisProperties&&this.xAxisProperties.values.length>0;var r,s=this.shouldRenderAxis(this.xAxisProperties),o=this.shouldRenderAxis(this.yAxisProperties);this.isXScrollBarVisible=!1,this.isYScrollBarVisible=!1;var n,l,c,p=this.yAxisOrientation,d=p===T.right;this.calculateAxes(this.categoryAxisProperties,this.valueAxisProperties,e.TextProperties,!0);for(var m=!1,y=2,f=0;!m&&y>f;){f++,n=M.getTickLabelMargins({width:this.viewportIn.width,height:this.viewport.height},this.leftRightMarginLimit,u,h,{x:this.xAxisProperties,y1:this.yAxisProperties},this.bottomMarginLimit,e.TextProperties,this.isXScrollBarVisible||this.isYScrollBarVisible,d,s,o,!1);var v=d?n.yRight:n.yLeft,b=d?n.yLeft:n.yRight,S=n.xMax;v+=10,b+=10,S+=12,d&&o&&(b+=20),!d&&o&&(v+=20),this.addUnitTypeToAxisLabel(this.xAxisProperties,this.yAxisProperties),l={x:this.xAxisProperties.axisLabel,y:this.yAxisProperties.axisLabel,y2:null},c=null!=l.x||null!=l.y||null!=l.y2,null!=l.x&&(S+=18),null!=l.y&&(v+=20),null!=l.y2&&(b+=20),this.margin.left=d?b:v,this.margin.right=d?v:b,this.margin.bottom=S;var w=this.yAxisProperties.values.length;this.calculateAxes(this.categoryAxisProperties,this.valueAxisProperties,e.TextProperties,!0),this.yAxisProperties.values.length===w&&(m=!0)}if(this.data.backdrop&&this.data.backdrop.show&&void 0!==this.data.backdrop.url)for(this.adjustViewportbyBackdrop(),m=!1,y=2,f=0;!m&&y>f;){f++,n=M.getTickLabelMargins({width:this.viewportIn.width,height:this.viewport.height},this.leftRightMarginLimit,u,h,{x:this.xAxisProperties,y1:this.yAxisProperties},this.bottomMarginLimit,e.TextProperties,this.isXScrollBarVisible||this.isYScrollBarVisible,d,s,o,!1);var v=d?n.yRight:n.yLeft,b=d?n.yLeft:n.yRight,S=n.xMax;v+=10,d&&o&&(b+=15),S+=12,this.addUnitTypeToAxisLabel(this.xAxisProperties,this.yAxisProperties),l={x:this.xAxisProperties.axisLabel,y:this.yAxisProperties.axisLabel,y2:null},c=null!=l.x||null!=l.y||null!=l.y2,null!=l.x&&(S+=18),null!=l.y&&(v+=20),null!=l.y2&&(b+=20),this.margin.left=d?b:v,this.margin.right=d?v:b,this.margin.bottom=S;var w=this.yAxisProperties.values.length;this.calculateAxes(this.categoryAxisProperties,this.valueAxisProperties,e.TextProperties,!0),this.yAxisProperties.values.length===w&&(m=!0)}if(this.renderChart(r,this.xAxisProperties,this.yAxisProperties,n,c,l,t),this.updateAxis(),this.data){var C=this.data,P=this.data.dataPoints,D=this.interactivityService&&this.interactivityService.hasSelection();this.mainGraphicsSVGSelection.attr("width",this.viewportIn.width).attr("height",this.viewportIn.height);var A=P.sort(function(e,t){return t.radius.sizeMeasure?t.radius.sizeMeasure.values[t.radius.index]-e.radius.sizeMeasure.values[e.radius.index]:0}),V=x(this.animator,t),N=this.drawScatterMarkers(A,D,C.sizeRange,V),L=this.data.dataLabelsSettings;if(L.show){var k,O,j;k=this.getEnhanchedScatterChartLabelLayout(L,this.viewportIn,C.sizeRange),O=this.cloneDataPoints(P),j=I.drawDefaultLabelsForDataPointChart(O,this.mainGraphicsG,k,this.viewportIn),j&&j.attr("transform",function(t){var i,a,r=t.size;return i=r.width/e.DataLabelXOffset,a=r.height/e.DataLabelYOffset,E.translate(i,a)})}else I.cleanDataLabels(this.mainGraphicsG);this.renderCrosshair();var F;if(this.interactivityService&&(F={dataPointsSelection:N,data:this.data,plotContext:this.mainGraphicsSVGSelection}),g(N,function(e){return e.data.tooltipInfo}),E.flushAllD3TransitionsIfNeeded(this.options),this.behavior){var z=[F];if(this.interactivityService){var G={layerOptions:z,clearCatcher:this.clearCatcher};this.interactivityService.bind(P,this.behavior,G)}}}}},e.prototype.cloneDataPoints=function(e){return e.map(function(e){return _.clone(e)})},e.prototype.darkenZeroLine=function(e){var t=e.selectAll("g.tick").filter(function(e){return 0===e}).node();t&&d3.select(t).select("line").classed("zero-line",!0)},e.prototype.getCategoryAxisFill=function(){if(this.dataView&&this.dataView.metadata.objects){var e=this.dataView.metadata.objects.categoryAxis;if(e)return e.axisColor}return{solid:{color:"#333"}}},e.prototype.getEnhanchedScatterChartLabelLayout=function(t,i,a){var r=this.xAxisProperties.scale,s=this.yAxisProperties.scale,o=m(t.fontSize),n=y.fontFamily;return{labelText:function(e){return f({label:e.formattedCategory.getValue(),fontSize:t.fontSize,maxWidth:i.width})},labelLayout:{x:function(e){return r(e.x)},y:function(r){var o=e.getBubbleRadius(r.radius,a,i)+I.labelMargin;return 0===t.position?s(r.y)-o:s(r.y)+o}},filter:function(e){return null!=e&&null!=e.formattedCategory.getValue()},style:{fill:function(e){return e.labelFill},"font-size":o,"font-family":n}}},e.getBubbleRadius=function(t,i,a){var r=null,s=null,o=t.sizeMeasure;if(!o)return e.BubbleRadius;var n=i.min?i.min:0,l=i.max?i.max:0,c=Math.min(n,0),u=Math.max(l,0);if(r={minRange:c,maxRange:u,delta:u-c},s=e.getBubblePixelAreaSizeRange(a,e.MinSizeRange,e.MaxSizeRange),o.values){var h=o.values[t.index];if(null!=h)return e.projectSizeToPixels(h,r,s)/2}return e.BubbleRadius},e.getBubblePixelAreaSizeRange=function(t,i,a){var r=1;if(t.height>0&&t.width>0){var s=Math.min(t.height,t.width);r=s*s/e.AreaOf300By300Chart}var o=Math.round(i*r),n=Math.round(a*r);return{minRange:o,maxRange:n,delta:n-o}},e.projectSizeToPixels=function(t,i,a){var r=0;if(i){if(r=a.maxRange,0!==i.delta){var s=Math.min(Math.max(t,i.minRange),i.maxRange);r=e.project(s,i,a)}r=2*Math.sqrt(r/Math.PI)}return Math.round(r)},e.project=function(t,i,a){if(0===i.delta||0===a.delta)return e.rangeContains(i,t)?a.minRange:null;var r=(t-i.minRange)/i.delta;return a.minRange+r*a.delta},e.rangeContains=function(e,t){return e.minRange<=t&&t<=e.maxRange},e.prototype.getValueAxisFill=function(){if(this.dataView&&this.dataView.metadata.objects){var e=this.dataView.metadata.objects.valueAxis;if(e)return e.axisColor}return{solid:{color:"#333"}}},e.prototype.renderCrosshair=function(){return this.mainGraphicsSVGSelection?(this.crosshairCanvasSelection=this.addCrosshairCanvasToDOM(this.mainGraphicsSVGSelection),this.data&&this.data.crosshair&&(this.crosshairVerticalLineSelection=this.addCrosshairLineToDOM(this.crosshairCanvasSelection,e.CrosshairVerticalLineSelector),this.crosshairHorizontalLineSelection=this.addCrosshairLineToDOM(this.crosshairCanvasSelection,e.CrosshairHorizontalLineSelector),this.crosshairTextSelection=this.addCrosshairTextToDOM(this.crosshairCanvasSelection),this.bindCrosshairEvents()),this.crosshairCanvasSelection):void 0},e.prototype.addCrosshairCanvasToDOM=function(t){var i=e.CrosshairCanvasSelector;return this.addElementToDOM(t,{name:"g",selector:i.selector,className:i["class"],styles:{display:"none"}})},e.prototype.addCrosshairLineToDOM=function(t,i){var a=e.CrosshairLineSelector;return this.addElementToDOM(t,{name:"line",selector:i.selector,className:a["class"]+" "+i["class"],attributes:{x1:0,y1:0,x2:0,y2:0}})},e.prototype.addCrosshairTextToDOM=function(t){var i=e.CrosshairTextSelector;return this.addElementToDOM(t,{name:"text",selector:i.selector,className:i["class"]})},e.prototype.bindCrosshairEvents=function(){var e=this;this.axisGraphicsContextScrollable&&this.axisGraphicsContextScrollable.on("mousemove",function(){var t=d3.event.currentTarget,i=d3.mouse(t),a=t.viewportElement,r=a.getBoundingClientRect(),s=a.getBBox(),o=r.width/s.width,n=r.height/s.height,l=i[0],c=i[1];s.width>0&&!v(o,1,1e-5)&&(l/=o),s.height>0&&!v(n,1,1e-5)&&(c/=n),e.updateCrosshair(l,c)}).on("mouseover",function(){e.crosshairCanvasSelection.style("display","block")}).on("mouseout",function(){e.crosshairCanvasSelection.style("display","none")})},e.prototype.updateCrosshair=function(t,i){if(this.viewportIn&&this.crosshairHorizontalLineSelection&&this.crosshairVerticalLineSelection&&this.crosshairTextSelection&&this.xAxisProperties){var a,r,s=e.CrosshairTextMargin,o=this.xAxisProperties.scale,n=this.yAxisProperties.scale;this.crosshairHorizontalLineSelection.attr({x1:0,y1:i,x2:this.viewportIn.width,y2:i}),this.crosshairVerticalLineSelection.attr({x1:t,y1:0,x2:t,y2:this.viewportIn.height}),a=Math.round(100*o.invert(t))/100,r=Math.round(100*n.invert(i))/100,this.crosshairTextSelection.attr({x:t+s,y:i-s}).text("("+a+", "+r+")")}},e.prototype.addElementToDOM=function(e,t){if(!e||!t)return null;var i,a;return i=e.selectAll(t.selector),a=i.data(t.data||[[]]),a.enter().append(t.name).attr(t.attributes).style(t.styles).classed(t.className,!0),a.exit().remove(),a},e.prototype.renderBackground=function(){this.data.backdrop&&this.data.backdrop.show&&void 0!==this.data.backdrop.url?this.backgroundGraphicsContext.attr("xlink:href",this.data.backdrop.url).attr("x",0).attr("y",0).attr("width",this.viewportIn.width).attr("height",this.viewportIn.height):this.backgroundGraphicsContext.attr("width",0).attr("height",0)},e.prototype.renderChart=function(t,i,a,r,s,o,n,l,c){var u=this.bottomMarginLimit,h=this.leftRightMarginLimit,p=x(this.animator,n);if(this.renderBackground(),this.shouldRenderAxis(i)){i.axis.orient("bottom"),i.willLabelsFit||i.axis.tickPadding(5);var g=this.xAxisGraphicsContext;p?g.transition().duration(p).call(i.axis).call(this.darkenZeroLine):g.call(i.axis).call(this.darkenZeroLine);var m=g.selectAll("g.tick").filter(function(e){return 0===e});if(m){var y=this.getValueAxisFill();y&&m.selectAll("line").style({stroke:y.solid.color})}var f=g.selectAll("text");i.willLabelsWordBreak?f.call(M.LabelLayoutStrategy.wordBreak,i,u):f.call(M.LabelLayoutStrategy.rotate,u,b,e.TextProperties,!i.willLabelsFit,u===r.xMax,i,this.margin,this.isXScrollBarVisible||this.isYScrollBarVisible)}else this.xAxisGraphicsContext.selectAll("*").remove();if(this.shouldRenderAxis(a)){var v=this.yAxisOrientation;a.axis.tickSize(-this.viewportIn.width).tickPadding(10).orient(v.toLowerCase());var S=this.y1AxisGraphicsContext;p?S.transition().duration(p).call(a.axis).call(this.darkenZeroLine):S.call(a.axis).call(this.darkenZeroLine);var w=S.selectAll("g.tick").filter(function(e){return 0===e});if(w){var C=this.getCategoryAxisFill();C&&w.selectAll("line").style({stroke:C.solid.color})}r.yLeft>=h&&S.selectAll("text").call(M.LabelLayoutStrategy.clip,h-10,d)}else this.y1AxisGraphicsContext.selectAll("*").remove();if(s){var P=!this.shouldRenderAxis(i,"showAxisTitle"),D=!this.shouldRenderAxis(a,"showAxisTitle"),A=this.valueAxisProperties&&null!=this.valueAxisProperties.secShowAxisTitle&&this.valueAxisProperties.secShowAxisTitle===!1;this.renderAxesLabels(o,this.legendViewport.height,P,D,A)}else this.axisGraphicsContext.selectAll(".xAxisLabel").remove(),this.axisGraphicsContext.selectAll(".yAxisLabel").remove()},e.prototype.renderAxesLabels=function(t,i,a,r,s){this.axisGraphicsContext.selectAll(".xAxisLabel").remove(),this.axisGraphicsContext.selectAll(".yAxisLabel").remove();var o=this.margin,n=this.viewportIn.width,l=this.viewport.height,c=e.AxisFontSize,u=this.yAxisOrientation,h=u===T.right;if(!a){var p=this.axisGraphicsContext.append("text").style("text-anchor","middle").text(t.x).call(function(e){e.each(function(){var e=d3.select(this);e.attr({"class":"xAxisLabel",transform:E.translate(n/2,l-c-2)})})});p.call(M.LabelLayoutStrategy.clip,n,d)}if(!r){var g=this.axisGraphicsContext.append("text").style("text-anchor","middle").text(t.y).call(function(e){e.each(function(){var e=d3.select(this);e.attr({"class":"yAxisLabel",transform:"rotate(-90)",y:h?n+o.right-c:-o.left,x:-((l-o.top-i)/2),dy:"1em"})})});g.call(M.LabelLayoutStrategy.clip,l-(o.bottom+o.top),d)}if(!s&&t.y2){var m=this.axisGraphicsContext.append("text").style("text-anchor","middle").text(t.y2).call(function(e){e.each(function(){var e=d3.select(this);e.attr({"class":"yAxisLabel",transform:"rotate(-90)",y:h?-o.left:n+o.right-c,x:-((l-o.top-i)/2),dy:"1em"})})});m.call(M.LabelLayoutStrategy.clip,l-(o.bottom+o.top),d)}},e.prototype.updateAxis=function(){this.adjustMargins();var e=this.yAxisOrientation,t=e===T.right;this.xAxisGraphicsContext.attr("transform",E.translate(0,this.viewportIn.height)),this.y1AxisGraphicsContext.attr("transform",E.translate(t?this.viewportIn.width:0,0)),this.svg.attr({width:this.viewport.width,height:this.viewport.height}),this.svgScrollable.attr({width:this.viewport.width,height:this.viewport.height}),this.svgScrollable.attr({x:0});var i=this.margin.left,a=this.margin.top;this.axisGraphicsContext.attr("transform",E.translate(i,a)),this.axisGraphicsContextScrollable.attr("transform",E.translate(i,a)),this.clearCatcher.attr("transform",E.translate(-i,-a)),this.isXScrollBarVisible?(this.svgScrollable.attr({x:i}),this.axisGraphicsContextScrollable.attr("transform",E.translate(0,a)),this.svgScrollable.attr("width",this.viewportIn.width),this.svg.attr("width",this.viewport.width).attr("height",this.viewport.height+this.ScrollBarWidth)):this.isYScrollBarVisible&&(this.svgScrollable.attr("height",this.viewportIn.height+a),this.svg.attr("width",this.viewport.width+this.ScrollBarWidth).attr("height",this.viewport.height))},e.prototype.getUnitType=function(e){return e.formatter&&e.formatter.displayUnit&&e.formatter.displayUnit.value>1?e.formatter.displayUnit.title:null},e.prototype.addUnitTypeToAxisLabel=function(e,t){var i=this.getUnitType(e);e.isCategoryAxis?this.categoryAxisHasUnitType=null!==i:this.valueAxisHasUnitType=null!==i,e.axisLabel&&i&&(e.isCategoryAxis?e.axisLabel=M.createAxisLabel(this.categoryAxisProperties,e.axisLabel,i):e.axisLabel=M.createAxisLabel(this.valueAxisProperties,e.axisLabel,i)),i=this.getUnitType(t),t.isCategoryAxis?this.categoryAxisHasUnitType=null!==i:this.valueAxisHasUnitType=null!==i,t.axisLabel&&i&&(t.isCategoryAxis?t.axisLabel=M.createAxisLabel(this.categoryAxisProperties,t.axisLabel,i):t.axisLabel=M.createAxisLabel(this.valueAxisProperties,t.axisLabel,i))},e.prototype.drawScatterMarkers=function(t,i,a,r){var s,o=this,n=this.xAxisProperties.scale,l=this.yAxisProperties.scale,c=(!a||!a.min)&&this.data.fillPoint,u=this.data.useCustomColor;this.data.useShape?(this.mainGraphicsContext.selectAll(e.DotClasses.selector).remove(),s=this.mainGraphicsContext.classed("ScatterMarkers",!0).selectAll(e.ImageClasses.selector).data(t,function(e){return e.identity.getKey()}),s.enter().append("svg:image").classed(e.ImageClasses["class"],!0).attr("id","markerimage"),s.attr("xlink:href",function(e){return void 0!==e.svgurl&&null!=e.svgurl&&""!==e.svgurl?e.svgurl:o.svgDefaultImage}).attr("width",function(t){return 2*e.getBubbleRadius(t.radius,a,o.viewport)}).attr("height",function(t){return 2*e.getBubbleRadius(t.radius,a,o.viewport)}).transition().duration(function(e){return o.keyArray.indexOf(e.identity.getKey())>=0?r:0}).attr("transform",function(t){var i=e.getBubbleRadius(t.radius,a,o.viewport);return"translate("+(n(t.x)-i)+","+(l(t.y)-i)+") rotate("+t.rotation+","+i+","+i+")"})):(this.mainGraphicsContext.selectAll(e.ImageClasses.selector).remove(),s=this.mainGraphicsContext.classed("ScatterMarkers",!0).selectAll(e.DotClasses.selector).data(t,function(e){return e.identity.getKey()}),s.enter().append("path").classed(e.DotClasses["class"],!0).attr("id","markershape"),s.style({"stroke-opacity":function(t){return e.getBubbleOpacity(t,i)},"stroke-width":"1px",stroke:function(e){var t=u?e.colorFill:e.fill;return o.data.outline?d3.rgb(t).darker():d3.rgb(t)},fill:function(e){return d3.rgb(u?e.colorFill:e.fill)},"fill-opacity":function(t){return null!=t.size||c?e.getBubbleOpacity(t,i):0}}).attr("d",function(t){var i=e.getBubbleRadius(t.radius,a,o.viewport),r=4*i*i;return t.shapeSymbolType(r)}).transition().duration(function(e){return o.keyArray.indexOf(e.identity.getKey())>=0?r:0}).attr("transform",function(e){return"translate("+n(e.x)+","+l(e.y)+") rotate("+e.rotation+")"})),s.exit().remove(),this.keyArray=[];for(var h=0;h<t.length;h++)this.keyArray.push(t[h].identity.getKey());return s},e.getBubbleOpacity=function(t,i){return i&&!t.selected?e.DimmedBubbleOpacity:e.DefaultBubbleOpacity},e.prototype.calculateAxes=function(t,i,a,r){var s={viewport:this.viewport,margin:this.margin,forcedXDomain:[t?t.start:null,t?t.end:null],forceMerge:i&&i.secShow===!1,showCategoryAxisLabel:!1,showValueAxisLabel:!1,categoryAxisScaleType:t&&null!=t.axisScale?t.axisScale:null,valueAxisScaleType:i&&null!=i.axisScale?i.axisScale:null,valueAxisDisplayUnits:i&&null!=i.labelDisplayUnits?i.labelDisplayUnits:e.LabelDisplayUnitsDefault,categoryAxisDisplayUnits:t&&null!=t.labelDisplayUnits?t.labelDisplayUnits:e.LabelDisplayUnitsDefault,trimOrdinalDataOnOverflow:!1};i&&(s.forcedYDomain=M.applyCustomizedDomain([i.start,i.end],s.forcedYDomain)),s.showCategoryAxisLabel=!!t&&!!t.showAxisTitle,s.showValueAxisLabel=!0;var o=this.viewport.width-(this.margin.left+this.margin.right),n=this.calculateAxesProperties(s);return n[0].willLabelsFit=M.LabelLayoutStrategy.willLabelsFit(n[0],o,u,a),n[0].willLabelsWordBreak=!n[0].willLabelsFit&&!r&&M.LabelLayoutStrategy.willLabelsWordBreak(n[0],this.margin,o,u,p,b,a),n},e.prototype.calculateAxesProperties=function(t){var i=this.data,a=i.dataPoints;this.margin=t.margin,this.viewport=t.viewport;var r=0,s=10,o=0,n=10;a.length>0&&(r=d3.min(a,function(e){return e.y}),s=d3.max(a,function(e){return e.y}),o=d3.min(a,function(e){return e.x}),n=d3.max(a,function(e){return e.x}));var l,c,u,h,p=[o,n];return l=M.combineDomain(this.optimizeTranslateValues(t.forcedXDomain),p),u=O.getFormatString(i.xCol,e.Properties.general.formatString),this.xAxisProperties=M.createAxis({pixelSpan:this.viewportIn.width,dataDomain:l,metaDataColumn:i.xCol,formatString:u,outerPadding:0,isScalar:!0,isVertical:!1,forcedTickCount:t.forcedTickCount,useTickIntervalForDisplayUnits:!0,isCategoryAxis:!0,scaleType:t.categoryAxisScaleType,axisDisplayUnits:t.categoryAxisDisplayUnits}),this.xAxisProperties.axis.tickSize(-this.viewportIn.height,0),this.xAxisProperties.axisLabel=this.data.axesLabels.x,c=M.combineDomain(this.optimizeTranslateValues(t.forcedYDomain),[r,s]),h=O.getFormatString(i.yCol,e.Properties.general.formatString),this.yAxisProperties=M.createAxis({pixelSpan:this.viewportIn.height,dataDomain:c,metaDataColumn:i.yCol,formatString:h,outerPadding:0,isScalar:!0,isVertical:!0,forcedTickCount:t.forcedTickCount,useTickIntervalForDisplayUnits:!0,isCategoryAxis:!1,scaleType:t.valueAxisScaleType,axisDisplayUnits:t.valueAxisDisplayUnits}),this.yAxisProperties.axisLabel=this.data.axesLabels.y,[this.xAxisProperties,this.yAxisProperties]},e.prototype.optimizeTranslateValues=function(e){var t=this;return e&&e.map?e.map(function(e){return t.optimizeTranslateValue(e)}):e},e.prototype.optimizeTranslateValue=function(t){if(t){var i=t>=0?1:-1,a=Math.abs(t);if(a>e.MaxTranslateValue)return e.MaxTranslateValue*i;if(a<e.MinTranslateValue)return e.MinTranslateValue*i}return t},e.prototype.enumerateDataPoints=function(e){var t=this.data;if(t){var i=t.dataPoints.length;if(t.hasDynamicSeries)for(var a=t.legendData.dataPoints.length,r=0;a>r;r++){var s=t.legendData.dataPoints[r];e.pushInstance({objectName:"dataPoint",displayName:s.label,selector:j.normalizeSelector(s.identity.getSelector()),properties:{fill:{solid:{color:s.color}}}})}else{var o=t.showAllDataPoints;if(e.pushInstance({objectName:"dataPoint",selector:null,properties:{defaultColor:{solid:{color:t.defaultDataPointColor||this.colors.getColorByIndex(0).value}}}}).pushInstance({objectName:"dataPoint",selector:null,properties:{showAllDataPoints:o}}),o)for(var r=0;i>r;r++){var n=t.dataPoints[r];e.pushInstance({objectName:"dataPoint",displayName:n.formattedCategory.getValue(),selector:j.normalizeSelector(n.identity.getSelector(),!0),properties:{fill:{solid:{color:n.fill}}}})}}}},e.prototype.enumerateObjectInstances=function(e){var t=new W;switch(e.objectName){case"dataPoint":var i=this.dataView&&this.dataView.categorical?this.dataView.categorical:null;Y.hasGradientRole(i)||this.enumerateDataPoints(t);break;case"categoryAxis":this.getCategoryAxisValues(t);break;case"valueAxis":this.getValueAxisValues(t);break;case"categoryLabels":this.data?I.enumerateCategoryLabels(t,this.data.dataLabelsSettings,!0):I.enumerateCategoryLabels(t,null,!0);break;case"fillPoint":var a=this.data.sizeRange;if(a&&a.min)break;t.pushInstance({objectName:"fillPoint",selector:null,properties:{show:this.data.fillPoint}});break;case"backdrop":t.pushInstance({objectName:"backdrop",displayName:"Backdrop",selector:null,properties:{show:this.data.backdrop?this.data.backdrop.show:!1,url:this.data.backdrop?this.data.backdrop.url:null}});break;case"crosshair":t.pushInstance({objectName:"crosshair",selector:null,properties:{show:this.data.crosshair}});break;case"outline":t.pushInstance({objectName:"outline",selector:null,properties:{show:this.data.outline}});break;case"legend":this.getLegendValue(t)}return t.complete()},e.prototype.hasLegend=function(){return this.data&&this.data.hasDynamicSeries},e.prototype.getLegendValue=function(t){if(this.hasLegend()){var i=C.getValue(this.legendObjectProperties,H.show,this.legend.isVisible()),a=C.getValue(this.legendObjectProperties,H.showTitle,!0),r=C.getValue(this.legendObjectProperties,H.titleText,this.layerLegendData?this.layerLegendData.title:""),s=C.getValue(this.legendObjectProperties,H.labelColor,S.DefaultLegendLabelFillColor);this.legendLabelFontSize=C.getValue(this.legendObjectProperties,H.fontSize,e.LegendLabelFontSizeDefault),t.pushInstance({selector:null,properties:{show:i,position:B[this.legend.getOrientation()],showTitle:a,titleText:r,labelColor:s,fontSize:this.legendLabelFontSize},objectName:"legend"})}},e.prototype.getCategoryAxisValues=function(t){var i=X.both,a=!0,r=!1,s=[q.log,q.linear];a||this.categoryAxisProperties&&(this.categoryAxisProperties.start=null,this.categoryAxisProperties.end=null);var o={selector:null,properties:{},objectName:"categoryAxis",validValues:{axisScale:s}};o.properties.show=this.categoryAxisProperties&&null!=this.categoryAxisProperties.show?this.categoryAxisProperties.show:!0,this.yAxisIsCategorical&&(o.properties.position=this.valueAxisProperties&&null!=this.valueAxisProperties.position?this.valueAxisProperties.position:T.left),i===X.both&&(o.properties.axisType=a?X.scalar:X.categorical),a&&(o.properties.axisScale=this.categoryAxisProperties&&null!=this.categoryAxisProperties.axisScale&&r?this.categoryAxisProperties.axisScale:q.linear,o.properties.start=this.categoryAxisProperties?this.categoryAxisProperties.start:null,o.properties.end=this.categoryAxisProperties?this.categoryAxisProperties.end:null,o.properties.labelDisplayUnits=this.categoryAxisProperties&&null!=this.categoryAxisProperties.labelDisplayUnits?this.categoryAxisProperties.labelDisplayUnits:e.LabelDisplayUnitsDefault),o.properties.showAxisTitle=this.categoryAxisProperties&&null!=this.categoryAxisProperties.showAxisTitle?this.categoryAxisProperties.showAxisTitle:!0,t.pushInstance(o).pushInstance({selector:null,properties:{axisStyle:this.categoryAxisProperties&&this.categoryAxisProperties.axisStyle?this.categoryAxisProperties.axisStyle:K.showTitleOnly,labelColor:this.categoryAxisProperties?this.categoryAxisProperties.labelColor:null},objectName:"categoryAxis",validValues:{axisStyle:this.categoryAxisHasUnitType?[K.showTitleOnly,K.showUnitOnly,K.showBoth]:[K.showTitleOnly]}})},e.prototype.getValueAxisValues=function(t){var i=[q.log,q.linear],a=!1,r={selector:null,properties:{},objectName:"valueAxis",validValues:{axisScale:i,secAxisScale:i}};r.properties.show=this.valueAxisProperties&&null!=this.valueAxisProperties.show?this.valueAxisProperties.show:!0,this.yAxisIsCategorical||(r.properties.position=this.valueAxisProperties&&null!=this.valueAxisProperties.position?this.valueAxisProperties.position:T.left),r.properties.axisScale=this.valueAxisProperties&&null!=this.valueAxisProperties.axisScale&&a?this.valueAxisProperties.axisScale:q.linear,r.properties.start=this.valueAxisProperties?this.valueAxisProperties.start:null,r.properties.end=this.valueAxisProperties?this.valueAxisProperties.end:null,r.properties.showAxisTitle=this.valueAxisProperties&&null!=this.valueAxisProperties.showAxisTitle?this.valueAxisProperties.showAxisTitle:!0,r.properties.labelDisplayUnits=this.valueAxisProperties&&null!=this.valueAxisProperties.labelDisplayUnits?this.valueAxisProperties.labelDisplayUnits:e.LabelDisplayUnitsDefault,t.pushInstance(r).pushInstance({selector:null,properties:{axisStyle:this.valueAxisProperties&&null!=this.valueAxisProperties.axisStyle?this.valueAxisProperties.axisStyle:K.showTitleOnly,labelColor:this.valueAxisProperties?this.valueAxisProperties.labelColor:null},objectName:"valueAxis",validValues:{axisStyle:this.valueAxisHasUnitType?[K.showTitleOnly,K.showUnitOnly,K.showBoth]:[K.showTitleOnly]}})},e.prototype.onClearSelection=function(){this.interactivityService&&this.interactivityService.clearSelection()},e.AxisGraphicsContextClassName="axisGraphicsContext",e.ClassName="enhancedScatterChart",e.MainGraphicsContextClassName="mainGraphicsContext",e.LegendLabelFontSizeDefault=9,e.LabelDisplayUnitsDefault=0,e.AxisFontSize=11,e.CrosshairTextMargin=5,e.BubbleRadius=6,e.MinSizeRange=200,e.MaxSizeRange=3e3,e.AreaOf300By300Chart=9e4,e.DataLabelXOffset=2,e.DataLabelYOffset=1.8,e.DotClasses=r("dot"),e.ImageClasses=r("img"),e.TextProperties={fontFamily:"'Segoe UI', wf_segoe-ui_normal, helvetica, arial, sans-serif",fontSize:i.toString(e.AxisFontSize)},e.CrosshairCanvasSelector=r("crosshairCanvas"),e.CrosshairLineSelector=r("crosshairLine"),e.CrosshairVerticalLineSelector=r("crosshairVerticalLine"),e.CrosshairHorizontalLineSelector=r("crosshairHorizontalLine"),e.CrosshairTextSelector=r("crosshairText"),e.MaxTranslateValue=1e25,e.MinTranslateValue=1e-25,e.DefaultBubbleOpacity=.85,e.DimmedBubbleOpacity=.4,e.ColumnCategory="Category",e.ColumnSeries="Series",e.ColumnX="X",e.ColumnY="Y",e.ColumnSize="Size",e.ColumnGradient="Gradient",e.ColumnColorFill="ColorFill",e.ColumnShape="Shape",e.ColumnImage="Image",e.ColumnRotation="Rotation",e.ColumnBackdrop="Backdrop",e.ColumnXStart="X Start",e.ColumnXEnd="X End",e.ColumnYStart="Y Start",e.ColumnYEnd="Y End",e.capabilities={dataRoles:[{name:e.ColumnCategory,kind:P.Grouping,displayName:l("Role_DisplayName_Details")},{name:e.ColumnSeries,kind:P.Grouping,displayName:l("Role_DisplayName_Legend")},{name:e.ColumnX,kind:P.Measure,displayName:l("Role_DisplayName_X")},{name:e.ColumnY,kind:P.Measure,displayName:l("Role_DisplayName_Y")},{name:e.ColumnSize,kind:P.Measure,displayName:l("Role_DisplayName_Size")},{name:e.ColumnGradient,kind:P.Measure,displayName:l("Role_DisplayName_Gradient")},{name:e.ColumnColorFill,kind:P.Grouping,displayName:"Customized Color"},{name:e.ColumnShape,kind:P.Measure,displayName:"Shape"},{name:e.ColumnImage,kind:P.Grouping,displayName:"Image"},{name:e.ColumnRotation,kind:P.Measure,displayName:"Rotation"},{name:e.ColumnBackdrop,kind:P.Grouping,displayName:"Backdrop"},{name:e.ColumnXStart,kind:P.Measure,displayName:"X Start"},{name:e.ColumnXEnd,kind:P.Measure,displayName:"X End"},{name:e.ColumnYStart,kind:P.Measure,displayName:"Y Start"},{name:e.ColumnYEnd,kind:P.Measure,displayName:"Y End"}],dataViewMappings:[{conditions:[{Category:{max:1},Series:{max:1},X:{max:1},Y:{max:1},Size:{max:1},Gradient:{max:0},ColorFill:{max:1},Shape:{max:1},Image:{max:0},Rotation:{max:1},Backdrop:{max:1},"X Start":{max:1},"X End":{max:1},"Y Start":{max:1},"Y End":{max:1}},{Category:{max:1},Series:{max:0},X:{max:1},Y:{max:1},Size:{max:1},Gradient:{max:1},ColorFill:{max:1},Shape:{max:1},Image:{max:0},Rotation:{max:1},Backdrop:{max:1},"X Start":{max:1},"X End":{max:1},"Y Start":{max:1},"Y End":{max:1}},{Category:{max:1},Series:{max:1},X:{max:1},Y:{max:1},Size:{max:1},Gradient:{max:0},ColorFill:{max:0},Shape:{max:0},Image:{max:1},Rotation:{max:1},Backdrop:{max:1},"X Start":{max:1},"X End":{max:1},"Y Start":{max:1},"Y End":{max:1}},{Category:{max:1},Series:{max:0},X:{max:1},Y:{max:1},Size:{max:1},Gradient:{max:1},ColorFill:{
10max:0},Shape:{max:0},Image:{max:1},Rotation:{max:1},Backdrop:{max:1},"X Start":{max:1},"X End":{max:1},"Y Start":{max:1},"Y End":{max:1}}],categorical:{categories:{"for":{"in":e.ColumnCategory},dataReductionAlgorithm:{sample:{}}},values:{group:{by:e.ColumnSeries,select:[{bind:{to:e.ColumnX}},{bind:{to:e.ColumnY}},{bind:{to:e.ColumnSize}},{bind:{to:e.ColumnGradient}},{bind:{to:e.ColumnColorFill}},{bind:{to:e.ColumnShape}},{bind:{to:e.ColumnImage}},{bind:{to:e.ColumnRotation}},{bind:{to:e.ColumnBackdrop}},{bind:{to:e.ColumnXStart}},{bind:{to:e.ColumnXEnd}},{bind:{to:e.ColumnYStart}},{bind:{to:e.ColumnYEnd}}],dataReductionAlgorithm:{top:{}}}},rowCount:{preferred:{min:2}}}}],objects:{dataPoint:{displayName:l("Visual_DataPoint"),properties:{defaultColor:{displayName:l("Visual_DefaultColor"),type:{fill:{solid:{color:!0}}}},showAllDataPoints:{displayName:l("Visual_DataPoint_Show_All"),type:{bool:!0}},useShape:{displayName:l("Visual_UseImage"),type:{bool:!0}},fill:{displayName:l("Visual_Fill"),type:{fill:{solid:{color:!0}}}},fillRule:{displayName:l("Visual_Gradient"),type:{fillRule:{}},rule:{inputRole:e.ColumnGradient,output:{property:"fill",selector:[e.ColumnCategory]}}}}},general:{displayName:l("Visual_General"),properties:{formatString:{type:{formatting:{formatString:!0}}}}},categoryAxis:{displayName:l("Visual_XAxis"),properties:{show:{displayName:l("Visual_Show"),type:{bool:!0}},axisScale:{displayName:l("Visual_Axis_Scale"),type:{formatting:{axisScale:!0}}},start:{displayName:l("Visual_Axis_Start"),type:{numeric:!0}},end:{displayName:l("Visual_Axis_End"),type:{numeric:!0}},showAxisTitle:{displayName:l("Visual_Axis_Title"),type:{bool:!0}},axisStyle:{displayName:l("Visual_Axis_Style"),type:{formatting:{axisStyle:!0}}},axisColor:{displayName:"Color",type:{fill:{solid:{color:!0}}}},labelDisplayUnits:{displayName:"Display Units",type:{formatting:{labelDisplayUnits:!0}}}}},valueAxis:{displayName:l("Visual_YAxis"),properties:{show:{displayName:l("Visual_Show"),type:{bool:!0}},position:{displayName:l("Visual_YAxis_Position"),type:{formatting:{yAxisPosition:!0}}},axisScale:{displayName:l("Visual_Axis_Scale"),type:{formatting:{axisScale:!0}}},start:{displayName:l("Visual_Axis_Start"),type:{numeric:!0}},end:{displayName:l("Visual_Axis_End"),type:{numeric:!0}},showAxisTitle:{displayName:l("Visual_Axis_Title"),type:{bool:!0}},axisStyle:{displayName:l("Visual_Axis_Style"),type:{formatting:{axisStyle:!0}}},axisColor:{displayName:"Color",type:{fill:{solid:{color:!0}}}},labelDisplayUnits:{displayName:"Display Units",type:{formatting:{labelDisplayUnits:!0}}}}},legend:{displayName:l("Visual_Legend"),properties:{show:{displayName:l("Visual_Show"),type:{bool:!0}},position:{displayName:l("Visual_LegendPosition"),description:l("Visual_LegendPositionDescription"),type:{enumeration:D.type}},showTitle:{displayName:l("Visual_LegendShowTitle"),description:l("Visual_LegendShowTitleDescription"),type:{bool:!0}},titleText:{displayName:"Legend Name",description:l("Visual_LegendNameDescription"),type:{text:!0}},labelColor:{displayName:"Color",type:{fill:{solid:{color:!0}}}},fontSize:{displayName:"Text Size",type:{formatting:{fontSize:!0}}}}},categoryLabels:{displayName:l("Visual_CategoryLabels"),properties:{show:{displayName:l("Visual_Show"),type:{bool:!0}},color:{displayName:l("Visual_LabelsFill"),type:{fill:{solid:{color:!0}}}},fontSize:{displayName:"Text Size",type:{formatting:{fontSize:!0}}}}},fillPoint:{displayName:l("Visual_FillPoint"),properties:{show:{displayName:l("Visual_Fill"),type:{bool:!0}}}},backdrop:{displayName:"Backdrop",properties:{show:{displayName:l("Visual_Show"),type:{bool:!0}},url:{displayName:"Image URL",type:{text:!0}}}},crosshair:{displayName:"Crosshair",properties:{show:{displayName:"Crosshair",type:{bool:!0}}}},outline:{displayName:"Outline",properties:{show:{displayName:l("Visual_Outline"),type:{bool:!0}}}}}},e.Properties=e.getPropertiesByCapabilities(e.capabilities),e}();t.EnhancedScatterChart=Z;var J=function(){function e(e){this.behaviors=e||[]}return e.prototype.bindEvents=function(e,t){for(var i=this.behaviors,a=0,r=i.length;r>a;a++)i[a].bindEvents(e.layerOptions[a],t);e.clearCatcher.on("click",function(){t.handleClearSelection()})},e.prototype.renderSelection=function(e){for(var t=0,i=this.behaviors;t<i.length;t++){var a=i[t];a.renderSelection(e)}},e}();t.CustomVisualBehavior=J;var Q=function(){function e(e,t){this.dimmedBubbleOpacity=e,this.defaultBubbleOpacity=t}return e.prototype.bindEvents=function(e,t){var i=this.bubbles=e.dataPointsSelection,a=e.data;this.shouldEnableFill=(!a.sizeRange||!a.sizeRange.min)&&a.fillPoint,this.colorBorder=a.colorBorder,n(i,t)},e.prototype.renderSelection=function(e){var t=this,i=this.shouldEnableFill,a=this.colorBorder;this.bubbles.style("fill-opacity",function(a){return t.getMarkerFillOpacity(null!=a.size,i,e,a.selected)}),this.bubbles.style("stroke-opacity",function(i){return t.getMarkerStrokeOpacity(null!=i.size,a,e,i.selected)})},e.prototype.getMarkerFillOpacity=function(e,t,i,a){return e||t?i&&!a?this.dimmedBubbleOpacity:this.defaultBubbleOpacity:0},e.prototype.getMarkerStrokeOpacity=function(e,t,i,a){return e&&t?1:i&&!a?this.dimmedBubbleOpacity:this.defaultBubbleOpacity},e}();t.EnhancedScatterChartWebBehavior=Q}(i=t.samples||(t.samples={}))}(t=e.visuals||(e.visuals={}))}(i||(i={}))},function(e,t){function i(){}var a,r,s,o,o=(window.jsCommon,window.powerbi);window.powerbitests,window.InJs,window.debug,window.jasmine,window.Microsoft;!function(e){var t;!function(t){var o;!function(o){var n=e.data.DataRoleHelper,l=function(){function o(){this.data=[],this.locationsToLoad=0,this.locationsLoaded=0,this.renderLoopEnabled=!0,this.needsRender=!1}return o.converter=function(e){return{}},o.prototype.enumerateObjectInstances=function(e){var i=new t.ObjectEnumerationBuilder;switch(e.objectName){case"dataPoint":this.enumerateDataPoints(i)}return i.complete()},o.prototype.enumerateDataPoints=function(e){var i=this.data;if(i)for(var a=this.dataPointsToEnumerate,r=a.length,s=0;r>s;s++){var o=a[s];e.pushInstance({objectName:"dataPoint",displayName:o.label,selector:t.ColorHelper.normalizeSelector(o.identity.getSelector()),properties:{fill:{solid:{color:o.color}}}})}},o.prototype.init=function(e){this.container=e.element,this.viewport=e.viewport,this.readyToRender=!1,this.globeMapLocationCache||(this.globeMapLocationCache={}),this.style=e.style,this.colors=this.style.colorPalette.dataColors,this.colorHelper=new t.ColorHelper(this.colors,o.Properties.dataPoint.fill),a||i(),a&&this.setup()},o.prototype.setup=function(){this.initSettings(),this.initTextures(),this.initMercartorSphere(),this.initZoomControl(),this.initScene(),this.initHeatmap(),this.readyToRender=!0,this.composeRenderData(),this.initRayCaster()},o.prototype.initSettings=function(){var e=this.settings={};e.autoRotate=!1,e.earthRadius=30,e.cameraRadius=100,e.earthSegments=100,e.heatmapSize=1e3,e.heatPointSize=7,e.heatIntensity=10,e.heatmapScaleOnZoom=.95,e.barWidth=.3,e.barHeight=5,e.rotateSpeed=.5,e.zoomSpeed=.8,e.cameraAnimDuration=1e3,e.clickInterval=200},o.prototype.initScene=function(){var e=this.viewport,t=this.settings,i=new a.Clock,r=this.renderer=new a.WebGLRenderer({antialias:!0,preserveDrawingBuffer:!0});this.container.append(r.domElement),this.domElement=r.domElement;var s=this.camera=new a.PerspectiveCamera(35,e.width/e.height,.1,1e4),o=this.orbitControls=new a.OrbitControls(s,this.domElement),n=this.scene=new a.Scene;r.setSize(e.width,e.height),r.setClearColor(12240082,1),s.position.z=t.cameraRadius,o.maxDistance=t.cameraRadius,o.minDistance=t.earthRadius+1,o.rotateSpeed=t.rotateSpeed,o.zoomSpeed=t.zoomSpeed,o.autoRotate=t.autoRotate;var l=new a.AmbientLight(0),c=new a.DirectionalLight(16777215,.4),u=new a.DirectionalLight(16777215,.4),h=this.earth=this.createEarth();n.add(l),n.add(c),n.add(u),n.add(h),c.position.set(20,20,20),u.position.set(0,0,-20);var p=this;requestAnimationFrame(function d(){try{if(p.renderLoopEnabled&&requestAnimationFrame(d),!p.shouldRender())return;o.update(i.getDelta()),p.setEarthTexture(),p.intersectBars(),p.heatmap&&p.heatmap.display&&p.heatmap.display(),r.render(n,s),p.needsRender=!1}catch(e){}})},o.prototype.shouldRender=function(){return this.readyToRender&&this.needsRender},o.prototype.createEarth=function(){var e=new o.MercartorSphere(this.settings.earthRadius,this.settings.earthSegments,this.settings.earthSegments),t=new a.MeshPhongMaterial({map:this.mapTextures[0],side:a.DoubleSide,shininess:1,emissive:11184810});return new a.Mesh(e,t)},o.prototype.zoomClicked=function(e){this.orbitControls.enabled!==!1&&this.orbitControls.enableZoom!==!1&&(-1===e?this.orbitControls.constraint.dollyOut(Math.pow(.95,this.settings.zoomSpeed)):1===e&&this.orbitControls.constraint.dollyIn(Math.pow(.95,this.settings.zoomSpeed)),this.orbitControls.update(),this.animateCamera(this.camera.position))},o.prototype.rotateCam=function(e,t){this.orbitControls.enabled!==!1&&this.orbitControls.enableRotate!==!1&&(this.orbitControls.constraint.rotateLeft(2*Math.PI*e/this.domElement.offsetHeight*this.settings.rotateSpeed),this.orbitControls.constraint.rotateUp(2*Math.PI*t/this.domElement.offsetHeight*this.settings.rotateSpeed),this.orbitControls.update(),this.animateCamera(this.camera.position))},o.prototype.initTextures=function(){var e=this;if(!s){s=[];for(var t=2;5>=t;++t){var i=this.getBingMapCanvas(t);s.push(i)}}var r=function(t){var i=new a.Texture(t.get(0));return i.needsUpdate=!0,t.on("ready",function(t,a){i.needsUpdate=!0,e.needsRender=!0}),i};this.mapTextures=[];for(var o=0;o<s.length;++o)this.mapTextures.push(r(s[o]))},o.prototype.initHeatmap=function(){var e=this.settings;try{var t=this.heatmap=new r({width:e.heatmapSize,height:e.heatmapSize,intensityToAlpha:!0})}catch(i){}var s=this.heatTexture=new a.Texture(t.canvas);s.needsUpdate=!0;var o=new a.MeshBasicMaterial({map:s,transparent:!0}),n=new a.SphereGeometry(e.earthRadius+.01,e.earthSegments,e.earthSegments),l=new a.Mesh(n,o);window.heatmap=t,window.heatmapTexture=s,this.scene.add(l)},o.prototype.setEarthTexture=function(){if(this.camera){var e,t=this.settings.cameraRadius-this.settings.earthRadius,i=(this.camera.position.length()-this.settings.earthRadius)/t;e=.2>=i?this.mapTextures[3]:.4>=i?this.mapTextures[2]:.6>=i?this.mapTextures[1]:this.mapTextures[0],this.earth.material.map!==e&&(this.earth.material.map=e),this.selectedBar?this.orbitControls.rotateSpeed=this.settings.rotateSpeed:this.orbitControls.rotateSpeed=this.settings.rotateSpeed*i}},o.prototype.update=function(e){if(this.needsRender=!0,e.viewport.height!==this.viewport.height||e.viewport.width!==this.viewport.width){var t=this.viewport=e.viewport;return void(this.camera&&this.renderer&&(this.camera.aspect=t.width/t.height,this.camera.updateProjectionMatrix(),this.renderer.setSize(t.width,t.height)))}this.cleanHeatAndBar(),e.dataViews[0]&&(e.dataViews[0].categorical||e.dataViews[0].metadata)&&this.composeRenderData(e.dataViews[0].categorical,e.dataViews[0].metadata)},o.prototype.cleanHeatAndBar=function(){this.heatmap.clear(),this.heatTexture.needsUpdate=!0,this.barsGroup&&this.scene.remove(this.barsGroup)},o.prototype.renderMagic=function(){if(!this.readyToRender)return void this.defferedRender();var e=this.data,t=this.heatmap,i=this.settings;t.clear(),this.barsGroup&&this.scene.remove(this.barsGroup),this.barsGroup=new a.Object3D,this.scene.add(this.barsGroup),this.averageBarVector=new a.Vector3;for(var r=0,s=e.length;s>r;++r){var o=e[r];if(o.lat&&o.lng){if(o.heat>.001){o.heat<.1&&(o.heat=.1);var n=(180+o.lng)/360*i.heatmapSize,l=(1-(90+o.lat)/180)*i.heatmapSize;t.addPoint(n,l,i.heatPointSize,o.heat*i.heatIntensity)}if(o.height>=0){o.height<.01&&(o.height=.01);var c=o.lat/180*Math.PI,u=o.lng/180*Math.PI,n=Math.cos(u)*Math.cos(c),h=-Math.sin(u)*Math.cos(c),l=Math.sin(c),p=new a.Vector3(n,l,h);this.averageBarVector.add(p);var d=i.barHeight*o.height,g=[],m=[];if(o.heightBySeries)for(var y=0;y<o.heightBySeries.length;y++)o.heightBySeries[y]&&g.push(o.heightBySeries[y]),m.push(o.seriesToolTipData[y]);else g.push(1);for(var f=0,v=0;v<g.length;v++){f+=g[v];var x=new a.CubeGeometry(i.barWidth,i.barWidth,d*g[v]),b=new a.Mesh(x,this.getBarMaterialByIndex(v));b.position=p.clone().multiplyScalar(i.earthRadius+d/2*f),b.lookAt(p),b.toolTipData=0===m.length?o.toolTipData:this.getToolTipDataForSeries(o.toolTipData,m[v]),this.barsGroup.add(b),f+=g[v]}}}}this.barsGroup.children.length>0&&this.camera&&(this.averageBarVector.multiplyScalar(1/this.barsGroup.children.length),this.locationsLoaded===this.locationsToLoad&&this.animateCamera(this.averageBarVector)),t.update(),t.blur(),this.heatTexture.needsUpdate=!0,this.needsRender=!0},o.prototype.getBarMaterialByIndex=function(e){return new a.MeshPhongMaterial({color:this.dataPointsToEnumerate[e].color})},o.prototype.getToolTipDataForSeries=function(e,t){var i=jQuery.extend(!0,{series:{displayName:t.displayName,value:t.value}},e);return i.height.value=t.dataPointValue,i},o.prototype.createDataPointForEnumeration=function(e,i,a,r){var s=e.values[i].source,o=t.converterHelper.getFormattedLegendLabel(s,e.values,null),n=t.SelectionId.createWithId(e.identity),l=t.converterHelper.getSeriesName(s),c=e.objects&&e.objects.dataPoint?e.objects.dataPoint.fill.solid.color:r&&r.objects?this.colorHelper.getColorForMeasure(r.objects,""):this.colors.getColorByIndex(a).value;return{label:o,identity:n,category:l,color:c,selected:null}},o.prototype.composeRenderData=function(e,i){e?this.categoricalView=e:e=this.categoricalView,this.data=[],this.dataPointsToEnumerate=[];var a=[],r=this.globeMapLocationCache;if(e){var s=0,o=0,l=[];try{e.categories&&(l=e.categories);var c=e.values.grouped();s=n.getMeasureIndexOfRole(c,"Height"),o=n.getMeasureIndexOfRole(c,"Heat");var u=n.getMeasureIndexOfRole(c,"X"),h=n.getMeasureIndexOfRole(c,"Y")}catch(p){}var d,g,m,y,f,v,x,b,S,w,C,P;if(l&&l.length>0&&l[0].values){var D=l[0];a=D.values,b=D.source.displayName,d=D.source.type.category?D.source.type.category.toLowerCase():""}else a=[];if(void 0!==s&&e.values[s]&&void 0!==e.values)if(S=e.values[s].source.displayName,C=e.values[s].source.format,c.length>1){g=new Array(a.length),m=new Array(a.length),y=new Array(a.length),this.dataPointsToEnumerate=new Array(c.length);for(var A=0;A<c.length;A++){var T=c[A].values[s].values;this.dataPointsToEnumerate[A]=this.createDataPointForEnumeration(c[A],s,A);for(var V=0;V<T.length;V++)g[V]||(g[V]=0),g[V]+=T[V]?T[V]:0,m[V]||(m[V]=[]),m[V][A]=T[V],y[V]||(y[V]=[]),y[V][A]={displayName:e.values.source.displayName,value:c[A].name,dataPointValue:T[V]}}for(var A=0;A<c.length;A++)for(var T=c[A].values[s].values,V=0;V<T.length;V++)m[V][A]=T[V]/g[V]}else g=e.values[s].values,m=new Array(c.length),this.dataPointsToEnumerate[0]=this.createDataPointForEnumeration(c[0],s,0,i);else m=new Array(a.length),g=new Array(a.length);if(void 0!==o&&e.values[o]){if(c.length>1){f=new Array(a.length);for(var A=0;A<c.length;A++)for(var T=c[A].values[o].values,V=0;V<T.length;V++)f[V]||(f[V]=0),f[V]+=T[V]?T[V]:0}else f=e.values[o].values;w=e.values[o].source.displayName,P=e.values[o].source.format}else f=new Array(a.length);void 0!==u&&e.values[u]&&void 0!==h&&e.values[h]?(x=e.values[u].values,v=e.values[h].values):(x=null,v=null);for(var N=Math.max.apply(null,g)||1,L=Math.max.apply(null,f)||1,M=t.valueFormatter.create({format:P,value:f[0],value2:f[1]}),k=t.valueFormatter.create({format:C,value:g[0],value2:g[1]}),A=0,O=a.length;O>A;++A){var I,j,F,z,G,R=a[A];if(R&&"string"==typeof R){R=R.toLowerCase();var H=R+"/"+d;!x&&r[H]?(F=r[H],I=F.latitude,j=F.longitude):x&&(I=v[A],j=x[A]),z=g[A]/N,G=f[A]/L;var B={lat:I,lng:j,height:z?z||.01:void 0,heightBySeries:m[A],seriesToolTipData:y?y[A]:void 0,heat:G||0,toolTipData:{location:{displayName:b,value:a[A]},height:{displayName:S,value:k.format(g[A])},heat:{displayName:w,value:M.format(f[A])}}};this.data.push(B),x||F||this.geocodeRenderDatum(B,R,d)}}try{this.renderMagic()}catch(p){}}},o.prototype.geocodeRenderDatum=function(i,a,r){var s=this,o=a+"/"+r;this.globeMapLocationCache[o]={},this.locationsToLoad++;try{var n=e.visuals.BI.Services.GeocodingManager.geocode}catch(l){n=t.services.geocode}n&&n(a,r).always(function(e){s.globeMapLocationCache[o]=e,s.locationsLoaded++,e.latitude&&e.longitude&&(i.lat=e.latitude,i.lng=e.longitude,s.defferedRender())})},o.prototype.defferedRender=function(){var e=this;this.deferredRenderTimerId||(this.deferredRenderTimerId=setTimeout(function(){e.deferredRenderTimerId=null,e.composeRenderData()},500))},o.prototype.initRayCaster=function(){var e=this;this.rayCaster=new a.Raycaster;var t,i=this.settings,r=this.mousePosNormalized=new a.Vector2,s=this.mousePos=new a.Vector2,o=this.container.get(0);$(this.domElement).on("mousemove",function(t){var i=o.getBoundingClientRect();s.x=t.clientX,s.y=t.clientY,r.x=(t.clientX-i.left)/i.width*2-1,r.y=2*-((t.clientY-i.top)/i.height)+1,e.needsRender=!0}).on("mousedown",function(e){t=Date.now()}).on("mouseup",function(a){Date.now()-t>i.clickInterval||(e.hoveredBar&&a.shiftKey?(e.selectedBar=e.hoveredBar,e.animateCamera(e.selectedBar.position,function(){e.selectedBar&&(e.orbitControls.center.copy(e.selectedBar.position.clone().normalize().multiplyScalar(i.earthRadius)),e.orbitControls.minDistance=1)})):e.selectedBar&&(e.animateCamera(e.selectedBar.position,function(){e.orbitControls.center.set(0,0,0),e.orbitControls.minDistance=i.earthRadius+1}),e.selectedBar=null))}).on("mousewheel DOMMouseScroll",function(t){if(e.needsRender=!0,e.orbitControls.enabled&&e.orbitControls.enableZoom){e.heatTexture.needsUpdate=!0,t=t.originalEvent;var i=t.wheelDelta>0||t.detail<0?1:-1,a=i>0?e.settings.heatmapScaleOnZoom:1/e.settings.heatmapScaleOnZoom;e.heatmap.multiply(a),e.heatmap.update()}})},o.prototype.intersectBars=function(){if(this.rayCaster&&this.barsGroup){var e=this.rayCaster;e.setFromCamera(this.mousePosNormalized,this.camera);var i=e.intersectObjects(this.barsGroup.children);if(i&&i.length>0){var a=i[0].object;if(!a||!a.toolTipData)return;var r=a.toolTipData,s=[];r.location.displayName&&s.push(r.location),r.series&&s.push(r.series),r.height.displayName&&s.push(r.height),r.heat.displayName&&s.push(r.heat),this.hoveredBar=a,t.TooltipManager.ToolTipInstance.show(s,{x:this.mousePos.x,y:this.mousePos.y,width:0,height:0})}else this.hoveredBar=null,t.TooltipManager.ToolTipInstance.hide()}},o.prototype.animateCamera=function(e,t){var i=this;if(this.camera){var r=Date.now(),s=this.settings.cameraAnimDuration,o=r+s,n=this.camera.position.clone().normalize(),l=e.clone().normalize(),c=this.camera.position.length(),u=function(e){return e*=2,1>e?e*e*e/2:(e-=2,(e*e*e+2)/2)},h=function(){var e=Date.now(),p=(e-r)/s;p>1&&(p=1),p=u(p);var d=(new a.Vector3).add(n.clone().multiplyScalar(1-p)).add(l.clone().multiplyScalar(p)).normalize().multiplyScalar(c);i.camera.position=d,o>e?requestAnimationFrame(h):t&&t(),i.needsRender=!0};requestAnimationFrame(h)}},o.prototype.destroy=function(){if(clearTimeout(this.deferredRenderTimerId),this.renderLoopEnabled=!1,this.scene=null,this.heatmap=null,this.heatTexture=null,this.camera=null,this.renderer){if(this.renderer.context){var e=this.renderer.context.getExtension("WEBGL_lose_context");e&&e.loseContext(),this.renderer.context=null}this.renderer.domElement=null}this.renderer=null,this.data=null,this.barsGroup=null,this.orbitControls&&this.orbitControls.dispose(),this.orbitControls=null,this.domElement&&$(this.domElement).off("mousemove mouseup mousedown mousewheel DOMMouseScroll"),this.domElement=null,this.container&&this.container.empty()},o.prototype.initZoomControl=function(){var e=this,t=17,i=8.5*t,a=8.5*t,r=3*t,s=t+3,o=2*t,n={position:"absolute",left:"calc(100% - "+i+"px)",top:"calc(100% - "+a+"px)",zIndex:"1000"},l=d3.select(this.container[0]).append("div").style(n);this.zoomControl=l.append("svg").attr({width:i,height:a});var c=this.zoomControl.append("g").on("click",function(){return e.rotateCam(0,-5)});c.append("circle").attr({cx:r+o,cy:s+2*o,r:t,fill:"white",opacity:.5,stroke:"gray"}),c.append("path").attr({d:"M"+(r+2*t)+" "+(s+4.7*t)+" l12 -20 a40,70 0 0,1 -24,0z",fill:"gray"});var u=this.zoomControl.append("g").on("click",function(){return e.rotateCam(5,0)});u.append("circle").attr({cx:r,cy:s+o,r:t,fill:"white",stroke:"gray",opacity:.5}),u.append("path").attr({d:"M"+(r-t/1.5)+" "+(s+2*t)+" l20 -12 a70,40 0 0,0 0,24z",fill:"gray"});var h=this.zoomControl.append("g").on("click",function(){return e.rotateCam(0,5)});h.append("circle").attr({cx:r+o,cy:s,r:t,fill:"white",stroke:"gray",opacity:.5}),h.append("path").attr({d:"M"+(r+2*t)+" "+(s-t/1.5)+" l12 20 a40,70 0 0,0 -24,0z",fill:"gray"});var p=this.zoomControl.append("g").on("click",function(){return e.rotateCam(-5,0)});p.append("circle").attr({cx:r+2*o,cy:s+o,r:t,fill:"white",stroke:"gray",opacity:.5}),p.append("path").attr({d:"M"+(r+4.7*t)+" "+(s+2*t)+" l-20 -12 a70,40 0 0,1 0,24z",fill:"gray"});var d=this.zoomControl.append("g").on("click",function(){return e.zoomClicked(-1)});d.append("circle").attr({cx:r+4*t,cy:s+6*t,r:t,fill:"white",stroke:"gray",opacity:.5}),d.append("rect").attr({x:r+3.5*t,y:s+5.9*t,width:t,height:t/3,fill:"gray"}),d.append("rect").attr({x:r+4*t-t/6,y:s+5.55*t,width:t/3,height:t,fill:"gray"});var g=this.zoomControl.append("g").on("click",function(){return e.zoomClicked(1)});g.append("circle").attr({cx:r,cy:s+6*t,r:t,fill:"white",stroke:"gray",opacity:"0.50"}),g.append("rect").attr({x:r-t/2,y:s+5.9*t,width:t,height:t/3,fill:"gray"})},o.prototype.initMercartorSphere=function(){if(!o.MercartorSphere){var e=function(e,t,i){function r(e,t,i){return(1-i)*e+i*t}function s(e,t,i){var s=2*Math.PI,o=Math.PI,n=this.radius,l=-n*Math.cos(e*s)*Math.sin(t*o),c=-n*Math.cos(t*o),u=n*Math.sin(e*s)*Math.sin(t*o),h=e*n*2-n,p=t*n*2-n,d=0,g=r(l,h,i),m=r(c,p,i),y=r(u,d,i);return new a.Vector3(g,m,y)}function o(e,t,i){var r=90*(t-.5)*2/180*Math.PI,s=Math.sin(r),o=.5+.25*Math.log((1+s)/(1-s))/Math.PI;return new a.Vector2(e,o)}a.Geometry.call(this),this.radius=e,this.widthSegments=t,this.heightSegments=i,this.t=0;var n,l,c=[],u=[];for(l=0;i>=l;l++){var h=[],p=[];for(n=0;t>=n;n++){var d=n/t,g=l/i;this.vertices.push(s.call(this,d,g,this.t)),p.push(o.call(this,d,g,this.t)),h.push(this.vertices.length-1)}c.push(h),u.push(p)}for(l=0;l<this.heightSegments;l++)for(n=0;n<this.widthSegments;n++){var m=c[l][n+1],y=c[l][n],f=c[l+1][n],v=c[l+1][n+1],x=this.vertices[m].clone().normalize(),b=this.vertices[y].clone().normalize(),S=this.vertices[f].clone().normalize(),w=this.vertices[v].clone().normalize(),C=u[l][n+1].clone(),P=u[l][n].clone(),D=u[l+1][n].clone(),A=u[l+1][n+1].clone(),T=[x,b,S,w];this.faces.push(new a.Face4(m,y,f,v,T)),this.faceVertexUvs[0].push([C,P,D,A])}this.computeCentroids(),this.computeFaceNormals(),this.boundingSphere=new a.Sphere(new a.Vector3,e)};e.prototype=Object.create(a.Geometry.prototype),o.MercartorSphere=e}},o.prototype.getBingMapCanvas=function(e){function t(a,r){e>=a&&(a===e&&i(r),t(a+1,r+"0"),t(a+1,r+"1"),t(a+1,r+"2"),t(a+1,r+"3"))}function i(t){var i="https://t{server}.tiles.virtualearth.net/tiles/r{quad}.jpeg?g=0&mkt={language}",s=7,l=Math.round(Math.random()*s),u=navigator.languages&&navigator.languages.length?navigator.languages[0]:navigator.language,p=i.replace("{server}",l).replace("{quad}",t).replace("{language}",u),d=a(t),g=new Image;g.onload=function(){n++,h.drawImage(g,d.x*r,d.y*r,r,r),n===o&&c.trigger("ready",e)},g.crossOrigin="",g.src=p}function a(e){for(var t=0,i=0,a=e.length-1,r=a;r>=0;r--){var s=e.charAt(r),o=Math.pow(2,a-r);"1"===s?t+=o:"2"===s?i+=o:"3"===s&&(t+=o,i+=o)}return{x:t,y:i}}var r=256,s=Math.pow(2,e),o=s*s,n=0,l=r*s,c=$("<canvas/>").attr({width:l,height:l}),u=c.get(0),h=u.getContext("2d");return t(0,""),c},o.capabilities={dataRoles:[{name:"Category",kind:e.VisualDataRoleKind.Grouping,displayName:e.data.createDisplayNameGetter("Role_DisplayName_Location"),preferredTypes:[{geography:{address:!0}},{geography:{city:!0}},{geography:{continent:!0}},{geography:{country:!0}},{geography:{county:!0}},{geography:{place:!0}},{geography:{postalCode:!0}},{geography:{region:!0}},{geography:{stateOrProvince:!0}}]},{name:"Series",kind:e.VisualDataRoleKind.Grouping,displayName:"Legend"},{name:"X",kind:e.VisualDataRoleKind.Measure,displayName:"Longitude",description:"Use to override the longitude of locations",preferredTypes:[{geography:{longitude:!0}}]},{name:"Y",kind:e.VisualDataRoleKind.Measure,displayName:"Latitude",description:"Use to override the latitude of locations",preferredTypes:[{geography:{latitude:!0}}]},{name:"Height",kind:e.VisualDataRoleKind.Measure,displayName:"Bar Height"},{name:"Heat",kind:e.VisualDataRoleKind.Measure,displayName:"Heat Intensity"}],objects:{general:{displayName:e.data.createDisplayNameGetter("Visual_General"),properties:{formatString:{type:{formatting:{formatString:!0}}}}},legend:{displayName:e.data.createDisplayNameGetter("Visual_Legend"),properties:{show:{displayName:e.data.createDisplayNameGetter("Visual_Show"),type:{bool:!0}},position:{displayName:e.data.createDisplayNameGetter("Visual_LegendPosition"),type:{formatting:{legendPosition:!0}}},showTitle:{displayName:e.data.createDisplayNameGetter("Visual_LegendShowTitle"),type:{bool:!0}},titleText:{displayName:e.data.createDisplayNameGetter("Visual_LegendTitleText"),type:{text:!0}}}},dataPoint:{displayName:e.data.createDisplayNameGetter("Visual_DataPoint"),properties:{defaultColor:{displayName:e.data.createDisplayNameGetter("Visual_DefaultColor"),type:{fill:{solid:{color:!0}}}},showAllDataPoints:{displayName:e.data.createDisplayNameGetter("Visual_DataPoint_Show_All"),type:{bool:!0}},fill:{displayName:e.data.createDisplayNameGetter("Visual_Fill"),type:{fill:{solid:{color:!0}}}},fillRule:{displayName:e.data.createDisplayNameGetter("Visual_Gradient"),type:{fillRule:{}},rule:{inputRole:"Gradient",output:{property:"fill",selector:["Category"]}}}}},categoryLabels:{displayName:e.data.createDisplayNameGetter("Visual_CategoryLabels"),properties:{show:{displayName:e.data.createDisplayNameGetter("Visual_Show"),type:{bool:!0}},color:{displayName:e.data.createDisplayNameGetter("Visual_LabelsFill"),type:{fill:{solid:{color:!0}}}}}}},dataViewMappings:[{conditions:[{Category:{max:1},Series:{max:1},Height:{max:1},Heat:{max:1}}],categorical:{categories:{"for":{"in":"Category"},dataReductionAlgorithm:{top:{}}},values:{group:{by:"Series",select:[{bind:{to:"Height"}},{bind:{to:"Heat"}},{bind:{to:"X"}},{bind:{to:"Y"}}],dataReductionAlgorithm:{top:{}}}},rowCount:{preferred:{min:2}}}}],sorting:{custom:{}}},o.Properties={general:{formatString:{objectName:"general",propertyName:"formatString"}},dataPoint:{fill:{objectName:"dataPoint",propertyName:"fill"}}},o}();o.GlobeMap=l}(o=t.samples||(t.samples={}))}(t=e.visuals||(e.visuals={}))}(o||(o={}))},function(e,t){var i,a=window.jsCommon,i=window.powerbi;window.powerbitests,window.InJs,window.debug,window.jasmine,window.Microsoft;!function(e){var t;!function(t){var i;!function(i){var r=a.CssConstants.createClassAndSelector,s=a.PixelConverter,o=function(){function e(){}return e.prototype.bindEvents=function(e,t){var i=this.selection=e.selection,a=e.clearCatcher;i.on("click",function(e){t.handleSelection(e,d3.event.ctrlKey),d3.event.stopPropagation()}),a.on("click",function(){t.handleClearSelection()})},e.prototype.renderSelection=function(e){this.selection.style("opacity",function(t){return e&&!t.selected?n.DimmedAreaFillOpacity:n.NodeFillOpacity})},e}();i.RadarChartWebBehavior=o;var n=function(){function i(e){e&&(e.svg&&(this.svg=e.svg),e.animator&&(this.animator=e.animator),e.margin&&(this.margin=e.margin))}return i.converter=function(e,r){if(!(e&&e.categorical&&e.categorical.categories&&e.categorical.categories.length>0&&e.categorical.categories[0]&&e.categorical.values&&e.categorical.values.length>0&&r))return{legendData:{dataPoints:[]},settings:{showLegend:!0},series:[],dataLabelsSettings:t.dataLabelUtils.getDefaultPointLabelSettings()};for(var s=e.categorical,o=s.values,n=s&&s.values?s.values.grouped():null,l=[],c=new t.ColorHelper(r,i.Properties.dataPoint.fill),u={fontSize:8.25,dataPoints:[],title:""},h=i.parseSettings(e),p=i.parseLabelSettings(e),d=0,g=o.length;g>d;d++){var m,y,f,v=r.getColorByIndex(d).value,x=[],b=n&&n.length>d&&n[d].values?n[d]:null;if(o[d].source){var S=o[d].source;if(S.queryName&&(y=S.queryName,m=t.SelectionId.createWithMeasure(y)),S.displayName&&(f=S.displayName),S.objects){var w=S.objects;v=c.getColorForMeasure(w,y)}}u.dataPoints.push({label:f,color:v,icon:t.LegendIcon.Box,selected:!1,identity:m});for(var C=0,P=o[d].values.length;P>C;C++){var D=t.SelectionIdBuilder.builder().withMeasure(y).withCategory(s.categories[0],C).withSeries(e.categorical.values,b).createSelectionId(),A=t.TooltipBuilder.createTooltipInfo(i.formatStringProp,s,s.categories[0].values[C],o[d].values[C],null,null,d),T=t.valueFormatter.getFormatString(s.values[d].source,i.formatStringProp),V=a.PixelConverter.fromPoint(p.fontSize);x.push({x:C,y:o[d].values[C],color:v,identity:D,selected:!1,tooltipInfo:A,value:o[d].values[C],labelFormatString:T,labelFontSize:V})}x.length>0&&l.push({fill:v,name:f,data:x,identity:m})}return{legendData:u,settings:h,series:l,dataLabelsSettings:p}},i.prototype.init=function(e){var a=e.element;this.svg||(this.svg=d3.select(a.get(0)).append("svg"),this.svg.style("position","absolute")),this.margin||(this.margin=i.DefaultMargin),this.svg.classed(i.VisualClassName,!0),this.interactivityService=t.createInteractivityService(e.host),this.isInteractiveChart=e.interactivity&&e.interactivity.isInteractiveLegend,this.legend=t.createLegend(a,this.isInteractiveChart,this.interactivityService,!0,t.LegendPosition.Top),this.colors=e.style.colorPalette.dataColors,this.mainGroupElement=this.svg.append("g"),this.segments=this.mainGroupElement.append("g").classed(i.Segments["class"],!0),this.zeroSegment=this.mainGroupElement.append("g").classed(i.ZeroSegment["class"],!0),this.axis=this.mainGroupElement.append("g").classed(i.Axis["class"],!0),this.chart=this.mainGroupElement.append("g").classed(i.Chart["class"],!0)},i.prototype.update=function(e){if(e.dataViews&&e.dataViews[0]){var a=e.dataViews[0];this.radarChartData=i.converter(a,this.colors);var r,s=[],o=this.radarChartData.series,n=t.AnimatorCommon.GetAnimationDuration(this.animator,e.suppressAnimations);a.categorical&&a.categorical.categories&&a.categorical.categories[0]&&a.categorical.categories[0].values&&(s=a.categorical.categories[0].values),a.metadata&&a.metadata.columns&&a.metadata.columns.length>0&&(r=a.metadata.columns[0]),this.viewport={height:e.viewport.height>0?e.viewport.height:0,width:e.viewport.width>0?e.viewport.width:0},this.parseLegendProperties(a),this.renderLegend(this.radarChartData),this.updateViewport(),this.svg.attr({height:this.viewport.height,width:this.viewport.width});var l=this.mainGroupElement;l.attr("transform",t.SVGUtil.translate(this.viewport.width/2,this.viewport.height/2));var c=this.viewport.width-this.margin.left-this.margin.right,u=this.viewport.height-this.margin.top-this.margin.bottom;this.angle=i.Radians/s.length,this.radius=i.SegmentFactor*i.Scale*Math.min(c,u)/2,this.drawCircularSegments(s),this.drawAxes(s),this.drawAxesLabels(s,r),this.drawChart(o,n),this.drawDataLabels(o),this.drawZeroCircularSegment(s),0!==this.zeroPointRadius?this.drawZeroLabel():this.mainGroupElement.selectAll(i.ZeroLabel.selector).remove()}},i.prototype.getRadarChartLabelLayout=function(e,i){var a=t.dataLabelUtils.createColumnFormatterCacheManager(),r=this.angle,o=this.viewport,n=this.viewport.height/2,l=this.viewport.width/2,c=this.calculateChartDomain(this.radarChartData.series);return{labelText:function(r){var s=a.getOrCreate(r.labelFormatString,e);if(0===e.displayUnits){var n=_.max(i,function(e){return e.value}),l=n.value>0?n.value:0;s=a.getOrCreate(r.labelFormatString,e,l)}return t.dataLabelUtils.getLabelFormattedText({label:s.format(r.value),maxWidth:o.width,fontSize:e.fontSize})},labelLayout:{x:function(e){return-1*c(e.y)*Math.sin(e.x*r)+l},y:function(e){return-1*c(e.y)*Math.cos(e.x*r)+n-7;
11}},filter:function(e){return null!=e&&null!=e.value},style:{fill:e.labelColor,"font-size":function(t){return s.fromPoint(e.fontSize)}}}},i.prototype.drawCircularSegments=function(e){for(var a=[],r=this.angle,s=i.SegmentFactor,o=i.SegmentLevels,n=this.radius,l=0;o-1>l;l++)for(var c=n*((l+1)/o),u=-1*c,h=0;h<e.length;h++)a.push({x1:c*(1-s*Math.sin(h*r)),y1:c*(1-s*Math.cos(h*r)),x2:c*(1-s*Math.sin((h+1)*r)),y2:c*(1-s*Math.cos((h+1)*r)),translate:t.SVGUtil.translate(u,u)});var p=this.mainGroupElement.select(i.Segments.selector).selectAll(i.SegmentNode.selector).data(a);p.enter().append("svg:line").classed(i.SegmentNode["class"],!0),p.attr({x1:function(e){return e.x1},y1:function(e){return e.y1},x2:function(e){return e.x2},y2:function(e){return e.y2},transform:function(e){return e.translate}}),p.exit().remove()},i.prototype.drawDataLabels=function(e){var i=this.getAllDataPointsList(e);if(this.radarChartData.dataLabelsSettings.show){var a=this.getRadarChartLabelLayout(this.radarChartData.dataLabelsSettings,i),r=this.viewport,s=t.dataLabelUtils.drawDefaultLabelsForDataPointChart(i,this.mainGroupElement,a,r);s.attr("transform",t.SVGUtil.translate(-(r.width/2),-(r.height/2)))}else t.dataLabelUtils.cleanDataLabels(this.mainGroupElement)},i.prototype.drawAxes=function(e){var t=this.angle,a=-1*this.radius,r=this.mainGroupElement.select(i.Axis.selector).selectAll(i.AxisNode.selector),s=r.data(e);s.enter().append("svg:line"),s.attr({x1:0,y1:0,x2:function(e,i){return a*Math.sin(i*t)},y2:function(e,i){return a*Math.cos(i*t)}}).classed(i.AxisNode["class"],!0),s.exit().remove()},i.prototype.drawAxesLabels=function(a,r){var s=this,o=this.angle,n=-1*this.radius,l=a.length,c=t.valueFormatter.create({format:t.valueFormatter.getFormatString(r,i.formatStringProp,!0),value:a[0],value2:a[l-1]}),u=this.mainGroupElement.select(i.Axis.selector).selectAll(i.AxisLabel.selector),h=u.data(a);h.enter().append("svg:text"),h.attr({"text-anchor":"middle",dy:"1.5em",transform:t.SVGUtil.translate(0,-10),x:function(e,t){return(n-30)*Math.sin(t*o)},y:function(e,t){return(n-20)*Math.cos(t*o)}}).text(function(t){var a={fontFamily:i.AxesLabelsFontFamily,fontSize:i.AxesLabelsfontSize,text:c.format(t)};return e.TextMeasurementService.getTailoredTextOrDefault(a,Math.min(i.AxesLabelsMaxWidth,s.viewport.width))}).classed(i.AxisLabel["class"],!0),h.exit().remove()},i.prototype.drawChart=function(e,a){var r=this.angle,s=5,n=this.getDataPoints(e),l=d3.layout.stack(),c=l(n),u=this.calculateChartDomain(e),h=function(e){return e.map(function(e){var t=-1*u(e.y)*Math.sin(e.x*r),i=-1*u(e.y)*Math.cos(e.x*r);return t+","+i}).join(" ")},p=this.chart.selectAll(i.ChartArea.selector).data(c);p.enter().append("g").classed(i.ChartArea["class"],!0);var d=p.selectAll(i.ChartPolygon.selector).data(function(e){return e&&e.length>0?[e]:[]});d.enter().append("polygon").classed(i.ChartPolygon["class"],!0),d.style("fill",function(e){return e[0].color}).style("opacity",i.DimmedAreaFillOpacity).on("mouseover",function(e){d3.select(this).transition().duration(a).style("opacity",i.AreaFillOpacity)}).on("mouseout",function(e){d3.select(this).transition().duration(a).style("opacity",i.DimmedAreaFillOpacity)}).attr("points",h),d.exit().remove(),p.exit().remove();var g=this.chart.selectAll(i.ChartNode.selector).data(c);g.enter().append("g").classed(i.ChartNode["class"],!0);var m=g.selectAll(i.ChartDot.selector).data(function(e){return e.filter(function(e){return null!=e.y})});m.enter().append("svg:circle").classed(i.ChartDot["class"],!0),m.attr("r",s).attr({cx:function(e){return-1*u(e.y)*Math.sin(e.x*r)},cy:function(e){return-1*u(e.y)*Math.cos(e.x*r)}}).style("fill",function(e){return e.color}),m.exit().remove(),t.TooltipManager.addTooltip(m,function(e){return e.data.tooltipInfo},!0),g.exit().remove();var y=void 0;if(this.interactivityService){var f=this.getAllDataPointsList(e);y={selection:m,clearCatcher:this.svg},this.interactivityService.bind(f,new o,y)}},i.prototype.calculateChartDomain=function(e){var t=this.radius,i=this.getAllDataPointsList(e),a=d3.min(i,function(e){return e.y}),r=d3.max(i,function(e){return e.y});this.isPercentChart(i)&&(a=a>=0?0:-1,r=0>=r?0:1);var s=d3.scale.linear().domain([a,r]).range([0,t]);return this.zeroPointRadius=0>a&&r>0?s(0):0,s},i.prototype.renderLegend=function(e){if(e.legendData){var i=e.legendData;if(this.legendObjectProperties){t.LegendData.update(i,this.legendObjectProperties);var a=this.legendObjectProperties[t.legendProps.position];a&&this.legend.changeOrientation(t.LegendPosition[a])}else this.legend.changeOrientation(t.LegendPosition.Top);var r=this.viewport;this.legend.drawLegend(i,{height:r.height,width:r.width}),t.Legend.positionChartArea(this.svg,this.legend)}},i.prototype.drawZeroCircularSegment=function(e){for(var a=[],r=this.angle,s=i.SegmentFactor,o=this.zeroPointRadius,n=-1*o,l=0;l<e.length;l++)a.push({x1:o*(1-s*Math.sin(l*r)),y1:o*(1-s*Math.cos(l*r)),x2:o*(1-s*Math.sin((l+1)*r)),y2:o*(1-s*Math.cos((l+1)*r)),translate:t.SVGUtil.translate(n,n)});var c=this.mainGroupElement.select(i.ZeroSegment.selector).selectAll(i.ZeroSegmentNode.selector).data(a);c.enter().append("svg:line").classed(i.ZeroSegmentNode["class"],!0),c.attr({x1:function(e){return e.x1},y1:function(e){return e.y1},x2:function(e){return e.x2},y2:function(e){return e.y2},transform:function(e){return e.translate}}),c.exit().remove()},i.prototype.drawZeroLabel=function(){var e=[];e.push({x:this.zeroPointRadius*(1-i.SegmentFactor)+5,y:-1*this.zeroPointRadius});var t=this.mainGroupElement.select(i.ZeroSegment.selector).selectAll(i.ZeroLabel.selector).data(e);t.enter().append("text").classed(i.ZeroLabel["class"],!0).text("0"),t.attr({x:function(e){return e.x},y:function(e){return e.y}})},i.prototype.getDataPoints=function(e){for(var t=[],i=0;i<e.length;i++)t.push(e[i].data);return t},i.prototype.getAllDataPointsList=function(e){for(var t=[],i=0;i<e.length;i++)t=t.concat(e[i].data);return t},i.prototype.isPercentChart=function(e){for(var t=0;t<e.length;t++)if(-1===e[t].labelFormatString.indexOf("%"))return!1;return!0},i.prototype.parseLegendProperties=function(t){return t&&t.metadata?void(this.legendObjectProperties=e.DataViewObjects.getObject(t.metadata.objects,"legend",{})):void(this.legendObjectProperties={})},i.parseSettings=function(t){var a;return a=t&&t.metadata&&t.metadata.columns&&t.metadata.objects?t.metadata.objects:null,{showLegend:e.DataViewObjects.getValue(a,i.Properties.legend.show,!0)}},i.getPrecision=function(e){return Math.max(i.MinPrecision,Math.min(i.MaxPrecision,e))},i.parseLabelSettings=function(a){var r;r=a&&a.metadata&&a.metadata.objects?a.metadata.objects:null;var s=t.dataLabelUtils.getDefaultPointLabelSettings(),o={show:e.DataViewObjects.getValue(r,i.Properties.labels.show,s.show),labelColor:e.DataViewObjects.getFillColor(r,i.Properties.labels.color,s.labelColor),displayUnits:e.DataViewObjects.getValue(r,i.Properties.labels.displayUnits,s.displayUnits),precision:i.getPrecision(e.DataViewObjects.getValue(r,i.Properties.labels.precision,s.precision)),fontSize:e.DataViewObjects.getValue(r,i.Properties.labels.fontSize,s.fontSize),position:s.position};return o},i.prototype.enumerateObjectInstances=function(e){var i,a=new t.ObjectEnumerationBuilder;if(!this.radarChartData||!this.radarChartData.settings)return[];switch(i=this.radarChartData.settings,e.objectName){case"legend":a.pushInstance(this.enumerateLegend(i));break;case"dataPoint":this.enumerateDataPoint(a);break;case"labels":this.enumerateDataLabels(a)}return a.complete()},i.prototype.getLabelSettingsOptions=function(e,t){return{enumeration:e,dataLabelsSettings:t,show:!0,displayUnits:!0,precision:!0,fontSize:!0}},i.prototype.enumerateDataLabels=function(e){var i=this.radarChartData.dataLabelsSettings;t.dataLabelUtils.enumerateDataLabels(this.getLabelSettingsOptions(e,i))},i.prototype.enumerateLegend=function(i){var a,r,s=!0,o="",n=8;return s=e.DataViewObject.getValue(this.legendObjectProperties,t.legendProps.showTitle,s),o=e.DataViewObject.getValue(this.legendObjectProperties,t.legendProps.titleText,o),r=e.DataViewObject.getValue(this.legendObjectProperties,t.legendProps.labelColor,r),n=e.DataViewObject.getValue(this.legendObjectProperties,t.legendProps.fontSize,n),a={objectName:"legend",displayName:"legend",selector:null,properties:{show:i.showLegend,position:t.LegendPosition[this.legend.getOrientation()],showTitle:s,titleText:o,labelColor:r,fontSize:n}}},i.prototype.enumerateDataPoint=function(e){if(this.radarChartData&&this.radarChartData.series)for(var i=this.radarChartData.series,a=0;a<i.length;a++){var r=i[a];e.pushInstance({objectName:"dataPoint",displayName:r.name,selector:t.ColorHelper.normalizeSelector(r.identity.getSelector(),!1),properties:{fill:{solid:{color:r.fill}}}})}},i.prototype.updateViewport=function(){var e,i=this.legend.getMargins();switch(e=t.LegendPosition[this.legendObjectProperties[t.legendProps.position]]){case t.LegendPosition.Top:case t.LegendPosition.TopCenter:case t.LegendPosition.Bottom:case t.LegendPosition.BottomCenter:this.viewport.height-=i.height;break;case t.LegendPosition.Left:case t.LegendPosition.LeftCenter:case t.LegendPosition.Right:case t.LegendPosition.RightCenter:this.viewport.width-=i.width}},i.capabilities={dataRoles:[{displayName:"Category",name:"Category",kind:e.VisualDataRoleKind.Grouping},{displayName:"Y Axis",name:"Y",kind:e.VisualDataRoleKind.Measure}],dataViewMappings:[{conditions:[{Category:{min:1,max:1}}],categorical:{categories:{"for":{"in":"Category"},dataReductionAlgorithm:{top:{}}},values:{select:[{bind:{to:"Y"}}]}}}],objects:{general:{displayName:e.data.createDisplayNameGetter("Visual_General"),properties:{formatString:{type:{formatting:{formatString:!0}}}}},legend:{displayName:e.data.createDisplayNameGetter("Visual_Legend"),description:e.data.createDisplayNameGetter("Visual_LegendDescription"),properties:{show:{displayName:e.data.createDisplayNameGetter("Visual_Show"),type:{bool:!0}},position:{displayName:e.data.createDisplayNameGetter("Visual_LegendPosition"),description:e.data.createDisplayNameGetter("Visual_LegendPositionDescription"),type:{enumeration:t.legendPosition.type}},showTitle:{displayName:e.data.createDisplayNameGetter("Visual_LegendShowTitle"),description:e.data.createDisplayNameGetter("Visual_LegendShowTitleDescription"),type:{bool:!0}},titleText:{displayName:e.data.createDisplayNameGetter("Visual_LegendName"),description:e.data.createDisplayNameGetter("Visual_LegendNameDescription"),type:{text:!0},suppressFormatPainterCopy:!0},labelColor:{displayName:e.data.createDisplayNameGetter("Visual_LegendTitleColor"),type:{fill:{solid:{color:!0}}}},fontSize:{displayName:e.data.createDisplayNameGetter("Visual_TextSize"),type:{formatting:{fontSize:!0}}}}},dataPoint:{displayName:e.data.createDisplayNameGetter("Visual_DataPoint"),description:e.data.createDisplayNameGetter("Visual_DataPointDescription"),properties:{fill:{displayName:e.data.createDisplayNameGetter("Visual_Fill"),type:{fill:{solid:{color:!0}}}}}},labels:{displayName:e.data.createDisplayNameGetter("Visual_DataPointsLabels"),description:e.data.createDisplayNameGetter("Visual_DataPointsLabelsDescription"),properties:{show:{displayName:e.data.createDisplayNameGetter("Visual_Show"),type:{bool:!0}},color:{displayName:e.data.createDisplayNameGetter("Visual_LabelsFill"),description:e.data.createDisplayNameGetter("Visual_LabelsFillDescription"),type:{fill:{solid:{color:!0}}}},labelDisplayUnits:{displayName:e.data.createDisplayNameGetter("Visual_DisplayUnits"),description:e.data.createDisplayNameGetter("Visual_DisplayUnitsDescription"),type:{formatting:{labelDisplayUnits:!0}},suppressFormatPainterCopy:!0},labelPrecision:{displayName:e.data.createDisplayNameGetter("Visual_Precision"),description:e.data.createDisplayNameGetter("Visual_PrecisionDescription"),placeHolderText:e.data.createDisplayNameGetter("Visual_Precision_Auto"),type:{numeric:!0},suppressFormatPainterCopy:!0},fontSize:{displayName:e.data.createDisplayNameGetter("Visual_TextSize"),type:{formatting:{fontSize:!0}}}}}}},i.formatStringProp={objectName:"general",propertyName:"formatString"},i.Properties={legend:{show:{objectName:"legend",propertyName:"show"}},dataPoint:{fill:{objectName:"dataPoint",propertyName:"fill"}},labels:{show:{objectName:"labels",propertyName:"show"},color:{objectName:"labels",propertyName:"color"},displayUnits:{objectName:"labels",propertyName:"labelDisplayUnits"},precision:{objectName:"labels",propertyName:"labelPrecision"},fontSize:{objectName:"labels",propertyName:"fontSize"}}},i.VisualClassName="radarChart",i.Segments=r("segments"),i.SegmentNode=r("segmentNode"),i.ZeroSegment=r("zeroSegment"),i.ZeroSegmentNode=r("zeroSegmentNode"),i.ZeroLabel=r("zeroLabel"),i.Axis=r("axis"),i.AxisNode=r("axisNode"),i.AxisLabel=r("axisLabel"),i.Chart=r("chart"),i.ChartNode=r("chartNode"),i.ChartArea=r("chartArea"),i.ChartPolygon=r("chartPolygon"),i.ChartDot=r("chartDot"),i.MaxPrecision=17,i.MinPrecision=0,i.DefaultMargin={top:50,bottom:50,right:100,left:100},i.SegmentLevels=6,i.SegmentFactor=1,i.Radians=2*Math.PI,i.Scale=1,i.NodeFillOpacity=1,i.AreaFillOpacity=.6,i.DimmedAreaFillOpacity=.4,i.AxesLabelsFontFamily="sans-serif",i.AxesLabelsfontSize="11px",i.AxesLabelsMaxWidth=200,i}();i.RadarChart=n}(i=t.samples||(t.samples={}))}(t=e.visuals||(e.visuals={}))}(i||(i={}))},function(e,t){var i,a=window.jsCommon,i=window.powerbi;window.powerbitests,window.InJs,window.debug,window.jasmine,window.Microsoft;!function(e){var t;!function(t){var i;!function(i){var r=t.utility.SelectionManager,s=e.visuals.valueFormatter,o=t.AnimatorCommon.GetAnimationDuration,n=a.CssConstants.createClassAndSelector,l=a.PixelConverter,c=function(){function e(e){this.message=e}return Object.defineProperty(e.prototype,"code",{get:function(){return"BulletChartWarning"},enumerable:!0,configurable:!0}),e.prototype.getMessages=function(e){return{message:this.message,title:e.get(""),detail:e.get("")}},e.ErrorInvalidDataValues="Some data values are invalid or too big",e}();i.HistogramChartWarning=c;var u=function(){function i(e){this.ColumnPadding=1,this.MinColumnHeight=1,this.MinOpacity=.3,this.MaxOpacity=1,this.TooltipDisplayName="Range",this.SeparatorNumbers=", ",this.LegendSize=50,this.YLegendSize=50,this.XLegendSize=50,this.AxisSize=30,this.DataLabelMargin=0,this.widthOfColumn=0,this.yTitleMargin=0,this.outerPadding=5,this.ExcludeBrackets={left:"(",right:")"},this.IncludeBrackets={left:"[",right:"]"},this.margin={top:10,right:10,bottom:10,left:10},this.durationAnimations=200,this.oldInnerPaddingRatio=t.CartesianChart.InnerPaddingRatio,this.oldMinOrdinalRectThickness=t.CartesianChart.MinOrdinalRectThickness,this.textProperties={fontFamily:"wf_segoe-ui_normal",fontSize:l.toString(9)},e&&(e.svg&&(this.svg=e.svg),e.animator&&(this.animator=e.animator),this.margin=e.margin||this.margin)}return Object.defineProperty(i.prototype,"columnsSelection",{get:function(){return this.main.select(i.Columns.selector).selectAll(i.Column.selector)},enumerable:!0,configurable:!0}),i.prototype.init=function(e){this.hostService=e.host,this.svg?this.root=this.svg:this.root=d3.select(e.element.get(0)).append("svg");var a=e.style;this.colors=a&&a.colorPalette?a.colorPalette.dataColors:new t.DataColorPalette,this.root.classed(i.ClassName,!0),this.main=this.root.append("g"),this.axes=this.main.append("g").classed(i.Axes["class"],!0),this.axisX=this.axes.append("g").classed(i.Axis["class"],!0),this.axisY=this.axes.append("g").classed(i.Axis["class"],!0),this.legend=this.main.append("g").classed(i.Legends["class"],!0),this.columns=this.main.append("g").classed(i.Columns["class"],!0),this.labels=this.main.append("g").classed(i.Labels["class"],!0),this.selectionManager=new r({hostServices:e.host})},i.prototype.converter=function(e){if(!(e&&e.categorical&&e.categorical.categories&&e.categorical.categories[0]&&e.categorical.categories[0].values&&e.categorical.categories[0].values.length>0))return null;var t,a,r,o,n,l,c,u,h,p=[],d=[],g=[],m=0,y=0;if(e.categorical.values&&e.categorical.values[0]&&e.categorical.values[0].values&&(d=e.categorical.values[0].values),e.categorical.categories[0].identity&&e.categorical.categories[0].identity.length>0&&(g=e.categorical.categories[0].identity),t=this.parseSettings(e),!t)return null;r=i.getValuesByFrequencies(e.categorical.categories[0].values,d,g),r.forEach(function(e){p.push(e.value),y+=e.frequency}),a=d3.layout.histogram(),t.bins&&t.bins>i.MinNumberOfBins&&(a=a.bins(t.bins)),o=a.frequency(t.frequency)(p),o.forEach(function(e,a){var s,o;s=r.filter(function(t){return i.isValueContainedInRange(t,e,a)}),o=s.reduce(function(e,t){return e+t.frequency},0),e.y=t.frequency?o:o/y,m+=e.length});var f=t.yAxisSettings,v=null!==f.end&&f.end>f.start?f.end:d3.max(o,function(e){return e.y}),x=f.start<v?f.start:0;return t.yAxisSettings.end=v,t.yAxisSettings.start=x,t.maxX=d3.max(o,function(e){return d3.max(e)}),n=d3.scale.linear().domain([d3.min(o,function(e){return d3.min(e)}),d3.max(o,function(e){return d3.max(e)})]).range([0,this.viewport.width-this.YLegendSize-this.AxisSize]),l=d3.scale.linear().domain([x,v]).range([this.viewport.height-this.LegendSize,this.outerPadding]),c=s.create({format:s.getFormatString(e.categorical.categories[0].source,i.Properties.general.formatString),value:r[0].value,value2:r[r.length-1].value,precision:t.precision}),u=s.create({value:0===t.xAxisSettings.displayUnits?r[r.length-1].value:t.xAxisSettings.displayUnits,precision:t.xAxisSettings.precision}),h=s.create({value:t.yAxisSettings.displayUnits,precision:t.yAxisSettings.precision}),{xScale:n,yScale:l,settings:t,data:this.getData(r,p,o,t,h,u),formatter:c,xLabelFormatter:u,yLabelFormatter:h}},i.getValuesByFrequencies=function(e,i,a){var r=[];return e.forEach(function(e,s){var o=1,n=Number(e);n=isNaN(n)?0:n,i&&i[s]&&!isNaN(i[s])&&i[s]>1&&(o=i[s]),r.push({value:n,frequency:o,selectionId:t.SelectionId.createWithId(a[s])})}),r},i.prototype.getData=function(e,t,a,r,s,o){var n=this,c=d3.min(t),u=d3.max(t),h=l.fromPoint(r.labelSettings.fontSize);return a.map(function(t,a){return t.range=i.getRange(c,u,t.dx,a),t.tooltipInfo=n.getTooltipData(t.y,t.range,r,0===a,s,o),t.selectionIds=i.getSelectionIds(e,t,a),t.labelFontSize=h,t})},i.getRange=function(e,t,i,a){var r=e+a*i,s=r+i;return[r,s]},i.prototype.getTooltipData=function(e,t,a,r,s,o){return[{displayName:i.getLegendText(a),value:s.format(e)},{displayName:this.TooltipDisplayName,value:this.rangeToString(t,r,o)}]},i.getSelectionIds=function(e,t,a){var r=[];return e.forEach(function(e){i.isValueContainedInRange(e,t,a)&&r.push(e.selectionId)}),r},i.isValueContainedInRange=function(e,t,i){return(0===i&&e.value>=t.x||e.value>t.x)&&e.value<=t.x+t.dx},i.prototype.parseSettings=function(e){if(!(e&&e.metadata&&e.metadata.columns&&e.metadata.columns[0]))return null;var a,r,s={};r=new t.ColorHelper(this.colors,i.Properties.dataPoint.fill,i.DefaultHistogramSettings.fillColor),s.displayName=e.metadata.columns[0].displayName||i.DefaultHistogramSettings.displayName,a=i.getObjectsFromDataView(e);var o={axisColor:i.getXAxisColor(a).solid.color,title:i.getXTitle(a),precision:i.getXPrecision(a),style:i.getXStyle(a),displayUnits:i.getXDisplayUnit(a),show:i.getXAxisShow(a)},n={axisColor:i.getYAxisColor(a).solid.color,title:i.getYTitle(a),precision:i.getYPrecision(a),style:i.getYStyle(a),displayUnits:i.getYDisplayUnit(a),show:i.getYAxisShow(a),start:i.getYStart(a),end:i.getYEnd(a),position:i.getYPosition(a)},l={show:i.getLabelShow(a),color:i.getLabelColor(a).solid.color,displayUnits:i.getLabelDisplayUnits(a),precision:i.getLabelPrecision(a),fontSize:i.getLabelFontSize(a)};return s.fillColor=r.getColorForMeasure(a,""),s.bins=i.getBins(a),s.frequency=i.getFrequency(a),s.precision=i.getPrecision(a),s.displayName=i.getLegend(s.displayName,o.style,o.displayUnits),s.xAxisSettings=o,s.yAxisSettings=n,s.labelSettings=l,s},i.getLegend=function(e,i,a){var r,o=s.create({value:a});switch(i){case t.axisStyle.showTitleOnly:r=e;break;case t.axisStyle.showUnitOnly:r=0===a||1===a?e:o.displayUnit.title;break;case t.axisStyle.showBoth:r=0===a||1===a?e:e+" ("+o.displayUnit.title+")"}return r},i.getLabelFontSize=function(t){return e.DataViewObjects.getValue(t,i.Properties.labels.fontSize,i.DefaultHistogramSettings.labelSettings.fontSize)},i.getLabelShow=function(t){return e.DataViewObjects.getValue(t,i.Properties.labels.show,i.DefaultHistogramSettings.labelSettings.show)},i.getLabelColor=function(t){return e.DataViewObjects.getValue(t,i.Properties.labels.color,{solid:{color:i.DefaultHistogramSettings.labelSettings.color}})},i.getLabelDisplayUnits=function(t){return e.DataViewObjects.getValue(t,i.Properties.labels.displayUnits,i.DefaultHistogramSettings.labelSettings.displayUnits)},i.getLabelPrecision=function(t){var a=e.DataViewObjects.getValue(t,i.Properties.labels.precision,i.DefaultHistogramSettings.labelSettings.precision);return a<=i.MinPrecision?i.MinPrecision:a>=i.MaxPrecision?i.MaxPrecision:a},i.getXStyle=function(t){return e.DataViewObjects.getValue(t,i.Properties.xAxis.style,i.DefaultHistogramSettings.xAxisSettings.style)},i.getXDisplayUnit=function(t){return e.DataViewObjects.getValue(t,i.Properties.xAxis.displayUnits,i.DefaultHistogramSettings.xAxisSettings.displayUnits)},i.getXPrecision=function(t){var a=e.DataViewObjects.getValue(t,i.Properties.xAxis.precision,i.DefaultHistogramSettings.xAxisSettings.precision);return a<=i.MinPrecision?i.MinPrecision:a>=i.MaxPrecision?i.MaxPrecision:a},i.getXAxisShow=function(t){return e.DataViewObjects.getValue(t,i.Properties.xAxis.show,i.DefaultHistogramSettings.xAxisSettings.show)},i.getXAxisColor=function(t){return e.DataViewObjects.getValue(t,i.Properties.xAxis.axisColor,{solid:{color:i.DefaultHistogramSettings.xAxisSettings.axisColor}})},i.getXTitle=function(t){return e.DataViewObjects.getValue(t,i.Properties.xAxis.title,i.DefaultHistogramSettings.xAxisSettings.title)},i.getYStyle=function(t){return e.DataViewObjects.getValue(t,i.Properties.yAxis.style,i.DefaultHistogramSettings.yAxisSettings.style)},i.getYPosition=function(t){return e.DataViewObjects.getValue(t,i.Properties.yAxis.position,i.DefaultHistogramSettings.yAxisSettings.position)},i.getYAxisShow=function(t){return e.DataViewObjects.getValue(t,i.Properties.yAxis.show,i.DefaultHistogramSettings.yAxisSettings.show)},i.getYAxisColor=function(t){return e.DataViewObjects.getValue(t,i.Properties.yAxis.axisColor,{solid:{color:i.DefaultHistogramSettings.yAxisSettings.axisColor}})},i.getYStart=function(t){return e.DataViewObjects.getValue(t,i.Properties.yAxis.start,i.DefaultHistogramSettings.yAxisSettings.start)},i.getYEnd=function(t){return e.DataViewObjects.getValue(t,i.Properties.yAxis.end,i.DefaultHistogramSettings.yAxisSettings.end)},i.getYDisplayUnit=function(t){return e.DataViewObjects.getValue(t,i.Properties.yAxis.displayUnits,i.DefaultHistogramSettings.yAxisSettings.displayUnits)},i.getYPrecision=function(t){var a=e.DataViewObjects.getValue(t,i.Properties.yAxis.precision,i.DefaultHistogramSettings.yAxisSettings.precision);return a<=i.MinPrecision?i.MinPrecision:a>=i.MaxPrecision?i.MaxPrecision:a},i.getYTitle=function(t){return e.DataViewObjects.getValue(t,i.Properties.yAxis.title,i.DefaultHistogramSettings.yAxisSettings.title)},i.getBins=function(t){var a=Number(e.DataViewObjects.getValue(t,i.Properties.general.bins,i.DefaultHistogramSettings.bins));return!a||isNaN(a)||a<=i.MinNumberOfBins?i.DefaultHistogramSettings.bins:a>i.MaxNumberOfBins?i.MaxNumberOfBins:a},i.getFrequency=function(t){return e.DataViewObjects.getValue(t,i.Properties.general.frequency,i.DefaultHistogramSettings.frequency)},i.getPrecision=function(t){var a=e.DataViewObjects.getValue(t,i.Properties.labels.precision,i.DefaultHistogramSettings.precision);return a<=i.MinPrecision?i.MinPrecision:a>=i.MaxPrecision?i.MaxPrecision:a},i.prototype.validateData=function(e){return e&&e.data.some(function(e){return e.range.some(function(e){return isNaN(e)||e===1/0||e===-(1/0)})})?(this.hostService.setWarnings([new c(c.ErrorInvalidDataValues)]),!1):!0},i.prototype.update=function(e){if(e&&e.dataViews&&e.dataViews[0]){t.CartesianChart.InnerPaddingRatio=1;var i=e.dataViews[0];if(this.durationAnimations=o(this.animator,e.suppressAnimations),this.setSize(e.viewport),this.histogramDataView=this.converter(i),this.validateData(this.histogramDataView)||(this.histogramDataView.data=[]),this.histogramDataView){this.YLegendSize=this.histogramDataView.settings.yAxisSettings.title?50:25,this.XLegendSize=this.histogramDataView.settings.xAxisSettings.title?50:25,this.fixXTicSize(),this.xAxisProperties=this.calculateXAxes(i.categorical.categories[0].source,this.textProperties,!1);var a=i.categorical.values&&i.categorical.values[0]&&i.categorical.values[0].values?i.categorical.values[0].source:i.categorical.categories[0].source;this.yAxisProperties=this.calculateYAxes(a,this.textProperties,!1),this.render(),t.CartesianChart.InnerPaddingRatio=this.oldInnerPaddingRatio,t.CartesianChart.MinOrdinalRectThickness=this.oldMinOrdinalRectThickness}}},i.prototype.fixXTicSize=function(){if(this.histogramDataView&&this.histogramDataView.settings){var i=this.histogramDataView.xLabelFormatter.format(this.histogramDataView.settings.maxX),a={text:i,fontFamily:this.textProperties.fontFamily,fontSize:this.textProperties.fontSize},r=e.TextMeasurementService.measureSvgTextWidth(a);t.CartesianChart.MinOrdinalRectThickness=r+3}},i.prototype.setSize=function(e){var t,i;t=e.height-this.margin.top-this.margin.bottom,i=e.width-this.margin.left-this.margin.right,this.viewport={height:t,width:i},this.updateElements(e.height,e.width)},i.prototype.updateElements=function(e,i){this.root.attr({height:e,width:i}),this.main.attr("transform",t.SVGUtil.translate(this.margin.left,this.margin.top)),this.legend.attr("transform",t.SVGUtil.translate(this.margin.left,this.margin.top)),this.axisX.attr("transform",t.SVGUtil.translate(0,this.viewport.height-this.XLegendSize))},i.prototype.shouldShowYOnRight=function(){return this.histogramDataView.settings.yAxisSettings.position===t.yAxisPosition.right},i.prototype.columsAndAxesTransform=function(e){var i=20,a=this.shouldShowYOnRight()?10:this.histogramDataView.settings.yAxisSettings.title?this.margin.left+e+i:this.margin.left+e;this.DataLabelMargin=a,this.columns.attr("transform",t.SVGUtil.translate(a,0)),this.axes.attr("transform",t.SVGUtil.translate(a,0)),this.axisY.attr("transform",t.SVGUtil.translate(this.shouldShowYOnRight()?this.viewport.width-this.AxisSize-this.YLegendSize+.01:0,0)),this.axisX.attr("transform",t.SVGUtil.translate(0,this.viewport.height-this.XLegendSize))},i.prototype.render=function(){if(this.histogramDataView&&this.histogramDataView.settings){this.renderAxes();var e=this.renderColumns();this.adjustTransformToAxisLabels(),this.renderLegend(),this.histogramDataView.settings.labelSettings.show?this.renderLabels():this.main.selectAll(".labels").selectAll("*").remove(),this.bindSelectionHandler(e)}},i.prototype.adjustTransformToAxisLabels=function(){var t=0;this.main.selectAll("g.axis").filter(function(e,t){return 1===t}).selectAll("g.tick text").each(function(i,a){var r=e.TextMeasurementService.getSvgMeasurementProperties(this),s={text:r.text,fontFamily:r.fontFamily,fontSize:r.fontSize},o=e.TextMeasurementService.measureSvgTextWidth(s);o>t&&(t=o)});var i=70;this.yTitleMargin=this.shouldShowYOnRight()?this.viewport.width-this.AxisSize-i+this.YLegendSize+t:0,this.columsAndAxesTransform(t)},i.prototype.renderColumns=function(){var e,a,r=this,s=this.histogramDataView.data,o=this.histogramDataView.yScale,n=s.length;return e=n&&(this.viewport.width-this.AxisSize-this.YLegendSize)/n-this.ColumnPadding,0>e&&(e=0),this.widthOfColumn=e,a=this.columnsSelection.data(s),a.enter().append("svg:rect"),a.attr("x",this.ColumnPadding/2).attr("width",e).attr("height",function(e){return r.getColumnHeight(e,o)}).style("fill",this.histogramDataView.settings.fillColor).attr("class",i.Column["class"]).attr("transform",function(i,a){return t.SVGUtil.translate(e*a+r.ColumnPadding*a,o(i.y)-r.ColumnPadding/2.5)}),n&&a.classed(i.Column["class"]),a.exit().remove(),i.renderTooltip(a),a},i.renderTooltip=function(e){t.TooltipManager.addTooltip(e,function(e){return e.data.tooltipInfo})},i.prototype.getColumnHeight=function(e,t){var i=this.viewport.height-this.XLegendSize-t(e.y);return i>0?i:this.MinColumnHeight},i.prototype.renderAxes=function(){var e,t,i=this;e=this.xAxisProperties.axis.tickFormat(function(e){return i.histogramDataView.xLabelFormatter.format(e)}).orient("bottom"),t=this.yAxisProperties.axis.orient(this.histogramDataView.settings.yAxisSettings.position.toLowerCase()).tickFormat(function(e){return i.histogramDataView.yLabelFormatter.format(e)});var a=this.histogramDataView.settings.xAxisSettings.show,r=this.histogramDataView.settings.yAxisSettings.show;a?this.axisX.transition().duration(1).call(e):this.axisX.selectAll("*").remove(),r?this.axisY.call(t):this.axisY.selectAll("*").remove(),this.main.selectAll("g.axis").filter(function(e,t){return 0===t}).selectAll("g.tick text").style({fill:this.histogramDataView.settings.xAxisSettings.axisColor}),this.main.selectAll("g.axis").filter(function(e,t){return 1===t}).selectAll("g.tick text").style({fill:this.histogramDataView.settings.yAxisSettings.axisColor})},i.prototype.getLabaelLayout=function(){var e=this,t=this.histogramDataView.settings.labelSettings,i=l.fromPoint(t.fontSize),a=s.create({value:t.displayUnits,precision:t.precision});return{labelText:function(e){return a.format(e.y).toString()},labelLayout:{x:function(t){return e.DataLabelMargin+e.histogramDataView.xScale(t.x)+e.widthOfColumn/2},y:function(t){return e.histogramDataView.yScale(t.y)-5}},filter:function(e){return null!=e},style:{fill:t.color,"font-size":i}}},i.prototype.renderLabels=function(){var e=this.getLabaelLayout(),i=this.histogramDataView.data;t.dataLabelUtils.drawDefaultLabelsForDataPointChart(i,this.main,e,this.viewport)},i.rangesToArray=function(e){return e.reduce(function(e,t,i){var a;return a=0===i?t.range:t.range.slice(1),e.concat(a)},[])},i.prototype.rangeToString=function(e,t,i){var a,r=this.IncludeBrackets.right,s=i.format(e[0]),o=i.format(e[1]);return a=t?this.IncludeBrackets.left:this.ExcludeBrackets.left,""+a+s+this.SeparatorNumbers+o+r},i.prototype.renderLegend=function(){var e,t,a=this.getDataLegends(this.histogramDataView.settings);e=this.main.select(i.Legends.selector).selectAll(i.Legend.selector),t=e.data(a),t.enter().append("svg:text"),t.attr("x",0).attr("y",0).attr("dx",function(e){return e.dx}).attr("dy",function(e){return e.dy}).attr("transform",function(e){return e.transform}).attr("class",i.Legend["class"]).text(function(e){return e.text}).classed(i.Legend["class"],!0),t.exit().remove(),this.legend.select("text").style({display:this.histogramDataView.settings.xAxisSettings.title===!0?"block":"none"}),this.legend.selectAll("text").filter(function(e,t){return 1===t}).style({display:this.histogramDataView.settings.yAxisSettings.title===!0?"block":"none"})},i.prototype.getDataLegends=function(e){var a=i.getLegendText(e);return a=i.getLegend(a,e.yAxisSettings.style,e.yAxisSettings.displayUnits),[{transform:t.SVGUtil.translate(this.viewport.width/2,this.viewport.height),text:e.displayName,dx:"1em",dy:"-1em"},{transform:t.SVGUtil.translateAndRotate(this.shouldShowYOnRight()?this.yTitleMargin:0,this.viewport.height/2,0,0,270),text:a,dx:"3em"}]},i.getLegendText=function(e){return e.frequency?i.FrequencyText:i.DensityText},i.prototype.bindSelectionHandler=function(e){var t=this;this.setSelection(e),e.on("click",function(i){t.selectionManager.clear(),i.selectionIds.forEach(function(a){t.selectionManager.select(a,!0).then(function(a){a.length>0?t.setSelection(e,i):t.setSelection(e)})}),d3.event.stopPropagation()}),this.root.on("click",function(){t.selectionManager.clear(),t.setSelection(e)})},i.prototype.setSelection=function(e,t){e.transition().duration(this.durationAnimations).style("fill-opacity",this.MaxOpacity),t&&e.filter(function(e){return e!==t}).transition().duration(this.durationAnimations).style("fill-opacity",this.MinOpacity);
12},i.prototype.enumerateObjectInstances=function(e){var t,i=[];if(!this.histogramDataView||!this.histogramDataView.settings)return i;switch(t=this.histogramDataView.settings,e.objectName){case"general":var a={objectName:"general",displayName:"general",selector:null,properties:{bins:t.bins,frequency:t.frequency}};i.push(a);break;case"dataPoint":var r={objectName:"dataPoint",displayName:"dataPoint",selector:null,properties:{fill:t.fillColor}};i.push(r);break;case"labels":var s=t.labelSettings,o={objectName:"labels",displayName:"labels",selector:null,properties:{show:s.show,color:s.color,displayUnits:s.displayUnits,precision:s.precision,fontSize:s.fontSize}};i.push(o);break;case"xAxis":var n=t.xAxisSettings,l={objectName:"xAxis",displayName:"X-Axis",selector:null,properties:{show:n.show,title:n.title,style:n.style,axisColor:n.axisColor,displayUnits:n.displayUnits,precision:n.precision}};i.push(l);break;case"yAxis":var c=t.yAxisSettings,u={objectName:"yAxis",displayName:"Y-Axis",selector:null,properties:{show:c.show,position:c.position,start:c.start,end:c.end,title:c.title,style:c.style,axisColor:c.axisColor,displayUnits:c.displayUnits,precision:c.precision}};i.push(u)}return i},i.getObjectsFromDataView=function(e){return e&&e.metadata&&e.metadata.columns&&e.metadata.objects?e.metadata.objects:null},i.prototype.destroy=function(){this.root=null},i.prototype.calculateXAxes=function(a,r,s){var o={viewport:this.viewport,margin:this.margin,forcedXDomain:i.rangesToArray(this.histogramDataView.data),forceMerge:!0,showCategoryAxisLabel:!1,showValueAxisLabel:!1,categoryAxisScaleType:t.axisScale.linear,valueAxisScaleType:null,trimOrdinalDataOnOverflow:!1},n=this.viewport.width,l=this.calculateXAxesProperties(o,a);return l.willLabelsFit=t.AxisHelper.LabelLayoutStrategy.willLabelsFit(l,n,e.TextMeasurementService.measureSvgTextWidth,r),l.willLabelsWordBreak=!l.willLabelsFit&&!s&&t.AxisHelper.LabelLayoutStrategy.willLabelsWordBreak(l,this.margin,n,e.TextMeasurementService.measureSvgTextWidth,e.TextMeasurementService.estimateSvgTextHeight,e.TextMeasurementService.getTailoredTextOrDefault,r),l},i.prototype.calculateXAxesProperties=function(e,a){var r=t.AxisHelper.createAxis({pixelSpan:this.viewport.width-this.YLegendSize-this.AxisSize,dataDomain:e.forcedXDomain,metaDataColumn:a,formatString:t.valueFormatter.getFormatString(a,i.Properties.general.formatString),outerPadding:0,isScalar:!1,isVertical:!1,useTickIntervalForDisplayUnits:!0,isCategoryAxis:!0,getValueFn:function(e,t){return e},scaleType:e.categoryAxisScaleType});return r.axisLabel=this.histogramDataView.settings.displayName,r},i.prototype.calculateYAxes=function(e,i,a){var r={viewport:this.viewport,margin:this.margin,forceMerge:!0,showCategoryAxisLabel:!0,showValueAxisLabel:!1,categoryAxisScaleType:t.axisScale.linear,valueAxisScaleType:null,trimOrdinalDataOnOverflow:!1},s=this.histogramDataView.settings.yAxisSettings;r.forcedYDomain=t.AxisHelper.applyCustomizedDomain([s.start,s.end],r.forcedYDomain);var o=this.calculateYAxesProperties(r,e);return o},i.prototype.calculateYAxesProperties=function(e,a){var r=this.histogramDataView.settings.yAxisSettings,s=t.AxisHelper.createAxis({pixelSpan:this.viewport.height-this.XLegendSize+5,dataDomain:t.AxisHelper.combineDomain(e.forcedYDomain,[r.start,r.end]),metaDataColumn:a,formatString:t.valueFormatter.getFormatString(a,i.Properties.general.formatString),outerPadding:this.outerPadding,isScalar:!0,isVertical:!0,useTickIntervalForDisplayUnits:!0,isCategoryAxis:!1,getValueFn:function(e,t){return e},scaleType:e.categoryAxisScaleType});return s},i.ClassName="histogram",i.FrequencyText="Frequency",i.DensityText="Density",i.Properties={general:{bins:{objectName:"general",propertyName:"bins"},frequency:{objectName:"general",propertyName:"frequency"},formatString:{objectName:"general",propertyName:"formatString"}},dataPoint:{fill:{objectName:"dataPoint",propertyName:"fill"}},labels:{show:{objectName:"labels",propertyName:"show"},color:{objectName:"labels",propertyName:"color"},displayUnits:{objectName:"labels",propertyName:"displayUnits"},precision:{objectName:"labels",propertyName:"precision"},fontSize:{objectName:"labels",propertyName:"fontSize"}},xAxis:{show:{objectName:"xAxis",propertyName:"show"},axisColor:{objectName:"xAxis",propertyName:"axisColor"},title:{objectName:"xAxis",propertyName:"title"},displayUnits:{objectName:"xAxis",propertyName:"displayUnits"},precision:{objectName:"xAxis",propertyName:"precision"},style:{objectName:"xAxis",propertyName:"style"}},yAxis:{show:{objectName:"yAxis",propertyName:"show"},axisColor:{objectName:"yAxis",propertyName:"axisColor"},title:{objectName:"yAxis",propertyName:"title"},displayUnits:{objectName:"yAxis",propertyName:"displayUnits"},precision:{objectName:"yAxis",propertyName:"precision"},style:{objectName:"yAxis",propertyName:"style"},start:{objectName:"yAxis",propertyName:"start"},end:{objectName:"yAxis",propertyName:"end"},position:{objectName:"yAxis",propertyName:"position"}}},i.DefaultHistogramSettings={frequency:!0,displayName:"Histogram",bins:null,fillColor:"#5f9ea0",precision:2,xAxisSettings:{show:!0,axisColor:"#5f9ea0",title:!0,displayUnits:0,precision:2,style:t.axisStyle.showTitleOnly},yAxisSettings:{show:!0,axisColor:"#5f9ea0",title:!0,displayUnits:0,precision:2,style:t.axisStyle.showTitleOnly,start:0,position:t.yAxisPosition.left},labelSettings:{show:!1,color:"#5f9ea0",displayUnits:0,precision:2,fontSize:9}},i.Axes=n("axes"),i.Axis=n("axis"),i.Labels=n("labels"),i.Columns=n("columns"),i.Column=n("column"),i.Legends=n("legends"),i.Legend=n("legend"),i.capabilities={dataRoles:[{name:"Values",kind:e.VisualDataRoleKind.Grouping,displayName:e.data.createDisplayNameGetter("Role_DisplayName_Values")},{name:"Frequency",kind:e.VisualDataRoleKind.Measure,displayName:"Frequency"}],dataViewMappings:[{conditions:[{Values:{min:1,max:1},Frequency:{min:0,max:1}}],categorical:{categories:{bind:{to:"Values"},dataReductionAlgorithm:{top:{}}},values:{"for":{"in":"Frequency"}}}}],sorting:{implicit:{clauses:[{role:"Values",direction:1}]}},objects:{general:{displayName:e.data.createDisplayNameGetter("Visual_General"),properties:{formatString:{type:{formatting:{formatString:!0}}},bins:{displayName:"Bins",type:{numeric:!0}},frequency:{displayName:"Frequency",type:{bool:!0}}}},dataPoint:{displayName:e.data.createDisplayNameGetter("Visual_DataPoint"),properties:{fill:{displayName:e.data.createDisplayNameGetter("Visual_Fill"),type:{fill:{solid:{color:!0}}}}}},xAxis:{displayName:"X-Axis",properties:{show:{displayName:"Show",type:{bool:!0}},axis:{displayName:"Axis",type:{bool:!0}},axisColor:{displayName:"Color",type:{fill:{solid:{color:!0}}}},title:{displayName:"Title",type:{bool:!0}},displayUnits:{displayName:"Display Units",type:{formatting:{labelDisplayUnits:!0}}},precision:{displayName:"Decimal Places",type:{numeric:!0}},style:{displayName:"Style",type:{enumeration:t.axisStyle.type}}}},yAxis:{displayName:"Y-Axis",properties:{show:{displayName:"Show",type:{bool:!0}},axis:{displayName:"yAxis",type:{bool:!0}},axisColor:{displayName:"Color",type:{fill:{solid:{color:!0}}}},title:{displayName:"Title",type:{bool:!0}},displayUnits:{displayName:"Display Units",type:{formatting:{labelDisplayUnits:!0}}},precision:{displayName:"Decimal Places",type:{numeric:!0}},style:{displayName:"Style",type:{enumeration:t.axisStyle.type}},start:{displayName:"Start",type:{numeric:!0},placeHolderText:"Start",suppressFormatPainterCopy:!0},end:{displayName:"End",type:{numeric:!0},placeHolderText:"End",suppressFormatPainterCopy:!0},position:{displayName:"Position",type:{enumeration:t.yAxisPosition.type}}}},labels:{displayName:"Data Labels",properties:{show:{displayName:"Show",type:{bool:!0}},color:{displayName:"Color",type:{fill:{solid:{color:!0}}}},displayUnits:{displayName:"Display Units",type:{formatting:{labelDisplayUnits:!0}},suppressFormatPainterCopy:!0},precision:{displayName:"Decimal Places",type:{numeric:!0},suppressFormatPainterCopy:!0},fontSize:{displayName:"Text Size",type:{formatting:{fontSize:!0}}}}}}},i.MinNumberOfBins=0,i.MaxNumberOfBins=100,i.MinPrecision=0,i.MaxPrecision=17,i}();i.Histogram=u}(i=t.samples||(t.samples={}))}(t=e.visuals||(e.visuals={}))}(i||(i={}))},function(e,t){var i,a=window.jsCommon,i=window.powerbi;window.powerbitests,window.InJs,window.debug,window.jasmine,window.Microsoft;!function(e){var t;!function(t){var i;!function(i){var r,s=t.AnimatorCommon.GetAnimationDuration,o=a.CssConstants.createClassAndSelector,n=e.visuals.axisScale,l=a.PixelConverter,c=40,u=15,h=5,p=1,d="#00B8AA",g=0,m=17;!function(t){!function(e){e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical"}(t.Orientation||(t.Orientation={}));var i=t.Orientation;t.type=e.createEnumType([{value:i[0],displayName:"Horizontal"},{value:i[1],displayName:"Vertical"}])}(r=i.DotPlotLabelsOrientation||(i.DotPlotLabelsOrientation={})),i.DotPlotProperties={general:{formatString:{objectName:"general",propertyName:"formatString"}},labels:{show:{objectName:"labels",propertyName:"show"},fontSize:{objectName:"labels",propertyName:"fontSize"},labelPrecision:{objectName:"labels",propertyName:"labelPrecision"},labelDisplayUnits:{objectName:"labels",propertyName:"labelDisplayUnits"},labelColor:{objectName:"labels",propertyName:"color"},orientation:{objectName:"labels",propertyName:"orientation"}},dataPoint:{fill:{objectName:"dataPoint",propertyName:"fill"}},categories:{show:{objectName:"categories",propertyName:"show"},fontColor:{objectName:"categories",propertyName:"fontColor"},fontSize:{objectName:"categories",propertyName:"fontSize"}},categoryAxis:{show:{objectName:"categoryAxis",propertyName:"show"},showAxisTitle:{objectName:"categoryAxis",propertyName:"showAxisTitle"},labelColor:{objectName:"categoryAxis",propertyName:"labelColor"}}};var y=function(){function y(e){this.DefaultMargin={top:10,bottom:10,right:20,left:20},this.durationAnimations=200,this.scaleType=n.linear,this.textProperties={fontFamily:"wf_segoe-ui_normal",fontSize:a.PixelConverter.toString(9)},this.dotPlotSelectors={svgPlotSelector:o("dotplot"),plotSelector:o("dotplotSelector"),plotGroupSelector:o("dotplotGroup"),axisSelector:o("axisGraphicsContext"),xAxisSelector:o("x axis"),circleSeletor:o("circleSelector")},this.DefaultDotPlotSettings={labelSettings:{show:!0,precision:2,fontSize:t.dataLabelUtils.DefaultFontSizeInPt,displayUnits:0,labelColor:t.dataLabelUtils.defaultLabelColor},categorySettings:{show:!0,fontColor:t.LegendData.DefaultLegendLabelFillColor},defaultDataPointColor:d,categoryAxisSettings:{show:!0,showAxisTitle:!0,labelColor:{solid:{color:t.dataLabelUtils.defaultLabelColor}}},labelOrientation:r.Orientation.Horizontal,labelTextMaxSize:0},e&&(e.svg&&(this.svg=e.svg),e.animator&&(this.animator=e.animator),this.radius=e.radius||h,this.strokeWidth=e.strokeWidth||p)}return y.getTooltipData=function(e){return[{displayName:"Value",value:e.toString()}]},y.converter=function(a,s,o,n,u,h,p,d){var g,m=a.categorical.values,f=[],v=a.categorical.categories[0].source.displayName,x=e.DataViewObjects.getFillColor(s,i.DotPlotProperties.dataPoint.fill,h.getColorByIndex(0).value),b=a.categorical.categories[0].values.map(function(e,i){return{value:e,selectionId:t.SelectionId.createWithId(a.categorical.categories[0].identity[i])}}),S=0;for(var w in m){var C=m[w],P=_.max(C.values);S=P>S?P:S}g={categorySettings:this.getCategorySettings(s,u),defaultDataPointColor:x,labelSettings:this.parseSettings(s,u),categoryAxisSettings:this.parseCategoryAxisSettings(s,u),labelOrientation:e.DataViewObjects.getValue(s,i.DotPlotProperties.labels.orientation,r.Orientation.Horizontal)+""=="Vertical"?r.Orientation.Vertical:r.Orientation.Horizontal,labelTextMaxSize:0};var D={text:"W",fontFamily:"Segoe UI",fontSize:g.labelSettings.fontSize+"px"};g.labelTextMaxSize=e.TextMeasurementService.measureSvgTextWidth(D)*(S+" ").length;var A=a.categorical.categories[0],T=2*d+1,V=p.height-d-c-(g.labelOrientation===r.Orientation.Vertical?g.labelTextMaxSize:0),N=Math.floor((V-n.top)/T)-1,L=l.fromPoint(g.labelSettings.fontSize),M=d3.scale.linear().domain([0,N]).range([V-n.bottom,n.top+n.bottom]);for(var w in m)for(var C=m[w],k=_.min(C.values),P=_.max(C.values),O=e.DataViewObjects.getFillColor(s,i.DotPlotProperties.dataPoint.fill,h.getColorByIndex(0).value),I=C&&C.values?C.values.length:0,j=k/(P/N),F=d3.scale.log().domain([0>k?1:k,P]).range([0>=j?1:j,N]).clamp(!0),z=0;I>z;z++){for(var G=F(C.values[z]),R=[],H=0;G>H;H++)R.push({x:o(b[z].value)+o.rangeBand()/2,y:M(H)+(g.labelOrientation===r.Orientation.Vertical?g.labelTextMaxSize:0),tooltipInfo:y.getTooltipData(C.values[z].toFixed(g.labelSettings.precision))});var B=t.SelectionIdBuilder.builder().withCategory(A,z).createSelectionId(),U=y.getTooltipData(C.values[z].toFixed(g.labelSettings.precision));f.push({selected:!1,value:C.values[z],label:C.values[z],color:O,identity:B,tooltipInfo:U,dataPoints:R,labelFontSize:L})}return{dataPoints:f,values:a.categorical.categories[0].values,displayName:v,categories:b,settings:g}},y.prototype.init=function(e){var i=e.element;this.behavior=new f,this.interactivityService=t.createInteractivityService(e.host),this.radius=h,this.strokeWidth=p,this.colors=e.style.colorPalette.dataColors,this.svg=d3.select(i.get(0)).append("svg").classed(this.dotPlotSelectors.svgPlotSelector["class"],!0).style("position","absolute").style("left","5px"),this.clearCatcher=t.appendClearCatcher(this.svg);var a=this.svg.append("g").classed(this.dotPlotSelectors.axisSelector["class"],!0);this.dotPlot=this.svg.append("g").classed(this.dotPlotSelectors.plotSelector["class"],!0),this.xAxis=a.append("g").classed(this.dotPlotSelectors.xAxisSelector["class"],!0)},y.prototype.update=function(e){if(e.dataViews&&e.dataViews[0]){this.durationAnimations=s(this.animator,e.suppressAnimations);var i=this.dataView=e.dataViews[0],a=e.viewport;if(!i||!i.categorical||!i.categorical.values||i.categorical.values.length<1||!i.categorical||!i.categorical.categories||!i.categorical.categories[0])return void this.clearData();var o={height:a.height-this.DefaultMargin.top,width:a.width-this.DefaultMargin.left};this.viewportIn=o,this.svg.style({height:l.toString(a.height),width:l.toString(a.width)});var n=y.getObjectsFromDataView(i),u=y.parseCategoryAxisSettings(n,this.DefaultDotPlotSettings),h=this.calculateAxes(o,u,this.textProperties,n,!1),p=y.converter(i,n,h.scale,this.DefaultMargin,this.DefaultDotPlotSettings,this.colors,a,this.radius);this.dotPlotDataView=p;var d=p.dataPoints;this.interactivityService&&this.interactivityService.applySelectionStateToData(d),this.renderAxis(o.height-c,o,h,u,p,this.durationAnimations),this.drawDotPlot(d,p.settings);var g=p.settings.labelSettings;if(g.show){var m=this.getEnhanchedDotplotLayout(g,o),f=t.dataLabelUtils.drawDefaultLabelsForDataPointChart(d,this.svg,m,o,!e.suppressAnimations,this.durationAnimations);f&&f.attr("transform",function(e){return p.settings.labelOrientation===r.Orientation.Vertical?t.SVGUtil.translateAndRotate(e.size.height/2,0-e.size.width/2,e.anchorPoint.x,e.anchorPoint.y,-90):t.SVGUtil.translate(0,0)})}else t.dataLabelUtils.cleanDataLabels(this.svg)}},y.prototype.enumerateObjectInstances=function(e){var i=new t.ObjectEnumerationBuilder;switch(e.objectName){case"dataPoint":this.enumerateDataPoints(i,this.dataView);break;case"labels":this.enumerateDataLabels(i,this.dataView);break;case"categories":this.enumerateCategories(i,this.dataView);break;case"categoryAxis":this.enumerateCategoryAxisValues(i,this.dataView)}return i.complete()},y.prototype.enumerateCategoryAxisValues=function(t,a){var r=a&&a.metadata?a.metadata.objects:void 0;t.pushInstance({objectName:"categoryAxis",displayName:"Category Axis",selector:null,properties:{show:e.DataViewObjects.getValue(r,i.DotPlotProperties.categoryAxis.show,this.DefaultDotPlotSettings.categoryAxisSettings.show),showAxisTitle:e.DataViewObjects.getValue(r,i.DotPlotProperties.categoryAxis.showAxisTitle,this.DefaultDotPlotSettings.categoryAxisSettings.showAxisTitle),labelColor:r&&r.categoryAxis&&r.categoryAxis.labelColor?r.categoryAxis.labelColor:this.DefaultDotPlotSettings.categoryAxisSettings.labelColor}})},y.getObjectsFromDataView=function(e){return e&&e.metadata&&e.metadata.columns&&e.metadata.objects?e.metadata.objects:null},y.parseSettings=function(t,a){var r=this.getPrecision(t,a);return{show:e.DataViewObjects.getValue(t,i.DotPlotProperties.labels.show,a.labelSettings.show),precision:r,fontSize:e.DataViewObjects.getValue(t,i.DotPlotProperties.labels.fontSize,a.labelSettings.fontSize),displayUnits:e.DataViewObjects.getValue(t,i.DotPlotProperties.labels.labelDisplayUnits,a.labelSettings.displayUnits),labelColor:e.DataViewObjects.getFillColor(t,i.DotPlotProperties.labels.labelColor,a.labelSettings.labelColor)}},y.parseCategoryAxisSettings=function(t,a){return{show:e.DataViewObjects.getValue(t,i.DotPlotProperties.categoryAxis.show,a.categoryAxisSettings.show),showAxisTitle:e.DataViewObjects.getValue(t,i.DotPlotProperties.categoryAxis.showAxisTitle,a.categoryAxisSettings.showAxisTitle),labelColor:t&&t.categoryAxis&&t.categoryAxis.labelColor?t.categoryAxis.labelColor:a.categoryAxisSettings.labelColor}},y.getCategorySettings=function(t,a){return{show:e.DataViewObject.getValue(t,i.DotPlotProperties.categories.show,a.categorySettings.show),fontColor:e.DataViewObjects.getFillColor(t,i.DotPlotProperties.categories.fontColor,a.categorySettings.fontColor)}},y.getPrecision=function(t,a){var r=e.DataViewObjects.getValue(t,i.DotPlotProperties.labels.labelPrecision,a.labelSettings.precision);return g>=r?g:r>=m?m:r},y.prototype.drawDotPlot=function(e,i){var a=this.dotPlot.selectAll(this.dotPlotSelectors.plotGroupSelector.selector).data(e),r=this.interactivityService&&this.interactivityService.hasSelection();a.enter().append("g").attr({stroke:"black","stroke-width":this.strokeWidth}).style("fill-opacity",function(e){return t.ColumnUtil.getFillOpacity(e.selected,e.highlight,r,!1)}).classed(this.dotPlotSelectors.plotGroupSelector["class"],!0);var s=a.selectAll(this.dotPlotSelectors.circleSeletor.selector).data(function(e){return e.dataPoints});s.enter().append("circle").classed(this.dotPlotSelectors.circleSeletor["class"],!0),s.attr({cx:function(e){return e.x},cy:function(e){return e.y},r:this.radius,fill:i.defaultDataPointColor}),this.renderTooltip(a),s.exit().remove(),a.exit().remove();var o=this.interactivityService;if(o){o.applySelectionStateToData(e);var n={columns:a,clearCatcher:this.clearCatcher,interactivityService:this.interactivityService};o.bind(e,this.behavior,n)}},y.prototype.getEnhanchedDotplotLayout=function(e,r){var s=a.PixelConverter.fromPoint(e.fontSize),o=t.valueFormatter.create({format:t.valueFormatter.getFormatString(this.dataView.categorical.categories[0].source,i.DotPlotProperties.general.formatString),precision:e.precision,value:e.displayUnits});return{labelText:function(i){return t.dataLabelUtils.getLabelFormattedText({label:o.format(i.label),fontSize:e.fontSize,maxWidth:r.width})},labelLayout:{x:function(e){return e.dataPoints[e.dataPoints.length-1].x-5},y:function(e){return e.dataPoints[e.dataPoints.length-1].y-u-5}},filter:function(e){return e&&e.dataPoints&&e.dataPoints[e.dataPoints.length-1]},style:{fill:e.labelColor,"font-size":s}}},y.prototype.enumerateDataLabels=function(t,a){var s=a&&a.metadata?a.metadata.objects:void 0;t.pushInstance({objectName:"labels",displayName:"Labels",selector:null,properties:{show:e.DataViewObjects.getValue(s,i.DotPlotProperties.labels.show,this.DefaultDotPlotSettings.labelSettings.show),fontSize:e.DataViewObjects.getValue(s,i.DotPlotProperties.labels.fontSize,this.DefaultDotPlotSettings.labelSettings.fontSize),labelPrecision:e.DataViewObjects.getValue(s,i.DotPlotProperties.labels.labelPrecision,this.DefaultDotPlotSettings.labelSettings.precision),labelDisplayUnits:e.DataViewObjects.getValue(s,i.DotPlotProperties.labels.labelDisplayUnits,this.DefaultDotPlotSettings.labelSettings.displayUnits),color:e.DataViewObjects.getFillColor(s,i.DotPlotProperties.labels.labelColor,this.DefaultDotPlotSettings.labelSettings.labelColor),orientation:e.DataViewObjects.getValue(s,i.DotPlotProperties.labels.orientation,r.Orientation.Horizontal)}})},y.prototype.enumerateDataPoints=function(t,a){var r=a&&a.metadata?a.metadata.objects:void 0,s=e.DataViewObjects.getFillColor(r,i.DotPlotProperties.dataPoint.fill,this.DefaultDotPlotSettings.defaultDataPointColor);t.pushInstance({objectName:"dataPoint",displayName:"Data Points",selector:null,properties:{fill:{solid:{color:s}}}})},y.prototype.enumerateCategories=function(e,t){var i=t&&t.metadata?t.metadata.objects:void 0,a=y.getCategorySettings(i,this.DefaultDotPlotSettings);e.pushInstance({objectName:"categories",displayName:"Categories",selector:null,properties:{show:a.show,fontSize:a.fontSize,fontColor:a.fontColor}})},y.prototype.clearData=function(){this.dotPlot.selectAll("*").remove(),this.xAxis.selectAll("*").remove(),t.dataLabelUtils.cleanDataLabels(this.svg)},y.prototype.renderTooltip=function(e){t.TooltipManager.addTooltip(e,function(e){return e.data.tooltipInfo})},y.prototype.calculateAxes=function(i,a,r,s,o){var n=this.dataView.categorical.categories&&this.dataView.categorical.categories.length>0?this.dataView.categorical.categories[0]:{source:void 0,values:[t.valueFormatter.format(null)],identity:void 0},l={viewport:i,margin:this.DefaultMargin,forcedXDomain:this.dataView.categorical.categories[0].values,forceMerge:!1,showCategoryAxisLabel:!1,showValueAxisLabel:!1,categoryAxisScaleType:this.scaleType,valueAxisScaleType:null,valueAxisDisplayUnits:0,categoryAxisDisplayUnits:0,trimOrdinalDataOnOverflow:!1},c=i.width,u=this.calculateAxesProperties(i,a,l,n.source,s);return u.willLabelsFit=t.AxisHelper.LabelLayoutStrategy.willLabelsFit(u,c,e.TextMeasurementService.measureSvgTextWidth,r),u.willLabelsWordBreak=!u.willLabelsFit&&!o&&t.AxisHelper.LabelLayoutStrategy.willLabelsWordBreak(u,this.DefaultMargin,c,e.TextMeasurementService.measureSvgTextWidth,e.TextMeasurementService.estimateSvgTextHeight,e.TextMeasurementService.getTailoredTextOrDefault,r),u},y.prototype.calculateAxesProperties=function(e,a,r,s,o){var n=t.AxisHelper.createAxis({pixelSpan:e.width,dataDomain:r.forcedXDomain,metaDataColumn:s,formatString:t.valueFormatter.getFormatString(s,i.DotPlotProperties.general.formatString),outerPadding:0,isScalar:!1,isVertical:!1,forcedTickCount:r.forcedTickCount,useTickIntervalForDisplayUnits:!0,isCategoryAxis:!0,getValueFn:function(e,t){return a.show?e:""},scaleType:r.categoryAxisScaleType,axisDisplayUnits:r.categoryAxisDisplayUnits});return a.show&&(n.axisLabel=t.AxisHelper.createAxisLabel(o,"","")),n},y.prototype.renderAxis=function(i,a,r,s,o,n){this.xAxis.attr({transform:t.SVGUtil.translate(0,i)});var l=r.axis;l.orient("bottom"),this.xAxis.transition().duration(n).call(l).call(y.setAxisLabelColor,s.labelColor);var c=this.xAxis.selectAll(".tick text");c.data(r.values),c.call(t.AxisHelper.LabelLayoutStrategy.clip,r.xLabelMaxWidth,e.TextMeasurementService.svgEllipsis),c.append("title").text(function(e){return e}),this.xAxis.selectAll("line").style("opacity",o.settings.categoryAxisSettings.show?1:0),this.xAxis.selectAll(".xAxisLabel").remove(),o.settings.categoryAxisSettings.showAxisTitle&&this.xAxis.append("text").text(this.dataView.categorical.categories[0].source.displayName).style("text-anchor","middle").attr("class","xAxisLabel").style("fill",s.labelColor.solid.color).attr("transform","translate("+a.width/2+",40)")},y.setAxisLabelColor=function(e,t){e.selectAll("g.tick text").style("fill",t&&t.solid?t.solid.color:null)},y.capabilities={dataRoles:[{name:"Category",kind:e.VisualDataRoleKind.Grouping,displayName:"Category"},{name:"Values",kind:e.VisualDataRoleKind.Measure,displayName:"Values"}],dataViewMappings:[{conditions:[{Category:{max:1},Values:{max:1}}],categorical:{categories:{"for":{"in":"Category"},dataReductionAlgorithm:{top:{}}},values:{group:{by:"Series",select:[{"for":{"in":"Values"}}],dataReductionAlgorithm:{top:{}}}}}}],objects:{general:{displayName:"General",properties:{formatString:{type:{formatting:{formatString:!0}}}}},categoryAxis:{displayName:"X-Axis",properties:{show:{displayName:"Show",type:{bool:!0}},showAxisTitle:{displayName:"Title",description:"Title options",type:{bool:!0}},labelColor:{displayName:"Label color",type:{fill:{solid:{color:!0}}}}}},dataPoint:{displayName:"Data colors",properties:{fill:{displayName:"Fill",type:{fill:{solid:{color:!0}}}}}},labels:{displayName:"Data labels",description:"Display data label options",properties:{show:{displayName:"Show",type:{bool:!0}},showSeries:{displayName:"Show",type:{bool:!0}},color:{displayName:"Color",description:"Select color for data labels",type:{fill:{solid:{color:!0}}}},labelDisplayUnits:{displayName:"Display units",description:"Select the units (millions, billions, etc.)",type:{formatting:{labelDisplayUnits:!0}},suppressFormatPainterCopy:!0},labelPrecision:{displayName:"Decimal places",description:"Select the number of decimal places to display",placeHolderText:"Auto",type:{numeric:!0},suppressFormatPainterCopy:!0},showAll:{displayName:"Customize series",type:{bool:!0}},fontSize:{displayName:"Text Size",type:{formatting:{fontSize:!0}}},orientation:{displayName:"Orientation",type:{enumeration:r.type}}}}}},y}();i.DotPlot=y;var f=function(){function e(){}return e.prototype.bindEvents=function(e,t){this.columns=e.columns,this.clearCatcher=e.clearCatcher,this.interactivityService=e.interactivityService,this.columns.on("click",function(e,i){t.handleSelection(e,d3.event.ctrlKey)}),e.clearCatcher.on("click",function(){t.handleClearSelection()})},e.prototype.renderSelection=function(e){var i=this.interactivityService.hasSelection();this.columns.style("fill-opacity",function(a){return t.ColumnUtil.getFillOpacity(a.selected,a.highlight,!a.highlight&&e,!a.selected&&i)})},e}();i.DotplotBehavior=f}(i=t.samples||(t.samples={}))}(t=e.visuals||(e.visuals={}))}(i||(i={}))},function(e,t){var i,a=window.jsCommon,i=window.powerbi;window.powerbitests,window.InJs,window.debug,window.jasmine,window.Microsoft;!function(e){var t;!function(t){var i;!function(i){var r=a.PixelConverter;!function(e){e[e.ByWeight="By Weight"]="ByWeight",e[e.ByLinkType="By Link Type"]="ByLinkType",e[e.Interactive="Interactive"]="Interactive"}(i.LinkColorType||(i.LinkColorType={}));var s=i.LinkColorType,o=function(){function i(){this.labels={show:!0,color:t.dataLabelUtils.defaultLabelColor,fontSize:t.dataLabelUtils.DefaultFontSizeInPt},this.links={showArrow:!1,showLabel:!1,colorLink:s.Interactive,thickenLink:!0,displayUnits:0,decimalPlaces:null},this.nodes={displayImage:!1,defaultImage:"Home",imageUrl:"",imageExt:".png",nameMaxLength:10,highlightReachableLinks:!1},this.size={charge:-15}}return Object.defineProperty(i,"Default",{get:function(){return new this},enumerable:!0,configurable:!0}),i.parse=function(e,t){var i=new this;if(!e||!e.metadata||!e.metadata.objects)return i;var a=this.getProperties(t);for(var r in t.objects)for(var s in t.objects[r].properties)if(i[r]&&_.has(i[r],s)){var o=t.objects[r].properties[s].type,n=this.getValueFnByType(o);i[r][s]=n(e.metadata.objects,a[r][s],i[r][s])}return i},i.getProperties=function(e){var t={};for(var i in e.objects){t[i]={};for(var a in e.objects[i].properties)t[i][a]={objectName:i,propertyName:a}}return t},i.createEnumTypeFromEnum=function(t){var i=!1;return e.createEnumType(Object.keys(t).filter(function(e,a){return!!(a%2)===i&&t[e]===e&&!void(i=!i)||!!(a%2)!==i}).map(function(e){return{value:e,displayName:e}}))},i.getValueFnByType=function(t){switch(_.keys(t)[0]){case"fill":return e.DataViewObjects.getFillColor;default:return e.DataViewObjects.getValue}},i.enumerateObjectInstances=function(e,i,a){var r=new t.ObjectEnumerationBuilder,s=e&&e[i.objectName];if(!s)return r.complete();var o={objectName:i.objectName,selector:null,properties:{}};for(var n in s)_.has(s,n)&&(o.properties[n]=s[n]);return r.pushInstance(o),r.complete()},i}();i.ForceGraphSettings=o;var n=function(){function e(){this.Source=null,this.Target=null,this.Weight=null,this.LinkType=null,this.SourceType=null,this.TargetType=null}return e.getMetadataColumns=function(t){var i=t&&t.metadata&&t.metadata.columns;return i&&_.mapValues(new e,function(e,t){return i.filter(function(e){return e.roles&&e.roles[t]})[0]})},e.getTableValues=function(e){var t=e&&e.table,i=this.getMetadataColumns(e);return i&&t&&_.mapValues(i,function(e,i){return e&&t.rows.map(function(t){return t[e.index]})})},e.getTableRows=function(e){var t=e&&e.table,i=this.getMetadataColumns(e);return i&&t&&t.rows.map(function(e){return _.mapValues(i,function(t,i){return t&&e[t.index]})})},e.Roles=Object.freeze(_.mapValues(new e,function(e,t){return t})),e}();i.ForceGraphColumns=n;var l=function(){function i(){this.uniqieId="_"+i.Count++ +"_"}return Object.defineProperty(i,"Href",{get:function(){return window.location.href.replace(window.location.hash,"")},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"settings",{get:function(){return this.data&&this.data.settings},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"margin",{get:function(){return this.marginValue||{left:0,right:0,top:0,bottom:0}},set:function(e){this.marginValue=$.extend({},e),this.viewportInValue=i.substractMargin(this.viewport,this.margin)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"viewport",{get:function(){return this.viewportValue||{width:0,height:0}},set:function(e){this.viewportValue=$.extend({},e),this.viewportInValue=i.substractMargin(this.viewport,this.margin)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"viewportIn",{get:function(){return this.viewportInValue||this.viewport},enumerable:!0,configurable:!0}),i.substractMargin=function(e,t){return{width:Math.max(e.width-(t.left+t.right),0),height:Math.max(e.height-(t.top+t.bottom),0)}},i.prototype.scale1to10=function(e){var t=d3.scale.linear().domain([this.data.minFiles,this.data.maxFiles]).rangeRound([1,10]).clamp(!0);return t(e)},i.prototype.getLinkColor=function(e){switch(this.settings.links.colorLink){case s.ByWeight:return this.colors.getColorByIndex(this.scale1to10(e.weight)).value;case s.ByLinkType:return e.type&&this.data.linkTypes[e.type]?this.data.linkTypes[e.type].color:i.DefaultValues.defaultLinkColor}return i.DefaultValues.defaultLinkColor},i.prototype.enumerateObjectInstances=function(e){return o.enumerateObjectInstances(this.settings,e,i.capabilities)},i.converter=function(e,a){var r=e.categorical,s=i.parseSettings(e),l={},c=Number.MAX_VALUE,u=0,h={},p=[],d={},g=0,m=[],y=n.getMetadataColumns(e);if(!y||!y.Source||!y.Target)return null;var f=n.getTableRows(e),v=o.getProperties(i.capabilities).general.formatString,x=t.valueFormatter.getFormatString(r.categories[0].source,v),b=t.valueFormatter.getFormatString(r.categories[1].source,v),S=y.Weight&&t.valueFormatter.create({format:t.valueFormatter.getFormatString(y.Weight,v,!0),precision:s.links.decimalPlaces,value:s.links.displayUnits||_.max(f,function(e){return e.Weight}).Weight});return f.forEach(function(i){h[i.Source+","+i.Target]=1;var r=l[i.Source]||(l[i.Source]={name:i.Source,image:i.SourceType||"",adj:{}}),s=l[i.Target]||(l[i.Target]={name:i.Target,image:i.TargetType||"",adj:{}});r.adj[s.name]=1,s.adj[r.name]=1,m=[{displayName:e.metadata.columns[0].displayName,value:t.valueFormatter.format(r.name,x)},{displayName:e.metadata.columns[1].displayName,value:t.valueFormatter.format(s.name,b)}],y.Weight&&m.push({displayName:e.metadata.columns[2].displayName,value:i.Weight});var o={source:r,target:s,weight:Math.max(i.Weight,0),formattedWeight:i.Weight&&S.format(i.Weight),type:i.LinkType||"",tooltipInfo:m};y.LinkType&&(d[i.LinkType]||(d[i.LinkType]={label:i.LinkType,color:a.getColorByIndex(g++).value})),o.weight<c&&(c=o.weight),o.weight>u&&(u=o.weight),p.push(o)}),{nodes:l,links:p,minFiles:c,maxFiles:u,linkedByName:h,linkTypes:d,settings:s}},i.parseSettings=function(e){var t=o.parse(e,i.capabilities);return t.size.charge=Math.min(Math.max(t.size.charge,-100),-.1),
13t.links.decimalPlaces=t.links.decimalPlaces&&Math.min(Math.max(t.links.decimalPlaces,0),5),t},i.prototype.init=function(e){var t=this;this.root=d3.select(e.element.get(0)),this.forceLayout=d3.layout.force(),this.forceLayout.drag().on("dragstart",function(e){e.isDrag=!0,t.fadeNode(e)}).on("dragend",function(e){e.isDrag=!1,t.fadeNode(e)}).on("drag",function(e){return t.fadeNode(e)}),this.colors=e.style.colorPalette.dataColors},i.prototype.update=function(e){var a=this;if(e.dataViews&&!(e.dataViews.length<1)&&(this.data=i.converter(this.dataView=e.dataViews[0],this.colors),this.data)){this.viewport=e.viewport;var o=Math.sqrt(Object.keys(this.data.nodes).length/(this.viewport.width*this.viewport.height));this.root.selectAll("svg").remove();var n=this.root.append("svg").attr("width",this.viewport.width).attr("height",this.viewport.height).classed(i.VisualClassName,!0);if(this.forceLayout.gravity(100*o).links(this.data.links).size([this.viewport.width,this.viewport.height]).linkDistance(100).charge(this.settings.size.charge/o).on("tick",this.tick()),this.updateNodes(),this.forceLayout.start(),this.paths=n.selectAll(".link").data(this.forceLayout.links()).enter().append("path").attr("class","link").attr("id",function(e,t){return"linkid_"+a.uniqieId+t}).attr("stroke-width",function(e){return a.settings.links.thickenLink?a.scale1to10(e.weight):i.DefaultValues.defaultLinkThickness}).style("stroke",function(e){return a.getLinkColor(e)}).style("fill",function(e){return a.settings.links.showArrow?a.getLinkColor(e):void 0}).on("mouseover",this.fadePath(.3,i.DefaultValues.defaultLinkHighlightColor)).on("mouseout",this.fadePath(1,i.DefaultValues.defaultLinkColor)),t.TooltipManager.addTooltip(this.paths,function(e){return e.data.tooltipInfo}),this.settings.links.showLabel){var l=n.selectAll(".linklabelholder").data(this.forceLayout.links());l.enter().append("g").attr("class","linklabelholder").append("text").attr("class","linklabel").attr("y","-12").attr("text-anchor","middle").style("fill","#000").append("textPath").attr("xlink:href",function(e,t){return i.Href+"#linkid_"+a.uniqieId+t}).attr("startOffset","25%").text(function(e){return a.settings.links.colorLink===s.ByLinkType?e.type:e.formattedWeight}),l.exit().remove()}this.nodes=n.selectAll(".node").data(this.forceLayout.nodes()).enter().append("g").attr("class","node").call(this.forceLayout.drag).on("mouseover",function(e){e.isOver=!0,a.fadeNode(e)}).on("mouseout",function(e){e.isOver=!1,a.fadeNode(e)}).on("mousedown",function(){return d3.event.stopPropagation()}).attr("drag-resize-disabled",!0),this.settings.nodes.displayImage?this.nodes.append("image").attr("xlink:href",function(e){return e.image&&""!==e.image?a.settings.nodes.imageUrl+e.image+a.settings.nodes.imageExt:a.settings.nodes.defaultImage&&""!==a.settings.nodes.defaultImage?a.settings.nodes.imageUrl+a.settings.nodes.defaultImage+a.settings.nodes.imageExt:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABsAAAAbCAMAAAHNDTTxAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAACuUExURQAAAMbGxvLy8sfHx/Hx8fLy8vHx8cnJycrKyvHx8fHx8cvLy/Ly8szMzM3NzfHx8dDQ0PHx8fLy8vHx8e/v79LS0tPT0/Ly8tTU1NXV1dbW1vHx8fHx8fDw8NjY2PT09PLy8vLy8vHx8fLy8vHx8fHx8enp6fDw8PLy8uPj4+Tk5OXl5fHx8b+/v/Pz8+bm5vHx8ejo6PLy8vHx8fLy8sTExPLy8vLy8sXFxfHx8YCtMbUAAAA6dFJOUwD/k/+b7/f///+r/////0z/w1RcEP//ZP///4fj/v8Yj3yXn/unDEhQ////YP9Y/8//aIMU/9+L/+fzC4s1AAAACXBIWXMAABcRAAAXEQHKJvM/AAABQElEQVQoU5WS61LCMBCFFymlwSPKVdACIgWkuNyL+P4v5ibZ0jKjP/xm0uw5ySa7mRItAhnMoIC5TwQZdCZiZjcoC8WU6EVsmZgzoqGdxafgvJAvjUXCb2M+0cXNsd/GDarZqSf7av3M2P1E3xhfLkPUvLD5joEYwVVJQXM6+9McWUwLf4nDTCQZAy96UoDjNI/jhl3xPLbQamu8xD7iaIsPKw7GJ7KZEnWLY3Gi8EFj5nqibXnwD5VEGjJXk5sbpLppfvvo1RazQVrhSopPK4TODrtnjS3dY4ic8KurruWQYF+UG60BacexTMyT2jlNg41dOmKvTpkUd/Jevy7ZxQ61ULRUpoododx8GeDPvIrktbFVdUsK6f8Na5VlVpjZJtowTXVy7kfXF5wCaV1tqXAFuIdWJu+JviaQzNzfQvQDGKRXXEmy83cAAAAASUVORK5CYII="}).attr("x","-12px").attr("y","-12px").attr("width","24px").attr("height","24px"):this.nodes.append("circle").attr("r",function(e){return e.weight<5?5:e.weight}),this.settings.labels.show&&this.nodes.append("text").attr({x:12,dy:".35em"}).style({fill:this.settings.labels.color,"font-size":r.fromPoint(this.settings.labels.fontSize)}).text(function(e){return e.name?e.name.length>a.settings.nodes.nameMaxLength?e.name.substr(0,a.settings.nodes.nameMaxLength):e.name:""})}},i.prototype.updateNodes=function(){var e=this.forceLayout.nodes();this.forceLayout.nodes(d3.values(this.data.nodes)),this.forceLayout.nodes().forEach(function(t,i){e[i]&&(t.x=e[i].x,t.y=e[i].y,t.px=e[i].px,t.py=e[i].py,t.weight=e[i].weight)})},i.prototype.tick=function(){var e=this,t=this.viewportIn,i=20*t.width,a=20*t.height,r=function(e){return Math.max((t.width-i)/2,Math.min((t.width+i)/2,e))},s=function(e){return Math.max((t.height-a)/2,Math.min((t.height+a)/2,e))},o=this.settings.links.showArrow?function(e){e.source.x=r(e.source.x),e.source.y=s(e.source.y),e.target.x=r(e.target.x),e.target.y=s(e.target.y);var t=e.target.x-e.source.x,i=e.target.y-e.source.y,a=Math.sqrt(t*t+i*i),o=Math.atan2(i,t)+Math.PI/7.85,n=Math.PI/2,l=e.target.x-6*Math.cos(o),c=e.target.y-6*Math.sin(o);return"M"+e.source.x+","+e.source.y+"A"+a+","+a+" 0 0 1,"+e.target.x+","+e.target.y+"A"+a+","+a+" 0 0 0,"+e.source.x+","+e.source.y+"M"+l+","+c+"l"+(3.5*Math.cos(n-o)-10*Math.cos(o))+","+(-3.5*Math.sin(n-o)-10*Math.sin(o))+"L"+(l-3.5*Math.cos(n-o)-10*Math.cos(o))+","+(c+3.5*Math.sin(n-o)-10*Math.sin(o))+"z"}:function(e){e.source.x=r(e.source.x),e.source.y=s(e.source.y),e.target.x=r(e.target.x),e.target.y=s(e.target.y);var t=e.target.x-e.source.x,i=e.target.y-e.source.y,a=Math.sqrt(t*t+i*i);return"M"+e.source.x+","+e.source.y+"A"+a+","+a+" 0 0,1 "+e.target.x+","+e.target.y};return function(){e.paths.each(function(){this.parentNode.insertBefore(this,this)}),e.paths.attr("d",o),e.nodes.attr("transform",function(e){return"translate("+r(e.x)+","+s(e.y)+")"})}},i.prototype.fadePath=function(e,t){var a=this;if(this.settings.links.colorLink===s.Interactive)return function(r){a.paths.style("stroke-opacity",function(t){return t.source===r.source&&t.target===r.target?1:e}),a.paths.style("stroke",function(e){return e.source===r.source&&e.target===r.target?t:i.DefaultValues.defaultLinkColor})}},i.prototype.isReachable=function(e,t){if(e.name===t.name)return!0;if(this.data.linkedByName[e.name+","+t.name])return!0;var i={};for(var a in this.data.nodes)i[a]=!1;i[e.name]=!0;var r=[];for(r.push(e.name);r.length>0;){var s=r.pop(),o=this.data.nodes[s];for(var n in o.adj){if(n===t.name)return!0;i[n]||(i[n]=!0,r.push(n))}}return!1},i.prototype.fadeNode=function(e){var t=this;if(this.settings.links.colorLink===s.Interactive){var a=function(e,i){return t.data.linkedByName[e.name+","+i.name]||t.data.linkedByName[i.name+","+e.name]||e.name===i.name},r=e.isOver||e.isDrag,o=r?.3:1,n=r?i.DefaultValues.defaultLinkHighlightColor:i.DefaultValues.defaultLinkColor,l=this;this.nodes.style("stroke-opacity",function(t){var i=(l.settings.nodes.highlightReachableLinks?l.isReachable(e,t):a(e,t))?1:o;return this.setAttribute("fill-opacity",i),i}),this.paths.style("stroke-opacity",function(i){return(t.settings.nodes.highlightReachableLinks?t.isReachable(e,i.source):i.source===e||i.target===e)?1:o}),this.paths.style("stroke",function(a){return(t.settings.nodes.highlightReachableLinks?t.isReachable(e,a.source):a.source===e||a.target===e)?n:i.DefaultValues.defaultLinkColor})}},i.prototype.destroy=function(){this.root=null},i.VisualClassName="forceGraph",i.Count=0,i.DefaultValues={defaultLinkColor:"#bbb",defaultLinkHighlightColor:"#f00",defaultLinkThickness:"1.5px"},i.capabilities={dataRoles:[{name:n.Roles.Source,kind:e.VisualDataRoleKind.Grouping,displayName:"Source"},{name:n.Roles.Target,kind:e.VisualDataRoleKind.Grouping,displayName:"Target"},{name:n.Roles.Weight,kind:e.VisualDataRoleKind.Measure,displayName:"Weight"},{name:n.Roles.LinkType,kind:e.VisualDataRoleKind.Grouping,displayName:"Link Type",description:"Links can be colored by link types"},{name:n.Roles.SourceType,kind:e.VisualDataRoleKind.Grouping,displayName:"Source Type",description:"Source type represents the image name for source entities"},{name:n.Roles.TargetType,kind:e.VisualDataRoleKind.Grouping,displayName:"Target Type",description:"Target type represents the image name for target entities"}],objects:{general:{properties:{formatString:{type:{formatting:{formatString:!0}}}}},labels:{displayName:"Data labels",properties:{show:{displayName:"Show",type:{bool:!0}},color:{displayName:"Fill",type:{fill:{solid:{color:!0}}}},fontSize:{displayName:"Text Size",type:{formatting:{fontSize:!0}}}}},links:{displayName:"Links",properties:{showArrow:{type:{bool:!0},displayName:"Arrow"},showLabel:{type:{bool:!0},displayName:"Label",description:"Displays weight on links"},colorLink:{type:{enumeration:o.createEnumTypeFromEnum(s)},displayName:"Color"},thickenLink:{type:{bool:!0},displayName:"Thickness",description:"Thickenss of links represents weight"},displayUnits:{displayName:"Display Units",type:{formatting:{labelDisplayUnits:!0}}},decimalPlaces:{displayName:"Decimal Places",placeHolderText:"Auto",type:{numeric:!0}}}},nodes:{displayName:"Nodes",properties:{displayImage:{type:{bool:!0},displayName:"Image",description:"Images are loaded from image url + source or target type + image extension"},defaultImage:{type:{text:!0},displayName:"Default image"},imageUrl:{type:{text:!0},displayName:"Image url"},imageExt:{type:{text:!0},displayName:"Image extension"},nameMaxLength:{type:{numeric:!0},displayName:"Max name length",description:"Max length of the name of entities displayed"},highlightReachableLinks:{type:{bool:!0},displayName:"Highlight all reachable links",description:"In interactive mode, whether a node's all reachable links will be highlighted"}}},size:{displayName:"Size",properties:{charge:{type:{numeric:!0},displayName:"Charge",description:"The larger the negative charge the more apart the entities, must be negative but greater than -100"}}}},dataViewMappings:[{conditions:[{Source:{max:1},Target:{max:1},Weight:{max:1},LinkType:{max:1},SourceType:{max:1},TargetType:{max:1}}],categorical:{categories:{"for":{"in":"Source"},dataReductionAlgorithm:{top:{}}},values:{select:[{bind:{to:"Target"}},{bind:{to:"Weight"}},{bind:{to:"LinkType"}},{bind:{to:"SourceType"}},{bind:{to:"TargetType"}}]},rowCount:{preferred:{min:1}}}}],suppressDefaultTitle:!0},i}();i.ForceGraph=l}(i=t.samples||(t.samples={}))}(t=e.visuals||(e.visuals={}))}(i||(i={}))},function(e,t){var i,a=window.jsCommon,i=window.powerbi;window.powerbitests,window.InJs,window.debug,window.jasmine,window.Microsoft;!function(e){var t;!function(t){var i;!function(i){function r(t){var i=!1;return e.createEnumType(Object.keys(t).filter(function(e,a){return!!(a%2)===i&&t[e]===e&&!void(i===!i)||!!(a%2)!==i}).map(function(e){return{value:e,displayName:e}}))}var s=t.utility.SelectionManager,o=a.PixelConverter,n="0.00 %;-0.00 %;0.00 %",l=864e5,c=6048e5,u=2629746e3,h=31556952e3,p=40,d=5;!function(e){e[e.Day="Day"]="Day",e[e.Week="Week"]="Week",e[e.Month="Month"]="Month",e[e.Year="Year"]="Year"}(i.GanttDateType||(i.GanttDateType={}));var g,m=i.GanttDateType;!function(e){var t=a.CssConstants.createClassAndSelector;e.ClassName=t("gantt"),e.Chart=t("chart"),e.ChartLine=t("chart-line"),e.Body=t("gantt-body"),e.AxisGroup=t("axis"),e.Domain=t("domain"),e.AxisTick=t("tick"),e.Tasks=t("tasks"),e.TaskGroup=t("task-group"),e.SingleTask=t("task"),e.TaskRect=t("task-rect"),e.TaskProgress=t("task-progress"),e.TaskResource=t("task-resource"),e.SingleMilestone=t("milestone"),e.TaskLabels=t("task-labels"),e.TaskLines=t("task-lines"),e.SingleTaskLine=t("task-line"),e.Label=t("label"),e.LegendItems=t("legendItem"),e.LegendTitle=t("legendTitle")}(g||(g={}));var y=function(){function i(){this.textProperties={fontFamily:"wf_segoe-ui_normal",fontSize:a.PixelConverter.toString(9)},this.margin=i.DefaultMargin}return i.getProperties=function(e){var t={};for(var i in e.objects){t[i]={};for(var a in e.objects[i].properties)t[i][a]={objectName:i,propertyName:a}}return t},Object.defineProperty(i,"DefaultMargin",{get:function(){return{top:50,right:40,bottom:40,left:10}},enumerable:!0,configurable:!0}),i.prototype.init=function(e){this.viewport=_.clone(e.viewport),this.style=e.style,this.body=d3.select(e.element.get(0)),this.hostServices=e.host,this.selectionManager=new s({hostServices:e.host}),this.isInteractiveChart=e.interactivity&&e.interactivity.isInteractiveLegend,this.interactivityService=t.createInteractivityService(this.hostServices),this.createViewport(e.element),this.updateChartSize(),this.behavior=new f,this.colors=e.style.colorPalette.dataColors},i.prototype.createViewport=function(e){this.ganttDiv=this.body.append("div").classed(g.Body["class"],!0),this.ganttSvg=this.ganttDiv.append("svg").classed(g.ClassName["class"],!0),this.clearCatcher=t.appendClearCatcher(this.ganttSvg),this.axisGroup=this.ganttSvg.append("g").classed(g.AxisGroup["class"],!0),this.lineGroup=this.ganttSvg.append("g").classed(g.TaskLines["class"],!0),this.chartGroup=this.ganttSvg.append("g").classed(g.Chart["class"],!0),this.taskGroup=this.chartGroup.append("g").classed(g.Tasks["class"],!0),this.legend=t.createLegend(e,this.isInteractiveChart,this.interactivityService,!0,t.LegendPosition.Top)},i.prototype.clearViewport=function(){this.body.selectAll(g.LegendItems.selector).remove(),this.body.selectAll(g.LegendTitle.selector).remove(),this.axisGroup.selectAll(g.AxisTick.selector).remove(),this.axisGroup.selectAll(g.Domain.selector).remove(),this.lineGroup.selectAll("*").remove(),this.chartGroup.selectAll(g.ChartLine.selector).remove(),this.chartGroup.selectAll(g.TaskGroup.selector).remove(),this.chartGroup.selectAll(g.SingleTask.selector).remove()},i.prototype.updateChartSize=function(){this.ganttDiv.style({height:o.toString(this.viewport.height),width:o.toString(this.viewport.width)})},i.getTaskProperty=function(e,t,i){if(!(t&&e&&e.length>0&&e[0].roles))return null;var a=e.indexOf(e.filter(function(e){return e.roles[i]})[0]);return-1!==a?t[a]:null},i.hasRole=function(e,t){var i=e.roles;return i&&i[t]},i.getTooltipInfo=function(e,t,a){void 0===a&&(a="Days");var r=[];return e.taskType&&r.push({displayName:i.capabilities.dataRoles[0].name,value:e.taskType}),r.push({displayName:i.capabilities.dataRoles[1].name,value:e.name}),isNaN(e.start.getDate())||r.push({displayName:i.capabilities.dataRoles[2].name,value:t.startDateFormatter.format(e.start.toLocaleDateString())}),r.push({displayName:i.capabilities.dataRoles[3].name,value:t.durationFormatter.format(e.duration)+" "+a}),r.push({displayName:i.capabilities.dataRoles[4].name,value:t.completionFormatter.format(e.completion)}),e.resource&&r.push({displayName:i.capabilities.dataRoles[5].name,value:e.resource}),r},i.isChartHasTask=function(e){if(e.table&&e.table.columns)for(var t=0,a=e.table.columns;t<a.length;t++){var r=a[t];if(i.hasRole(r,"Task"))return!0}return!1},i.getFormatters=function(e){if(!e||!e.metadata||!e.metadata.columns)return null;for(var a="d",r="#",s=0,o=e.metadata.columns;s<o.length;s++){var l=o[s];if(e.categorical.categories)for(var c=0,u=e.categorical.categories;c<u.length;c++){var h=u[c];i.hasRole(h.source,"StartDate")&&(a=l.format)}}return{startDateFormatter:t.valueFormatter.create({format:a}),durationFormatter:t.valueFormatter.create({format:r}),completionFormatter:t.valueFormatter.create({format:n,value:1,allowFormatBeautification:!0})}},i.createTasks=function(e,a,r){var s=e.table.columns,o=e.table.rows,n=e.categorical.categories[0],l=new t.ColorHelper(r,void 0);return o.map(function(r,o){var c=i.getTaskProperty(s,r,"StartDate");c=i.isValidDate(c)?c:new Date(Date.now());var u=i.getTaskProperty(s,r,"Duration"),h=i.getTaskProperty(s,r,"Completion"),p=i.convertToDecimal(h);p=1>=p?p:1;var d=i.getTaskProperty(s,r,"Legend"),g=l.getColorForMeasure(e.metadata.objects,d),m={id:o,name:i.getTaskProperty(s,r,"Task"),start:c?c:new Date(Date.now()),duration:u>0?u:1,end:null,completion:p>0?p:0,resource:i.getTaskProperty(s,r,"Resource"),taskType:d,color:g?g:i.DefaultValues.TaskColor,tooltipInfo:null,description:"",identity:t.SelectionId.createWithIdAndMeasure(n.identity[o],d),selected:!1};return m.end=d3.time.day.offset(m.start,m.duration),m.tooltipInfo=i.getTooltipInfo(m,a),m})},i.createSeries=function(e,a,r,s){var o=new t.ColorHelper(s,void 0),n=_.groupBy(a,function(e){return e.taskType}),l=i.getAllTasksTypes(r),c=_.map(l.types,function(i){return{tasks:n[i],fill:o.getColorForMeasure(e,i),name:i,identity:t.SelectionId.createWithMeasure(i),selected:!1}});return c},i.converter=function(e,a){if(!e||!e.categorical||!i.isChartHasTask(e)||0===e.table.rows.length)return null;var r=i.parseSettings(e,a),s=i.getAllTasksTypes(e),o={fontSize:r.legend.fontSize,dataPoints:[],title:s.typeName},n=new t.ColorHelper(a,void 0);o.dataPoints=_.map(s.types,function(i){return{label:i,color:n.getColorForMeasure(e.metadata.objects,i),icon:t.LegendIcon.Circle,selected:!1,identity:t.SelectionId.createWithMeasure(i)}});var l=this.getFormatters(e),c=i.createTasks(e,l,a),u=i.createSeries(e.metadata.objects,c,e,a),h={dataView:e,settings:r,tasks:c,series:u,legendData:o,taskTypes:s};return h},i.parseSettings=function(t,a){var r=_.cloneDeep(i.DefaultSettings);if(!t||!t.metadata||!t.metadata.objects)return r;var s=t.metadata.objects;return r.general.groupTasks=e.DataViewObjects.getValue(s,i.Properties.general.groupTasks,i.DefaultSettings.general.groupTasks),r.taskLabels.show=e.DataViewObjects.getValue(s,i.Properties.taskLabels.show,i.DefaultSettings.taskLabels.show),r.taskLabels.fill=e.DataViewObjects.getFillColor(s,i.Properties.taskLabels.fill,i.DefaultSettings.taskLabels.fill),r.taskLabels.fontSize=e.DataViewObjects.getValue(s,i.Properties.taskLabels.fontSize,i.DefaultSettings.taskLabels.fontSize),r.taskLabels.width=e.DataViewObjects.getValue(s,i.Properties.taskLabels.width,r.taskLabels.show?i.DefaultSettings.taskLabels.width:0),r.taskCompletion.show=e.DataViewObjects.getValue(s,i.Properties.taskCompletion.show,i.DefaultSettings.taskCompletion.show),delete r.taskCompletion.show,r.taskCompletion.fill=e.DataViewObjects.getFillColor(s,i.Properties.taskCompletion.fill,i.DefaultSettings.taskCompletion.fill),r.taskResource.show=e.DataViewObjects.getValue(s,i.Properties.taskResource.show,i.DefaultSettings.taskResource.show),r.taskResource.fontSize=e.DataViewObjects.getValue(s,i.Properties.taskResource.fontSize,i.DefaultSettings.taskResource.fontSize),r.taskResource.fill=e.DataViewObjects.getFillColor(s,i.Properties.taskResource.fill,i.DefaultSettings.taskResource.fill),r.dateType.type=e.DataViewObjects.getValue(s,i.Properties.dateType.type,i.DefaultSettings.dateType.type),r.legend.show=e.DataViewObjects.getValue(s,i.Properties.legend.show,i.DefaultSettings.legend.show),r.legend.fontSize=e.DataViewObjects.getValue(s,i.Properties.legend.fontSize,i.DefaultSettings.legend.fontSize),r.legend.labelColor=e.DataViewObjects.getFillColor(s,i.Properties.legend.labelColor,i.DefaultSettings.legend.labelColor),r.legend.position=e.DataViewObjects.getValue(s,i.Properties.legend.position,i.DefaultSettings.legend.position),r.legend.showTitle=e.DataViewObjects.getValue(s,i.Properties.legend.showTitle,i.DefaultSettings.legend.showTitle),r.legend.titleText=e.DataViewObjects.getValue(s,i.Properties.legend.titleText,i.DefaultSettings.legend.titleText),r},i.isValidDate=function(e){return"[object Date]"!==Object.prototype.toString.call(e)?!1:!isNaN(e.getTime())},i.convertToDecimal=function(e){return e>=0&&1>=e?e:e/100},i.getAllTasksTypes=function(e){var t,i=[],a="",r=e.table.rows,s=_.findIndex(e.table.columns,function(e){return e.roles.hasOwnProperty("Legend")});return-1!==s&&(a=e.table.columns[s].displayName,i=_.unique(r,function(e){return e[s]}).map(function(e){return e[s]})),t={typeName:a,types:i}},i.prototype.renderLegend=function(){if(this.viewModel.legendData){t.LegendData.update(this.viewModel.legendData,e.DataViewObjects.getObject(this.viewModel.dataView.metadata.objects,"legend",{}));var i=this.viewModel.settings.legend.show?t.LegendPosition[this.viewModel.settings.legend.position]:t.LegendPosition.None;switch(this.legend.changeOrientation(i),this.legend.drawLegend(this.viewModel.legendData,_.clone(this.viewport)),t.Legend.positionChartArea(this.ganttDiv,this.legend),this.legend.getOrientation()){case t.LegendPosition.Left:case t.LegendPosition.LeftCenter:case t.LegendPosition.Right:case t.LegendPosition.RightCenter:this.viewport.width-=this.legend.getMargins().width;break;case t.LegendPosition.Top:case t.LegendPosition.TopCenter:case t.LegendPosition.Bottom:case t.LegendPosition.BottomCenter:this.viewport.height-=this.legend.getMargins().height}}},i.prototype.update=function(e){if(e.dataViews&&e.dataViews[0]){if(this.viewModel=i.converter(e.dataViews[0],this.colors),!this.viewModel)return void this.clearViewport();this.viewport=_.clone(e.viewport),this.margin=i.DefaultMargin,this.renderLegend(),this.updateChartSize();var t=this.viewModel.tasks;if(this.interactivityService&&(this.interactivityService.applySelectionStateToData(t),this.interactivityService.applySelectionStateToData(this.viewModel.series)),t.length>0){var a=_.sortBy(t,function(e){return e.start}),r=_.sortBy(t,function(e){return e.end}),s=this.getDateType(),n=a[0].start,l=r[t.length-1].end,c=Math.ceil(Math.round(l.valueOf()-n.valueOf())/s),u=this.groupTasks(t);c=0===c||1===c?2:c;var h=50*c;this.ganttSvg.attr({height:o.toString(u.length*p+this.margin.top),width:o.toString(this.margin.left+this.viewModel.settings.taskLabels.width+h+i.DefaultValues.ResourceWidth)});var d={height:this.viewport.height,width:h},m=this.calculateAxes(d,this.textProperties,n,l,h,c,!1);if(this.timeScale=m.scale,this.renderAxis(m,200),this.renderTasks(u),this.createMilestoneLine(u),this.updateTaskLabels(u,this.viewModel.settings.taskLabels.width),this.updateElementsPositions(this.viewport,this.margin),this.interactivityService){var y={clearCatcher:this.clearCatcher,taskSelection:this.taskGroup.selectAll(g.SingleTask.selector),legendSelection:this.body.selectAll(g.LegendItems.selector),interactivityService:this.interactivityService};this.interactivityService.bind(t,this.behavior,y)}}}},i.prototype.getDateType=function(){var e=c;switch(this.viewModel.settings.dateType.type){case"Day":e=l;break;case"Week":e=c;break;case"Month":e=u;break;case"Year":e=h}return e},i.prototype.calculateAxes=function(i,a,r,s,o,n,l){var c=e.ValueType.fromPrimitiveTypeAndCategory(e.PrimitiveType.Date),u={displayName:"StartDate",queryName:"StartDate",type:c,index:0},h={viewport:i,margin:this.margin,forcedXDomain:[r,s],forceMerge:!1,showCategoryAxisLabel:!1,showValueAxisLabel:!1,categoryAxisScaleType:e.visuals.axisScale.linear,valueAxisScaleType:null,valueAxisDisplayUnits:0,categoryAxisDisplayUnits:0,trimOrdinalDataOnOverflow:!1,forcedTickCount:n},p=i.width,d=this.calculateAxesProperties(i,h,o,u);return d.willLabelsFit=t.AxisHelper.LabelLayoutStrategy.willLabelsFit(d,p,e.TextMeasurementService.measureSvgTextWidth,a),d.willLabelsWordBreak=!d.willLabelsFit&&!l&&t.AxisHelper.LabelLayoutStrategy.willLabelsWordBreak(d,this.margin,p,e.TextMeasurementService.measureSvgTextWidth,e.TextMeasurementService.estimateSvgTextHeight,e.TextMeasurementService.getTailoredTextOrDefault,a),d},i.prototype.calculateAxesProperties=function(e,a,r,s){var o=this,n=t.AxisHelper.createAxis({pixelSpan:e.width,dataDomain:a.forcedXDomain,metaDataColumn:s,formatString:i.DefaultValues.DateFormatStrings[this.viewModel.settings.dateType.type],outerPadding:0,isScalar:!0,isVertical:!1,forcedTickCount:a.forcedTickCount,useTickIntervalForDisplayUnits:!0,isCategoryAxis:!0,getValueFn:function(e,a){return t.valueFormatter.format(new Date(e),i.DefaultValues.DateFormatStrings[o.viewModel.settings.dateType.type])},scaleType:a.categoryAxisScaleType,axisDisplayUnits:a.categoryAxisDisplayUnits});return n.axisLabel=s.displayName,n},i.prototype.groupTasks=function(e){if(this.viewModel.settings.general.groupTasks){var t=_.groupBy(e,function(e){return e.name}),i=_.map(t,function(e,i){return{name:i,tasks:t[i]}});return i.forEach(function(e,t){e.tasks.forEach(function(e){return e.id=t}),e.id=t}),i}return e.map(function(e){return{name:e.name,id:e.id,tasks:[e]}})},i.prototype.renderAxis=function(e,t){var i=e.axis;i.orient("bottom"),this.axisGroup.transition().duration(t).call(i)},i.prototype.updateTaskLabels=function(a,r){var s,n=this,l=15,c=this.viewModel?this.viewModel.settings.taskLabels.show:!0,u=this.viewModel?this.viewModel.settings.taskLabels.fill:i.DefaultSettings.taskLabels.fill,h=this.viewModel?this.viewModel.settings.taskLabels.fontSize:i.DefaultSettings.taskLabels.fontSize;c?(s=this.lineGroup.selectAll(g.Label.selector).data(a),s.enter().append("text").classed(g.Label["class"],!0),s.attr({x:l,y:function(e,t){return n.getTaskLabelCoordinateY(e.id)},fill:u,"stroke-width":1}).style("font-size",o.fromPoint(h)).text(function(e){return e.name}),s.call(t.AxisHelper.LabelLayoutStrategy.clip,r-20,e.TextMeasurementService.svgEllipsis),s.append("title").text(function(e){return e.name}),s.exit().remove()):this.lineGroup.selectAll(g.Label.selector).remove()},i.prototype.renderTasks=function(a){var r=this,s=this.taskGroup.selectAll(g.TaskGroup.selector).data(a),n=this.viewModel?this.viewModel.settings.taskCompletion.fill:i.DefaultSettings.taskCompletion.fill,l=this.viewModel?this.viewModel.settings.taskResource.show:!0,c=4,u=this.viewModel?this.viewModel.settings.taskResource.fill:i.DefaultSettings.taskResource.fill,h=this.viewModel?this.viewModel.settings.taskResource.fontSize:i.DefaultSettings.taskResource.fontSize;s.enter().append("g").classed(g.TaskGroup["class"],!0);var p=s.selectAll(g.SingleTask.selector).data(function(e){return e.tasks});p.enter().append("g").classed(g.SingleTask["class"],!0);var d=p.selectAll(g.TaskRect.selector).data(function(e){return[e]});d.enter().append("rect").classed(g.TaskRect["class"],!0),d.classed(g.TaskRect["class"],!0).attr({x:function(e){return r.timeScale(e.start)},y:function(e){return r.getBarYCoordinate(e.id)},width:function(e){return r.taskDurationToWidth(e)},height:function(){return r.getBarHeight()}}).style("fill",function(e){return e.color}),d.exit().remove();var m=p.selectAll(g.TaskProgress.selector).data(function(e){return[e]});if(m.enter().append("rect").classed(g.TaskProgress["class"],!0),m.attr({x:function(e){return r.timeScale(e.start)},y:function(e){return r.getBarYCoordinate(e.id)+r.getBarHeight()/2-i.DefaultValues.ProgressBarHeight/2},width:function(e){return r.setTaskProgress(e)},height:i.DefaultValues.ProgressBarHeight}).style("fill",n),m.exit().remove(),l){var y=p.selectAll(g.TaskResource.selector).data(function(e){return[e]});y.enter().append("text").classed(g.TaskResource["class"],!0),y.attr({x:function(e){return r.timeScale(e.end)+c},y:function(e){return r.getBarYCoordinate(e.id)+r.getBarHeight()/2+c}}).text(function(e){return e.resource}).style({fill:u,"font-size":o.fromPoint(h)}).call(t.AxisHelper.LabelLayoutStrategy.clip,i.DefaultValues.ResourceWidth-10,e.TextMeasurementService.svgEllipsis),y.exit().remove()}else p.selectAll(g.TaskResource.selector).remove();t.TooltipManager.addTooltip(p,function(e){return e.data.tooltipInfo}),p.exit().remove(),s.exit().remove()},i.prototype.onClearSelection=function(){this.selectionManager.clear()},i.prototype.getTaskLabelCoordinateY=function(e){var t=+this.viewModel.settings.taskLabels.fontSize;return p*e+(this.getBarHeight()+5-(40-t)/4)},i.prototype.setTaskProgress=function(e){var t=e.completion/1,i=this.timeScale,a=(i(e.end)-i(e.start))*t;return a},i.prototype.getBarYCoordinate=function(e){return p*e+d},i.prototype.getBarHeight=function(){return p/1.5},i.prototype.taskDurationToWidth=function(e){return this.timeScale(e.end)-this.timeScale(e.start)},i.prototype.getTooltipForMilstoneLine=function(e,t){var i=new Date(e).toDateString(),a=[{displayName:t,value:i}];return a},i.prototype.createMilestoneLine=function(e,i,a){void 0===i&&(i="Today"),void 0===a&&(a=Date.now());var r=[{x1:this.timeScale(a),y1:0,x2:this.timeScale(a),y2:this.getMilestoneLineLength(e.length),tooltipInfo:this.getTooltipForMilstoneLine(a,i)}],s=this.chartGroup.selectAll(g.ChartLine.selector).data(r);s.enter().append("line").classed(g.ChartLine["class"],!0),s.attr({x1:function(e){return e.x1},y1:function(e){return e.y1},x2:function(e){return e.x2},y2:function(e){return e.y2},tooltipInfo:function(e){return e.tooltipInfo}}),t.TooltipManager.addTooltip(s,function(e){return e.data.tooltipInfo}),s.exit().remove()},i.prototype.updateElementsPositions=function(e,i){this.axisGroup.attr("transform",t.SVGUtil.translate(this.viewModel.settings.taskLabels.width+i.left,15)),this.chartGroup.attr("transform",t.SVGUtil.translate(this.viewModel.settings.taskLabels.width+i.left,i.top)),this.lineGroup.attr("transform",t.SVGUtil.translate(0,i.top))},i.prototype.getMilestoneLineLength=function(e){return e*p},i.prototype.enumerateGeneral=function(e){return[]},i.prototype.enumerateLegend=function(e){return[{displayName:i.Properties.legend.show.objectName,selector:null,properties:e.legend,objectName:i.Properties.legend.show.objectName}]},i.prototype.enumerateDataPoints=function(e){return this.viewModel.series.map(function(e){return{objectName:"dataPoint",displayName:e.name,selector:t.ColorHelper.normalizeSelector(e.identity.getSelector(),!1),properties:{fill:{solid:{color:e.fill}}}}})},i.prototype.enumerateTaskCompletion=function(e){return[{selector:null,properties:e.taskCompletion,objectName:i.Properties.taskCompletion.show.objectName}]},i.prototype.enumerateTaskLabels=function(e){return[{selector:null,properties:e.taskLabels,objectName:i.Properties.taskLabels.show.objectName}]},i.prototype.enumerateTaskResources=function(e){return[{selector:null,properties:e.taskResource,objectName:i.Properties.taskResource.show.objectName}]},i.prototype.enumerateDateType=function(e){return[{selector:null,properties:e.dateType,objectName:i.Properties.dateType.type.objectName}]},i.prototype.enumerateObjectInstances=function(e){var a=this.viewModel&&this.viewModel.settings||i.DefaultSettings,r=new t.ObjectEnumerationBuilder,s=function(e){return e.forEach(function(e){return r.pushInstance(e)})};switch(e.objectName){case"general":s(this.enumerateGeneral(a));break;case"legend":s(this.enumerateLegend(a));break;case"dataPoint":s(this.enumerateDataPoints(a));break;case"taskLabels":s(this.enumerateTaskLabels(a));break;case"taskCompletion":s(this.enumerateTaskCompletion(a));break;case"taskResource":s(this.enumerateTaskResources(a));break;case"dateType":s(this.enumerateDateType(a))}return r.complete()},i.DefaultSettings={general:{groupTasks:!1},legend:{show:!0,position:t.legendPosition.right,showTitle:!0,titleText:"",labelColor:"#000000",fontSize:8},taskLabels:{show:!0,fill:"#000000",fontSize:9,width:110},taskCompletion:{show:!0,fill:"#000000"},taskResource:{show:!0,fill:"#000000",fontSize:9},dateType:{type:m.Week}},i.DefaultValues={AxisTickSize:6,MaxTaskOpacity:1,MinTaskOpacity:.4,ProgressBarHeight:4,ResourceWidth:100,TaskColor:"#00B099",TaskLineWidth:15,DefaultDateType:m.Week,DateFormatStrings:{Day:"MMM dd",Week:"MMM dd",Month:"MMM yyyy",Year:"yyyy"}},i.capabilities={dataRoles:[{name:"Legend",kind:e.VisualDataRoleKind.Grouping,displayName:"Legend"},{name:"Task",kind:e.VisualDataRoleKind.Grouping,displayName:"Task"},{name:"StartDate",kind:e.VisualDataRoleKind.Grouping,displayName:"Start Date"},{name:"Duration",kind:e.VisualDataRoleKind.Measure,displayName:"Duration",requiredTypes:[{numeric:!0},{integer:!0}]},{name:"Completion",kind:e.VisualDataRoleKind.Measure,displayName:"% Completion",requiredTypes:[{numeric:!0},{integer:!0}]},{name:"Resource",kind:e.VisualDataRoleKind.Grouping,displayName:"Resource"}],dataViewMappings:[{conditions:[{Legend:{min:0,max:1},Task:{min:1,max:1},StartDate:{min:0,max:0},Duration:{min:0,max:0},Completion:{min:0,max:0},Resource:{min:0,max:0}},{Legend:{min:0,max:1},Task:{min:1,max:1},StartDate:{min:0,max:1},Duration:{min:0,max:0},Completion:{min:0,max:0},Resource:{min:0,max:0}},{Legend:{min:0,
14max:1},Task:{min:0,max:1},StartDate:{min:0,max:1},Duration:{min:0,max:1},Completion:{min:0,max:1},Resource:{min:0,max:1}}],table:{rows:{select:[{"for":{"in":"Legend"}},{"for":{"in":"Task"}},{"for":{"in":"StartDate"}},{"for":{"in":"Duration"}},{"for":{"in":"Completion"}},{"for":{"in":"Resource"}}]}}}],objects:{general:{displayName:e.data.createDisplayNameGetter("Visual_General"),properties:{groupTasks:{displayName:"Group Tasks",type:{bool:!0}}}},legend:{displayName:"Legend",description:"Display legend options",properties:{show:{displayName:"Show",type:{bool:!0}},position:{displayName:"Position",description:"Select the location for the legend",type:{enumeration:t.legendPosition.type}},showTitle:{displayName:"Title",description:"Display a title for legend symbols",type:{bool:!0}},titleText:{displayName:"Legend Name",description:"Title text",type:{text:!0},suppressFormatPainterCopy:!0},labelColor:{displayName:"Color",type:{fill:{solid:{color:!0}}}},fontSize:{displayName:"Text Size",type:{formatting:{fontSize:!0}}}}},taskLabels:{displayName:"Category Labels",properties:{show:{displayName:"Show",type:{bool:!0}},fill:{displayName:"Fill",type:{fill:{solid:{color:!0}}}},fontSize:{displayName:"Font Size",type:{formatting:{fontSize:!0}}},width:{displayName:"Width",type:{numeric:!0}}}},taskCompletion:{displayName:"Task Completion",properties:{show:{type:{bool:!0}},fill:{displayName:"Completion Color",type:{fill:{solid:{color:!0}}}}}},taskResource:{displayName:"Data Labels",properties:{show:{displayName:"Show",type:{bool:!0}},fill:{displayName:"Color",type:{fill:{solid:{color:!0}}}},fontSize:{displayName:"Font Size",type:{formatting:{fontSize:!0}}}}},dateType:{displayName:"Gantt Date Type",properties:{type:{displayName:"Type",type:{enumeration:r(m)}}}}},sorting:{"default":{}}},i.Properties=i.getProperties(i.capabilities),i}();i.Gantt=y;var f=function(){function e(){}return e.prototype.bindEvents=function(e,t){this.options=e;var i=e.clearCatcher;e.taskSelection.on("click",function(e){t.handleSelection(e,d3.event.ctrlKey),d3.event.stopPropagation()}),i.on("click",function(){t.handleClearSelection()})},e.prototype.renderSelection=function(e){this.options.taskSelection.style("opacity",function(t){return e&&!t.selected?y.DefaultValues.MinTaskOpacity:y.DefaultValues.MaxTaskOpacity})},e}();i.GanttChartBehavior=f;var v=function(){function e(){}return Object.defineProperty(e.prototype,"code",{get:function(){return"GanttChartWarning"},enumerable:!0,configurable:!0}),e.prototype.getMessages=function(e){var t,i="This visual requires task value",a="",r="";return t={message:i,title:e.get(a),detail:e.get(r)}},e}();i.GanttChartWarning=v}(i=t.samples||(t.samples={}))}(t=e.visuals||(e.visuals={}))}(i||(i={}))},function(e,t){var i,a=window.jsCommon,i=window.powerbi,r=(window.powerbitests,window.InJs,window.debug,window.jasmine,window.Microsoft,this&&this.__extends||function(e,t){function i(){this.constructor=e}for(var a in t)t.hasOwnProperty(a)&&(e[a]=t[a]);e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)});!function(e){var t;!function(t){var i;!function(i){var s=a.CssConstants.createClassAndSelector,o=t.utility.SelectionManager,n=a.PixelConverter.toString,l=a.PixelConverter.fromPoint,c=a.PixelConverter.fromPointToPixel;i.Months=e.createEnumType([{value:1,displayName:"January"},{value:2,displayName:"February"},{value:3,displayName:"March"},{value:4,displayName:"April"},{value:5,displayName:"May"},{value:6,displayName:"June"},{value:7,displayName:"July"},{value:8,displayName:"August"},{value:9,displayName:"September"},{value:10,displayName:"October"},{value:11,displayName:"November"},{value:12,displayName:"December"}]),i.WeekDays=e.createEnumType([{value:0,displayName:"Sunday"},{value:1,displayName:"Monday"},{value:2,displayName:"Tuesday"},{value:3,displayName:"Wednesday"},{value:4,displayName:"Thursday"},{value:5,displayName:"Friday"},{value:6,displayName:"Saturday"}]),function(e){e[e.year=0]="year",e[e.quarter=1]="quarter",e[e.month=2]="month",e[e.week=3]="week",e[e.day=4]="day"}(i.GranularityType||(i.GranularityType={}));var u=i.GranularityType,h={objectName:"cells",propertyName:"fillSelected"},p={objectName:"cells",propertyName:"fillUnselected"},d={objectName:"granularity",propertyName:"scaleColor"},g={objectName:"granularity",propertyName:"sliderColor"},m={objectName:"rangeHeader",propertyName:"fontColor"},y={objectName:"rangeHeader",propertyName:"textSize"},f={objectName:"rangeHeader",propertyName:"show"},v={objectName:"labels",propertyName:"fontColor"},x={objectName:"labels",propertyName:"textSize"},b={objectName:"labels",propertyName:"show"},S={objectName:"calendar",propertyName:"month"},w={objectName:"calendar",propertyName:"day"},C={objectName:"weekDay",propertyName:"day"},P=[{granularityType:u.year,name:"year"},{granularityType:u.quarter,name:"quarter"},{granularityType:u.month,name:"month"},{granularityType:u.week,name:"week"},{granularityType:u.day,name:"day"}],D=function(){function e(){this.datePeriods=[]}return e.prototype.shortMonthName=function(e){return e.toString().split(" ")[1]},e.prototype.resetDatePeriods=function(){this.datePeriods=[]},e.prototype.getDatePeriods=function(){return this.datePeriods},e.prototype.getExtendedLabel=function(){return this.extendedLabel},e.prototype.setExtendedLabel=function(e){this.extendedLabel=e},e.prototype.createLabels=function(e){var t,i=[];return _.map(this.datePeriods,function(a){!_.isEmpty(i)&&e.sameLabel(a,t)||(t=a,i.push(e.generateLabel(a)))}),i},e.prototype.addDate=function(e,t){var i=this.getDatePeriods(),a=i[i.length-1];0!==i.length&&_.isEqual(a.identifierArray,t)?a.endDate=e:(i.length>0&&(a.endDate=e),i.push({identifierArray:t,startDate:e,endDate:e,week:this.determineWeek(e),year:this.determineYear(e),fraction:1,index:i.length}))},e.prototype.setNewEndDate=function(e){_.last(this.datePeriods).endDate=e},e.prototype.splitPeriod=function(e,t,i){var a=this.datePeriods[e];a.fraction-=t;var r={identifierArray:a.identifierArray,startDate:i,endDate:a.endDate,week:this.determineWeek(i),year:this.determineYear(i),fraction:t,index:a.index+a.fraction};a.endDate=i,this.datePeriods.splice(e+1,0,r)},e.prototype.previousMonth=function(e){return e>0?e-1:11},e.prototype.nextMonth=function(e){return 11>e?e+1:0},e.prototype.countWeeks=function(e,t){var i;if(t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()>=e.getDate())i=t.getDate()-e.getDate();else{i=t.getDate()-1;for(var a=this.nextMonth(e.getMonth()),r=t.getMonth();r!==a;)i+=new Date(t.getFullYear(),r,0).getDate(),r=this.previousMonth(r);i+=new Date(t.getFullYear(),a,0).getDate()-e.getDate()}return 1+Math.floor(i/7)},e.prototype.determineWeek=function(e){var t=e.getFullYear();this.inPreviousYear(e)&&t--;var i=I.calendar.getDateOfFirstWeek(t),a=this.countWeeks(i,e);return[a,t]},e.prototype.inPreviousYear=function(e){var t=I.calendar.getDateOfFirstWeek(e.getFullYear());return t>e},e.prototype.determineYear=function(e){var t=new Date(e.getFullYear(),I.calendar.getFirstMonthOfYear(),I.calendar.getFirstDayOfYear());return e.getFullYear()-(e>=t?0:1)},e}();i.TimelineGranularity=D;var A=function(e){function t(){e.apply(this,arguments)}return r(t,e),t.prototype.getType=function(){return u.day},t.prototype.splitDate=function(e){return[this.shortMonthName(e),e.getDate(),e.getFullYear()]},t.prototype.sameLabel=function(e,t){return e.startDate.getTime()===t.startDate.getTime()},t.prototype.generateLabel=function(e){return{title:this.shortMonthName(e.startDate)+" "+e.startDate.getDate()+" - "+e.year,text:e.startDate.getDate().toString(),id:e.index}},t}(D);i.DayGranularity=A;var T=function(e){function t(){e.apply(this,arguments)}return r(t,e),t.prototype.getType=function(){return u.month},t.prototype.splitDate=function(e){return[this.shortMonthName(e),e.getFullYear()]},t.prototype.sameLabel=function(e,t){return this.shortMonthName(e.startDate)===this.shortMonthName(t.startDate)},t.prototype.generateLabel=function(e){var t=this.shortMonthName(e.startDate);return{title:t,text:t,id:e.index}},t}(D);i.MonthGranularity=T;var V=function(e){function t(){e.apply(this,arguments)}return r(t,e),t.prototype.getType=function(){return u.week},t.prototype.splitDate=function(e){return this.determineWeek(e)},t.prototype.sameLabel=function(e,t){return _.isEqual(e.week,t.week)},t.prototype.generateLabel=function(e){return{title:"Week "+e.week[0]+" - "+e.week[1],text:"W"+e.week[0],id:e.index}},t}(D);i.WeekGranularity=V;var N=function(e){function t(){e.apply(this,arguments)}return r(t,e),t.prototype.quarterText=function(e){for(var t=3,i=e.getFullYear();e<I.calendar.getQuarterStartDate(i,t);)t>0?t--:(t=3,i--);return t++,"Q"+t},t.prototype.getType=function(){return u.quarter},t.prototype.splitDate=function(e){return[this.quarterText(e),e.getFullYear()]},t.prototype.sameLabel=function(e,t){return this.quarterText(e.startDate)===this.quarterText(t.startDate)&&e.year===t.year},t.prototype.generateLabel=function(e){var t=this.quarterText(e.startDate);return{title:t+" "+e.year,text:t,id:e.index}},t}(D);i.QuarterGranularity=N;var L=function(e){function t(){e.apply(this,arguments)}return r(t,e),t.prototype.getType=function(){return u.year},t.prototype.splitDate=function(e){return[e.getFullYear()]},t.prototype.sameLabel=function(e,t){return e.year===t.year},t.prototype.generateLabel=function(e){return{title:"Year "+e.year,text:e.year.toString(),id:e.index}},t}(D);i.YearGranularity=L;var M=function(){function e(t,i){this.granularities=[],this.setDatesRange(t,i);var a=this.dates[this.dates.length-1];this.endingDate=e.nextDay(a)}return e.previousDay=function(e){var t=new Date(e.getTime());return t.setDate(t.getDate()-1),t},e.nextDay=function(e){var t=new Date(e.getTime());return t.setDate(t.getDate()+1),t},e.prototype.setDatesRange=function(t,i){this.dates=[];for(var a=t;i>=a;)this.dates.push(a),a=e.nextDay(a)},e.prototype.addGranularity=function(e){e.resetDatePeriods();for(var t=0,i=this.dates;t<i.length;t++){var a=i[t],r=e.splitDate(a);e.addDate(a,r)}e.setNewEndDate(this.endingDate),this.granularities.push(e)},e.prototype.getGranularity=function(e){return this.granularities[e]},e.prototype.createGranularities=function(){this.granularities=[],this.addGranularity(new L),this.addGranularity(new N),this.addGranularity(new T),this.addGranularity(new V),this.addGranularity(new A)},e.prototype.createLabels=function(){var e=this;this.granularities.forEach(function(t){t.setExtendedLabel({dayLabels:t.getType()>=u.day?t.createLabels(e.granularities[u.day]):[],weekLabels:t.getType()>=u.week?t.createLabels(e.granularities[u.week]):[],monthLabels:t.getType()>=u.month?t.createLabels(e.granularities[u.month]):[],quarterLabels:t.getType()>=u.quarter?t.createLabels(e.granularities[u.quarter]):[],yearLabels:t.getType()>=u.year?t.createLabels(e.granularities[u.year]):[]})})},e}();i.TimelineGranularityData=M;var k=function(){function e(){}return e.getStartSelectionDate=function(e){return e.currentGranularity.getDatePeriods()[e.selectionStartIndex].startDate},e.getEndSelectionDate=function(e){return e.currentGranularity.getDatePeriods()[e.selectionEndIndex].endDate},e.getEndSelectionPeriod=function(e){return e.currentGranularity.getDatePeriods()[e.selectionEndIndex]},e.getCellColor=function(t,i,a){var r=t.datePeriod.startDate>=e.getStartSelectionDate(i)&&t.datePeriod.endDate<=e.getEndSelectionDate(i);return r?a.colorInProperty:a.colorOutProperty||"transparent"},e.getGranularityType=function(e){var t=_.findIndex(P,function(t){return t.name===e});return P[t].granularityType},e.getGranularityName=function(e){var t=_.findIndex(P,function(t){return t.granularityType===e});return P[t].name},e.separateSelection=function(t,i,a){var r=t.currentGranularity.getDatePeriods(),s=_.findIndex(r,function(e){return i<e.endDate}),o=_.findIndex(r,function(e){return a<=e.endDate});t.selectionStartIndex=s,t.selectionEndIndex=o;var n=e.getDateRatio(r[s],i,!0),l=e.getDateRatio(r[o],a,!1);if(l>0&&t.currentGranularity.splitPeriod(o,l,a),n>0){var c=r[s].fraction-n;t.currentGranularity.splitPeriod(s,c,i),t.selectionStartIndex++,t.selectionEndIndex++}},e.getDateRatio=function(e,t,i){var a=i?t.getTime()-e.startDate.getTime():e.endDate.getTime()-t.getTime(),r=e.endDate.getTime()-e.startDate.getTime();return 0===r?0:a/r},e.timeRangeText=function(t){var i=t.currentGranularity.splitDate(e.getStartSelectionDate(t)),a=t.currentGranularity.splitDate(e.getEndSelectionPeriod(t).startDate);return i.join(" ")+" - "+a.join(" ")},e.dateRangeText=function(e){return e.startDate.toDateString()+" - "+M.previousDay(e.endDate).toDateString()},e.unseparateSelection=function(e){var t=_.findIndex(e,function(e){return e.fraction<1});return t>=0?(e[t].endDate=e[t+1].endDate,e[t].fraction+=e[t+1].fraction,e.splice(t+1,1),!0):!1},e}();i.Utils=k;var O=function(){function e(e){var t=this;this.firstDayOfWeek=e.weekDayProperty,this.firstMonthOfYear=e.firstMonthProperty-1,this.firstDayOfYear=e.firstDayProperty,this.dateOfFirstWeek={},this.quarterFirstMonths=[0,3,6,9].map(function(e){return e+t.firstMonthOfYear})}return e.prototype.getFirstDayOfWeek=function(){return this.firstDayOfWeek},e.prototype.getFirstMonthOfYear=function(){return this.firstMonthOfYear},e.prototype.getFirstDayOfYear=function(){return this.firstDayOfYear},e.prototype.getQuarterStartDate=function(e,t){return new Date(e,this.quarterFirstMonths[t],this.firstDayOfYear)},e.prototype.isChanged=function(e){return this.firstMonthOfYear!==e.firstMonthProperty-1||this.firstDayOfYear!==e.firstDayProperty||this.firstDayOfWeek!==e.weekDayProperty},e.prototype.calculateDateOfFirstWeek=function(e){for(var t=new Date(e,this.firstMonthOfYear,this.firstDayOfYear);t.getDay()!==this.firstDayOfWeek;)t=M.nextDay(t);return t},e.prototype.getDateOfFirstWeek=function(e){return this.dateOfFirstWeek[e]||(this.dateOfFirstWeek[e]=this.calculateDateOfFirstWeek(e)),this.dateOfFirstWeek[e]},e}();i.Calendar=O;var I=function(){function a(){var e=this;this.requiresNoUpdate=!1,this.datasetsChangedState=!1,this.selector=["Y","Q","M","W","D"],this.timelineMargins={LeftMargin:15,RightMargin:15,TopMargin:15,BottomMargin:10,CellWidth:40,CellHeight:25,StartXpoint:10,StartYpoint:20,ElementWidth:30,MinCellWidth:30,MaxCellHeight:60,PeriodSlicerRectWidth:15,PeriodSlicerRectHeight:23},this.defaultTimelineProperties={DefaultLabelsShow:!0,TimelineDefaultTextSize:9,TimelineDefaultCellColor:"#ADD8E6",TimelineDefaultCellColorOut:"",TimelineDefaultTimeRangeShow:!0,DefaultTimeRangeColor:"#777777",DefaultLabelColor:"#777777",DefaultScaleColor:"#000000",DefaultSliderColor:"#AAAAAA",DefaultGranularity:u.month,DefaultFirstMonth:1,DefaultFirstDay:1,DefaultFirstWeekDay:0},this.timelineSelectors={TimelineVisual:s("Timeline"),SelectionRangeContainer:s("selectionRangeContainer"),textLabel:s("label"),LowerTextCell:s("lowerTextCell"),UpperTextCell:s("upperTextCell"),UpperTextArea:s("upperTextArea"),LowerTextArea:s("lowerTextArea"),RangeTextArea:s("rangeTextArea"),CellsArea:s("cellsArea"),CursorsArea:s("cursorsArea"),MainArea:s("mainArea"),SelectionCursor:s("selectionCursor"),Cell:s("cell"),CellRect:s("cellRect"),VertLine:s("timelineVertLine"),TimelineSlicer:s("timelineSlicer"),PeriodSlicerGranularities:s("periodSlicerGranularities"),PeriodSlicerSelection:s("periodSlicerSelection"),PeriodSlicerSelectionRect:s("periodSlicerSelectionRect"),PeriodSlicerRect:s("periodSlicerRect")},this.drag=d3.behavior.drag().origin(function(t){return t.x=t.selectionIndex*e.timelineProperties.cellWidth,t}).on("dragstart",function(){e.dragstarted()}).on("drag",function(t){e.dragged(t)}).on("dragend",function(){e.dragended()})}return a.prototype.changeGranularity=function(e,t,i){k.unseparateSelection(this.timelineData.currentGranularity.getDatePeriods())&&k.unseparateSelection(this.timelineData.currentGranularity.getDatePeriods()),this.timelineData.currentGranularity=this.timelineGranularityData.getGranularity(e),k.separateSelection(this.timelineData,t,i)},a.prototype.init=function(e){this.hostServices=e.host,this.initialized=!1;var t=e.element;this.selectionManager=new o({hostServices:e.host}),this.timelineProperties={element:t,textYPosition:50,cellsYPosition:3*this.timelineMargins.TopMargin+65,topMargin:this.timelineMargins.TopMargin,bottomMargin:this.timelineMargins.BottomMargin,leftMargin:this.timelineMargins.LeftMargin,startXpoint:this.timelineMargins.StartXpoint,startYpoint:this.timelineMargins.StartYpoint,cellWidth:this.timelineMargins.CellWidth,cellHeight:this.timelineMargins.CellHeight,elementWidth:this.timelineMargins.ElementWidth,rightMargin:this.timelineMargins.RightMargin},this.body=d3.select(t.get(0)),this.timelineDiv=this.body.append("div"),this.svg=this.timelineDiv.append("svg").attr("width",n(e.viewport.width)).classed(this.timelineSelectors.TimelineVisual["class"],!0),this.addWrappElements()},a.prototype.addWrappElements=function(){this.clearCatcher=t.appendClearCatcher(this.svg),this.clearCatcher.data([this]).on("click",function(e){return e.clear()}).on("touchstart",function(e){return e.clear()}),this.rangeText=this.svg.append("g").classed(this.timelineSelectors.RangeTextArea["class"],!0).append("text"),this.mainGroupElement=this.svg.append("g").classed(this.timelineSelectors.MainArea["class"],!0),this.yearLabelsElement=this.mainGroupElement.append("g"),this.quarterLabelsElement=this.mainGroupElement.append("g"),this.monthLabelsElement=this.mainGroupElement.append("g"),this.weekLabelsElement=this.mainGroupElement.append("g"),this.dayLabelsElement=this.mainGroupElement.append("g"),this.cellsElement=this.mainGroupElement.append("g").classed(this.timelineSelectors.CellsArea["class"],!0),this.cursorGroupElement=this.svg.append("g").classed(this.timelineSelectors.CursorsArea["class"],!0)},a.prototype.clear=function(){this.initialized&&(this.selectionManager.clear(),this.timelineData&&(this.timelineData.selectionStartIndex=0,this.timelineData.selectionEndIndex=this.timelineData.currentGranularity.getDatePeriods().length-1,_.any(this.timelineData.timelineDatapoints,function(e){return e.index%1!==0})?this.selectPeriod(this.timelineData.currentGranularity.getType()):(a.updateCursors(this.timelineData,this.timelineProperties.cellWidth),this.fillCells(this.timelineFormat.cellFormat),this.renderCursors(this.timelineData,this.timelineFormat,this.timelineProperties.cellHeight,this.timelineProperties.cellsYPosition),this.renderTimeRangeText(this.timelineData,this.timelineFormat.rangeTextFormat),this.fillColorGranularity(this.timelineFormat.granularityFormat)),this.setSelection(this.timelineData)))},a.prototype.drawGranular=function(e){var t=this,i=!1,a=e.startXpoint,r=e.startYpoint,s=e.elementWidth;this.selectorContainer=this.svg.append("g").classed(this.timelineSelectors.TimelineSlicer["class"],!0),this.selectorContainer.on("mouseleave",function(e){return i=!1}),this.horizLine=this.selectorContainer.append("rect");var o=this.selector;this.horizLine.attr({height:n(1),x:n(a),y:n(r+2),width:n((o.length-1)*s)}),this.vertLine=this.selectorContainer.selectAll("vertLines").data(o).enter().append("rect"),this.vertLine.classed(this.timelineSelectors.VertLine["class"],!0).attr({x:function(e,t){return n(a+t*s)},y:n(r),width:n(2),height:n(3)}).style({cursor:"pointer"});var l=this.selectorContainer.selectAll(this.timelineSelectors.PeriodSlicerGranularities.selector).data(o).enter().append("text").classed(this.timelineSelectors.PeriodSlicerGranularities["class"],!0);this.textLabels=l.text(function(e){return e}).attr({x:function(e,t){return n(a-3+t*s)},y:n(r-3)}),this.selectedText=this.selectorContainer.append("text").classed(this.timelineSelectors.PeriodSlicerSelection["class"],!0),this.selectedText.text(k.getGranularityName(this.defaultTimelineProperties.DefaultGranularity)).attr({x:n(a+2*s),y:n(r+17)});var c=this.selectorContainer.selectAll(this.timelineSelectors.PeriodSlicerSelectionRect.selector).data(o).enter().append("rect").classed(this.timelineSelectors.PeriodSlicerSelectionRect["class"],!0),u=function(e,a){t.selectPeriod(a),i=!0};c.attr({x:function(e,t){return n(a-s/2+t*s)},y:n(3),width:n(s),height:n(23)}).style({cursor:"pointer"}).on("mousedown",u).on("touchstart",u).on("mouseup",function(){return i=!1}).on("touchend",function(){return i=!1}).on("mouseover",function(e,a){i&&t.selectPeriod(a)});var h=d3.behavior.drag().on("dragstart",function(e,t){i=!0}).on("dragend",function(e,t){i=!1});this.periodSlicerRect=this.selectorContainer.append("rect").classed(this.timelineSelectors.PeriodSlicerRect["class"],!0).attr({x:n(a-6+this.defaultTimelineProperties.DefaultGranularity*s),y:n(r-16),rx:n(4),width:n(15),height:n(23)}).on("mouseup",function(e){return i=!1}),this.periodSlicerRect.call(h)},a.prototype.fillColorGranularity=function(e){this.periodSlicerRect.style("stroke",e.sliderColorProperty),this.selectedText.attr("fill",e.scaleColorProperty),this.textLabels.attr("fill",e.scaleColorProperty),this.vertLine.attr("fill",e.scaleColorProperty),this.horizLine.attr("fill",e.scaleColorProperty)},a.prototype.redrawPeriod=function(e){var t=this.timelineMargins.StartXpoint+e*this.timelineMargins.ElementWidth;this.periodSlicerRect.transition().attr("x",n(t-7)),this.selectedText.text(k.getGranularityName(e));var i=k.getStartSelectionDate(this.timelineData),a=k.getEndSelectionDate(this.timelineData);this.changeGranularity(e,i,a)},a.setMeasures=function(e,t,i,a,r,s){r.cellsYPosition=r.textYPosition;var o=c(e.sizeProperty);e.showProperty&&(r.cellsYPosition+=1.5*o*(t+1));var n=Math.max(0,a.height-s.TopMargin),l=a.width-s.RightMargin-s.MinCellWidth*i,u=Math.max(s.MinCellWidth,Math.min(s.MaxCellHeight,l,n-r.cellsYPosition-20)),h=Math.max(s.MinCellWidth,(a.width-u-s.RightMargin)/i);r.cellHeight=u,r.cellWidth=h},a.prototype.visualChangeOnly=function(e){if(e&&e.dataViews&&e.dataViews[0]&&e.dataViews[0].metadata&&this.options&&this.options.dataViews&&this.options.dataViews[0]&&this.options.dataViews[0].metadata){var t=e.dataViews[0].metadata.objects,i=this.options.dataViews[0].metadata.objects,a=["rangeHeader","cells","labels","granularity"],r=!a.every(function(e){return _.isEqual(t?t[e]:void 0,i?i[e]:void 0)});return e.suppressAnimations||r}return!1},a.prototype.datasetsChanged=function(e){if(e&&e.dataViews&&e.dataViews[0]&&e.dataViews[0].categorical&&e.dataViews[0].categorical.categories&&e.dataViews[0].categorical.categories[0]&&e.dataViews[0].categorical.categories[0].source&&this.options&&this.options.dataViews&&this.options.dataViews[0]&&this.options.dataViews[0].categorical&&this.options.dataViews[0].categorical.categories&&this.options.dataViews[0].categorical.categories[0]&&this.options.dataViews[0].categorical.categories[0].source){var t=e.dataViews[0].categorical.categories[0].source.displayName,i=this.options.dataViews[0].categorical.categories[0].source.displayName;if(!_.isEqual(t,i))return!0}return!1},a.prototype.unavailableType=function(e){return!(e.categories&&1===e.categories.length&&e.categories[0].values&&0!==e.categories[0].values.length&&e.categories[0].source&&e.categories[0].source.type)},a.prototype.unavailableChildIdentityField=function(e){return!e.root||!e.root.childIdentityFields||0===e.root.childIdentityFields.length},a.prototype.createTimelineOptions=function(e){if(this.dataView=e,!e.categorical||!e.metadata||this.unavailableType(e.categorical)||!e.tree||this.unavailableChildIdentityField(e.tree))return!1;var t=e.tree.root.childIdentityFields[0];return this.valueType=t?t.ref:null,e.categorical.categories[0].source.type.dateTime||e.categorical.categories[0].source.type.numeric&&("Year"===this.valueType||"Date"===this.valueType)?(this.values=this.prepareValues(this.dataView.categorical.categories[0].values),!0):!1},a.prototype.prepareValues=function(e){e=e.filter(Boolean);for(var t in e){var i=e[t];if("String"==typeof i&&"Invalid Date"!==String(new Date(i)))return e[t]=new Date(i)}return e},a.prototype.createTimelineData=function(){var e,t;if("Year"===this.valueType){var i=this.values;e=new Date(_.min(i),0),t=new Date(_.max(i),11)}else{var r=this.values;e=_.min(r),t=_.max(r)}if(this.timelineFormat=a.fillTimelineFormat(this.options.dataViews[0].metadata.objects,this.defaultTimelineProperties),this.initialized||(this.drawGranular(this.timelineProperties),this.fillColorGranularity(this.timelineFormat.granularityFormat)),this.initialized){var s=M.nextDay(t),o=this.timelineGranularityData.getGranularity(u.day).getDatePeriods(),n=o[0].startDate,l=o[o.length-1].endDate,c=e.getTime()>=n.getTime()&&s.getTime()<=l.getTime();this.newGranularity=this.timelineData.currentGranularity.getType(),c?this.changeGranularity(this.newGranularity,e,s):(l>s&&(t=o[o.length-1].startDate),e>n&&(e=n),this.initialized=!1)}this.initialized||(this.timelineGranularityData=new M(e,t),this.timelineData={elementsCount:0,timelineDatapoints:[],cursorDataPoints:new Array})},a.prototype.update=function(e){var t=this.visualChangeOnly(e);if(this.datasetsChangedState=this.datasetsChanged(e),this.requiresNoUpdate=this.requiresNoUpdate&&!this.datasetsChangedState&&!t,this.requiresNoUpdate)return void(this.requiresNoUpdate=!1);if(this.options=e,e.dataViews&&e.dataViews[0]){var i=this.createTimelineOptions(e.dataViews[0]);if(!i)return void this.clearData();this.newGranularity=this.defaultTimelineProperties.DefaultGranularity,t||this.createTimelineData(),this.timelineFormat=a.converter(this.timelineData,this.timelineProperties,this.defaultTimelineProperties,this.timelineGranularityData,e.dataViews[0],this.initialized,this.newGranularity,e.viewport,this.timelineMargins),this.render(this.timelineData,this.timelineFormat,this.timelineProperties,e),this.initialized=!0}},a.prototype.selectPeriod=function(e){this.redrawPeriod(e),this.timelineFormat=a.converter(this.timelineData,this.timelineProperties,this.defaultTimelineProperties,this.timelineGranularityData,this.options.dataViews[0],this.initialized,this.timelineData.currentGranularity.getType(),this.options.viewport,this.timelineMargins),this.render(this.timelineData,this.timelineFormat,this.timelineProperties,this.options)},a.isDataNotMatch=function(e){return e.categorical.categories.length<=0||void 0===e.categorical.categories[0]||void 0===e.categorical.categories[0].identityFields||e.categorical.categories[0].identityFields.length<=0},a.converter=function(e,t,i,r,s,o,n,l,c){var u=a.fillTimelineFormat(s.metadata.objects,i);if(o||(e.cursorDataPoints.push({x:0,selectionIndex:0,cursorIndex:0}),e.cursorDataPoints.push({x:0,selectionIndex:0,cursorIndex:1})),o&&!a.calendar.isChanged(u.calendarFormat)||(a.calendar=new O(u.calendarFormat),r.createGranularities(),r.createLabels(),e.currentGranularity=r.getGranularity(n),e.selectionStartIndex=0,e.selectionEndIndex=e.currentGranularity.getDatePeriods().length-1),e.categorySourceName=s.categorical.categories[0].source.displayName,e.columnIdentity=s.categorical.categories[0].identityFields[0],s.categorical.categories[0].source.type.numeric&&(e.columnIdentity.ref="Date"),!this.isDataNotMatch(s)){var h=e.currentGranularity.getDatePeriods();e.elementsCount=h.length,e.timelineDatapoints=[];for(var p=0,d=h;p<d.length;p++){var g=d[p],m={index:g.index,datePeriod:g};e.timelineDatapoints.push(m)}var y=e.currentGranularity.getDatePeriods().filter(function(e){return e.index%1===0}).length;return a.setMeasures(u.labelFormat,e.currentGranularity.getType(),y,l,t,c),a.updateCursors(e,t.cellWidth),u}},a.prototype.render=function(e,i,a,r){var s=this.timelineData.timelineDatapoints.filter(function(e){return e.index%1===0}).length;this.svgWidth=1+this.timelineProperties.cellHeight+a.cellWidth*s,this.renderTimeRangeText(e,i.rangeTextFormat),this.fillColorGranularity(this.timelineFormat.granularityFormat),this.timelineDiv.attr({height:n(r.viewport.height),width:n(r.viewport.width),"drag-resize-disabled":!0}).style({"overflow-x":"auto","overflow-y":"auto"}),this.svg.attr({height:n(Math.max(0,r.viewport.height-this.timelineMargins.TopMargin)),width:n(Math.max(0,this.svgWidth))});var o=t.SVGUtil.translate(a.leftMargin,a.topMargin),l=t.SVGUtil.translate(a.cellHeight/2,a.topMargin);this.mainGroupElement.attr("transform",l),this.selectorContainer.attr("transform",o),this.cursorGroupElement.attr("transform",l);var c=this.timelineData.currentGranularity.getExtendedLabel(),u=this.timelineData.currentGranularity.getType(),h=0,p=1.5;this.renderLabels(c.yearLabels,this.yearLabelsElement,h,0===u),h+=p,this.renderLabels(c.quarterLabels,this.quarterLabelsElement,h,1===u),h+=p,this.renderLabels(c.monthLabels,this.monthLabelsElement,h,2===u),h+=p,this.renderLabels(c.weekLabels,this.weekLabelsElement,h,3===u),h+=p,this.renderLabels(c.dayLabels,this.dayLabelsElement,h,4===u),this.renderCells(e,i,a,r.suppressAnimations),this.renderCursors(e,i,a.cellHeight,a.cellsYPosition)},a.prototype.renderLabels=function(i,a,r,s){var o=this,n=a.selectAll(this.timelineSelectors.textLabel.selector);if(!this.timelineFormat.labelFormat.showProperty)return void n.remove();var u=n.data(i);u.enter().append("text").classed(this.timelineSelectors.textLabel["class"],!0),u.text(function(a,r){if(!s&&0===r&&i.length>1){var n=l(o.timelineFormat.labelFormat.sizeProperty),c={text:i[0].text,fontFamily:"arial",fontSize:n},u=e.TextMeasurementService.measureSvgTextWidth(c)/2;c={text:i[1].text,fontFamily:"arial",fontSize:n};var h=e.TextMeasurementService.measureSvgTextWidth(c)/2,p=o.timelineProperties.cellWidth*(i[1].id-i[0].id);if(u+h>p)return""}var d={label:a.text,maxWidth:o.timelineProperties.cellWidth*(s?.9:3),fontSize:o.timelineFormat.labelFormat.sizeProperty};return t.dataLabelUtils.getLabelFormattedText(d)}).style("font-size",l(this.timelineFormat.labelFormat.sizeProperty)).attr({x:function(e){return(e.id+.5)*o.timelineProperties.cellWidth},y:this.timelineProperties.textYPosition+(1+r)*c(this.timelineFormat.labelFormat.sizeProperty),fill:this.timelineFormat.labelFormat.colorProperty}).append("title").text(function(e){return e.title}),u.exit().remove()},a.prototype.clearData=function(){this.initialized=!1,this.mainGroupElement.selectAll(this.timelineSelectors.CellRect.selector).remove(),this.mainGroupElement.selectAll(this.timelineSelectors.textLabel.selector).remove(),this.rangeText.text(""),this.cursorGroupElement.selectAll(this.timelineSelectors.SelectionCursor.selector).remove(),this.svg.select(this.timelineSelectors.TimelineSlicer.selector).remove(),this.mainGroupElement.selectAll(this.timelineSelectors.textLabel.selector)},a.updateCursors=function(e,t){var i=e.timelineDatapoints[e.selectionStartIndex].datePeriod;e.cursorDataPoints[0].selectionIndex=i.index;var a=e.timelineDatapoints[e.selectionEndIndex].datePeriod;e.cursorDataPoints[1].selectionIndex=a.index+a.fraction},a.fillTimelineFormat=function(t,i){var a={rangeTextFormat:{showProperty:e.DataViewObjects.getValue(t,f,i.TimelineDefaultTimeRangeShow),colorProperty:e.DataViewObjects.getFillColor(t,m,i.DefaultTimeRangeColor),sizeProperty:e.DataViewObjects.getValue(t,y,i.TimelineDefaultTextSize)},cellFormat:{colorInProperty:e.DataViewObjects.getFillColor(t,h,i.TimelineDefaultCellColor),colorOutProperty:e.DataViewObjects.getFillColor(t,p,i.TimelineDefaultCellColorOut)},granularityFormat:{scaleColorProperty:e.DataViewObjects.getFillColor(t,d,i.DefaultScaleColor),sliderColorProperty:e.DataViewObjects.getFillColor(t,g,i.DefaultSliderColor)},labelFormat:{showProperty:e.DataViewObjects.getValue(t,b,i.DefaultLabelsShow),colorProperty:e.DataViewObjects.getFillColor(t,v,i.DefaultLabelColor),sizeProperty:e.DataViewObjects.getValue(t,x,i.TimelineDefaultTextSize)},calendarFormat:{firstMonthProperty:e.DataViewObjects.getValue(t,S,1),firstDayProperty:Math.max(1,Math.min(31,e.DataViewObjects.getValue(t,w,i.DefaultFirstDay))),weekDayProperty:Math.max(0,Math.min(6,e.DataViewObjects.getValue(t,C,i.DefaultFirstWeekDay)))}};return a},a.prototype.fillCells=function(e){var t=this,i=this.timelineData.timelineDatapoints,a=this.mainGroupElement.selectAll(this.timelineSelectors.CellRect.selector).data(i);a.attr("fill",function(i){return k.getCellColor(i,t.timelineData,e)})},a.prototype.renderCells=function(e,t,i,a){
15var r=this,s=e.timelineDatapoints,o=0,l=this.cellsElement.selectAll(this.timelineSelectors.CellRect.selector).data(s);l.enter().append("rect").classed(this.timelineSelectors.CellRect["class"],!0),l.attr({height:n(i.cellHeight),width:function(e){return n(e.datePeriod.fraction*i.cellWidth)},x:function(e){var t=o;return o+=e.datePeriod.fraction*i.cellWidth,n(t)},y:n(i.cellsYPosition),id:function(e){return e.index}});var c=function(a,s){d3.event.preventDefault();var o=r.timelineData.cursorDataPoints,n=d3.event;n.altKey||n.shiftKey?r.timelineData.selectionEndIndex<s?(o[1].selectionIndex=a.datePeriod.index+a.datePeriod.fraction,e.selectionEndIndex=s):(o[0].selectionIndex=a.datePeriod.index,e.selectionStartIndex=s):(e.selectionStartIndex=s,e.selectionEndIndex=s,o[0].selectionIndex=a.datePeriod.index,o[1].selectionIndex=a.datePeriod.index+a.datePeriod.fraction),r.fillCells(t.cellFormat),r.renderCursors(e,t,i.cellHeight,i.cellsYPosition),r.renderTimeRangeText(e,t.rangeTextFormat),r.fillColorGranularity(r.timelineFormat.granularityFormat),r.setSelection(e)};l.on("click",c).on("touchstart",c),this.fillCells(t.cellFormat),l.exit().remove()},a.prototype.dragstarted=function(){this.timelineData.dragging=!0},a.prototype.dragged=function(e){if(this.timelineData.dragging===!0){var t=1,i=d3.select(this.timelineSelectors.TimelineVisual.selector);if(i){var a=i.style("transform");if(void 0!==a&&"none"!==a){var r=a.split("(")[1];t=Number(r.split(", ")[0])}}var s=this.findCursorOverElement(d3.event.x);if(!s)return;var o=s.datapoint,n=s.index;0===e.cursorIndex&&n<=this.timelineData.selectionEndIndex&&(this.timelineData.selectionStartIndex=n,this.timelineData.cursorDataPoints[0].selectionIndex=o.datePeriod.index),1===e.cursorIndex&&n>=this.timelineData.selectionStartIndex&&(this.timelineData.selectionEndIndex=n,this.timelineData.cursorDataPoints[1].selectionIndex=o.datePeriod.index+o.datePeriod.fraction),this.fillCells(this.timelineFormat.cellFormat),this.renderCursors(this.timelineData,this.timelineFormat,this.timelineProperties.cellHeight,this.timelineProperties.cellsYPosition),this.renderTimeRangeText(this.timelineData,this.timelineFormat.rangeTextFormat),this.fillColorGranularity(this.timelineFormat.granularityFormat)}},a.prototype.findCursorOverElement=function(e){var t=this.timelineData.timelineDatapoints||[],i=t.length,a=this.timelineProperties.cellWidth;if(t[0]&&t[1]&&e<=t[1].index*a)return{index:0,datapoint:t[0]};if(t[i-1]&&e>=t[i-1].index*a)return{index:i-1,datapoint:t[i-1]};for(var r=1;i>r;r++){var s=t[r].index*a,o=t[r+1].index*a;if(e>=s&&o>=e)return{index:r,datapoint:t[r]}}return null},a.prototype.dragended=function(){this.setSelection(this.timelineData)},a.prototype.renderCursors=function(e,i,a,r){var s=this,o=this.cursorGroupElement.selectAll(this.timelineSelectors.SelectionCursor.selector).data(e.cursorDataPoints);return o.enter().append("path").classed(this.timelineSelectors.SelectionCursor["class"],!0),o.attr("transform",function(e){return t.SVGUtil.translate(e.selectionIndex*s.timelineProperties.cellWidth,a/2+r)}).attr({d:d3.svg.arc().innerRadius(0).outerRadius(a/2).startAngle(function(e){return e.cursorIndex*Math.PI+Math.PI}).endAngle(function(e){return e.cursorIndex*Math.PI+2*Math.PI})}).call(this.drag),o.exit().remove(),o},a.prototype.renderTimeRangeText=function(e,i){var a=(P.length+2)*this.timelineProperties.elementWidth,r=this.svgWidth-a-this.timelineProperties.leftMargin;if(i.showProperty&&r>0){var s=k.timeRangeText(e),o={label:s,maxWidth:r,fontSize:i.sizeProperty},n=t.dataLabelUtils.getLabelFormattedText(o);this.rangeText.classed(this.timelineSelectors.SelectionRangeContainer["class"],!0),this.rangeText.attr({x:P.length*(this.timelineProperties.elementWidth+this.timelineProperties.leftMargin),y:40,fill:i.colorProperty}).style({"font-size":l(i.sizeProperty)}).text(n).append("title").text(s)}else this.rangeText.text("")},a.prototype.setSelection=function(t){this.requiresNoUpdate=!0;var i=e.data.SQExprBuilder.dateTime(k.getStartSelectionDate(t)),a=e.data.SQExprBuilder.dateTime(new Date(k.getEndSelectionDate(t).getTime()-1)),r=e.data.SQExprBuilder.between(t.columnIdentity,i,a),s=e.data.SemanticFilter.fromSQExpr(r),o={merge:[{objectName:"general",selector:void 0,properties:{filter:s}}]};this.hostServices.persistProperties(o),this.hostServices.onSelect({data:[]})},a.prototype.enumerateObjectInstances=function(e){var i=new t.ObjectEnumerationBuilder;switch(e.objectName){case"rangeHeader":this.enumerateRangeHeader(i,this.dataView);break;case"cells":this.enumerateCells(i,this.dataView);break;case"granularity":this.enumerateGranularity(i,this.dataView);break;case"labels":this.enumerateLabels(i,this.dataView);break;case"calendar":this.enumerateCalendar(i,this.dataView);break;case"weekDay":this.enumerateWeekDay(i,this.dataView)}return i.complete()},a.prototype.enumerateRangeHeader=function(t,i){var a=i&&i.metadata?i.metadata.objects:void 0;t.pushInstance({objectName:"rangeHeader",displayName:"Selection Color",selector:null,properties:{show:e.DataViewObjects.getValue(a,f,this.defaultTimelineProperties.TimelineDefaultTimeRangeShow),fontColor:e.DataViewObjects.getFillColor(a,m,this.defaultTimelineProperties.DefaultTimeRangeColor),textSize:e.DataViewObjects.getValue(a,y,this.defaultTimelineProperties.TimelineDefaultTextSize)}})},a.prototype.enumerateCells=function(t,i){var a=i&&i.metadata?i.metadata.objects:void 0;t.pushInstance({objectName:"cells",selector:null,properties:{fillSelected:e.DataViewObjects.getFillColor(a,h,this.defaultTimelineProperties.TimelineDefaultCellColor),fillUnselected:e.DataViewObjects.getFillColor(a,p,this.defaultTimelineProperties.TimelineDefaultCellColorOut)}})},a.prototype.enumerateGranularity=function(t,i){var a=i&&i.metadata?i.metadata.objects:void 0;t.pushInstance({objectName:"granularity",selector:null,properties:{scaleColor:e.DataViewObjects.getFillColor(a,d,this.defaultTimelineProperties.DefaultScaleColor),sliderColor:e.DataViewObjects.getFillColor(a,g,this.defaultTimelineProperties.DefaultSliderColor)}})},a.prototype.enumerateLabels=function(t,i){var a=i&&i.metadata?i.metadata.objects:void 0;t.pushInstance({objectName:"labels",selector:null,properties:{show:e.DataViewObjects.getValue(a,b,this.defaultTimelineProperties.DefaultLabelsShow),fontColor:e.DataViewObjects.getFillColor(a,v,this.defaultTimelineProperties.DefaultLabelColor),textSize:e.DataViewObjects.getValue(a,x,this.defaultTimelineProperties.TimelineDefaultTextSize)}})},a.prototype.enumerateCalendar=function(t,i){var a=i&&i.metadata?i.metadata.objects:void 0;t.pushInstance({objectName:"calendar",selector:null,properties:{month:Math.max(1,Math.min(12,e.DataViewObjects.getValue(a,S,1))),day:Math.max(1,Math.min(31,e.DataViewObjects.getValue(a,w,1)))}})},a.prototype.enumerateWeekDay=function(t,i){var a=i&&i.metadata?i.metadata.objects:void 0;t.pushInstance({objectName:"weekDay",selector:null,properties:{day:Math.max(0,Math.min(6,e.DataViewObjects.getValue(a,C,0)))}})},a.capabilities={dataRoles:[{name:"Time",kind:e.VisualDataRoleKind.Grouping,displayName:"Time"}],dataViewMappings:[{conditions:[{Time:{max:1}}],categorical:{categories:{"for":{"in":"Time"},dataReductionAlgorithm:{sample:{}}},values:{select:[{bind:{to:"Time"}}]}}}],objects:{general:{displayName:"General",properties:{formatString:{type:{formatting:{formatString:!0}}},selected:{type:{bool:!0}},filter:{type:{filter:{}},rule:{output:{property:"selected",selector:["Time"]}}}}},calendar:{displayName:"Fiscal Year Start",properties:{month:{displayName:"Month",type:{enumeration:i.Months}},day:{displayName:"Day",type:{numeric:!0}}}},weekDay:{displayName:"First Day of Week",properties:{day:{displayName:"Day",type:{enumeration:i.WeekDays}}}},rangeHeader:{displayName:"Range Header",properties:{show:{displayName:"Show",type:{bool:!0}},fontColor:{displayName:"Font color",type:{fill:{solid:{color:!0}}}},textSize:{displayName:"Text Size",type:{numeric:!0}}}},cells:{displayName:"Cells",properties:{fillSelected:{displayName:"Selected cell color",type:{fill:{solid:{color:!0}}}},fillUnselected:{displayName:"Unselected cell color",type:{fill:{solid:{color:{nullable:!0}}}}}}},granularity:{displayName:"Granularity",properties:{scaleColor:{displayName:"Scale color",type:{fill:{solid:{color:!0}}}},sliderColor:{displayName:"Slider color",type:{fill:{solid:{color:!0}}}}}},labels:{displayName:"Labels",properties:{show:{displayName:"Show",type:{bool:!0}},fontColor:{displayName:"Font color",type:{fill:{solid:{color:!0}}}},textSize:{displayName:"Text Size",type:{numeric:!0}}}}}},a}();i.Timeline=I}(i=t.samples||(t.samples={}))}(t=e.visuals||(e.visuals={}))}(i||(i={}))},function(e,t){var i,a=window.jsCommon,i=window.powerbi;window.powerbitests,window.InJs,window.debug,window.jasmine,window.Microsoft;!function(e){var t;!function(t){var i;!function(i){var r=e.visuals.valueFormatter,s=a.PixelConverter,o="axisGraphicsContext",n="dataPointsContainer",l="x axis",c="y axis",u="#777",h=8,p=4,d=10,g="#666666",m="wf_segoe-ui_normal",y="normal",f=20,v=10,x=20,b=45,S=10,w=20,C={legendSettings:{show:!0,showTitle:!0,labelColor:g,titleText:"",fontSize:h},categoryAxisSettings:{show:!0,labelColor:u,showAxisTitle:!1},valueAxisSettings:{show:!0,labelColor:u,showAxisTitle:!1},dataLabelsSettings:t.dataLabelUtils.getDefaultPointLabelSettings()},P=function(){function e(){}return e.prototype.bindEvents=function(e,t){this.selection=e.selection,this.clearCatcher=e.clearCatcher,this.interactivityService=e.interactivityService,this.selection.on("click",function(e,i){t.handleSelection(e,d3.event.ctrlKey)}),this.clearCatcher.on("click",function(){t.handleClearSelection()})},e.prototype.renderSelection=function(e){var i=this.interactivityService.hasSelection();this.selection.style("fill-opacity",function(a){return t.ColumnUtil.getFillOpacity(a.selected,a.highlight,!a.highlight&&e,!a.selected&&i)})},e}(),D=function(){function i(){this.margin={left:b,right:15,bottom:f,top:10}}return i.prototype.converter=function(a,o,n){if(!(a&&a.categorical&&a.categorical.values&&a.categorical.categories&&o))return null;for(var l,c,u=a.categorical,p=u.categories,d=u.values,g=[],m={dataPoints:[],title:d.source?d.source.displayName:"",fontSize:h},y=0,f=p&&p.length>0?p[0]:null,v=i.Properties.general.formatString,x=!!(d.length>0&&d[0].highlights),b=this.parseSettings(a),S=s.fromPoint(b.dataLabelsSettings.fontSize),w=0;w<d.length;w++){var C=d[w].source.groupName,P=d[w].identity?t.SelectionId.createWithId(d[w].identity):t.SelectionId.createWithMeasure(d[w].source.queryName);C?m.dataPoints.push({label:C,color:o.getColorByIndex(w).value,icon:t.LegendIcon.Box,selected:!1,identity:P}):C=d[w].source.displayName;var D=t.TooltipBuilder.createTooltipInfo(v,{categories:null,values:d},null,null,null,null,w);g[w]={dataPoints:[],tooltipInfo:D,highlight:x,identity:P,selected:!1};var A=d[w].values;if(0!==A.length)for(var T=0;T<A.length;T++){var V=x?d[w].highlights[T]:A[T];V>y&&(y=V),g[w].dataPoints.push({x:T,y:isNaN(V)?0:V,text:C,labelFontSize:S})}}n&&n.applySelectionStateToData(g),l=r.create({format:"g",value:y}),c=r.create({format:r.getFormatString(f.source,i.Properties.general.formatString),value:f.values});for(var N=[],L=this.getTextPropertiesFunction,M=0;M<f.values.length;M++){var k=void 0;if(null!=f.values[M]){k=c.format(f.values[M]);var O=e.TextMeasurementService.measureSvgTextWidth(L(k));O>i.MaxNumberOfAxisXValues&&(i.MaxNumberOfAxisXValues=O)}N.push(k)}return{series:g,legendData:m,valueFormatter:l,categoryFormatter:c,streamGraphSettings:b,categoriesText:N}},i.prototype.parseSettings=function(t){if(!t||!t.metadata)return C;var a=t.metadata.objects,r=_.cloneDeep(C),s=r.categoryAxisSettings;s.show=e.DataViewObjects.getValue(a,i.Properties.categoryAxis.show,s.show),s.labelColor=e.DataViewObjects.getFillColor(a,i.Properties.categoryAxis.labelColor,s.labelColor),s.showAxisTitle=e.DataViewObjects.getValue(a,i.Properties.categoryAxis.showAxisTitle,s.showAxisTitle);var o=r.valueAxisSettings;o.show=e.DataViewObjects.getValue(a,i.Properties.valueAxis.show,o.show),o.labelColor=e.DataViewObjects.getFillColor(a,i.Properties.valueAxis.labelColor,o.labelColor),o.showAxisTitle=e.DataViewObjects.getValue(a,i.Properties.valueAxis.showAxisTitle,o.showAxisTitle);var n=r.dataLabelsSettings;n.show=e.DataViewObjects.getValue(a,i.Properties.labels.show,n.show),n.labelColor=e.DataViewObjects.getFillColor(a,i.Properties.labels.color,n.labelColor),n.fontSize=e.DataViewObjects.getValue(a,i.Properties.labels.fontSize,n.fontSize);var l=r.legendSettings,c=t.categorical.values.source,u=c&&_.isEmpty(l.titleText)?c.displayName:l.titleText;return l.show=e.DataViewObjects.getValue(a,i.Properties.legend.show,l.show),l.showTitle=e.DataViewObjects.getValue(a,i.Properties.legend.showTitle,l.showTitle),l.titleText=e.DataViewObjects.getValue(a,i.Properties.legend.titleText,u),l.labelColor=e.DataViewObjects.getValue(a,i.Properties.legend.labelColor,l.labelColor),l.fontSize=e.DataViewObjects.getValue(a,i.Properties.legend.fontSize,l.fontSize),_.isEmpty(l.titleText)&&(l.titleText=u),r},i.prototype.init=function(e){var a=e.element,r=this.svg=d3.select(a.get(0)).append("svg").classed(i.VisualClassName,!0).style("position","absolute");this.clearCatcher=t.appendClearCatcher(r),this.axisGraphicsContext=r.append("g").classed(o,!0),this.xAxis=this.axisGraphicsContext.append("g").classed(l,!0),this.yAxis=this.axisGraphicsContext.append("g").classed(c,!0),this.dataPointsContainer=r.append("g").classed(n,!0),this.viewport=e.viewport,this.colors=e.style.colorPalette.dataColors,this.behavior=new P;var s=e.interactivity;this.interactivityService=t.createInteractivityService(e.host),this.legend=t.createLegend(a,s&&s.isInteractiveLegend,this.interactivityService,!0)},i.prototype.update=function(e){if(!e.dataViews||!e.dataViews[0]||!e.dataViews[0].categorical)return void this.clearData();this.viewport={width:Math.max(0,e.viewport.width),height:Math.max(0,e.viewport.height)};var i=e.suppressAnimations?0:250,a=this.dataView=e.dataViews[0],r=this.data=this.converter(a,this.colors,this.interactivityService);if(!r||!r.series||!r.series.length)return void this.clearData();this.renderLegend(r),this.renderXAxisLabels(),this.renderYAxisLabels(),this.svg.attr({width:this.viewport.width+"px",height:this.viewport.height+"px"});var s=this.renderChart(r.series,i);t.TooltipManager.addTooltip(s,function(e){return e.data.tooltipInfo});var o=this.interactivityService;if(o){var n={selection:s,clearCatcher:this.clearCatcher,interactivityService:o};o.bind(r.series,this.behavior,n)}},i.prototype.getStreamGraphLabelLayout=function(e,t){var i=this.data.streamGraphSettings.dataLabelsSettings,a=s.fromPoint(i.fontSize);return{labelText:function(e){return e.text},labelLayout:{x:function(t){return e(t.x)},y:function(e){return t(e.y0)}},filter:function(e){return null!=e&&null!=e.text},style:{fill:i.labelColor,"font-size":a}}},i.prototype.renderChart=function(e,a){var r=this,s=d3.layout.stack().values(function(e){return e.dataPoints}),o=this.viewport.width,l=this.viewport.height;this.getWiggle(this.dataView)&&s.offset("wiggle");var c=s(e),u=this.margin,h=d3.scale.linear().domain([0,e[0].dataPoints.length-1]).range([u.left,o-u.right]),d=d3.max(c,function(e){return d3.max(e.dataPoints,function(e){return e.y0+e.y})}),g=d3.min(c,function(e){return d3.min(e.dataPoints,function(e){return e.y0+e.y})}),m=d3.scale.linear().domain([Math.min(g,0),d]).range([l-u.bottom,u.top]).nice(),y=d3.svg.area().interpolate("monotone").x(function(e){return h(e.x)}).y0(function(e){return m(e.y0)}).y1(function(e){return m(e.y0+e.y)}).defined(function(e){return!isNaN(e.y0)&&!isNaN(e.y)}),f=this.dataPointsContainer.selectAll(i.Layer.selector).data(c);if(f.enter().append("path").classed(i.Layer["class"],!0),f.style("fill",function(e,t){return r.colors.getColorByIndex(t).value}).style("fill-opacity",t.ColumnUtil.DefaultOpacity).transition().duration(a).attr("d",function(e){return y(e.dataPoints)}),f.selectAll("path").append("g").classed(n,!0),f.exit().remove(),this.data.streamGraphSettings.dataLabelsSettings.show){var v=d3.scale.linear().domain([0,e[0].dataPoints.length-1]).range([0,o-u.left-u.right]),x=this.getStreamGraphLabelLayout(v,m),b=[];e.forEach(function(e){var t;t=e.dataPoints.filter(function(e){return e&&null!==e.y&&void 0!==e.y}),t.length>0&&(b=b.concat(t))});var S={height:l-u.top-u.bottom,width:o-u.right-u.left},w=t.dataLabelUtils.drawDefaultLabelsForDataPointChart(b,this.svg,x,S);if(w){var C=p+u.left;w.attr("transform",function(e){return t.SVGUtil.translate(C+e.size.width/2,e.size.height/2)})}}else t.dataLabelUtils.cleanDataLabels(this.svg);return this.drawAxis(this.data,h,m),f},i.prototype.drawAxis=function(a,r,s){for(var o=this.margin,n=this.viewport.height-o.bottom,l=this.viewport.width-o.left-o.right,c=this.data.categoriesText,u=d3.svg.axis(),h=i.MaxNumberOfAxisXValues,p=this.getTextPropertiesFunction,g=0;g<c.length;g++)if(null!=c[g]){var m=c[g].toString(),y=e.TextMeasurementService.measureSvgTextWidth(p(m));y>h&&(h=y)}u.scale(r).orient("bottom").ticks(c.length).tickFormat(function(t){var i=c[t];return a.categoryFormatter&&(i=a.categoryFormatter.format(i)),null===t||void 0===t||0!==t&&t!==c.length-1||(i=e.TextMeasurementService.getTailoredTextOrDefault(p(i),2*(t?o.right:o.left))),i});var f=d3.svg.axis().scale(s).orient("left").tickFormat(function(t){var i=t;return a.valueFormatter&&(i=a.valueFormatter.format(i)),i=e.TextMeasurementService.getTailoredTextOrDefault(p(i.toString()),b-d)});this.setMaxTicks(u,l,Math.max(2,Math.round(l/h))),this.setMaxTicks(f,n);var v=this.data.streamGraphSettings.valueAxisSettings;if(v.show){var x=v.labelColor;this.yAxis.attr("transform",t.SVGUtil.translate(o.left,0)).call(f),this.yAxis.selectAll("text").style("fill",x)}else this.yAxis.selectAll("*").remove();var S=this.data.streamGraphSettings.categoryAxisSettings;if(S.show){var x=S.labelColor;this.xAxis.attr("transform",t.SVGUtil.translate(0,n)).call(u),this.xAxis.selectAll("text").style("fill",x)}else this.xAxis.selectAll("*").remove()},i.prototype.renderYAxisLabels=function(){this.axisGraphicsContext.selectAll(i.YAxisLabel.selector).remove();var a=this.data.streamGraphSettings.valueAxisSettings;if(this.margin.left=a.show?b:S,a.showAxisTitle){this.margin.left+=w;var r=this.data.streamGraphSettings.categoryAxisSettings,s=r.show===!0,o=r.showAxisTitle===!0,n=this.margin.top,l=this.viewport.height-n-(s?f:v)-(o?x:0),c=this.dataView.categorical.values,u=c.source?c.source.displayName:this.getYAxisTitleFromValues(c),h=this.getTextPropertiesFunction(u);u=e.TextMeasurementService.getTailoredTextOrDefault(h,l);var p=i.YAxisLabel["class"],d=this.axisGraphicsContext.append("text").style("text-anchor","middle").style("font-family",h.fontFamily).style("font-size",h.fontSize).style("font-style",h.fontStyle).style("font-weight",h.fontWeight).text(u).call(function(e){e.each(function(){var e=d3.select(this);e.attr({"class":p,transform:"rotate(-90)",fill:a.labelColor,x:-(n+l/2),dy:"1em"})})});d.call(t.AxisHelper.LabelLayoutStrategy.clip,l,e.TextMeasurementService.svgEllipsis)}},i.prototype.getYAxisTitleFromValues=function(e){for(var i=[],a=0;a<e.length;a++)e[a]&&e[a].source&&e[a].source.displayName&&i.push({displayName:e[a].source.displayName});var r=i.map(function(e){return e?e.displayName:""}).filter(function(e,t,i){return""!==e&&i.indexOf(e)===t});return t.valueFormatter.formatListAnd(r)},i.prototype.renderXAxisLabels=function(){this.axisGraphicsContext.selectAll(i.XAxisLabel.selector).remove();var a=this.data.streamGraphSettings.categoryAxisSettings;if(this.margin.bottom=a.show?f:v,a.showAxisTitle&&this.dataView.categorical.categories[0].source){this.margin.bottom+=x;var r=this.data.streamGraphSettings.valueAxisSettings,s=r.show===!0,o=r.showAxisTitle===!0,n=(s?b:S)+(o?w:0),l=this.viewport.width-this.margin.right-n,c=this.viewport.height,u=this.dataView.categorical.categories[0].source.displayName,h=this.getTextPropertiesFunction(u);u=e.TextMeasurementService.getTailoredTextOrDefault(h,l);var p=i.XAxisLabel["class"],d=this.axisGraphicsContext.append("text").style("text-anchor","middle").style("font-family",h.fontFamily).style("font-size",h.fontSize).style("font-weight",h.fontWeight).text(u).call(function(e){e.each(function(){var e=d3.select(this);e.attr({"class":p,transform:t.SVGUtil.translate(n+l/2,c),fill:a.labelColor,dy:"-0.5em"})})});d.call(t.AxisHelper.LabelLayoutStrategy.clip,l,e.TextMeasurementService.svgEllipsis)}},i.prototype.renderLegend=function(i){var a=i.streamGraphSettings.legendSettings,r=i.legendData;if(this.dataView&&this.dataView.metadata){var s=e.DataViewObjects.getObject(this.dataView.metadata.objects,"legend",{});s.titleText=a.titleText,t.LegendData.update(r,s);var o=s[t.legendProps.position];o&&this.legend.changeOrientation(t.LegendPosition[o]),this.legend.drawLegend(r,_.clone(this.viewport)),t.Legend.positionChartArea(this.svg,this.legend),this.updateViewPort()}},i.prototype.updateViewPort=function(){var e=this.legend.getMargins(),i=this.legend.getOrientation();switch(i){case t.LegendPosition.Top:case t.LegendPosition.TopCenter:case t.LegendPosition.Bottom:case t.LegendPosition.BottomCenter:this.viewport.height=Math.max(0,this.viewport.height-e.height);break;case t.LegendPosition.Left:case t.LegendPosition.LeftCenter:case t.LegendPosition.Right:case t.LegendPosition.RightCenter:this.viewport.width=Math.max(0,this.viewport.width-e.width)}},i.prototype.setMaxTicks=function(e,t,i){var a=void 0===i?this.getTicksByAxis(e).length:Math.min(i,this.getTicksByAxis(e).length);e.scale().domain.toString()===d3.scale.linear().domain.toString()?e.ticks(this.getFittedTickLength(e,t,a)):e.tickValues(this.getFittedTickValues(e,t,a))},i.prototype.getFittedTickLength=function(e,t,i){for(var a=this.getTicksByAxis(e),r=this.getMeasureTickFunction(e,a);i>0&&t>0&&(this.measureTicks(a,r)>t||e.scale().ticks([i]).length>i);i--,a=this.getTicksByAxis(e))e.ticks(i);return i},i.prototype.getFittedTickValues=function(e,t,i){for(var a,r=this.getTicksByAxis(e),s=[],o=this.getMeasureTickFunction(e,r),n=i,l=[];i>0&&t>0;n--,l=[]){switch(n){case 0:return[];case 1:l=[0];break;case 2:l=[0,r.length-1];break;default:for(var c=r.length/(n-1),u=0;n-1>u;u++)l.push(Math.round(c*u));l.push(r.length-1)}var h=l.map(function(e){return[r[e],e]});if(a=t/r.length*2,h.reduce(function(e,t){return s.push([o(e[0])+o(t[0]),(t[1]-e[1])*a]),t}),!s.some(function(e){return e[0]>e[1]}))return h.map(function(e){return e[0]})}return[]},i.prototype.measureTicks=function(e,t){return e.map(function(e){return t(e)}).reduce(function(e,t){return e+t})},i.prototype.getTicksByAxis=function(e){var t=e.scale(),i=null===e.tickValues()?t.ticks?t.ticks.apply(t,e.ticks()):t.domain():e.tickValues();return void 0===i.length?[i]:i},i.prototype.getMeasureTickFunction=function(t,i){var a="top"===t.orient()||"bottom"===t.orient()?e.TextMeasurementService.measureSvgTextWidth:e.TextMeasurementService.measureSvgTextHeight,r=this.getTextPropertiesFunction,s={};return function(e){return s[e]?s[e]:s[e]=a(r(t.tickFormat()(e)))+t.tickPadding()}},i.prototype.getTextPropertiesFunction=function(e){var t=m,i=s.fromPoint(h),a=y;return{text:e,fontFamily:t,fontSize:i,fontWeight:a}},i.prototype.getWiggle=function(t){if(t&&t.metadata){var i=t.metadata.objects;if(i){var a=e.DataViewObjects.getObject(i,"general",void 0);if(a)return a.wiggle}}return!0},i.prototype.enumerateValueAxisValues=function(e){var t=this.data&&this.data.streamGraphSettings?this.data.streamGraphSettings.valueAxisSettings:C.valueAxisSettings;e.pushInstance({selector:null,objectName:"valueAxis",displayName:"Y-Axis",properties:{show:t.show,showAxisTitle:t.showAxisTitle,labelColor:t.labelColor}})},i.prototype.enumerateCategoryAxisValues=function(e){var t=this.data&&this.data.streamGraphSettings?this.data.streamGraphSettings.categoryAxisSettings:C.categoryAxisSettings;e.pushInstance({selector:null,objectName:"categoryAxis",displayName:"X-Axis",properties:{show:t.show,showAxisTitle:t.showAxisTitle,labelColor:t.labelColor}})},i.prototype.enumerateLegend=function(e){var i=this.data&&this.data.streamGraphSettings?this.data.streamGraphSettings.legendSettings:C.legendSettings;e.pushInstance({selector:null,objectName:"legend",displayName:"Legend",properties:{show:i.show,position:t.LegendPosition[this.legend.getOrientation()],showTitle:i.showTitle,titleText:i.titleText,labelColor:i.labelColor,fontSize:i.fontSize}})},i.prototype.clearData=function(){this.svg.selectAll(i.Layer.selector).remove(),this.legend.drawLegend({dataPoints:[]},this.viewport),this.yAxis.selectAll("*").remove(),this.axisGraphicsContext.selectAll(i.YAxisLabel.selector).remove(),this.xAxis.selectAll("*").remove(),this.axisGraphicsContext.selectAll(i.XAxisLabel.selector).remove(),this.svg.select(".labels").remove()},i.prototype.onClearSelection=function(){this.interactivityService&&this.interactivityService.clearSelection()},i.prototype.enumerateObjectInstances=function(e){var i,a=new t.ObjectEnumerationBuilder,r=this.dataView;switch(this.data&&(i=this.data.streamGraphSettings.dataLabelsSettings?this.data.streamGraphSettings.dataLabelsSettings:C.dataLabelsSettings),e.objectName){case"legend":r&&r.categorical&&r.categorical.values&&r.categorical.values.source&&this.enumerateLegend(a);break;case"categoryAxis":this.enumerateCategoryAxisValues(a);break;case"valueAxis":this.enumerateValueAxisValues(a);break;case"labels":var s={enumeration:a,dataLabelsSettings:i,show:!0,fontSize:!0};t.dataLabelUtils.enumerateDataLabels(s);break;case"general":var o={objectName:"general",displayName:"General",selector:null,properties:{wiggle:this.getWiggle(r)}};a.pushInstance(o)}return a.complete()},i.VisualClassName="streamGraph",i.Properties={general:{formatString:{objectName:"general",propertyName:"formatString"}},legend:{show:{objectName:"legend",propertyName:"show"},showTitle:{objectName:"legend",propertyName:"showTitle"},titleText:{objectName:"legend",propertyName:"titleText"},labelColor:{objectName:"legend",propertyName:"labelColor"},fontSize:{objectName:"legend",propertyName:"fontSize"}},categoryAxis:{show:{objectName:"categoryAxis",propertyName:"show"},labelColor:{objectName:"categoryAxis",propertyName:"labelColor"},showAxisTitle:{objectName:"categoryAxis",propertyName:"showAxisTitle"}},valueAxis:{show:{objectName:"valueAxis",propertyName:"show"},labelColor:{objectName:"valueAxis",propertyName:"labelColor"},showAxisTitle:{objectName:"valueAxis",propertyName:"showAxisTitle"}},labels:{show:{objectName:"labels",propertyName:"show"},color:{objectName:"labels",propertyName:"color"},fontSize:{objectName:"labels",propertyName:"fontSize"}}},i.Layer={"class":"layer",selector:".layer"},i.XAxisLabel={"class":"xAxisLabel",selector:".xAxisLabel"},i.YAxisLabel={"class":"yAxisLabel",selector:".yAxisLabel"},i.MaxNumberOfAxisXValues=5,i.capabilities={dataRoles:[{name:"Category",kind:e.VisualDataRoleKind.Grouping,displayName:"Category"},{name:"Series",kind:e.VisualDataRoleKind.Grouping,displayName:"Series"},{name:"Y",kind:e.VisualDataRoleKind.Measure,displayName:e.data.createDisplayNameGetter("Role_DisplayName_Values")}],dataViewMappings:[{conditions:[{Category:{max:1},Series:{max:0}},{Category:{max:1},Series:{min:1,max:1},Y:{max:1}}],categorical:{categories:{"for":{"in":"Category"},dataReductionAlgorithm:{bottom:{}}},values:{group:{by:"Series",select:[{"for":{"in":"Y"}}],dataReductionAlgorithm:{bottom:{}}}}}}],objects:{general:{displayName:"General",properties:{formatString:{type:{formatting:{formatString:!0}}},wiggle:{type:{bool:!0},displayName:"Wiggle"}}},categoryAxis:{displayName:"X-Axis",properties:{show:{displayName:"show",type:{bool:!0}},showAxisTitle:{displayName:"Title",type:{bool:!0}},labelColor:{displayName:"Color",type:{fill:{solid:{color:!0}}}}}},valueAxis:{displayName:"Y-Axis",properties:{show:{displayName:"show",type:{bool:!0}},showAxisTitle:{displayName:"Title",type:{bool:!0}},labelColor:{displayName:"Color",type:{fill:{solid:{color:!0}}}}}},legend:{displayName:"Legend",properties:{show:{displayName:"show",type:{bool:!0}},position:{displayName:"Position",type:{enumeration:t.legendPosition.type}},showTitle:{displayName:"Title",type:{bool:!0}},titleText:{displayName:"Legend Name",type:{text:!0},suppressFormatPainterCopy:!0},labelColor:{displayName:"Color",type:{fill:{solid:{color:!0}}}},fontSize:{displayName:"Text Size",type:{formatting:{fontSize:!0}}}}},labels:{displayName:"Data Labels",properties:{show:{displayName:"Show",type:{bool:!0}},color:{displayName:"Color",type:{fill:{solid:{color:!0}}}},fontSize:{displayName:"Text Size",type:{formatting:{fontSize:!0}}}}}},supportsHighlight:!0},i}();i.StreamGraph=D}(i=t.samples||(t.samples={}))}(t=e.visuals||(e.visuals={}))}(i||(i={}))},function(e,t){var i,a=window.jsCommon,i=window.powerbi;window.powerbitests,window.InJs,window.debug,window.jasmine,window.Microsoft;!function(e){var t;!function(t){var i;!function(i){function r(t){var i=!1;return e.createEnumType(Object.keys(t).filter(function(e,a){return!!(a%2)===i&&t[e]===e&&!void(i===!i)||!!(a%2)!==i}).map(function(e){return{value:e,displayName:e}}))}var s=t.utility.SelectionManager,o=e.visuals.valueFormatter,n=a.CssConstants.createClassAndSelector,l=e.TextMeasurementService,c=t.dataLabelUtils.defaultLabelPrecision,u=t.dataLabelUtils.defaultLabelColor,h=t.dataLabelUtils.DefaultFontSizeInPt,p=t.dataLabelUtils.defaultLabelDensity;i.createEnumTypeFromEnum=r,function(e){e[e.DateOnly="Date only"]="DateOnly",e[e.TimeOnly="Time only"]="TimeOnly"}(i.PulseChartXAxisDateFormat||(i.PulseChartXAxisDateFormat={}));var d=i.PulseChartXAxisDateFormat;!function(e){e[e.Center="Center"]="Center",e[e.Bottom="Bottom"]="Bottom"}(i.XAxisPosition||(i.XAxisPosition={}));var g=i.XAxisPosition;!function(e){e[e.TopLeft="Top Left"]="TopLeft",e[e.TopRight="Top Right"]="TopRight"}(i.RunnerCounterPosition||(i.RunnerCounterPosition={}));var m=i.RunnerCounterPosition,y=function(){function i(e){e&&e.svg&&(this.svg=e.svg),this.margin=i.DefaultMargin}return i.getProperties=function(e){var t={};for(var i in e.objects){t[i]={};for(var a in e.objects[i].properties)t[i][a]={objectName:i,propertyName:a}}return t},i.GetPopupValueTextProperties=function(e,t){return void 0===t&&(t=12),{text:e||"",fontFamily:"sans-serif",fontSize:t+"px"}},i.GetPopupTitleTextProperties=function(e,t){return void 0===t&&(t=12),{text:e||"",fontFamily:"sans-serif",fontWeight:"bold",fontSize:t+"px"}},i.GetPopupDescriptionTextProperties=function(e,t){return void 0===t&&(t=12),{text:e||"",fontFamily:"sans-serif",fontSize:t+"px"}},i.GetRunnerCounterTextProperties=function(e,t){return void 0===t&&(t=12),{text:e||"",fontFamily:"sans-serif",fontSize:t+"px"}},i.ConvertTextPropertiesToStyle=function(e){return{"font-family":e.fontFamily,"font-weight":e.fontWeight,"font-size":e.fontSize}},i.GetDateTimeFormatString=function(e,t){switch(e){case d.DateOnly:return t;case d.TimeOnly:return"H:mm";default:return""}},i.GetFullWidthOfDateFormat=function(e,i){return i.text=t.valueFormatter.create({format:e}).format(new Date(2e3,10,20,20,20,20)),l.measureSvgTextWidth(i)},i.AddOnTouchClick=function(e,t){var i=function(e,i){d3.event.preventDefault(),t(e,i)};return e.on("click",i).on("touchstart",i)},i.getCategoricalColumnOfRole=function(e,t){var i=function(e){return e.filter(function(e){return e.source&&e.source.roles&&e.source.roles[t]})[0]};return i(e.categorical.categories)||i(e.categorical.values)},i.converter=function(e,a,r){if(!(e&&e.categorical&&e.categorical.values&&e.categorical.values[0]&&e.categorical.values[0].values&&e.categorical.categories))return null;var s=_.mapValues(i.RoleNames,function(t,a){return i.getCategoricalColumnOfRole(e,a)}),n=s.Timestamp;if(!n)return null;var c=!(n.source&&n.source.type&&n.source.type.dateTime),u=i.parseSettings(e,a,s),h=n.values;if(!h||_.isEmpty(e.categorical.values)||!s.Value||_.isEmpty(s.Value.values))return null;var p=Math.min.apply(null,s.Value.values),g=Math.max.apply(null,s.Value.values),m=Math.min.apply(null,h),y=Math.max.apply(null,h);u.xAxis.dateFormat=864e5>y-m&&new Date(y).getDate()===new Date(m).getDate()?d.TimeOnly:d.DateOnly,
16u.xAxis.formatterOptions={value:c?m:new Date(m),value2:c?y:new Date(y)},u.yAxis.formatterOptions={value:p,value2:g,format:o.getFormatString(s.Value.source,i.DefaultSettings.formatStringProperty)},c?u.xAxis.formatterOptions.format=o.getFormatString(n.source,i.DefaultSettings.formatStringProperty):u.xAxis.formatterOptions.format=i.GetDateTimeFormatString(u.xAxis.dateFormat,n.source.format);var f=70,v=c?60:i.GetFullWidthOfDateFormat(n.source.format,i.GetPopupValueTextProperties())+5,S=l.measureSvgTextHeight(i.GetPopupDescriptionTextProperties("lj",u.popup.fontSize)),w=s.RunnerCounter&&t.valueFormatter.getFormatString(s.RunnerCounter.source,u.formatStringProperty);u.popup.width=Math.max(v+20,u.popup.width);var C=i.DefaultSettings.dots.minSize,P=i.DefaultSettings.dots.maxSize;u.dots&&(C=u.dots.minSize,P=u.dots.maxSize);for(var D=i.createScale(!0,s.EventSize?[d3.min(s.EventSize.values),d3.max(s.EventSize.values)]:[0,0],C,P),A=b.getCategoryAxisProperties(e.metadata),T=!(!n.values||!n.source),V=x.getDefaultPulseChartLabelSettings(),N=i.getGapWidths(h),L=Math.max.apply(null,N),M=0,k=0,O=1,I=e.categorical.values&&e.categorical.values.grouped(),j=I[k]&&I[k].values[M]&&I[k].values[M].values,F=I[O]&&I[O].values[M]&&I[O].values[M].values,z=[],G=[],R=0,H=0,B=n.values.length;B>R;R++,H++){var U=h[R],E=t.AxisHelper.normalizeNonFiniteNumber(n.values[R]),W=s.RunnerCounter&&s.RunnerCounter.values&&s.RunnerCounter.values[R],Y=t.SelectionIdBuilder.builder().withCategory(n,R).createSelectionId(),X=Math.max((y-m)/i.MaxGapCount,i.MinGapWidth[u.xAxis.dateFormat]),q=N[R],K=u.gaps.show&&q>0&&q>X+(100-u.gaps.visibleGapsPercentage)*(L-X)/100;if(K&&G.length>0&&(z.push({displayName:I[k].name,key:Y.getKey(),lineIndex:z.length,color:u.series.fill,xCol:n.source,yCol:n.source,data:G,identity:Y,selected:!1,labelSettings:V,width:u.series.width,widthOfGap:q}),H=0,G=[]),!c||null!==U&&null!==E){var Z=null,J=s.EventSize&&s.EventSize.values&&s.EventSize.values[R]||0;if(s.EventTitle&&s.EventTitle.values&&s.EventTitle.values[R]||s.EventDescription&&s.EventDescription.values&&s.EventDescription.values[R]){var Q=U;!c&&U&&(Q=t.valueFormatter.create({format:n.source.format}).format(U)),Z={value:Q,title:s.EventTitle&&s.EventTitle.values&&s.EventTitle.values[R],description:s.EventDescription&&s.EventDescription.values&&s.EventDescription.values[R]}}var $={categoryValue:U,value:E,categoryIndex:R,seriesIndex:z.length,tooltipInfo:null,popupInfo:Z,selected:!1,identity:Y,key:JSON.stringify({ser:Y.getKey(),catIdx:R}),labelFill:V.labelColor,labelSettings:V,x:U,y:j&&j[R]||F&&F[R]||0,pointColor:u.series.fill,groupIndex:i.getGroupIndex(R,I),eventSize:s.EventSize?D(J):0,runnerCounterValue:W,runnerCounterFormatString:w};G.push($)}}r&&r.applySelectionStateToData(G),G.length>0&&z.push({displayName:I[k].name,key:Y.getKey(),lineIndex:z.length,color:u.series.fill,xCol:n.source,yCol:n.source,data:G,identity:Y,selected:!1,labelSettings:V,width:u.series.width,widthOfGap:0}),A=b.getCategoryAxisProperties(e.metadata);var ee=b.getValueAxisProperties(e.metadata),te=e.categorical.categories,ie=[];if(te)for(var ae=0;ae<te.length;ae++)te[ae]&&te[ae].source&&te[ae].source.displayName&&ie.push({displayName:te[ae].source.displayName});var re=t.converterHelper.createAxesLabels(A,ee,n.source,ie);return r&&r.applySelectionStateToData(z),{columns:s,series:z,isScalar:c,dataLabelsSettings:V,axesLabels:{x:re.xAxisLabel,y:re.yAxisLabel},hasDynamicSeries:T,categoryMetadata:n.source,categories:h,settings:u,grouped:I,hasHighlights:!!s.Value.highlights,widthOfXAxisLabel:f,widthOfTooltipValueLabel:v,heightOfTooltipDescriptionTextLine:S,runnerCounterHeight:l.measureSvgTextHeight(i.GetRunnerCounterTextProperties("lj",u.runnerCounter.fontSize))}},i.createAxisY=function(e,i,a,r){void 0===r&&(r=!0);var s=t.valueFormatter.create(a),o=Math.max(2,Math.round(i/40)),n=d3.svg.axis().scale(e).ticks(o).outerTickSize(0).tickFormat(s.format);return n},i.createAxisX=function(e,a,r,s,o,n,l){for(var c=i.getXAxisScales(a,e,r),u=new Array(c.length),h=0,p=!1;h<u.length;h++){var d=i.getXAxisValuesToDisplay(c[h],p,e,o,l);if(!p&&n===g.Bottom&&d.length<i.MinimumTicksToRotate){var m=i.getXAxisValuesToDisplay(c[h],!0,e,o,l);if(m.length>d.length){p=!0,h=-1;continue}}u[h]={values:d,scale:c[h],rotate:p}}return s.tickCount=u.length&&5*u.map(function(e){return e.values.length}).reduce(function(e,t){return e+t}),s.value=r.domain()[0],s.value2=r.domain()[1],u.forEach(function(e){var i=e.values.filter(function(e){return null!==e}),a=t.valueFormatter.create(s);e.axis=d3.svg.axis().scale(e.scale).tickValues(i).tickFormat(a.format).outerTickSize(0)}),u},i.getXAxisScales=function(e,t,a){return e.map(function(e){var r=e.data,s=r[0].categoryValue,o=r[r.length-1].categoryValue,n=a(r[0].categoryValue),l=a(r[r.length-1].categoryValue);return i.createScale(t,[s,o],n,l)})},i.getXAxisValuesToDisplay=function(e,t,a,r,s){var o=e,n=t?i.XAxisTickHeight*(t?Math.abs(Math.sin(i.AxisTickRotateAngle*Math.PI/180)):0):s,l=i.XAxisTickSpace;if(e.range()[1]<n)return[];var c=e.invert(e.range()[0]+n/2),u=e.invert(e.range()[1]-n/2),h=e.range()[1]-e.range()[0],p=Math.floor((h+l)/(n+l));t&&(p=Math.min(i.MinimumTicksToRotate,p));var g=[];if(g=a?d3.range(c,u,(u-c)/(100*p)):(r===d.TimeOnly?d3.time.minute:d3.time.day).range(c,u),(!g.length||_.last(g)<u)&&g.push(u),!p)return[];p=Math.min(g.length,p);var m=d3.scale.ordinal().domain(d3.range(p)).rangePoints([0,g.length-1]).range();g=m.map(function(e){return g[Math.round(e)]});for(var y=1;y<g.length;y++){var f=o(g[y-1]),v=o(g[y]);n+l/3>v-f&&g.splice(y--,1)}return g},i.getGroupIndex=function(e,t){for(var i=0;i<t.length;i++)if(t[i].values&&t[i].values[0]&&void 0!==t[i].values[0].values[e]&&null!==t[i].values[0].values[e])return i;return 0},i.getGapWidths=function(e){for(var t=[],i=0,a=0,r=e.length;r>i;i++)a&&e[i]?t.push(e[i]-a):t.push(0),a=e[i];return t},i.createScale=function(e,t,i,a){var r;return r=e?d3.scale.linear():d3.time.scale(),r.domain(t).range([i,a])},Object.defineProperty(i.prototype,"runnerCounterPlaybackButtonsHeight",{get:function(){return Math.max(i.PlaybackButtonsHeight,this.data&&this.data.runnerCounterHeight/2+17)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"popupHeight",{get:function(){return this.data&&this.data.settings&&this.data.settings.popup&&this.data.settings.popup.show&&this.data.settings.popup.height||0},enumerable:!0,configurable:!0}),i.prototype.init=function(a){e.formattingService.initialize(),this.host=a.host,this.selectionManager=new s({hostServices:this.host});var r=this.svg=d3.select(a.element.get(0)).append("svg").classed("pulseChart",!0);this.gaps=r.append("g").classed(i.Gaps["class"],!0),this.yAxis=r.append("g").attr("class","y axis"),this.chart=r.append("g").attr("class",i.Chart["class"]),this.dots=r.append("g").attr("class","dots"),this.animationDot=this.dots.append("circle").classed(i.AnimationDot["class"],!0).attr("display","none"),this.animationHandler=new v(this,r);var o=a.style;this.colors=o&&o.colorPalette?o.colorPalette.dataColors:new t.DataColorPalette},i.prototype.update=function(e){if(e&&e.dataViews&&e.dataViews[0]){this.viewport=$.extend({},e.viewport);var t=e.dataViews[0];if(this.updateData(i.converter(t,this.colors)),!this.validateData(this.data))return void this.clearAll(!0);var a=this.getChartWidth();if(this.calculateXAxisProperties(a),this.data.xScale.ticks(void 0).length<2)return void this.clearAll(!0);var r=this.getChartHeight(this.data.settings.xAxis.show&&this.data.series.some(function(e){return e.xAxisProperties.rotate}));this.calculateYAxisProperties(r),this.size={width:a,height:r},this.updateElements(),this.render(!0)}},i.prototype.updateData=function(e){if(!this.data)return void(this.data=e);var t=this.getDataArrayToCompare(this.data),i=this.getDataArrayToCompare(e);_.isEqual(t,i)||this.clearAll(!1),this.data=e},i.prototype.getDataArrayToCompare=function(e){if(!e||!e.series)return null;var t=_.flatten(e.series.map(function(e){return e.data}));return _.flatten(t.map(function(e){return e&&_.flatten([[e.categoryValue,e.eventSize,e.groupIndex,e.runnerCounterValue,e.y,e.seriesIndex],e.popupInfo&&[e.popupInfo.description,e.popupInfo.title,e.popupInfo.value]])}))},i.prototype.validateData=function(e){return e?!e.categories.some(function(e){return!(e instanceof Date||$.isNumeric(e))}):!1},i.prototype.getChartWidth=function(){var e=this.margin.right;this.data.settings.yAxis&&this.data.settings.yAxis.show&&(e+=i.MaxWidthOfYAxis);var t=this.viewport.width-this.margin.left-e;return Math.max(t,i.DefaultViewport.width)},i.prototype.getChartHeight=function(e){var t=10+(e?this.data.widthOfXAxisLabel*Math.abs(Math.sin(i.AxisTickRotateAngle*Math.PI/180)):3);!this.data.settings.popup.alwaysOnTop&&this.popupHeight&&(t=Math.max(this.margin.bottom+this.popupHeight,t));var a=this.viewport.height-this.margin.top-this.runnerCounterPlaybackButtonsHeight-t-this.popupHeight;return Math.max(a,i.DefaultViewport.height)},i.prototype.updateElements=function(){var e=this.margin.top+this.runnerCounterPlaybackButtonsHeight+this.popupHeight;this.svg.attr(this.viewport),this.svg.style("display",void 0),this.gaps.attr("transform",t.SVGUtil.translate(this.margin.left,e+this.size.height/2)),this.chart.attr("transform",t.SVGUtil.translate(this.margin.left,e)),this.yAxis.attr("transform",t.SVGUtil.translate(this.size.width+this.margin.left,e)),this.dots.attr("transform",t.SVGUtil.translate(this.margin.left,e))},i.prototype.calculateXAxisProperties=function(e){this.data.xScale=i.createScale(this.data.isScalar,[this.data.categories[0],this.data.categories[this.data.categories.length-1]],0,e);var t=i.createAxisX(this.data.isScalar,this.data.series,this.data.xScale,$.extend({},this.data.settings.xAxis.formatterOptions),this.data.settings.xAxis.dateFormat,this.data.settings.xAxis.position,this.data.widthOfXAxisLabel);this.data.series.forEach(function(e,i){e.xAxisProperties=t[i]})},i.prototype.calculateYAxisProperties=function(e){this.data.yScales=this.getYAxisScales(e);var t=[];this.data.yScales.forEach(function(e){return t=t.concat(e.domain())}),this.data.commonYScale=i.createScale(!0,[d3.max(t),d3.min(t)],0,e),this.data.yAxis=i.createAxisY(this.data.commonYScale,e,this.data.settings.yAxis.formatterOptions)},i.prototype.getYAxisScales=function(e){var t=this.data,a=e/t.grouped.length;return t.grouped.map(function(e,t){var r=e.values[0].values.map(function(e){return e||0}),s=Number.MAX_VALUE,o=-Number.MAX_VALUE;if(r.forEach(function(e){s>e&&(s=e),e>o&&(o=e)}),o===s){var n=0===o?1:Math.abs(o/2);o+=n,s-=n}return i.createScale(!0,[o,s],a*t,a*(t+1))})},Object.defineProperty(i.prototype,"autoplayPauseDuration",{get:function(){return 1e3*(this.data&&this.data.settings&&this.data.settings.playback?this.data.settings.playback.autoplayPauseDuration:i.DefaultSettings.playback.autoplayPauseDuration)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isAutoPlay",{get:function(){return this.data&&this.data.settings&&this.data.settings.playback&&this.data.settings.playback.autoplay},enumerable:!0,configurable:!0}),i.prototype.render=function(e){var i=t.AnimatorCommon.GetAnimationDuration(this.animator,e),a=this.data;this.lastSelectedPoint=null;var r=a.xScale,s=a.yScales;this.lineX=d3.svg.line().x(function(e){return r(e.categoryValue)}).y(function(e){return s[e.groupIndex](e.y)}),this.data&&this.data.settings&&this.data.settings.playback&&this.data.settings.playback.color&&this.animationHandler.setControlsColor(this.data.settings.playback.color),this.animationHandler.render(),this.animationHandler.setRunnerCounterValue(),this.renderAxes(a,i),this.renderGaps(a,i)},i.prototype.renderAxes=function(e,t){this.renderXAxis(e,t),this.renderYAxis(e,t)},i.prototype.renderXAxis=function(e,a){var r,s,o,n=i.DefaultSettings.xAxis.color,l=i.DefaultSettings.xAxis.fontColor;this.data&&this.data.settings&&this.data.settings.xAxis&&(n=this.data.settings.xAxis.color,l=this.data.settings.xAxis.fontColor),r=this.rootSelection.selectAll(i.XAxisNode.selector),s=r.data(e.series),s.enter().insert("g","g."+i.LineContainer["class"]).classed(i.XAxisNode["class"],!0),s.call(function(t){t.forEach(function(t,i){d3.select(t[0]).call(e.series[i].xAxisProperties.axis.orient("bottom"))})}),s.exit().remove(),o=s.selectAll(".tick").selectAll(".axisBox").data([[]]),o.enter().insert("rect","text").classed("axisBox",!0),o.style("display",this.data.settings.xAxis.position===g.Center?"inherit":"none").style("fill",this.data.settings.xAxis.backgroundColor);var c=this.data.settings.xAxis.position===g.Center?-11:0;o.attr({x:-(this.data.widthOfXAxisLabel/2),y:c+"px",width:this.data.widthOfXAxisLabel,height:i.XAxisTickHeight+"px"}),o.exit().remove(),s.style("stroke",this.data.settings.xAxis.position===g.Center?n:"none").style("display",this.data.settings.xAxis.show?"inherit":"none"),s.call(function(e){var t=e.datum().xAxisProperties.rotate,a=t?Math.abs(Math.sin(i.AxisTickRotateAngle*Math.PI/180)):0,r=c+3;e.selectAll("text").attr("transform",function(){return"translate(0, "+(r+9+$(this).width()/2*a)+") rotate("+(t?i.AxisTickRotateAngle:0)+")"}).style("fill",l).style("stroke","none").attr("dy",-9)}),s.selectAll(".domain").style("stroke",n),s.selectAll(".domain").forEach(function(e){$(e).insertBefore($(e).parent().children().first())});var u=this.size.height;switch(this.data.settings.xAxis.position){case g.Center:u/=2;break;case g.Bottom:}s.attr("transform",t.SVGUtil.translate(0,u))},i.prototype.renderYAxis=function(e,t){var a=e.yAxis,r=!1,s=i.DefaultSettings.yAxis.color,o=i.DefaultSettings.yAxis.fontColor;a.orient("right"),this.data&&this.data.settings&&this.data.settings.yAxis&&this.data.settings.yAxis.show&&(r=!0),this.data&&this.data.settings&&this.data.settings.yAxis&&this.data.settings.yAxis&&(s=this.data.settings.yAxis.color,o=this.data.settings.yAxis.fontColor),this.yAxis.call(a).attr("display",r?"inline":"none"),this.yAxis.selectAll(".domain, path, line").style("stroke",s),this.yAxis.selectAll("text").style("fill",o),this.yAxis.selectAll("g.tick line").attr("x1",-this.size.width)},i.prototype.renderChart=function(){var e=this.data,t=this.data.series,a=this.rootSelection=this.chart.selectAll(i.LineNode.selector).data(t),r=a.enter().append("g").classed(i.LineNode["class"],!0);r.append("g").classed(i.LineContainer["class"],!0),r.append("g").classed(i.TooltipContainer["class"],!0),r.append("g").classed(i.DotsContainer["class"],!0),this.animationHandler.isAnimated?this.showAnimationDot():this.hideAnimationDot(),this.drawTooltips(e,this.selectionManager.getSelectionIds()),this.drawDots(e),this.drawLines(e),a.exit().remove()},i.prototype.drawLinesStatic=function(e,t){var a=this,r=i.Line,s=i.LineContainer,o=this.rootSelection,n=o.filter(function(i,a){return!t||e>a}).select(s.selector).selectAll(r.selector).data(function(e){return[e]});n.enter().append("path").classed(r["class"],!0),n.style({fill:"none",stroke:function(e){return e.color},"stroke-width":function(e){return e.width+"px"}}),n.attr("d",function(e){return a.lineX(e.data)}),n.exit().remove()},i.prototype.drawLinesStaticBeforeAnimation=function(e){var t=this,a=i.Line,r=i.LineContainer,s=this.rootSelection;this.animationSelection=s.filter(function(t,i){return i===e}).select(r.selector).selectAll(a.selector).data(function(e){return[e]}),this.animationSelection.enter().append("path").classed(a["class"],!0),this.animationSelection.style({fill:"none",stroke:function(e){return e.color},"stroke-width":function(e){return e.width+"px"}}),this.animationSelection.attr("d",function(e){var i=t.animationHandler.flooredPosition.index;if(0===i)return t.moveAnimationDot(e.data[0]),t.lineX([]);var a=e.data.slice(0,i+1);return t.moveAnimationDot(a[a.length-1]),t.lineX(a)}),this.animationSelection.exit().remove()},i.prototype.moveAnimationDot=function(e){var t=this.data.xScale,i=this.data.yScales;this.animationDot.attr("cx",t(e.x)).attr("cy",i[e.groupIndex](e.y))},i.prototype.playAnimation=function(e){var t=this;void 0===e&&(e=0);var i=this.animationHandler.flooredPosition.index;this.showAnimationDot(),this.animationSelection.transition().delay(e).duration(this.animationDuration).ease("linear").attrTween("d",function(e,a){return t.getInterpolation(e.data,i)}).each("end",function(e){return t.handleSelection(t.animationHandler.flooredPosition)})},i.prototype.pauseAnimation=function(){this.animationSelection&&(this.hideAnimationDot(),this.animationSelection.selectAll("path").transition(),this.animationSelection.transition().duration(0).delay(0))},i.prototype.stopAnimation=function(){this.pauseAnimation(),d3.timer.flush()},i.prototype.findNextPoint=function(e){for(var t=e.series;t<this.data.series.length;t++)for(var i=this.data.series[t],a=t===e.series?Math.floor(e.index+1):0;a<i.data.length;a++)if(i.data[a]&&i.data[a].popupInfo)return{series:t,index:a};return null},i.prototype.findPrevPoint=function(e){for(var t=e.series;t>=0;t--)for(var i=this.data.series[t],a=t===e.series?Math.ceil(e.index-1):i.data.length;a>=0;a--)if(i.data[a]&&i.data[a].popupInfo)return{series:t,index:a};return null},i.prototype.isAnimationSeriesAndIndexLast=function(e){return this.isAnimationSeriesLast(e)&&this.isAnimationIndexLast(e)},i.prototype.isAnimationSeriesLast=function(e){return e.series>=this.data.series.length-1},i.prototype.isAnimationIndexLast=function(e){var t=this.data.series[e.series];return e.index>=t.data.length-1},i.prototype.drawLines=function(e){var t=this.animationHandler.position.series,i=this.animationHandler.isAnimated;this.drawLinesStatic(t,i),i&&this.drawLinesStaticBeforeAnimation(t)},i.prototype.showAnimationDot=function(){if(this.animationHandler.isPlaying){var e=i.DefaultSettings.dots.size;this.data&&this.data.settings&&this.data.settings.dots&&this.data.settings.dots.size&&(e=this.data.settings.dots.size),this.animationDot.attr("display","inline").attr("fill",this.data.settings.dots.color).style("opacity",this.dotOpacity).attr("r",e)}},i.prototype.hideAnimationDot=function(){this.animationDot.attr("display","none")},i.prototype.getInterpolation=function(e,t){var i=this;if(this.data){var a=this.data.xScale,r=this.data.yScales,s=t+1;this.showAnimationDot();var o=d3.svg.line().x(function(e){return e.x}).y(function(e){return e.y}).interpolate("linear"),n=e.slice(0,t+1).map(function(e){return{x:a(e.x),y:r[e.groupIndex](e.y)}}),l=a(e[t].x),c=a(e[s].x),u=r[e[t].groupIndex](e[t].y),h=r[e[s].groupIndex](e[s].y),p=d3.scale.linear().domain([0,1]).range([t,s]),d=d3.scale.linear().domain([0,1]).range([l,c]),g=d3.scale.linear().domain([0,1]).range([u,h]);return this.animationHandler.setRunnerCounterValue(t),function(e){if(!i.animationHandler.isPlaying)return o(n);var t=d(e),a=g(e);return i.animationDot.attr("cx",t).attr("cy",a),n.push({x:t,y:a}),i.animationHandler.position.index=p(e),o(n)}}},i.prototype.clearSelection=function(){this.data&&this.data.hasHighlights||!this.selectionManager.hasSelection()?this.selectionManager.selectedIds=[]:this.selectionManager.clear(),this.chart.selectAll(i.Tooltip.selector).remove()},i.prototype.handleSelection=function(e){var t=this;if(this.data){var i=this.animationHandler.animationPlayingIndex,a=this.data.series[e.series].data[e.index],r=this.animationHandler.isPlaying&&this.isAnimationSeriesAndIndexLast(e);if((!a||!a.popupInfo)&&this.animationHandler.isPlaying)return void(r?setTimeout(function(){return t.animationHandler.toEnd()},0):this.animationHandler.play(0,!0));r?setTimeout(function(){return t.animationHandler.toEnd()},0):this.animationHandler.pause(),this.selectionManager.select(a.identity).then(function(e){t.setSelection(e),clearTimeout(t.handleSelectionTimeout),t.handleSelectionTimeout=setTimeout(function(){t.animationHandler.animationPlayingIndex===i&&((r||t.animationHandler.isPaused)&&t.clearSelection(),!r&&t.animationHandler.isPaused&&t.animationHandler.play())},t.pauseDuration)})}},Object.defineProperty(i.prototype,"animationDuration",{get:function(){return 1e3/(this.data&&this.data.settings&&this.data.settings.playback?this.data.settings.playback.playSpeed:i.DefaultSettings.playback.playSpeed)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"pauseDuration",{get:function(){return 1e3*(this.data&&this.data.settings&&this.data.settings.playback?this.data.settings.playback.pauseDuration:i.DefaultSettings.playback.pauseDuration)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"dotOpacity",{get:function(){return 1-(this.data&&this.data.settings&&this.data.settings.dots?this.data.settings.dots.transparency:i.DefaultSettings.dots.transparency)/100},enumerable:!0,configurable:!0}),i.prototype.drawDots=function(e){var t=this;if(e&&e.xScale){var a=e.xScale,r=e.yScales,s=i.Dot,o=i.DotsContainer,n=this.rootSelection,l=this.data.settings.dots.color,c=this.data.settings.dots.size,u=this.animationHandler.isAnimated,h=this.animationHandler.position,p=n.filter(function(e,t){return!u||t<=h.series}).select(o.selector).selectAll(s.selector).data(function(e,t){return _.filter(e.data,function(e,i){return u&&t===h.series&&i>h.index?!1:!!e.popupInfo})});p.enter().append("circle").classed(s["class"],!0),p.attr("cx",function(e){return a(e.categoryValue)}).attr("cy",function(e){return r[e.groupIndex](e.y)}).attr("r",function(e){return e.eventSize||c}).style("fill",l).style("opacity",this.dotOpacity).style("cursor","pointer").call(i.AddOnTouchClick,function(e){d3.event.stopPropagation(),t.selectionManager.select(e.identity,d3.event.ctrlKey).then(function(e){return t.setSelection(e)})}),p.exit().remove()}},i.prototype.renderGaps=function(e,a){var r,s,o,n,l=e.series,c=e.isScalar,u=e.xScale;r=[{left:-4.5,top:-5,height:10,width:3},{left:1.5,top:-5,height:10,width:3}],s=this.gaps.selectAll(i.Gap.selector).data(l.slice(0,l.length-1)),o=s.enter().append("g"),s.attr("transform",function(e,i){var a,r=e.widthOfGap/2,s=e.data[e.data.length-1].categoryValue;return a=u(c?r+s:new Date(r+s.getTime())),t.SVGUtil.translate(a,0)}),n=s.selectAll(i.GapNode.selector).data(r),n.enter().append("rect").attr({x:function(e){return e.left},y:function(e){return e.top},height:function(e){return e.height},width:function(e){return e.width}}).classed(i.GapNode["class"],!0),o.classed(i.Gap["class"],!0),s.exit().remove(),n.exit().remove()},i.prototype.setSelection=function(e){this.data&&(this.drawDots(this.data),this.drawTooltips(this.data,e))},i.prototype.isPopupShow=function(e,t){return this.popupHeight&&e.popupInfo&&t?s.containsSelection(t,e.identity):!1},i.prototype.drawTooltips=function(e,a){var r=this,s=e.xScale,o=e.yScales,n=i.Tooltip,c=i.TooltipContainer,u=this.rootSelection,h=d3.svg.line().x(function(e){return e.x}).y(function(e){return e.y}),p=i.DefaultTooltipSettings.marginTop,d=this.data.settings.popup.width,g=this.data.settings.popup.height,m=20,y=function(e,t){return r.isHigherMiddle(e,t)?-1*p+m:r.size.height+p},f=u.select(c.selector).selectAll(n.selector).data(function(e){return _.filter(e.data,function(e){return r.isPopupShow(e,a)})});f.enter().append("g").classed(n["class"],!0),f.attr("transform",function(e){var i=s(e.x)-d/2,a=y(e.y,e.groupIndex);return e.popupInfo.offsetX=Math.min(r.viewport.width-r.margin.right-d,Math.max(-r.margin.left,i))-i,t.SVGUtil.translate(i+e.popupInfo.offsetX,a)});var v=f.selectAll(i.TooltipRect.selector).data(function(e){return[e]});v.enter().append("path").classed(i.TooltipRect["class"],!0),v.attr("display",function(e){return e.popupInfo?"inherit":"none"}).style("fill",this.data.settings.popup.color).attr("d",function(e){var t=[{x:-2,y:r.isHigherMiddle(e.y,e.groupIndex)?-1*p:0},{x:-2,y:r.isHigherMiddle(e.y,e.groupIndex)?-1*(p+g):g},{x:d-2,y:r.isHigherMiddle(e.y,e.groupIndex)?-1*(p+g):g},{x:d-2,y:r.isHigherMiddle(e.y,e.groupIndex)?-1*p:0}];return h(t)});var x=f.selectAll(i.TooltipTriangle.selector).data(function(e){return[e]});x.enter().append("path").classed(i.TooltipTriangle["class"],!0),x.style("fill",this.data.settings.popup.color).attr("d",function(e){var t=[{x:d/2-5-e.popupInfo.offsetX,y:r.isHigherMiddle(e.y,e.groupIndex)?-1*p:0},{x:d/2-e.popupInfo.offsetX,y:r.isHigherMiddle(e.y,e.groupIndex)?-1*(p-5):-5},{x:d/2+5-e.popupInfo.offsetX,y:r.isHigherMiddle(e.y,e.groupIndex)?-1*p:0}];return h(t)}).style("stroke-width","1px");var b=f.selectAll(i.TooltipLine.selector).data(function(e){return[e]});b.enter().append("path").classed(i.TooltipLine["class"],!0),b.style("fill",this.data.settings.popup.color).style("stroke",this.data.settings.popup.color).style("stroke-width","1px").attr("d",function(e){var t=[{x:d/2-e.popupInfo.offsetX,y:r.isHigherMiddle(e.y,e.groupIndex)?o[e.groupIndex](e.y)+y(e.y,e.groupIndex)-e.eventSize:o[e.groupIndex](e.y)-y(e.y,e.groupIndex)+e.eventSize},{x:d/2-e.popupInfo.offsetX,y:r.isHigherMiddle(e.y,e.groupIndex)?-1*p:0}];return h(t)});var S=this.data.settings.popup.showTime,w=this.data.settings.popup.showTitle,C=f.selectAll(i.TooltipTimeRect.selector).data(function(e){return[e]}),P={display:S?void 0:"none"};C.enter().append("path").classed(i.TooltipTimeRect["class"],!0),C.style("fill",this.data.settings.popup.timeFill).style(P).attr("d",function(e){var t=[{x:d-r.data.widthOfTooltipValueLabel-2,y:r.isHigherMiddle(e.y,e.groupIndex)?-1*(p+g):0},{x:d-r.data.widthOfTooltipValueLabel-2,y:r.isHigherMiddle(e.y,e.groupIndex)?-1*(p+g-i.DefaultTooltipSettings.timeHeight):i.DefaultTooltipSettings.timeHeight},{x:d-2,y:r.isHigherMiddle(e.y,e.groupIndex)?-1*(p+g-i.DefaultTooltipSettings.timeHeight):i.DefaultTooltipSettings.timeHeight},{x:d-2,y:r.isHigherMiddle(e.y,e.groupIndex)?-1*(p+g):0}];return h(t)});var D=f.selectAll(i.TooltipTime.selector).data(function(e){return[e]});D.enter().append("text").classed(i.TooltipTime["class"],!0),D.style(i.ConvertTextPropertiesToStyle(i.GetPopupValueTextProperties())).style(P).style("fill",this.data.settings.popup.timeColor).attr("x",function(e){return d-r.data.widthOfTooltipValueLabel}).attr("y",function(e){return r.isHigherMiddle(e.y,e.groupIndex)?-1*(p+g-i.DefaultTooltipSettings.timeHeight+3):i.DefaultTooltipSettings.timeHeight-3}).text(function(e){return e.popupInfo.value});var A={display:w?void 0:"none"},T=f.selectAll(i.TooltipTitle.selector).data(function(e){return[e]});T.enter().append("text").classed(i.TooltipTitle["class"],!0),T.style(A).style(i.ConvertTextPropertiesToStyle(i.GetPopupTitleTextProperties())).style("fill",this.data.settings.popup.fontColor).attr("x",function(e){return i.PopupTextPadding}).attr("y",function(e){return(r.isHigherMiddle(e.y,e.groupIndex)?-1*(p+g-12):12)+i.PopupTextPadding}).text(function(e){if(!e.popupInfo)return"";var t=d-2*i.PopupTextPadding-(S?r.data.widthOfTooltipValueLabel-i.PopupTextPadding:0)-10;return l.getTailoredTextOrDefault(i.GetPopupTitleTextProperties(e.popupInfo.title),t)});var V=function(e){var t=i.PopupTextPadding+r.data.settings.popup.fontSize,a=t+i.DefaultTooltipSettings.timeHeight;return e.popupInfo&&(t=w&&e.popupInfo.title||S&&e.popupInfo.value?a:t),{y:r.isHigherMiddle(e.y,e.groupIndex)?-1*(p+g-t):t,x:i.PopupTextPadding,width:d-2*i.PopupTextPadding,height:g-t}},N=f.selectAll(i.TooltipDescription.selector).data(function(e){return[e]});N.enter().append("text").classed(i.TooltipDescription["class"],!0),N.style(i.ConvertTextPropertiesToStyle(i.GetPopupDescriptionTextProperties(null,this.data.settings.popup.fontSize))).style("fill",this.data.settings.popup.fontColor).text(function(e){return e.popupInfo&&e.popupInfo.description}).attr("y",function(e){var t=V(e),i=d3.select(this)[0][0];return l.wordBreak(i,t.width,t.height),0}).attr("transform",function(e){var i=V(e);return t.SVGUtil.translate(0,i.y)}),N.selectAll("tspan").attr("x",i.PopupTextPadding),f.exit().remove()},i.prototype.isHigherMiddle=function(e,t){if(this.data.settings.popup.alwaysOnTop)return!0;if(this.data.yScales.length>1)return 0===t;var i=this.data.commonYScale.domain(),a=d3.min(i),r=Math.abs((d3.max(i)-a)/2);return r=0===r?r:a+r,e>=r},i.getObjectsFromDataView=function(e){return e&&e.metadata&&e.metadata.columns&&e.metadata.objects?e.metadata.objects:null},i.parseSettings=function(e,t,a){var r={},s=i.getObjectsFromDataView(e);return r.xAxis=this.getAxisXSettings(s,t),r.yAxis=this.getAxisYSettings(s,t),r.popup=this.getPopupSettings(s,t),r.dots=this.getDotsSettings(s,t),r.series=this.getSeriesSettings(s,t),r.gaps=this.getGapsSettings(s),r.playback=this.getPlaybackSettings(s,t),r.runnerCounter=this.getRunnerCounterSettings(s,t,a),r},i.getPopupSettings=function(a,r){var s=e.DataViewObjects.getValue(a,i.Properties.popup.show,i.DefaultSettings.popup.show),o=e.DataViewObjects.getValue(a,i.Properties.popup.alwaysOnTop,i.DefaultSettings.popup.alwaysOnTop),n=Math.max(i.PopupMinWidth,Math.min(i.PopupMaxWidth,e.DataViewObjects.getValue(a,i.Properties.popup.width,i.DefaultSettings.popup.width))),l=Math.max(i.PopupMinHeight,Math.min(i.PopupMaxHeight,e.DataViewObjects.getValue(a,i.Properties.popup.height,i.DefaultSettings.popup.height))),c=new t.ColorHelper(r,i.Properties.popup.color,i.DefaultSettings.popup.color),u=c.getColorForMeasure(a,""),h=parseInt(e.DataViewObjects.getValue(a,i.Properties.popup.fontSize,i.DefaultSettings.popup.fontSize),10),p=new t.ColorHelper(r,i.Properties.popup.fontColor,i.DefaultSettings.popup.fontColor),d=p.getColorForMeasure(a,""),g=e.DataViewObjects.getValue(a,i.Properties.popup.showTime,i.DefaultSettings.popup.showTime),m=e.DataViewObjects.getValue(a,i.Properties.popup.showTitle,i.DefaultSettings.popup.showTitle),y=new t.ColorHelper(r,i.Properties.popup.timeColor,i.DefaultSettings.popup.timeColor),f=y.getColorForMeasure(a,""),v=new t.ColorHelper(r,i.Properties.popup.timeFill,i.DefaultSettings.popup.timeFill),x=v.getColorForMeasure(a,"");return{show:s,alwaysOnTop:o,width:n,height:l,color:u,fontSize:h,fontColor:d,showTime:g,showTitle:m,timeColor:f,timeFill:x}},i.getDotsSettings=function(a,r){var s=i.Properties.dots,o=i.DefaultSettings.dots,n=new t.ColorHelper(r,s.color,o.color),l=n.getColorForMeasure(a,""),c=Math.max(0,Math.min(9999,e.DataViewObjects.getValue(a,s.minSize,o.minSize))),u=Math.max(c,Math.min(9999,e.DataViewObjects.getValue(a,s.maxSize,o.maxSize))),h=Math.max(c,Math.min(u,e.DataViewObjects.getValue(a,s.size,o.size))),p=Math.max(0,Math.min(100,e.DataViewObjects.getValue(a,s.transparency,o.transparency)));return{color:l,size:h,minSize:c,maxSize:u,transparency:p}},i.getSeriesSettings=function(a,r){var s=Math.max(1,Math.min(100,e.DataViewObjects.getValue(a,i.Properties.series.width,i.DefaultSettings.series.width))),o=new t.ColorHelper(r,i.Properties.series.fill,i.DefaultSettings.series.fill),n=o.getColorForMeasure(a,"");return{width:s,fill:n}},i.getGapsSettings=function(t){var a=e.DataViewObjects.getValue(t,i.Properties.gaps.show,i.DefaultSettings.gaps.show),r=Math.max(1,Math.min(100,e.DataViewObjects.getValue(t,i.Properties.gaps.transparency,i.DefaultSettings.gaps.visibleGapsPercentage)));return{show:a,visibleGapsPercentage:r}},i.getAxisXSettings=function(a,r){var s=i.Properties.xAxis,o=i.DefaultSettings.xAxis,n=new t.ColorHelper(r,s.color,o.color).getColorForMeasure(a,""),l=new t.ColorHelper(r,s.fontColor,o.fontColor).getColorForMeasure(a,""),c=e.DataViewObjects.getValue(a,s.show,o.show),u=e.DataViewObjects.getValue(a,s.position,o.position),h=new t.ColorHelper(r,s.backgroundColor,o.backgroundColor).getColorForMeasure(a,"");return{show:c,position:u,color:n,fontColor:l,backgroundColor:h}},i.getAxisYSettings=function(a,r){var s=i.Properties.yAxis,o=i.DefaultSettings.yAxis,n=new t.ColorHelper(r,s.color,o.color),l=n.getColorForMeasure(a,""),c=new t.ColorHelper(r,s.fontColor,o.fontColor),u=c.getColorForMeasure(a,""),h=e.DataViewObjects.getValue(a,s.show,o.show);return{color:l,fontColor:u,show:h}},i.getPlaybackSettings=function(a,r){var s={},o=i.Properties.playback,n=i.DefaultSettings.playback;s.autoplay=e.DataViewObjects.getValue(a,o.autoplay,n.autoplay),s.playSpeed=Math.max(1,Math.min(99999,e.DataViewObjects.getValue(a,o.playSpeed,n.playSpeed))),s.pauseDuration=Math.max(0,Math.min(9999,e.DataViewObjects.getValue(a,o.pauseDuration,n.pauseDuration))),s.autoplayPauseDuration=Math.max(1,Math.min(9999,e.DataViewObjects.getValue(a,o.autoplayPauseDuration,n.autoplayPauseDuration)));
17var l=new t.ColorHelper(r,o.color,n.color);s.color=l.getColorForMeasure(a,"");var c=e.DataViewObjects.getValue(a,o.position,"");if(c.length>3)try{s.position=JSON.parse(c)}catch(u){}return s.position=s.position||n.position,s},i.getRunnerCounterSettings=function(a,r,s){var o=e.DataViewObjects.getValue(a,i.Properties.runnerCounter.show,i.DefaultSettings.runnerCounter.show),n=e.DataViewObjects.getValue(a,i.Properties.runnerCounter.label,s.RunnerCounter&&s.RunnerCounter.source&&s.RunnerCounter.source.displayName||i.DefaultSettings.runnerCounter.label),l=e.DataViewObjects.getValue(a,i.Properties.runnerCounter.position,i.DefaultSettings.runnerCounter.position),c=parseInt(e.DataViewObjects.getValue(a,i.Properties.runnerCounter.fontSize,i.DefaultSettings.runnerCounter.fontSize),10),u=new t.ColorHelper(r,i.Properties.runnerCounter.fontColor,i.DefaultSettings.runnerCounter.fontColor).getColorForMeasure(a,"");return{show:o,label:n,position:l,fontSize:c,fontColor:u}},i.prototype.clearAll=function(e){this.gaps.selectAll(i.Gap.selector).remove(),this.animationHandler&&(this.animationHandler.reset(),this.animationHandler.clear()),e&&this.svg.style("display","none"),this.clearChart()},i.prototype.clearChart=function(){this.clearSelection(),this.hideAnimationDot(),this.chart.selectAll(i.Line.selector).remove(),this.chart.selectAll(i.Dot.selector).remove()},i.prototype.clearRedundant=function(e){var t=this;if(this.data){var a=this.chart.selectAll(i.Tooltip.selector).filter(function(i){return i.seriesIndex<e.series||i.seriesIndex===e.series&&t.data.series[i.seriesIndex].data[e.index].value>=i.value}),r=a.data().map(function(e){return e.identity});if(this.clearSelection(),r.length){var s=r.map(function(e){return t.selectionManager.select(e,!0)});$.when.apply(null,s).then(function(e){return t.setSelection(e)})}this.chart.selectAll(i.Line.selector).remove(),this.chart.selectAll(i.Dot.selector).remove()}},i.prototype.enumerateObjectInstances=function(e){var i=new t.ObjectEnumerationBuilder;switch(e.objectName){case"general":this.readGeneralInstance(i);break;case"popup":this.readPopupInstance(i);break;case"dots":this.readDotsInstance(i);break;case"xAxis":this.xAxisInstance(i);break;case"yAxis":this.yAxisInstance(i);break;case"series":this.readSeriesInstance(i);break;case"gaps":this.readGapsInstance(i);break;case"playback":this.readPlaybackInstance(i);break;case"runnerCounter":this.readRunnerCounterInstance(i)}return i.complete()},i.prototype.getSettings=function(e){return this.data&&this.data.settings&&this.data.settings[e]?this.data.settings[e]:i.DefaultSettings[e]},i.prototype.readGeneralInstance=function(e){var t={objectName:"general",displayName:"general",selector:null,properties:{}};e.pushInstance(t)},i.prototype.readPopupInstance=function(e){var t=this.getSettings("popup"),i={objectName:"popup",displayName:"popup",selector:null,properties:{show:t.show,alwaysOnTop:t.alwaysOnTop,width:t.width,height:t.height,color:t.color,fontColor:t.fontColor,fontSize:t.fontSize,showTime:t.showTime,showTitle:t.showTitle,timeColor:t.timeColor,timeFill:t.timeFill}};e.pushInstance(i)},i.prototype.readDotsInstance=function(e){var t=this.getSettings("dots"),i={objectName:"dots",displayName:"Dots",selector:null,properties:{color:t.color,size:t.size,minSize:t.minSize,maxSize:t.maxSize,transparency:t.transparency}};e.pushInstance(i)},i.prototype.xAxisInstance=function(e){var t=this.getSettings("xAxis");e.pushInstance({objectName:"xAxis",displayName:"xAxis",selector:null,properties:{show:t.show,position:t.position,color:t.color,fontColor:t.fontColor,backgroundColor:t.backgroundColor}})},i.prototype.yAxisInstance=function(e){var t=this.getSettings("yAxis");e.pushInstance({objectName:"yAxis",displayName:"yAxis",selector:null,properties:{color:t.color,fontColor:t.fontColor,show:t.show}})},i.prototype.readSeriesInstance=function(e){var t=this.getSettings("series"),i={objectName:"series",displayName:"series",selector:null,properties:{fill:t.fill,width:t.width}};e.pushInstance(i)},i.prototype.readGapsInstance=function(e){var t=this.getSettings("gaps"),i={objectName:"gaps",selector:null,properties:{show:t.show,transparency:t.visibleGapsPercentage}};e.pushInstance(i)},i.prototype.readPlaybackInstance=function(e){var t=this.getSettings("playback");e.pushInstance({objectName:"playback",displayName:"playback",selector:null,properties:{autoplay:t.autoplay,playSpeed:t.playSpeed,pauseDuration:t.pauseDuration,autoplayPauseDuration:t.autoplayPauseDuration,color:t.color}})},i.prototype.readRunnerCounterInstance=function(e){var t=this.getSettings("runnerCounter"),i={objectName:"runnerCounter",selector:null,properties:{}};this.data&&this.data.columns&&this.data.columns.RunnerCounter&&(i.properties={show:t.show,label:t.label,position:t.position,fontSize:t.fontSize,fontColor:t.fontColor}),e.pushInstance(i)},i.prototype.destroy=function(){this.data=null,this.clearAll(!0)},i.RoleDisplayNames={Timestamp:"Timestamp",Category:"Category",Value:"Value",EventTitle:"Event Title",EventDescription:"Event Description",EventSize:"Event Size",RunnerCounter:"Runner Counter"},i.RoleNames=_.mapValues(i.RoleDisplayNames,function(e,t){return t}),i.capabilities={dataRoles:[{displayName:i.RoleDisplayNames.Timestamp,name:i.RoleNames.Timestamp,kind:e.VisualDataRoleKind.Grouping},{displayName:i.RoleDisplayNames.Value,name:i.RoleNames.Value,kind:e.VisualDataRoleKind.Measure},{displayName:i.RoleDisplayNames.EventTitle,name:i.RoleNames.EventTitle,kind:e.VisualDataRoleKind.GroupingOrMeasure},{displayName:i.RoleDisplayNames.EventDescription,name:i.RoleNames.EventDescription,kind:e.VisualDataRoleKind.GroupingOrMeasure},{displayName:i.RoleDisplayNames.EventSize,name:i.RoleNames.EventSize,kind:e.VisualDataRoleKind.GroupingOrMeasure},{displayName:i.RoleDisplayNames.RunnerCounter,name:i.RoleNames.RunnerCounter,kind:e.VisualDataRoleKind.GroupingOrMeasure}],dataViewMappings:[{conditions:[{Timestamp:{max:1},Value:{max:1},Category:{max:1},EventTitle:{max:1},EventDescription:{max:1},EventSize:{max:1},RunnerCounter:{max:1}}],categorical:{categories:{"for":{"in":i.RoleNames.Timestamp},dataReductionAlgorithm:{top:{count:1e4}}},values:{group:{by:i.RoleNames.Category,select:[{bind:{to:i.RoleNames.Value}},{bind:{to:i.RoleNames.EventTitle}},{bind:{to:i.RoleNames.EventDescription}},{bind:{to:i.RoleNames.EventSize}},{bind:{to:i.RoleNames.RunnerCounter}}],dataReductionAlgorithm:{top:{}}}}}}],objects:{series:{displayName:"Series",description:"Series",properties:{fill:{displayName:e.data.createDisplayNameGetter("Visual_Fill"),type:{fill:{solid:{color:!0}}}},width:{displayName:"Width",type:{numeric:!0}}}},gaps:{displayName:"Gaps",description:"Gaps",properties:{show:{displayName:e.data.createDisplayNameGetter("Visual_Show"),type:{bool:!0}},transparency:{displayName:"Visible gaps",type:{numeric:!0}}}},general:{displayName:"General",properties:{formatString:{type:{formatting:{formatString:!0}}},fill:{displayName:"Background color",type:{fill:{solid:{color:!0}}}}}},popup:{displayName:"Popup",properties:{show:{displayName:e.data.createDisplayNameGetter("Visual_Show"),type:{bool:!0}},alwaysOnTop:{displayName:"Always on top",type:{bool:!0}},width:{displayName:"Width",type:{numeric:!0}},height:{displayName:"Height",type:{numeric:!0}},color:{displayName:e.data.createDisplayNameGetter("Visual_Fill"),type:{fill:{solid:{color:!0}}}},fontSize:{displayName:"Text size",type:{formatting:{fontSize:!0}}},fontColor:{displayName:"Text color",type:{fill:{solid:{color:!0}}}},showTime:{displayName:"Show time",type:{bool:!0}},showTitle:{displayName:"Show title",type:{bool:!0}},timeColor:{displayName:"Time color",type:{fill:{solid:{color:!0}}}},timeFill:{displayName:"Time fill",type:{fill:{solid:{color:!0}}}}}},dots:{displayName:"Dots",properties:{color:{displayName:e.data.createDisplayNameGetter("Visual_Fill"),type:{fill:{solid:{color:!0}}}},minSize:{displayName:"Min Size",type:{numeric:!0}},maxSize:{displayName:"Max Size",type:{numeric:!0}},size:{displayName:"Default Size",type:{numeric:!0}},transparency:{displayName:"Transparency",type:{numeric:!0}}}},xAxis:{displayName:e.data.createDisplayNameGetter("Visual_XAxis"),properties:{show:{displayName:e.data.createDisplayNameGetter("Visual_Show"),type:{bool:!0}},position:{displayName:"Position",type:{enumeration:r(g)}},fontColor:{displayName:"Font Color",type:{fill:{solid:{color:!0}}}},color:{displayName:"Axis Color",type:{fill:{solid:{color:!0}}}},backgroundColor:{displayName:"Background Color",type:{fill:{solid:{color:!0}}}}}},yAxis:{displayName:e.data.createDisplayNameGetter("Visual_YAxis"),properties:{show:{displayName:e.data.createDisplayNameGetter("Visual_Show"),type:{bool:!0}},fontColor:{displayName:"Font Color",type:{fill:{solid:{color:!0}}}},color:{displayName:"Axis Color",type:{fill:{solid:{color:!0}}}}}},playback:{displayName:"Playback",properties:{autoplay:{displayName:"Autoplay",type:{bool:!0}},playSpeed:{displayName:"Speed (dots/sec)",type:{numeric:!0}},pauseDuration:{displayName:"Pause Duration",type:{numeric:!0}},autoplayPauseDuration:{displayName:"Start Delay",type:{numeric:!0}},color:{displayName:"Buttons Color",type:{fill:{solid:{color:!0}}}},position:{displayName:"Position",type:{text:!0}}}},runnerCounter:{displayName:"Runner Counter",properties:{show:{displayName:e.data.createDisplayNameGetter("Visual_Show"),type:{bool:!0}},label:{displayName:"Label",type:{text:!0}},position:{displayName:"Position",type:{enumeration:r(m)}},fontSize:{displayName:"Text Size",type:{formatting:{fontSize:!0}}},fontColor:{displayName:"Font Color",type:{fill:{solid:{color:!0}}}}}}},sorting:{implicit:{clauses:[{role:i.RoleNames.Timestamp,direction:1}]}},supportsHighlight:!0},i.Properties=i.getProperties(i.capabilities),i.DefaultMargin={top:20,bottom:20,right:25,left:25},i.DefaultViewport={width:50,height:50},i.PlaybackButtonsHeight=26,i.PopupMinHeight=20,i.PopupMinWidth=20,i.PopupMaxHeight=200,i.PopupMaxWidth=2e3,i.MaxWidthOfYAxis=50,i.PopupTextPadding=3,i.XAxisTickSpace=15,i.XAxisTickHeight=16,i.MinimumTicksToRotate=3,i.AxisTickRotateAngle=-35,i.DefaultSettings={precision:0,popup:{show:!0,alwaysOnTop:!1,width:100,height:80,color:"#808181",fontSize:10,fontColor:"white",showTime:!0,showTitle:!0,timeColor:"white",timeFill:"#010101"},dots:{color:"#808181",size:5,minSize:5,maxSize:20,transparency:25},gaps:{show:!1,visibleGapsPercentage:1},series:{fill:"#3779B7",width:2},xAxis:{color:"#777777",fontColor:"#777777",position:g.Center,show:!0,dateFormat:d.TimeOnly,backgroundColor:"#E1F2F7"},yAxis:{color:"#777777",fontColor:"#777777",show:!0},playback:{autoplay:!1,playSpeed:5,pauseDuration:10,autoplayPauseDuration:0,color:"#777",position:null},runnerCounter:{show:!0,label:"",position:m.TopRight,fontSize:13,fontColor:"#777777"},formatStringProperty:i.Properties.general.formatString},i.DefaultTooltipSettings={dataPointColor:"#808181",marginTop:20,timeHeight:15},i.MaxGapCount=100,i.MinGapWidth=_.object([[d.DateOnly,144e4],[d.TimeOnly,6e4]],void 0),i.Chart=n("chart"),i.Line=n("line"),i.LineContainer=n("lineContainer"),i.LineNode=n("lineNode"),i.XAxisNode=n("xAxisNode"),i.Dot=n("dot"),i.DotsContainer=n("dotsContainer"),i.Tooltip=n("Tooltip"),i.TooltipRect=n("tooltipRect"),i.TooltipTriangle=n("tooltipTriangle"),i.Gaps=n("gaps"),i.Gap=n("gap"),i.GapNode=n("gapNode"),i.TooltipLine=n("tooltipLine"),i.TooltipTime=n("tooltipTime"),i.TooltipTimeRect=n("tooltipTimeRect"),i.TooltipTitle=n("tooltipTitle"),i.TooltipDescription=n("tooltipDescription"),i.TooltipContainer=n("tooltipContainer"),i.AnimationDot=n("animationDot"),i}();i.PulseChart=y;var f;!function(e){e[e.Ready=0]="Ready",e[e.Play=1]="Play",e[e.Paused=2]="Paused",e[e.Stopped=3]="Stopped"}(f||(f={}));var v=function(){function e(t,i){var a=this;this.animationPlayingIndex=0,this.runnerCounterTopLeftPosition=180,this.isAutoPlayed=!1,this.isPositionWasSaved=!1,this.chart=t,this.svg=i,this.setDefaultValues();var r=this.container=this.svg.append("g");this.animationPlay=r.append("g").classed(e.AnimationPlay["class"],!0),this.animationPlay.append("circle").attr("cx",12).attr("cy",12).attr("r",10).attr("fill","transparent"),this.animationPlay.call(y.AddOnTouchClick,function(){return a.play()}),this.animationPlay.append("path").attr("d","M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm-3 17v-10l9 5.146-9 4.854z"),this.animationPause=r.append("g").classed(e.AnimationPause["class"],!0),this.animationPause.append("circle").attr("cx",12).attr("cy",12).attr("r",10).attr("fill","transparent"),this.animationPause.call(y.AddOnTouchClick,function(){return a.stop()}),this.animationPause.append("path").attr("d","M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm-1 17h-3v-10h3v10zm5-10h-3v10h3v-10z"),this.animationReset=r.append("g").classed(e.AnimationReset["class"],!0),this.animationReset.append("circle").attr("cx",12).attr("cy",12).attr("r",10).attr("fill","transparent"),this.animationReset.call(y.AddOnTouchClick,function(){return a.reset()}),this.animationReset.append("path").attr("d","M22 12c0 5.514-4.486 10-10 10s-10-4.486-10-10 4.486-10 10-10 10 4.486 10 10zm-22 0c0 6.627 5.373 12 12 12s12-5.373 12-12-5.373-12-12-12-12 5.373-12 12zm13 0l5-4v8l-5-4zm-5 0l5-4v8l-5-4zm-2 4h2v-8h-2v8z"),this.animationPrev=r.append("g").classed(e.AnimationPrev["class"],!0),this.animationPrev.append("circle").attr("cx",12).attr("cy",12).attr("r",10).attr("fill","transparent"),this.animationPrev.call(y.AddOnTouchClick,function(){return a.prev()}),this.animationPrev.append("path").attr("d","M9.5 12l7.5-4.5v9l-7.5-4.5zm-4.5 0l6.5 4v-1.634l-3.943-2.366 3.943-2.366v-1.634l-6.5 4zm17 0c0 5.514-4.486 10-10 10s-10-4.486-10-10 4.486-10 10-10 10 4.486 10 10zm-22 0c0 6.627 5.373 12 12 12s12-5.373 12-12-5.373-12-12-12-12 5.373-12 12z"),this.animationNext=r.append("g").classed(e.AnimationNext["class"],!0),this.animationNext.append("circle").attr("cx",12).attr("cy",12).attr("r",10).attr("fill","transparent"),this.animationNext.call(y.AddOnTouchClick,function(){return a.next()}),this.animationNext.append("path").attr("d","M7 16.5v-9l7.5 4.5-7.5 4.5zm5.5-8.5v1.634l3.943 2.366-3.943 2.366v1.634l6.5-4-6.5-4zm-.5-6c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12z").attr("rotate",180),this.animationToEnd=r.append("g").classed(e.AnimationToEnd["class"],!0),this.animationToEnd.append("circle").attr("cx",12).attr("cy",12).attr("r",10).attr("fill","transparent"),this.animationToEnd.call(y.AddOnTouchClick,function(){return a.toEnd()}),this.animationToEnd.append("path").attr("d","M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm-6 16v-8l5 4-5 4zm5 0v-8l5 4-5 4zm7-8h-2v8h2v-8z"),this.runnerCounter=r.append("g").classed(e.RunnerCounter["class"],!0),this.runnerCounterText=this.runnerCounter.append("text"),this.setControlsColor(e.DefaultControlsColor)}return Object.defineProperty(e,"AnimationMinPosition",{get:function(){return{series:0,index:0}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"runnerCounterPosition",{get:function(){return this.chart.data.settings.runnerCounter.position},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxTextWidthOfRunnerCounterValue",{get:function(){var e=this.runnerCounterPosition===m.TopLeft||this.runnerCounterPosition===m.TopRight;return this.chart.viewport.width-(e?this.runnerCounterTopLeftPosition:0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isAnimated",{get:function(){return this.animatorState===f.Paused||this.animatorState===f.Play||this.animatorState===f.Stopped},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isPlaying",{get:function(){return this.animatorState===f.Play},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isPaused",{get:function(){return this.animatorState===f.Paused},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isStopped",{get:function(){return this.animatorState===f.Stopped},enumerable:!0,configurable:!0}),e.prototype.setDefaultValues=function(){this.position=e.AnimationMinPosition,this.animatorState=f.Ready,this.runnerCounterValue=null},e.prototype.render=function(){this.renderControls(),this.disableControls(),this.chart.isAutoPlay||(this.isAutoPlayed=!0,this.savedPosition&&(this.savedPosition=null)),this.chart.isAutoPlay&&this.isAutoPlayed&&this.animatorState===f.Play&&!this.isPositionWasSaved&&!_.isEqual(this.autoPlayPosition,this.savedPosition)&&(this.chart.stopAnimation(),this.isAutoPlayed=!1,this.isPositionWasSaved=!0,this.animatorState=f.Ready),this.animatorState===f.Play?this.play():this.chart.isAutoPlay&&!this.isAutoPlayed&&this.animatorState===f.Ready?(this.autoPlayPosition=this.savedPosition,this.isAutoPlayed=!0,this.savedPosition&&this.savedPosition.series<this.chart.data.series.length&&this.savedPosition.index<this.chart.data.series[this.savedPosition.series].data.length&&(this.position=this.savedPosition),this.play(this.chart.autoplayPauseDuration)):this.chart.renderChart()},e.prototype.setControlsColor=function(e){this.color=e},e.prototype.renderControls=function(){this.show(),this.animationPlay.attr("transform",t.SVGUtil.translate(0,0)).attr("fill",this.color),this.animationPause.attr("transform",t.SVGUtil.translate(30,0)).attr("fill",this.color),this.animationReset.attr("transform",t.SVGUtil.translate(60,0)).attr("fill",this.color),this.animationPrev.attr("transform",t.SVGUtil.translate(90,0)).attr("fill",this.color),this.animationNext.attr("transform",t.SVGUtil.translate(120,0)).attr("fill",this.color),this.animationToEnd.attr("transform",t.SVGUtil.translate(150,0)).attr("fill",this.color),this.runnerCounter.attr("fill",this.color).attr("transform",t.SVGUtil.translate(this.runnerCounterPosition===m.TopLeft?this.runnerCounterTopLeftPosition:this.chart.viewport.width-2,this.chart.data.runnerCounterHeight/2+7)),this.runnerCounterText.style("text-anchor",this.runnerCounterPosition===m.TopLeft?"start":"end"),this.chart.data&&this.chart.data.settings&&(this.runnerCounterText.style(y.ConvertTextPropertiesToStyle(y.GetRunnerCounterTextProperties(null,this.chart.data.settings.runnerCounter.fontSize))),this.runnerCounterText.style("fill",this.chart.data.settings.runnerCounter.fontColor)),this.drawCounterValue()},e.setControlVisiblity=function(t,i,a){void 0===a&&(a=!1),t.style("opacity",i?e.DefaultOpacity:e.DimmedOpacity),i?t.attr("display","inline"):a&&t.attr("display","none")},e.prototype.disableControls=function(){var t=this.chart.data&&this.chart.data.settings&&this.chart.data.settings.runnerCounter.show;switch(e.setControlVisiblity(this.animationReset,!0),e.setControlVisiblity(this.animationToEnd,!0),this.animatorState){case f.Play:e.setControlVisiblity(this.animationPlay,!1),e.setControlVisiblity(this.animationPrev,!0),e.setControlVisiblity(this.animationNext,!0),e.setControlVisiblity(this.animationPause,!0),e.setControlVisiblity(this.runnerCounter,t,!0);break;case f.Paused:e.setControlVisiblity(this.animationPlay,!0),e.setControlVisiblity(this.animationPause,!0),e.setControlVisiblity(this.animationPrev,!0),e.setControlVisiblity(this.animationNext,!0),e.setControlVisiblity(this.runnerCounter,t,!0);break;case f.Stopped:e.setControlVisiblity(this.animationPlay,!0),e.setControlVisiblity(this.animationPrev,!0),e.setControlVisiblity(this.animationNext,!0),e.setControlVisiblity(this.runnerCounter,t,!0),e.setControlVisiblity(this.animationPause,!1);break;case f.Ready:e.setControlVisiblity(this.animationPlay,!0),e.setControlVisiblity(this.animationPrev,!1),e.setControlVisiblity(this.animationNext,!1),e.setControlVisiblity(this.animationPause,!1),e.setControlVisiblity(this.runnerCounter,!1,!0);break;default:e.setControlVisiblity(this.animationPlay,!0),e.setControlVisiblity(this.animationPrev,!1),e.setControlVisiblity(this.animationNext,!1),e.setControlVisiblity(this.animationPause,!1),e.setControlVisiblity(this.runnerCounter,!1,!0)}},e.prototype.show=function(){this.container.style("display","inline")},e.prototype.setRunnerCounterValue=function(e){var i=this.chart.data&&this.chart.data.series&&this.chart.data.series[this.position.series]&&this.chart.data.series[this.position.series].data&&this.chart.data.series[this.position.series].data[$.isNumeric(e)?e:this.flooredPosition.index],a=i&&null!=i.runnerCounterValue?i.runnerCounterValue:"";if(i&&i.runnerCounterFormatString){var r=t.valueFormatter.create({format:i.runnerCounterFormatString});a=r.format(a)}this.runnerCounterValue=this.chart.data.settings.runnerCounter.label+" "+a,this.drawCounterValue()},e.prototype.drawCounterValue=function(){var e=""+this.runnerCounterValue;this.runnerCounterText.text(e),l.svgEllipsis(this.runnerCounterText.node(),this.maxTextWidthOfRunnerCounterValue)},e.prototype.play=function(e,t){if(void 0===e&&(e=0),void 0===t&&(t=!1),this.animatorState!==f.Play||t){if(this.animatorState===f.Ready&&(this.animationPlayingIndex++,this.chart.clearChart()),this.chart.isAnimationIndexLast(this.position))return void this.playNext();this.animatorState===f.Paused&&this.chart.clearSelection(),this.animatorState=f.Play,this.chart.renderChart(),this.chart.playAnimation(e),this.disableControls()}},e.prototype.playNext=function(){this.pause(),this.chart.isAnimationSeriesLast(this.position)?(this.setDefaultValues(),this.chart.clearSelection()):(this.position={series:this.position.series+1,index:e.AnimationMinPosition.index},this.play())},e.prototype.pause=function(){this.animatorState===f.Play&&(this.animatorState=f.Paused,this.chart.pauseAnimation()),this.disableControls()},e.prototype.reset=function(){this.clearTimeouts(),this.chart.stopAnimation(),this.chart.clearSelection(),this.chart.clearChart(),this.setDefaultValues(),this.animatorState=f.Stopped,this.disableControls(),this.savedPosition=null},e.prototype.next=function(){if(this.isAnimated){this.stop();var e=this.chart.findNextPoint(this.position);e?(this.position=e,this.chart.renderChart()):this.toEnd()}},e.prototype.prev=function(){if(this.isAnimated){this.stop();var e=this.chart.findPrevPoint(this.position);e?(this.chart.clearRedundant(e),this.position=e,this.chart.renderChart()):this.reset()}},e.prototype.toEnd=function(){this.savedPosition=null,this.chart.stopAnimation(),this.chart.clearSelection(),this.chart.clearChart(),this.setDefaultValues(),this.disableControls(),this.chart.renderChart()},e.prototype.stop=function(){this.isAnimated&&(this.drawCounterValue(),this.savedPosition=this.position,this.chart.stopAnimation(),this.animatorState=f.Stopped,this.disableControls())},Object.defineProperty(e.prototype,"position",{get:function(){return this.positionValue},set:function(e){this.positionValue=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"flooredPosition",{get:function(){return this.position&&{series:this.position.series,index:Math.floor(this.position.index)}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"savedPosition",{get:function(){return this.chart.data&&this.chart.data.settings&&this.chart.data.settings.playback&&this.chart.data.settings.playback.position},set:function(e){this.chart.isAutoPlay||(e=null),this.chart.data&&this.chart.data.settings&&this.chart.data.settings.playback&&(this.isPositionWasSaved=!0,this.chart.data&&this.chart.data.settings&&this.chart.data.settings.playback&&(this.chart.data.settings.playback.position=e),this.chart.host.persistProperties({merge:[{objectName:"playback",selector:null,properties:{position:e&&JSON.stringify(e)||""}}]}))},enumerable:!0,configurable:!0}),e.prototype.clear=function(){this.isAnimated&&this.chart.stopAnimation(),this.setDefaultValues(),this.container.style("display","none")},e.prototype.clearTimeouts=function(){clearTimeout(this.chart.handleSelectionTimeout)},e.AnimationPlay=n("animationPlay"),e.AnimationPause=n("animationPause"),e.AnimationReset=n("animationReset"),e.AnimationToEnd=n("animationToEnd"),e.AnimationPrev=n("animationPrev"),e.AnimationNext=n("animationNext"),e.RunnerCounter=n("runnerCounter"),e.DimmedOpacity=.25,e.DefaultOpacity=1,e.DefaultControlsColor="#777",e}();i.PulseAnimator=v;var x;!function(e){function t(){return{show:!1,position:0,displayUnits:0,precision:c,labelColor:u,fontSize:h,labelDensity:p}}e.getDefaultPulseChartLabelSettings=t}(x=i.PulseChartDataLabelUtils||(i.PulseChartDataLabelUtils={}));var b;!function(e){function t(e,t){var i={};if(!e)return i;var a=e.objects;if(a){var r=a.categoryAxis;r&&(i={show:r.show,axisType:r.axisType,axisScale:r.axisScale,start:r.start,end:r.end,showAxisTitle:null==r.showAxisTitle?t:r.showAxisTitle,axisStyle:r.axisStyle,labelColor:r.labelColor,labelDisplayUnits:r.labelDisplayUnits,labelPrecision:r.labelPrecision,duration:r.duration})}return i}function i(e,t){var i={};if(!e)return i;var a=e.objects;if(a){var r=a.valueAxis;r&&(i={show:r.show,position:r.position,axisScale:r.axisScale,start:r.start,end:r.end,showAxisTitle:null==r.showAxisTitle?t:r.showAxisTitle,axisStyle:r.axisStyle,labelColor:r.labelColor,labelDisplayUnits:r.labelDisplayUnits,labelPrecision:r.labelPrecision,secShow:r.secShow,secPosition:r.secPosition,secAxisScale:r.secAxisScale,secStart:r.secStart,secEnd:r.secEnd,secShowAxisTitle:r.secShowAxisTitle,secAxisStyle:r.secAxisStyle,secLabelColor:r.secLabelColor,secLabelDisplayUnits:r.secLabelDisplayUnits,secLabelPrecision:r.secLabelPrecision})}return i}e.getCategoryAxisProperties=t,e.getValueAxisProperties=i}(b=i.PulseChartAxisPropertiesHelper||(i.PulseChartAxisPropertiesHelper={}))}(i=t.samples||(t.samples={}))}(t=e.visuals||(e.visuals={}))}(i||(i={}))},function(e,t){var i,i=(window.jsCommon,window.powerbi);window.powerbitests,window.InJs,window.debug,window.jasmine,window.Microsoft;!function(e){var t;!function(t){var i;!function(i){var a=t.utility.SelectionManager,r=function(){function i(){this.margin={top:10,right:30,bottom:10,left:10},this.LegendSize=50,this.AxisSize=30}return i.prototype.init=function(e){var r=this;this.hostServices=e.host,this.selectionManager=new a({hostServices:this.hostServices}),this.root=d3.select(e.element.get(0)).append("svg").classed(i.Identity["class"],!0),this.root.on("click",function(e){r.clearSelection()}),this.main=this.root.append("g"),this.axes=this.main.append("g").classed(i.Axes["class"],!0),this.axisX=this.axes.append("g").classed(i.Axis["class"],!0),this.axisY=this.axes.append("g").classed(i.Axis["class"],!0),this.axisY2=this.axes.append("g").classed(i.Axis["class"],!0),this.legends=this.main.append("g").classed(i.Legends["class"],!0),this.line=this.main.append("g").classed(i.Values["class"],!0),this.colors=e.style&&e.style.colorPalette?e.style.colorPalette.dataColors:new t.DataColorPalette},i.prototype.update=function(e){if(e.dataViews&&e.dataViews[0]){var t=e.viewport,i=this.model=this.converter(e.dataViews[0],t);this.clearSelection(),this.resize(t),this.draw(i)}},i.prototype.destroy=function(){this.root=null},i.prototype.setIsStopped=function(e){var t={merge:[{objectName:"misc",selector:void 0,properties:{isstopped:e}}]};this.hostServices.persistProperties(t),this.hostServices.onSelect({data:[]})},i.prototype.enumerateObjectInstances=function(e){var t=[];if(!this.model||!this.model.settings)return t;var i=this.model.settings;switch(e.objectName){case"lineoptions":var a={objectName:"lineoptions",displayName:"lineoptions",selector:null,properties:{fill:i.lineFill,lineThickness:i.lineThickness}};t.push(a);break;case"dotoptions":var r={objectName:"dotoptions",displayName:"dotoptions",selector:null,properties:{color:i.dotFill,dotSizeMin:i.dotSizeMin,dotSizeMax:i.dotSizeMax}};t.push(r);break;case"counteroptions":var s={objectName:"counteroptions",displayName:"counteroptions",selector:null,properties:{counterTitle:i.counterTitle}};t.push(s);break;case"misc":var o={objectName:"misc",displayName:"misc",selector:null,properties:{isanimated:i.isanimated,isstopped:i.isstopped,duration:i.duration}};t.push(o)}return t},i.prototype.selectDot=function(e,t){var i=d3.select(e);i.classed("point_selected")?this.clearSelection():(t&&this.selectionManager.select(t),this.root.classed("filtered",!0),this.line.selectAll("circle.point").classed("point_selected",!1),d3.select(e).classed("point_selected",!0)),d3.event.stopPropagation()},i.prototype.clearSelection=function(){this.root.classed("filtered",!1),this.root.selectAll("circle.point").classed("point_selected",!1),this.selectionManager.clear()},i.prototype.converter=function(e,i){if(!(e.categorical&&e.categorical.categories&&e.categorical.categories[0]&&e.categorical.categories[0].values&&e.categorical.categories[0].values.length>0&&e.categorical&&e.categorical.values&&e.categorical.values[0]&&e.categorical.values[0].values&&e.categorical.values[0].values.length>0))return null;var a,r,s,o,n=[],l=this,c=t.AxisHelper.getCategoryValueType(e.categorical.categories[0].source,!0);this.isDateTime=t.AxisHelper.isDateTime(c);var u,h=!0,p=this.parseSettings(e),d=Math.max(0,i.width-this.margin.left-this.margin.right-this.LegendSize-this.AxisSize),g=Math.max(0,i.height-this.margin.top-this.margin.bottom-this.LegendSize),m="";n=e.categorical.categories[0].values,a=e.categorical.categories[0].source,r=d3.extent(n),this.isDateTime?(s=r[0].getTime(),o=r[1].getTime(),s=new Date(s),o=new Date(o+.05*(o-s)),m="MMM dd yyyy",u=t.valueFormatter.create({format:m})):(s=r[0],o=r[1],o+=.05*(o-s),u=t.valueFormatter.create({value:0}));var y=t.AxisHelper.createAxis({pixelSpan:d,dataDomain:[s,o],metaDataColumn:a,formatString:null,outerPadding:0,isCategoryAxis:!0,isScalar:h,isVertical:!1,forcedTickCount:void 0,useTickIntervalForDisplayUnits:!0,getValueFn:function(e,t){return l.isDateTime?u.format(new Date(e)):e}});y.formatter=u,a=e.categorical.values[0].source,n=e.categorical.values[0].values,r=d3.extent(n),s=r[0],o=r[1];for(var f,v=[],x=0,b=0,S=0,w=0;w<e.categorical.categories[0].values.length;w++)b=e.categorical.values[0].values[w],S=e.categorical.categories[0].values[w],x+=b,f=t.SelectionId.createWithId(e.categorical.categories[0].identity[w]),v.push({dot:(b-s)/(o-s),value:b,sum:x,time:S,selector:f});x+=.1*(x-s);var C=t.AxisHelper.createAxis({pixelSpan:g,dataDomain:[s,x],metaDataColumn:a,formatString:null,outerPadding:0,isCategoryAxis:!1,isScalar:!0,isVertical:!0,useTickIntervalForDisplayUnits:!0}),P=t.AxisHelper.createAxis({pixelSpan:g,dataDomain:[s,x],metaDataColumn:a,formatString:null,outerPadding:0,isCategoryAxis:!1,isScalar:!0,isVertical:!0,useTickIntervalForDisplayUnits:!0});return P.axis.orient("right"),{points:v,settings:p,xAxis:y,yAxis:C,yAxis2:P,legends:this.generateAxisLabels(i,p)}},i.prototype.parseSettings=function(a){if(!(a&&a.metadata&&a.metadata.columns&&a.metadata.columns[0]))return null;var r=a.metadata.objects,s=new t.ColorHelper(this.colors,i.Properties.lineoptions.fill,i.DefaultSettings.lineFill),o=new t.ColorHelper(this.colors,i.Properties.dotoptions.color,i.DefaultSettings.dotFill),n=i.DefaultSettings.xAxisTitle,l=i.DefaultSettings.yAxisTitle;a.categorical.categories[0]&&a.categorical.categories[0].source&&a.categorical.categories[0].source.displayName&&a.categorical.values[0]&&a.categorical.values[0].source&&a.categorical.values[0].source.displayName&&(n=a.categorical.categories[0].source.displayName,l=a.categorical.values[0].source.displayName);var c=i.DefaultSettings.lineThickness,u=i.DefaultSettings.dotSizeMin,h=i.DefaultSettings.dotSizeMax,p=i.DefaultSettings.counterTitle,d=i.DefaultSettings.isanimated,g=i.DefaultSettings.isstopped,m=i.DefaultSettings.duration;return r&&(c=e.DataViewObjects.getValue(r,i.Properties.lineoptions.lineThickness,i.DefaultSettings.lineThickness),u=e.DataViewObjects.getValue(r,i.Properties.dotoptions.dotSizeMin,i.DefaultSettings.dotSizeMin),h=e.DataViewObjects.getValue(r,i.Properties.dotoptions.dotSizeMax,i.DefaultSettings.dotSizeMax),p=e.DataViewObjects.getValue(r,i.Properties.counteroptions.counterTitle,i.DefaultSettings.counterTitle),
18d=e.DataViewObjects.getValue(r,i.Properties.misc.isanimated,i.DefaultSettings.isanimated),g=e.DataViewObjects.getValue(r,i.Properties.misc.isstopped,i.DefaultSettings.isstopped),m=e.DataViewObjects.getValue(r,i.Properties.misc.duration,i.DefaultSettings.duration)),{xAxisTitle:n,yAxisTitle:l,lineFill:s.getColorForMeasure(r,""),lineThickness:c,dotFill:o.getColorForMeasure(r,""),dotSizeMin:u,dotSizeMax:h,counterTitle:p,isstopped:g,isanimated:d,duration:m}},i.prototype.generateAxisLabels=function(e,i){return[{transform:t.SVGUtil.translate((e.width-this.margin.left-this.margin.right)/2,e.height-this.margin.top-this.margin.bottom),text:i.xAxisTitle,dx:"1em",dy:"-1em"},{transform:t.SVGUtil.translateAndRotate(0,(e.height-this.margin.top-this.margin.bottom)/2,0,0,270),text:i.yAxisTitle,dx:"3em"}]},i.prototype.resize=function(e){this.root.attr({height:Math.max(0,e.height),width:Math.max(0,e.width)}),this.main.attr("transform",t.SVGUtil.translate(this.margin.left,this.margin.top)),this.legends.attr("transform",t.SVGUtil.translate(this.margin.left,this.margin.top)),this.line.attr("transform",t.SVGUtil.translate(this.margin.left+this.LegendSize,0)),this.axes.attr("transform",t.SVGUtil.translate(this.margin.left+this.LegendSize,0)),this.axisX.attr("transform",t.SVGUtil.translate(0,e.height-this.margin.top-this.margin.bottom-this.LegendSize)),this.axisY2.attr("transform",t.SVGUtil.translate(e.width-this.margin.left-this.margin.right-this.LegendSize-this.AxisSize,0))},i.prototype.draw=function(e){var t=this,i=this;if(this.line.selectAll("*").remove(),this.legends.selectAll("*").remove(),this.axisX.selectAll("*").remove(),this.axisY.selectAll("*").remove(),this.axisY2.selectAll("*").remove(),e&&(this.renderLegends(e),e&&e.points&&e.points.length)){if(this.axisX.call(e.xAxis.axis),this.axisY.call(e.yAxis.axis),this.axisY2.call(e.yAxis2.axis),e.settings.isanimated){var a=this.line.append("g").classed("lineDotChart__playBtn",!0).attr("transform","translate(40, 20)");if(a.append("circle").attr("r",17),e.settings.isstopped)return a.append("path").attr("d","M0 2l10 6-10 6z").attr("transform","translate(-4,-8)"),void a.on("click.lineDotChart__playBt",function(){i.setIsStopped(!1)});a.append("path").attr("d","M0 2l10 6-10 6z").attr("transform-origin","center").attr("transform","translate(6, 8) rotate(180)"),a.append("rect").attr("width","2").attr("height","12").attr("transform","translate(-7,-6)"),a.on("click.lineDotChart__playBt",function(){i.setIsStopped(!0)})}var r=this.line.append("clipPath").attr("id","lineClip").append("rect").attr("x",0).attr("y",0).attr("width",1).attr("height",1e4),s=d3.svg.line().x(function(t){return e.xAxis.scale(t.time)}).y(function(t){return e.yAxis.scale(t.sum)}),o=this.line.selectAll("path.plot").data([e.points]);o.enter().append("path"),o.classed("plot",!0).attr("stroke",function(t,i){return e.settings.lineFill}).attr("stroke-width",e.settings.lineThickness).attr("d",s);var n=o.node().getTotalLength(),l=o.node().getPointAtLength(0).x,c=o.node().getPointAtLength(n).x;o.attr("clip-path","url("+location.href+"#lineClip)"),e.settings.isanimated?r.attr("x",l).interrupt().transition().ease("linear").duration(1e3*e.settings.duration).attr("width",c-l):r.interrupt().attr("x",l).attr("width",c-l),o.exit().remove();var u=300,h=0,p=this.line.selectAll("circle.point").data(e.points),i=this;p.enter().append("circle").attr("fill",e.settings.dotFill).attr("opacity",.77).attr("r",function(t){return e.settings.dotSizeMin+t.dot*(e.settings.dotSizeMax-e.settings.dotSizeMin)}).classed("point",!0).on("mouseover.point",this.showDataPoint).on("mouseout.point",this.hideDataPoint).on("click.point",function(e){i.selectDot(this,e.selector)}),e.settings.isanimated?p.interrupt().attr("transform",function(t){return"translate("+e.xAxis.scale(t.time)+" "+e.yAxis.scale(t.sum)+") scale(0.005)"}).transition().duration(u).delay(function(i,a){return t.pointDelay(e.points,a,e.settings.duration)}).ease("linear").attr("transform",function(t){return"translate("+e.xAxis.scale(t.time)+" "+e.yAxis.scale(t.sum)+") scale(3.4)"}).transition().duration(u).delay(function(i,a){return t.pointDelay(e.points,a,e.settings.duration)+u}).ease("elastic").attr("transform",function(t){return"translate("+e.xAxis.scale(t.time)+" "+e.yAxis.scale(t.sum)+") scale(1)"}):p.interrupt().attr("transform",function(t){return"translate("+e.xAxis.scale(t.time)+" "+e.yAxis.scale(t.sum)+") scale(1)"}),p.exit().remove();for(var d=0;d<p[0].length;d++)this.addTooltip(e,p[0][d]);var g=this.line.selectAll("text").data(e.points);g.enter().append("text").classed("text",!0).text(function(t,i){return e.settings.counterTitle+" "+(i+1)}).attr("x",c-260).attr("y",30),e.settings.isanimated?g.attr("opacity",0).interrupt().transition().duration(h).delay(function(i,a){return t.pointDelay(e.points,a,e.settings.duration)}).attr("transform","translate(0 0)").attr("opacity",1).transition().duration(h).delay(function(i,a){return e.points[a+1]?t.pointDelay(e.points,a+1,e.settings.duration):Number.POSITIVE_INFINITY}).attr("opacity",0):g.interrupt().attr("transform","translate(0 0)").attr("opacity",function(t,i){return Number(i===e.points.length-1)}),g.exit().remove()}},i.prototype.pointDelay=function(e,t,i){if(!e.length||!e[t]||0===t)return 0;if(this.isDateTime)var a=e[t].time,r=e[0].time.getTime(),s=e[e.length-1].time.getTime(),o=a.getTime();else var a=e[t].time,r=e[0].time,s=e[e.length-1].time,o=a;return 1e3*i*(o-r)/(s-r)},i.prototype.showDataPoint=function(e,t){d3.select(this).classed("show",!0)},i.prototype.hideDataPoint=function(e,t){d3.select(this).classed("show",!1)},i.prototype.addTooltip=function(e,i){var a=d3.select(i),r=a.datum();t.TooltipManager.addTooltip(a,function(t){return[{displayName:e.settings.xAxisTitle,value:e.xAxis.formatter.format(r.time)},{displayName:e.settings.yAxisTitle,value:r.value.toString()}]})},i.prototype.renderLegends=function(e){var t=this.legends.selectAll(i.Legend.selector).data(e.legends);t.enter().append("svg:text"),t.attr("x",0).attr("y",0).attr("dx",function(e){return e.dx}).attr("dy",function(e){return e.dy}).attr("transform",function(e){return e.transform}).text(function(e){return e.text}).classed(i.Legend["class"],!0),t.exit().remove()},i.DefaultSettings={lineFill:"rgb(102, 212, 204)",lineThickness:3,dotFill:"#005c55",dotSizeMin:4,dotSizeMax:38,counterTitle:"Total features",xAxisTitle:"",yAxisTitle:"",duration:20,isanimated:!0,isstopped:!0},i.capabilities={dataRoles:[{name:"Date",kind:e.VisualDataRoleKind.Grouping,displayName:"Date"},{name:"Values",kind:e.VisualDataRoleKind.Measure,displayName:"Values"}],dataViewMappings:[{conditions:[{Date:{min:0,max:1},Values:{min:0,max:1},Labels:{min:0,max:1}}],categorical:{categories:{"for":{"in":"Date"},dataReductionAlgorithm:{sample:{}}},values:{"for":{"in":"Values"}}}}],objects:{general:{displayName:e.data.createDisplayNameGetter("Visual_General"),properties:{formatString:{type:{formatting:{formatString:!0}}}}},lineoptions:{displayName:"Line",properties:{fill:{displayName:e.data.createDisplayNameGetter("Visual_Fill"),type:{fill:{solid:{color:!0}}}},lineThickness:{displayName:"Thickness",type:{numeric:!0}}}},dotoptions:{displayName:"Dot",properties:{color:{displayName:e.data.createDisplayNameGetter("Visual_Fill"),type:{fill:{solid:{color:!0}}}},dotSizeMin:{displayName:"Min size",type:{numeric:!0}},dotSizeMax:{displayName:"Min size",type:{numeric:!0}}}},counteroptions:{displayName:"Counter",properties:{counterTitle:{displayName:"Title",type:{text:!0}}}},misc:{displayName:"Animation",properties:{isanimated:{displayName:"Animated",type:{bool:!0}},isstopped:{displayName:"Stop on load",type:{bool:!0}},duration:{displayName:"Time",type:{numeric:!0}}}}}},i.Identity={"class":"lineDotChart",selector:".lineDotChart"},i.Axes={"class":"axes",selector:".axes"},i.Axis={"class":"axis",selector:".axis"},i.Legends={"class":"legends",selector:".legends"},i.Legend={"class":"legend",selector:".legend"},i.Values={"class":"line",selector:".line"},i.Properties={general:{formatString:{objectName:"general",propertyName:"formatString"}},lineoptions:{fill:{objectName:"lineoptions",propertyName:"fill"},lineThickness:{objectName:"lineoptions",propertyName:"lineThickness"}},dotoptions:{color:{objectName:"dotoptions",propertyName:"color"},dotSizeMin:{objectName:"dotoptions",propertyName:"dotSizeMin"},dotSizeMax:{objectName:"dotoptions",propertyName:"dotSizeMax"}},counteroptions:{counterTitle:{objectName:"counteroptions",propertyName:"counterTitle"}},misc:{isanimated:{objectName:"misc",propertyName:"isanimated"},isstopped:{objectName:"misc",propertyName:"isstopped"},duration:{objectName:"misc",propertyName:"duration"}}},i}();i.LineDotChart=r}(i=t.samples||(t.samples={}))}(t=e.visuals||(e.visuals={}))}(i||(i={}))},function(e,t){var i,i=(window.jsCommon,window.powerbi);window.powerbitests,window.InJs,window.debug,window.jasmine,window.Microsoft;!function(e){var t;!function(t){var i;!function(i){var a=t.utility.SelectionManager;i.sunburstRoleNames={nodes:"Nodes",values:"Values"};var r=function(){function i(){this.total=0}return i.prototype.init=function(e){var t=this;this.arc=d3.svg.arc().startAngle(function(e){return e.x}).endAngle(function(e){return e.x+e.dx}).innerRadius(function(e){return Math.sqrt(e.y)}).outerRadius(function(e){return Math.sqrt(e.y+e.dy)}),this.colors=e.style.colorPalette.dataColors,this.selectionManager=new a({hostServices:e.host}),this.svg=d3.select(e.element.get(0)).append("svg"),this.svg.classed("mainDrawArea",!0),this.g=this.svg.append("g"),this.g.classed("container",!0),this.svg.append("text").classed("sunBurstPercentageFixed",!0),this.svg.on("mousedown",function(e){t.svg.selectAll("path").style("opacity",1),t.svg.select(".sunBurstPercentageFixed").style("opacity",0),t.selectionManager.clear()})},i.setAllUnhide=function(e){e.attr("setUnHide","true")},i.prototype.update=function(e){if(e.dataViews.length>0){var t=this.converter(e.dataViews[0],this.colors);this.viewport=e.viewport,this.updateInternal(t)}},i.prototype.updateInternal=function(e){var a=this;this.svg.attr({height:this.viewport.height,width:this.viewport.width}),this.g.attr("transform",t.SVGUtil.translate(this.viewport.width/2,this.viewport.height/2));var r=Math.min(this.viewport.width,this.viewport.height)/2,s=d3.layout.partition().size([2*Math.PI,r*r]).value(function(e){return e.value}),o=this.g.datum(e).selectAll("path").data(s.nodes);o.enter().append("path"),o.attr("display",function(e){return e.depth?null:"none"}).attr("d",this.arc).style("stroke","#fff").style("fill",function(e){return e.color}).style("fill-rule","evenodd").on("mousedown",function(e){e.selector&&a.selectionManager.select(e.selector),d3.selectAll("path").call(i.setAllUnhide).attr("setUnHide",null),a.highlightPath(e,a,!0);var t=a.svg.select(".sunBurstPercentageFixed"),r=0===a.total?0:(100*e.total/a.total).toPrecision(3);t.text(e?r+"%":""),t.style("fill",e.color),a.onResize(),event.stopPropagation()}),this.renderTooltip(o),o.exit().remove(),this.onResize()},i.getTreePath=function(e){for(var t=[],i=e;i.parent;)t.unshift(i),i=i.parent;return t},i.prototype.onResize=function(){var t=this.viewport.width,i=this.viewport.height,a=this.svg.select(".sunBurstPercentageFixed"),r=e.TextMeasurementService.measureSvgTextElementWidth(a[0][0]);a.style("opacity",1),a.attr("y",i/2+4),a.attr("x",t/2-r/2)},i.prototype.highlightPath=function(e,t,a){var r=e?i.getTreePath(e):[];t.svg.selectAll("path").each(function(){"true"!==d3.select(this).attr("setUnHide")&&d3.select(this).style("opacity",i.minOpacity)}),t.svg.selectAll("path").filter(function(e){return r.indexOf(e)>=0}).each(function(){d3.select(this).style("opacity",1),a===!0&&d3.select(this).attr("setUnHide","true")})},i.prototype.renderTooltip=function(e){t.TooltipManager.addTooltip(e,function(e){return e.data.tooltipInfo})},i.getTooltipData=function(e,t){return[{displayName:e,value:0>t?"":t.toString()}]},i.prototype.covertTreeNodeToSunBurstNode=function(e,a,r,s,o){var n;e.identity&&(s=s.concat([e.identity]),n={data:s});var l=0===s.length?null:new t.SelectionId(n,!1),c=e.values?e.values[0].value:0,u={name:e.name,value:Math.max(c,0),selector:l,total:c};if(e.value&&(u.color=o?o:r.getColor(e.value).value),this.total+=u.value,e.children&&e.children.length>0){u.tooltipInfo=i.getTooltipData(e.value,-1),u.children=[];for(var h=0;h<e.children.length;h++){var p=this.covertTreeNodeToSunBurstNode(e.children[h],u,r,s,u.color);u.children.push(p),u.total+=p.total}}else u.tooltipInfo=i.getTooltipData(e.value,c);return a&&(u.parent=a),u},i.prototype.converter=function(e,t){var i=t.getNewColorScale();this.total=0;var a=this.covertTreeNodeToSunBurstNode(e.matrix.rows.root,null,i,[],void 0);return a},i.minOpacity=.2,i.roleNames={nodes:"Nodes",values:"Values"},i.capabilities={dataRoles:[{name:i.roleNames.nodes,kind:e.VisualDataRoleKind.Grouping,displayName:"Groups"},{name:i.roleNames.values,kind:e.VisualDataRoleKind.Measure,displayName:"Values"}],objects:{general:{displayName:e.data.createDisplayNameGetter("Visual_General"),properties:{formatString:{type:{formatting:{formatString:!0}}}}}},dataViewMappings:[{conditions:[{Groups:{min:0},Values:{max:1}}],matrix:{rows:{"for":{"in":i.roleNames.nodes}},values:{"for":{"in":i.roleNames.values}}}}]},i}();i.Sunburst=r}(i=t.samples||(t.samples={}))}(t=e.visuals||(e.visuals={}))}(i||(i={}))},function(e,t){var i,i=(window.jsCommon,window.powerbi);window.powerbitests,window.InJs,window.debug,window.jasmine,window.Microsoft;!function(e){var t;!function(e){var t;!function(t){t.sunburstCustom={name:"sunburstCustom",watermarkKey:"defaultWatermark",capabilities:e.samples.Sunburst.capabilities,create:function(){return new e.samples.Sunburst}},t.asterPlot={name:"asterPlot",capabilities:e.samples.AsterPlot.capabilities,create:function(){return new e.samples.AsterPlot}},t.tornadoChart={name:"tornadoChart",capabilities:e.samples.TornadoChart.capabilities,create:function(){return new e.samples.TornadoChart}},t.sankeyDiagram={name:"sankeyDiagram",capabilities:e.samples.SankeyDiagram.capabilities,create:function(){return new e.samples.SankeyDiagram}},t.mekkoChart={name:"mekkoChart",watermarkKey:"mekko",capabilities:e.samples.MekkoChart.capabilities,create:function(){return new e.samples.MekkoChart({chartType:0})},customizeQuery:e.ColumnChart.customizeQuery,getSortableRoles:function(t){return e.ColumnChart.getSortableRoles(t)}},t.bulletChart={name:"bulletChart",capabilities:e.samples.BulletChart.capabilities,create:function(){return new e.samples.BulletChart}},t.wordCloud={name:"wordCloud",capabilities:e.samples.WordCloud.capabilities,create:function(){return new e.samples.WordCloud}},t.chicletSlicer={name:"chicletSlicer",capabilities:e.samples.ChicletSlicer.capabilities,create:function(){return new e.samples.ChicletSlicer}},t.chordChart={name:"chordChart",capabilities:e.samples.ChordChart.capabilities,create:function(){return new e.samples.ChordChart}},t.enhancedScatterChart={name:"enhancedScatterChart",capabilities:e.samples.EnhancedScatterChart.capabilities,create:function(){return new e.samples.EnhancedScatterChart}},t.radarChart={name:"radarChart",capabilities:e.samples.RadarChart.capabilities,create:function(){return new e.samples.RadarChart}},t.dotPlot={name:"dotPlot",capabilities:e.samples.DotPlot.capabilities,create:function(){return new e.samples.DotPlot}},t.histogram={name:"histogram",capabilities:e.samples.Histogram.capabilities,create:function(){return new e.samples.Histogram}},t.timeline={name:"timeline",capabilities:e.samples.Timeline.capabilities,create:function(){return new e.samples.Timeline}},t.forceGraph={name:"forceGraph",capabilities:e.samples.ForceGraph.capabilities,create:function(){return new e.samples.ForceGraph}},t.gantt={name:"gantt",capabilities:e.samples.Gantt.capabilities,create:function(){return new e.samples.Gantt}},t.streamGraph={name:"streamGraph",capabilities:e.samples.StreamGraph.capabilities,create:function(){return new e.samples.StreamGraph}},t.pulseChart={name:"pulseChart",capabilities:e.samples.PulseChart.capabilities,create:function(){return new e.samples.PulseChart}},t.lineDotChart={name:"lineDotChart",capabilities:e.samples.LineDotChart.capabilities,create:function(){return new e.samples.LineDotChart}}}(t=e.plugins||(e.plugins={}))}(t=e.visuals||(e.visuals={}))}(i||(i={}))}]);
\No newline at end of file