-
Notifications
You must be signed in to change notification settings - Fork 0
/
c3.min.js
4 lines (4 loc) · 122 KB
/
c3.min.js
1
2
3
4
!function(a){"use strict";function e(a){var b=this.internal=new f(this);b.loadConfig(a),b.init(),function d(a,b,c){for(var e in a)b[e]=a[e].bind(c),Object.keys(a[e]).length>0&&d(a[e],b[e],c)}(c,this,this)}function f(b){var c=this;c.d3=a.d3?a.d3:"undefined"!=typeof require?require("d3"):void 0,c.api=b,c.config=c.getDefaultConfig(),c.data={},c.cache={},c.axes={}}function u(a,b){function n(a,b){a.attr("transform",function(a){return"translate("+Math.ceil(b(a)+k)+", 0)"})}function o(a,b){a.attr("transform",function(a){return"translate(0,"+Math.ceil(b(a))+")"})}function p(a){var b=a[0],c=a[a.length-1];return c>b?[b,c]:[c,b]}function q(a){var b,c,d=[];if(a.ticks)return a.ticks.apply(a,j);for(c=a.domain(),b=Math.ceil(c[0]);b<c[1];b++)d.push(b);return d.length>0&&d[0]>0&&d.unshift(d[0]-(d[1]-d[0])),d}function r(){var d,a=c.copy();return b.isCategory&&(d=c.domain(),a.domain([d[0],d[1]-1])),a}function s(a){return i?i(a):a}function t(i){i.each(function(){function J(a){var b=c(a)+k;return B[0]<b&&b<B[1]?e:0}var y,z,A,i=a.select(this),j=this.__chart__||c,l=this.__chart__=r(),t=h?h:q(l),u=i.selectAll(".tick").data(t,l),v=u.enter().insert("g",".domain").attr("class","tick").style("opacity",1e-6),w=u.exit().remove(),x=a.transition(u).style("opacity",1),B=c.rangeExtent?c.rangeExtent():p(c.range()),C=i.selectAll(".domain").data([0]),D=(C.enter().append("path").attr("class","domain"),a.transition(C));v.append("line"),v.append("text");var E=v.select("line"),F=x.select("line"),G=u.select("text").text(s),H=v.select("text"),I=x.select("text");switch(b.isCategory?(k=Math.ceil((l(1)-l(0))/2),z=m?0:k,A=m?k:0):k=z=0,d){case"bottom":y=n,E.attr("y2",e),H.attr("y",Math.max(e,0)+g),F.attr("x1",z).attr("x2",z).attr("y2",J),I.attr("x",0).attr("y",Math.max(e,0)+g),G.attr("dy",".71em").style("text-anchor","middle"),D.attr("d","M"+B[0]+","+f+"V0H"+B[1]+"V"+f);break;case"top":y=n,E.attr("y2",-e),H.attr("y",-(Math.max(e,0)+g)),F.attr("x2",0).attr("y2",-e),I.attr("x",0).attr("y",-(Math.max(e,0)+g)),G.attr("dy","0em").style("text-anchor","middle"),D.attr("d","M"+B[0]+","+-f+"V0H"+B[1]+"V"+-f);break;case"left":y=o,E.attr("x2",-e),H.attr("x",-(Math.max(e,0)+g)),F.attr("x2",-e).attr("y1",A).attr("y2",A),I.attr("x",-(Math.max(e,0)+g)).attr("y",k),G.attr("dy",".32em").style("text-anchor","end"),D.attr("d","M"+-f+","+B[0]+"H0V"+B[1]+"H"+-f);break;case"right":y=o,E.attr("x2",e),H.attr("x",Math.max(e,0)+g),F.attr("x2",e).attr("y2",0),I.attr("x",Math.max(e,0)+g).attr("y",0),G.attr("dy",".32em").style("text-anchor","start"),D.attr("d","M"+f+","+B[0]+"H0V"+B[1]+"H"+f)}if(l.rangeBand){var K=l,L=K.rangeBand()/2;j=l=function(a){return K(a)+L}}else j.rangeBand?j=l:w.call(y,l);v.call(y,j),x.call(y,l)})}var f,i,j,m,c=a.scale.linear(),d="bottom",e=6,g=3,h=null,k=0,l=!0;return b=b||{},f=b.withOuterTick?6:0,t.scale=function(a){return arguments.length?(c=a,t):c},t.orient=function(a){return arguments.length?(d=a in{top:1,right:1,bottom:1,left:1}?a+"":"bottom",t):d},t.tickFormat=function(a){return arguments.length?(i=a,t):i},t.tickCentered=function(a){return arguments.length?(m=a,t):m},t.tickOffset=function(){return k},t.ticks=function(){return arguments.length?(j=arguments,t):j},t.tickCulling=function(a){return arguments.length?(l=a,t):l},t.tickValues=function(a){if("function"==typeof a)h=function(){return a(c.domain())};else{if(!arguments.length)return h;h=a}return t},t}var c,d,b={version:"0.3.0"};b.generate=function(a){return new e(a)},b.chart={fn:e.prototype,internal:{fn:f.prototype}},c=b.chart.fn,d=b.chart.internal.fn,d.init=function(){var a=this,b=a.config;if(a.initParams(),b.data_url)a.convertUrlToData(b.data_url,b.data_mimeType,b.data_keys,a.initWithData);else if(b.data_json)a.initWithData(a.convertJsonToData(b.data_json,b.data_keys));else if(b.data_rows)a.initWithData(a.convertRowsToData(b.data_rows));else{if(!b.data_columns)throw Error("url or json or rows or columns is required.");a.initWithData(a.convertColumnsToData(b.data_columns))}},d.initParams=function(){var a=this,b=a.d3,c=a.config;a.clipId="c3-"+ +new Date+"-clip",a.clipIdForXAxis=a.clipId+"-xaxis",a.clipIdForYAxis=a.clipId+"-yaxis",a.clipIdForGrid=a.clipId+"-grid",a.clipPath=a.getClipPath(a.clipId),a.clipPathForXAxis=a.getClipPath(a.clipIdForXAxis),a.clipPathForYAxis=a.getClipPath(a.clipIdForYAxis),a.clipPathForGrid=a.getClipPath(a.clipIdForGrid),a.dragStart=null,a.dragging=!1,a.flowing=!1,a.cancelClick=!1,a.mouseover=!1,a.transiting=!1,a.color=a.generateColor(),a.levelColor=a.generateLevelColor(),a.dataTimeFormat=c.data_xLocaltime?b.time.format:b.time.format.utc,a.axisTimeFormat=c.axis_x_localtime?b.time.format:b.time.format.utc,a.defaultAxisTimeFormat=a.axisTimeFormat.multi([[".%L",function(a){return a.getMilliseconds()}],[":%S",function(a){return a.getSeconds()}],["%I:%M",function(a){return a.getMinutes()}],["%I %p",function(a){return a.getHours()}],["%-m/%-d",function(a){return a.getDay()&&1!==a.getDate()}],["%-m/%-d",function(a){return 1!==a.getDate()}],["%-m/%-d",function(a){return a.getMonth()}],["%Y/%-m/%-d",function(){return!0}]]),a.hiddenTargetIds=[],a.hiddenLegendIds=[],a.focusedTargetIds=[],a.defocusedTargetIds=[],a.xOrient=c.axis_rotated?"left":"bottom",a.yOrient=c.axis_rotated?"bottom":"left",a.y2Orient=c.axis_rotated?"top":"right",a.subXOrient=c.axis_rotated?"left":"bottom",a.isLegendRight="right"===c.legend_position,a.isLegendInset="inset"===c.legend_position,a.isLegendTop="top-left"===c.legend_inset_anchor||"top-right"===c.legend_inset_anchor,a.isLegendLeft="top-left"===c.legend_inset_anchor||"bottom-left"===c.legend_inset_anchor,a.legendStep=0,a.legendItemWidth=0,a.legendItemHeight=0,a.legendOpacityForHidden=.15,a.currentMaxTickWidth=0,a.rotated_padding_left=30,a.rotated_padding_right=c.axis_rotated&&!c.axis_x_show?0:30,a.rotated_padding_top=5,a.withoutFadeIn={},a.axes.subx=b.selectAll([])},d.initWithData=function(b){var f,h,c=this,d=c.d3,e=c.config,i=!0;c.initPie&&c.initPie(),c.initBrush&&c.initBrush(),c.initZoom&&c.initZoom(),c.selectChart=d.select(e.bindto),c.selectChart.empty()&&(c.selectChart=d.select(document.createElement("div")).style("opacity",0),c.observeInserted(c.selectChart),i=!1),c.selectChart.html("").classed("c3",!0),c.data.xs={},c.data.targets=c.convertDataToTargets(b),e.data_filter&&(c.data.targets=c.data.targets.filter(e.data_filter)),e.data_hide&&c.addHiddenTargetIds(e.data_hide===!0?c.mapToIds(c.data.targets):e.data_hide),c.hasType("gauge")&&(e.legend_show=!1),c.updateSizes(),c.updateScales(),c.x.domain(d.extent(c.getXDomain(c.data.targets))),c.y.domain(c.getYDomain(c.data.targets,"y")),c.y2.domain(c.getYDomain(c.data.targets,"y2")),c.subX.domain(c.x.domain()),c.subY.domain(c.y.domain()),c.subY2.domain(c.y2.domain()),c.orgXDomain=c.x.domain(),c.brush&&c.brush.scale(c.subX),e.zoom_enabled&&c.zoom.scale(c.x),c.svg=c.selectChart.append("svg").style("overflow","hidden").on("mouseenter",function(){return e.onmouseover.call(c)}).on("mouseleave",function(){return e.onmouseout.call(c)}),f=c.svg.append("defs"),c.clipChart=c.appendClip(f,c.clipId),c.clipXAxis=c.appendClip(f,c.clipIdForXAxis),c.clipYAxis=c.appendClip(f,c.clipIdForYAxis),c.clipGrid=c.appendClip(f,c.clipIdForGrid),c.updateSvgSize(),h=c.main=c.svg.append("g").attr("transform",c.getTranslate("main")),c.initSubchart&&c.initSubchart(),c.initTooltip&&c.initTooltip(),c.initLegend&&c.initLegend(),h.append("text").attr("class",g.text+" "+g.empty).attr("text-anchor","middle").attr("dominant-baseline","middle"),c.initRegion(),c.initGrid(),h.append("g").attr("clip-path",c.clipPath).attr("class",g.chart),e.grid_lines_front&&c.initGridLines(),c.initEventRect(),c.initBar&&c.initBar(),c.initLine&&c.initLine(),c.initArc&&c.initArc(),c.initGauge&&c.initGauge(),c.initText&&c.initText(),h.insert("rect",e.zoom_privileged?null:"g."+g.regions).attr("class",g.zoomRect).attr("width",c.width).attr("height",c.height).style("opacity",0).on("dblclick.zoom",null),e.axis_x_extent&&c.brush.extent(c.getDefaultExtent()),c.initAxis(),c.updateTargets(c.data.targets),i&&(c.updateDimension(),c.config.oninit.call(c),c.redraw({withTransform:!0,withUpdateXDomain:!0,withUpdateOrgXDomain:!0,withTransitionForAxis:!1})),null==a.onresize&&(a.onresize=c.generateResize()),a.onresize.add&&(a.onresize.add(function(){e.onresize.call(c)}),a.onresize.add(function(){c.api.flush()}),a.onresize.add(function(){e.onresized.call(c)})),c.api.element=c.selectChart.node()},d.smoothLines=function(a,b){var c=this;"grid"===b&&a.each(function(){var a=c.d3.select(this),b=a.attr("x1"),d=a.attr("x2"),e=a.attr("y1"),f=a.attr("y2");a.attr({x1:Math.ceil(b),x2:Math.ceil(d),y1:Math.ceil(e),y2:Math.ceil(f)})})},d.updateSizes=function(){var a=this,b=a.config,c=a.legend?a.getLegendHeight():0,d=a.legend?a.getLegendWidth():0,e=a.isLegendRight||a.isLegendInset?0:c,f=a.hasArcType(),g=b.axis_rotated||f?0:a.getHorizontalAxisHeight("x"),h=b.subchart_show&&!f?b.subchart_size_height+g:0;a.currentWidth=a.getCurrentWidth(),a.currentHeight=a.getCurrentHeight(),a.margin=b.axis_rotated?{top:a.getHorizontalAxisHeight("y2")+a.getCurrentPaddingTop(),right:f?0:a.getCurrentPaddingRight(),bottom:a.getHorizontalAxisHeight("y")+e+a.getCurrentPaddingBottom(),left:h+(f?0:a.getCurrentPaddingLeft())}:{top:4+a.getCurrentPaddingTop(),right:f?0:a.getCurrentPaddingRight(),bottom:g+h+e+a.getCurrentPaddingBottom(),left:f?0:a.getCurrentPaddingLeft()},a.margin2=b.axis_rotated?{top:a.margin.top,right:0/0,bottom:20+e,left:a.rotated_padding_left}:{top:a.currentHeight-h-e,right:0/0,bottom:g+e,left:a.margin.left},a.margin3={top:0,right:0/0,bottom:0,left:0},a.updateSizeForLegend&&a.updateSizeForLegend(c,d),a.width=a.currentWidth-a.margin.left-a.margin.right,a.height=a.currentHeight-a.margin.top-a.margin.bottom,a.width<0&&(a.width=0),a.height<0&&(a.height=0),a.width2=b.axis_rotated?a.margin.left-a.rotated_padding_left-a.rotated_padding_right:a.width,a.height2=b.axis_rotated?a.height:a.currentHeight-a.margin2.top-a.margin2.bottom,a.width2<0&&(a.width2=0),a.height2<0&&(a.height2=0),a.arcWidth=a.width-(a.isLegendRight?d+10:0),a.arcHeight=a.height-(a.isLegendRight?0:10),a.hasType("gauge")&&(a.arcHeight+=a.height-a.getGaugeLabelHeight()),a.updateRadius&&a.updateRadius(),a.isLegendRight&&f&&(a.margin3.left=a.arcWidth/2+1.1*a.radiusExpanded)},d.updateTargets=function(a){var b=this,c=b.config;b.updateTargetsForText(a),b.updateTargetsForBar(a),b.updateTargetsForLine(a),b.updateTargetsForArc&&b.updateTargetsForArc(a),b.updateTargetsForSubchart&&b.updateTargetsForSubchart(a),b.svg.selectAll("."+g.target).filter(function(a){return b.isTargetToShow(a.id)}).transition().duration(c.transition_duration).style("opacity",1)},d.redraw=function(a,b){var k,l,m,n,o,p,q,s,t,u,w,x,y,z,A,B,C,D,E,F,H,I,J,c=this,d=c.main,e=c.d3,f=c.config,h=c.getShapeIndices(c.isAreaType),i=c.getShapeIndices(c.isBarType),j=c.getShapeIndices(c.isLineType),v=c.hasArcType(),G=c.filterTargetsToShow(c.data.targets),K=c.xv.bind(c),L=(c.config.axis_rotated?c.circleY:c.circleX).bind(c),M=(c.config.axis_rotated?c.circleX:c.circleY).bind(c);if(a=a||{},k=r(a,"withY",!0),l=r(a,"withSubchart",!0),m=r(a,"withTransition",!0),p=r(a,"withTransform",!1),q=r(a,"withUpdateXDomain",!1),s=r(a,"withUpdateOrgXDomain",!1),t=r(a,"withTrimXDomain",!0),u=r(a,"withLegend",!1),n=r(a,"withTransitionForExit",m),o=r(a,"withTransitionForAxis",m),B=m?f.transition_duration:0,C=n?B:0,D=o?B:0,b=b||c.generateAxisTransitions(D),u&&f.legend_show&&c.updateLegend(c.mapToIds(c.data.targets),a,b),c.isCategorized()&&0===G.length&&c.x.domain([0,c.axes.x.selectAll(".tick").size()]),G.length?(c.updateXDomain(G,q,s,t),f.axis_x_tick_values||!f.axis_x_tick_fit&&!f.axis_x_tick_count||(H=c.generateTickValues(c.mapTargetsToUniqueXs(G),f.axis_x_tick_count),c.xAxis.tickValues(H),c.subXAxis.tickValues(H))):(c.xAxis.tickValues([]),c.subXAxis.tickValues([])),c.y.domain(c.getYDomain(G,"y")),c.y2.domain(c.getYDomain(G,"y2")),c.redrawAxis(b,v),c.updateAxisLabels(m),q&&G.length)if(f.axis_x_tick_culling&&H){for(I=1;I<H.length;I++)if(H.length/I<f.axis_x_tick_culling_max){J=I;break}c.svg.selectAll("."+g.axisX+" .tick text").each(function(a){var b=H.indexOf(a);b>=0&&e.select(this).style("display",b%J?"none":"block")})}else c.svg.selectAll("."+g.axisX+" .tick text").style("display","block");!f.axis_rotated&&f.axis_x_tick_rotate&&c.rotateTickText(c.axes.x,b.axisX,f.axis_x_tick_rotate),w=c.generateDrawArea?c.generateDrawArea(h,!1):void 0,x=c.generateDrawBar?c.generateDrawBar(i):void 0,y=c.generateDrawLine?c.generateDrawLine(j,!1):void 0,z=c.generateXYForText(h,i,j,!0),A=c.generateXYForText(h,i,j,!1),c.subY.domain(c.y.domain()),c.subY2.domain(c.y2.domain()),c.tooltip.style("display","none"),c.updateXgridFocus(),d.select("text."+g.text+"."+g.empty).attr("x",c.width/2).attr("y",c.height/2).text(f.data_empty_label_text).transition().style("opacity",G.length?0:1),c.redrawGrid(B,k),c.redrawRegion(B),c.redrawBar(C),c.redrawLine(C),c.redrawArea(C),f.point_show&&c.redrawCircle(),c.hasDataLabel()&&c.redrawText(C),c.redrawArc&&c.redrawArc(B,C,p),c.redrawSubchart&&c.redrawSubchart(l,b,B,C,h,i,j),d.selectAll("."+g.selectedCircles).filter(c.isBarType.bind(c)).selectAll("circle").remove(),f.interaction_enabled&&!a.flow&&c.redrawEventRect(),e.transition().duration(B).each(function(){var b=[];c.addTransitionForBar(b,x),c.addTransitionForLine(b,y),c.addTransitionForArea(b,w),f.point_show&&c.addTransitionForCircle(b,L,M),c.addTransitionForText(b,z,A,a.flow),c.addTransitionForRegion(b),c.addTransitionForGrid(b),a.flow&&(E=c.generateWait(),b.forEach(function(a){E.add(a)}),F=c.generateFlow({targets:G,flow:a.flow,duration:B,drawBar:x,drawLine:y,drawArea:w,cx:L,cy:M,xv:K,xForText:z,yForText:A}))}).call(E||function(){},F||function(){}),c.mapToIds(c.data.targets).forEach(function(a){c.withoutFadeIn[a]=!0}),c.updateZoom&&c.updateZoom()},d.updateAndRedraw=function(a){var d,b=this,c=b.config;a=a||{},a.withTransition=r(a,"withTransition",!0),a.withTransform=r(a,"withTransform",!1),a.withLegend=r(a,"withLegend",!1),a.withUpdateXDomain=!0,a.withUpdateOrgXDomain=!0,a.withTransitionForExit=!1,a.withTransitionForTransform=r(a,"withTransitionForTransform",a.withTransition),b.updateSizes(),a.withLegend&&c.legend_show||(d=b.generateAxisTransitions(a.withTransitionForAxis?c.transition_duration:0),b.updateScales(),b.updateSvgSize(),b.transformAll(a.withTransitionForTransform,d)),b.redraw(a,d)},d.isTimeSeries=function(){return"timeseries"===this.config.axis_x_type},d.isCategorized=function(){return this.config.axis_x_type.indexOf("categor")>=0},d.isCustomX=function(){var a=this,b=a.config;return!a.isTimeSeries()&&(b.data_x||q(b.data_xs))},d.getTranslate=function(a){var d,e,b=this,c=b.config;return"main"===a?(d=n(b.margin.left),e=n(b.margin.top)):"context"===a?(d=n(b.margin2.left),e=n(b.margin2.top)):"legend"===a?(d=b.margin3.left,e=b.margin3.top):"x"===a?(d=0,e=c.axis_rotated?0:b.height):"y"===a?(d=0,e=c.axis_rotated?b.height:0):"y2"===a?(d=c.axis_rotated?0:b.width,e=c.axis_rotated?1:0):"subx"===a?(d=0,e=c.axis_rotated?0:b.height2):"arc"===a&&(d=b.arcWidth/2,e=b.arcHeight/2),"translate("+d+","+e+")"},d.initialOpacity=function(a){return null!==a.value&&this.withoutFadeIn[a.id]?1:0},d.opacityForCircle=function(a){return h(a.value)?this.isScatterType(a)?.5:1:0},d.opacityForText=function(){return this.hasDataLabel()?1:0},d.xx=function(a){return a?this.x(a.x):null},d.xv=function(a){var b=this;return Math.ceil(b.x(b.isTimeSeries()?b.parseDate(a.value):a.value))},d.yv=function(a){var b=this,c=a.axis&&"y2"===a.axis?b.y2:b.y;return Math.ceil(c(a.value))},d.subxx=function(a){return a?this.subX(a.x):null},d.transformMain=function(a,b){var d,e,f,c=this;b&&b.axisX?d=b.axisX:(d=c.main.select("."+g.axisX),a&&(d=d.transition())),b&&b.axisY?e=b.axisY:(e=c.main.select("."+g.axisY),a&&(e=e.transition())),b&&b.axisY2?f=b.axisY2:(f=c.main.select("."+g.axisY2),a&&(f=f.transition())),(a?c.main.transition():c.main).attr("transform",c.getTranslate("main")),d.attr("transform",c.getTranslate("x")),e.attr("transform",c.getTranslate("y")),f.attr("transform",c.getTranslate("y2")),c.main.select("."+g.chartArcs).attr("transform",c.getTranslate("arc"))},d.transformAll=function(a,b){var c=this;c.transformMain(a,b),c.config.subchart_show&&c.transformContext(a,b),c.legend&&c.transformLegend(a)},d.updateSvgSize=function(){var a=this;a.svg.attr("width",a.currentWidth).attr("height",a.currentHeight),a.svg.selectAll(["#"+a.clipId,"#"+a.clipIdForGrid]).select("rect").attr("width",a.width).attr("height",a.height),a.svg.select("#"+a.clipIdForXAxis).select("rect").attr("x",a.getXAxisClipX.bind(a)).attr("y",a.getXAxisClipY.bind(a)).attr("width",a.getXAxisClipWidth.bind(a)).attr("height",a.getXAxisClipHeight.bind(a)),a.svg.select("#"+a.clipIdForYAxis).select("rect").attr("x",a.getYAxisClipX.bind(a)).attr("y",a.getYAxisClipY.bind(a)).attr("width",a.getYAxisClipWidth.bind(a)).attr("height",a.getYAxisClipHeight.bind(a)),a.svg.select("."+g.zoomRect).attr("width",a.width).attr("height",a.height),a.selectChart.style("max-height",a.currentHeight+"px")},d.updateDimension=function(){var a=this;a.config.axis_rotated?(a.axes.x.call(a.xAxis),a.axes.subx.call(a.subXAxis)):(a.axes.y.call(a.yAxis),a.axes.y2.call(a.y2Axis)),a.updateSizes(),a.updateScales(),a.updateSvgSize(),a.transformAll(!1)},d.observeInserted=function(b){var c=this,d=new MutationObserver(function(e){e.forEach(function(e){if("childList"===e.type&&e.previousSibling){d.disconnect();var f=a.setInterval(function(){b.node().parentNode&&(a.clearInterval(f),c.updateDimension(),c.config.oninit.call(c),c.redraw({withTransform:!0,withUpdateXDomain:!0,withUpdateOrgXDomain:!0,withTransition:!1,withTransitionForTransform:!1,withLegend:!0}),b.transition().style("opacity",1))},10)}})});d.observe(b.node(),{attributes:!0,childList:!0,characterData:!0})},d.generateResize=function(){function b(){a.forEach(function(a){a()})}var a=[];return b.add=function(b){a.push(b)},b},d.endall=function(a,b){var c=0;a.each(function(){++c}).each("end",function(){--c||b.apply(this,arguments)})},d.generateWait=function(){var a=[],b=function(b,c){var d=setInterval(function(){var b=0;a.forEach(function(a){if(a.empty())return b+=1,void 0;try{a.transition()}catch(c){b+=1}}),b===a.length&&(clearInterval(d),c&&c())},10)};return b.add=function(b){a.push(b)},b},d.parseDate=function(b){var d,c=this;return d=b instanceof Date?b:"number"==typeof b?new Date(b):c.dataTimeFormat(c.config.data_xFormat).parse(b),(!d||isNaN(+d))&&a.console.error("Failed to parse x '"+b+"' to Date object"),d},d.getDefaultConfig=function(){var a={bindto:"#chart",size_width:void 0,size_height:void 0,padding_left:void 0,padding_right:void 0,padding_top:void 0,padding_bottom:void 0,zoom_enabled:!1,zoom_extent:void 0,zoom_privileged:!1,zoom_onzoom:function(){},interaction_enabled:!0,onmouseover:function(){},onmouseout:function(){},onresize:function(){},onresized:function(){},oninit:function(){},transition_duration:350,data_x:void 0,data_xs:{},data_xFormat:"%Y-%m-%d",data_xLocaltime:!0,data_xSort:!0,data_idConverter:function(a){return a},data_names:{},data_classes:{},data_groups:[],data_axes:{},data_type:void 0,data_types:{},data_labels:{},data_order:"desc",data_regions:{},data_color:void 0,data_colors:{},data_hide:!1,data_filter:void 0,data_selection_enabled:!1,data_selection_grouped:!1,data_selection_isselectable:function(){return!0},data_selection_multiple:!0,data_onclick:function(){},data_onmouseover:function(){},data_onmouseout:function(){},data_onselected:function(){},data_onunselected:function(){},data_ondragstart:function(){},data_ondragend:function(){},data_url:void 0,data_json:void 0,data_rows:void 0,data_columns:void 0,data_mimeType:void 0,data_keys:void 0,data_empty_label_text:"",subchart_show:!1,subchart_size_height:60,subchart_onbrush:function(){},color_pattern:[],color_threshold:{},legend_show:!0,legend_position:"bottom",legend_inset_anchor:"top-left",legend_inset_x:10,legend_inset_y:0,legend_inset_step:void 0,legend_item_onclick:void 0,legend_item_onmouseover:void 0,legend_item_onmouseout:void 0,legend_equally:!1,axis_rotated:!1,axis_x_show:!0,axis_x_type:"indexed",axis_x_localtime:!0,axis_x_categories:[],axis_x_tick_centered:!1,axis_x_tick_format:void 0,axis_x_tick_culling:{},axis_x_tick_culling_max:10,axis_x_tick_count:void 0,axis_x_tick_fit:!0,axis_x_tick_values:null,axis_x_tick_rotate:void 0,axis_x_tick_outer:!0,axis_x_max:void 0,axis_x_min:void 0,axis_x_padding:{},axis_x_height:void 0,axis_x_extent:void 0,axis_x_label:{},axis_y_show:!0,axis_y_max:void 0,axis_y_min:void 0,axis_y_center:void 0,axis_y_label:{},axis_y_tick_format:void 0,axis_y_tick_outer:!0,axis_y_padding:{},axis_y_ticks:10,axis_y_default:void 0,axis_y2_show:!1,axis_y2_max:void 0,axis_y2_min:void 0,axis_y2_center:void 0,axis_y2_label:{},axis_y2_tick_format:void 0,axis_y2_tick_outer:!0,axis_y2_padding:{},axis_y2_ticks:10,axis_y2_default:void 0,grid_x_show:!1,grid_x_type:"tick",grid_x_lines:[],grid_y_show:!1,grid_y_lines:[],grid_y_ticks:10,grid_focus_show:!0,grid_lines_front:!0,point_show:!0,point_r:2.5,point_focus_expand_enabled:!0,point_focus_expand_r:void 0,point_select_r:void 0,line_connectNull:!1,bar_width:void 0,bar_width_ratio:.6,bar_width_max:void 0,bar_zerobased:!0,area_zerobased:!0,pie_label_show:!0,pie_label_format:void 0,pie_label_threshold:.05,pie_expand:!0,gauge_label_show:!0,gauge_label_format:void 0,gauge_expand:!0,gauge_min:0,gauge_max:100,gauge_units:void 0,gauge_width:void 0,donut_label_show:!0,donut_label_format:void 0,donut_label_threshold:.05,donut_width:void 0,donut_expand:!0,donut_title:"",regions:[],tooltip_show:!0,tooltip_grouped:!0,tooltip_format_title:void 0,tooltip_format_name:void 0,tooltip_format_value:void 0,tooltip_contents:function(a,b,c,d){return this.getTooltipContent?this.getTooltipContent(a,b,c,d):""},tooltip_init_show:!1,tooltip_init_x:0,tooltip_init_position:{top:"0px",left:"50px"}};return Object.keys(this.additionalConfig).forEach(function(b){a[b]=this.additionalConfig[b]},this),a},d.additionalConfig={},d.loadConfig=function(a){function f(){var a=d.shift();return a&&c&&"object"==typeof c&&a in c?(c=c[a],f()):a?void 0:c}var c,d,e,b=this.config;Object.keys(b).forEach(function(g){c=a,d=g.split("_"),e=f(),l(e)&&(b[g]=e)})},d.getScale=function(a,b,c){return(c?this.d3.time.scale():this.d3.scale.linear()).range([a,b])},d.getX=function(a,b,c,d){var h,e=this,f=e.getScale(a,b,e.isTimeSeries()),g=c?f.domain(c):f;e.isCategorized()?(d=d||function(){return 0},f=function(a,b){var c=g(a)+d(a);return b?c:Math.ceil(c)}):f=function(a,b){var c=g(a);return b?c:Math.ceil(c)};for(h in g)f[h]=g[h];return f.orgDomain=function(){return g.domain()},e.isCategorized()&&(f.domain=function(a){return arguments.length?(g.domain(a),f):(a=this.orgDomain(),[a[0],a[1]+1])}),f},d.getY=function(a,b,c){var d=this.getScale(a,b);return c&&d.domain(c),d},d.getYScale=function(a){return"y2"===this.getAxisId(a)?this.y2:this.y},d.getSubYScale=function(a){return"y2"===this.getAxisId(a)?this.subY2:this.subY},d.updateScales=function(){var a=this,b=a.config,c=!a.x;a.xMin=b.axis_rotated?1:0,a.xMax=b.axis_rotated?a.height:a.width,a.yMin=b.axis_rotated?0:a.height,a.yMax=b.axis_rotated?a.width:1,a.subXMin=a.xMin,a.subXMax=a.xMax,a.subYMin=b.axis_rotated?0:a.height2,a.subYMax=b.axis_rotated?a.width2:1,a.x=a.getX(a.xMin,a.xMax,c?void 0:a.x.orgDomain(),function(){return a.xAxis.tickOffset()}),a.y=a.getY(a.yMin,a.yMax,c?b.axis_y_default:a.y.domain()),a.y2=a.getY(a.yMin,a.yMax,c?b.axis_y2_default:a.y2.domain()),a.subX=a.getX(a.xMin,a.xMax,a.orgXDomain,function(b){return b%1?0:a.subXAxis.tickOffset()}),a.subY=a.getY(a.subYMin,a.subYMax,c?b.axis_y_default:a.subY.domain()),a.subY2=a.getY(a.subYMin,a.subYMax,c?b.axis_y2_default:a.subY2.domain()),a.xAxisTickFormat=a.getXAxisTickFormat(),a.xAxisTickValues=b.axis_x_tick_values?b.axis_x_tick_values:c?void 0:a.xAxis.tickValues(),a.xAxis=a.getXAxis(a.x,a.xOrient,a.xAxisTickFormat,a.xAxisTickValues,b.axis_x_tick_outer),a.subXAxis=a.getXAxis(a.subX,a.subXOrient,a.xAxisTickFormat,a.xAxisTickValues,b.axis_x_tick_outer),a.yAxis=a.getYAxis(a.y,a.yOrient,b.axis_y_tick_format,b.axis_y_ticks,b.axis_y_tick_outer),a.y2Axis=a.getYAxis(a.y2,a.y2Orient,b.axis_y2_tick_format,b.axis_y2_ticks,b.axis_y2_tick_outer),c||(a.brush&&a.brush.scale(a.subX),b.zoom_enabled&&a.zoom.scale(a.x)),a.updateArc&&a.updateArc()},d.getYDomainMin=function(a){var f,g,h,i,j,k,b=this,c=b.config,d=b.mapToIds(a),e=b.getValuesAsIdKeyed(a);if(c.data_groups.length>0)for(k=b.hasNegativeValueInTargets(a),f=0;f<c.data_groups.length;f++)if(i=c.data_groups[f].filter(function(a){return d.indexOf(a)>=0}),0!==i.length)for(h=i[0],k&&e[h]&&e[h].forEach(function(a,b){e[h][b]=0>a?a:0}),g=1;g<i.length;g++)j=i[g],e[j]&&e[j].forEach(function(a,c){b.getAxisId(j)!==b.getAxisId(h)||!e[h]||k&&+a>0||(e[h][c]+=+a)});return b.d3.min(Object.keys(e).map(function(a){return b.d3.min(e[a])}))},d.getYDomainMax=function(a){var f,g,h,i,j,k,b=this,c=b.config,d=b.mapToIds(a),e=b.getValuesAsIdKeyed(a);if(c.data_groups.length>0)for(k=b.hasPositiveValueInTargets(a),f=0;f<c.data_groups.length;f++)if(i=c.data_groups[f].filter(function(a){return d.indexOf(a)>=0}),0!==i.length)for(h=i[0],k&&e[h]&&e[h].forEach(function(a,b){e[h][b]=a>0?a:0}),g=1;g<i.length;g++)j=i[g],e[j]&&e[j].forEach(function(a,c){b.getAxisId(j)!==b.getAxisId(h)||!e[h]||k&&0>+a||(e[h][c]+=+a)});return b.d3.max(Object.keys(e).map(function(a){return b.d3.max(e[a])}))},d.getYDomain=function(a,b){var k,l,m,n,r,s,t,u,v,w,c=this,d=c.config,e=a.filter(function(a){return c.getAxisId(a.id)===b}),f="y2"===b?d.axis_y2_min:d.axis_y_min,g="y2"===b?d.axis_y2_max:d.axis_y_max,i=h(f)?f:c.getYDomainMin(e),j=h(g)?g:c.getYDomainMax(e),p="y2"===b?d.axis_y2_center:d.axis_y_center,x=c.hasType("bar",e)&&d.bar_zerobased||c.hasType("area",e)&&d.area_zerobased,y=c.hasDataLabel()&&d.axis_rotated,z=c.hasDataLabel()&&!d.axis_rotated;return 0===e.length?"y2"===b?c.y2.domain():c.y.domain():(isNaN(i)&&(i=0),isNaN(j)&&(j=i),i===j&&(0>i?j=0:i=0),v=i>=0&&j>=0,w=0>=i&&0>=j,(h(f)&&v||h(g)&&w)&&(x=!1),x&&(v&&(i=0),w&&(j=0)),k=Math.abs(j-i),l=m=n=.1*k,p&&(r=Math.max(Math.abs(i),Math.abs(j)),j=r-p,i=p-r),y?(s=c.getDataLabelLength(i,j,b,"width"),t=o(c.y.range()),u=[s[0]/t,s[1]/t],m+=k*(u[1]/(1-u[0]-u[1])),n+=k*(u[0]/(1-u[0]-u[1]))):z&&(s=c.getDataLabelLength(i,j,b,"height"),m+=s[1],n+=s[0]),"y"===b&&q(d.axis_y_padding)&&(m=c.getAxisPadding(d.axis_y_padding,"top",l,k),n=c.getAxisPadding(d.axis_y_padding,"bottom",l,k)),"y2"===b&&q(d.axis_y2_padding)&&(m=c.getAxisPadding(d.axis_y2_padding,"top",l,k),n=c.getAxisPadding(d.axis_y2_padding,"bottom",l,k)),x&&(v&&(n=i),w&&(m=-j)),[i-n,j+m])},d.getXDomainMin=function(a){var b=this,c=b.config;return l(c.axis_x_min)?b.isTimeSeries()?this.parseDate(c.axis_x_min):c.axis_x_min:b.d3.min(a,function(a){return b.d3.min(a.values,function(a){return a.x})})},d.getXDomainMax=function(a){var b=this,c=b.config;return l(c.axis_x_max)?b.isTimeSeries()?this.parseDate(c.axis_x_max):c.axis_x_max:b.d3.max(a,function(a){return b.d3.max(a.values,function(a){return a.x})})},d.getXDomainPadding=function(a){var e,f,g,i,b=this,c=b.config,d=a[1]-a[0];return b.isCategorized()?f=0:b.hasType("bar")?(e=b.getMaxDataCount(),f=e>1?d/(e-1)/2:.5):f=.01*d,"object"==typeof c.axis_x_padding&&q(c.axis_x_padding)?(g=h(c.axis_x_padding.left)?c.axis_x_padding.left:f,i=h(c.axis_x_padding.right)?c.axis_x_padding.right:f):g=i="number"==typeof c.axis_x_padding?c.axis_x_padding:f,{left:g,right:i}},d.getXDomain=function(a){var b=this,c=[b.getXDomainMin(a),b.getXDomainMax(a)],d=c[0],e=c[1],f=b.getXDomainPadding(c),g=0,h=0;return 0!==d-e||b.isCategorized()||(b.isTimeSeries()?(d=new Date(.5*d.getTime()),e=new Date(1.5*e.getTime())):(d=0===d?1:.5*d,e=0===e?-1:1.5*e)),(d||0===d)&&(g=b.isTimeSeries()?new Date(d.getTime()-f.left):d-f.left),(e||0===e)&&(h=b.isTimeSeries()?new Date(e.getTime()+f.right):e+f.right),[g,h]},d.updateXDomain=function(a,b,c,d,e){var f=this,g=f.config;return c&&(f.x.domain(e?e:f.d3.extent(f.getXDomain(a))),f.orgXDomain=f.x.domain(),g.zoom_enabled&&f.zoom.scale(f.x).updateScaleExtent(),f.subX.domain(f.x.domain()),f.brush&&f.brush.scale(f.subX)),b&&(f.x.domain(e?e:!f.brush||f.brush.empty()?f.orgXDomain:f.brush.extent()),g.zoom_enabled&&f.zoom.scale(f.x).updateScaleExtent()),d&&f.x.domain(f.trimXDomain(f.x.orgDomain())),f.x.domain()},d.trimXDomain=function(a){var b=this;return a[0]<=b.orgXDomain[0]&&(a[1]=+a[1]+(b.orgXDomain[0]-a[0]),a[0]=b.orgXDomain[0]),b.orgXDomain[1]<=a[1]&&(a[0]=+a[0]-(a[1]-b.orgXDomain[1]),a[1]=b.orgXDomain[1]),a},d.isX=function(a){var b=this,c=b.config;return c.data_x&&a===c.data_x||q(c.data_xs)&&s(c.data_xs,a)},d.isNotX=function(a){return!this.isX(a)},d.getXKey=function(a){var b=this,c=b.config;return c.data_x?c.data_x:q(c.data_xs)?c.data_xs[a]:null},d.getXValuesOfXKey=function(a,b){var d,c=this,e=b&&q(b)?c.mapToIds(b):[];return e.forEach(function(b){c.getXKey(b)===a&&(d=c.data.xs[b])}),d},d.getIndexByX=function(a){var b=this,c=b.filterByX(b.data.targets,a);return c.length?c[0].index:null},d.getXValue=function(a,b){var c=this;return a in c.data.xs&&c.data.xs[a]&&h(c.data.xs[a][b])?c.data.xs[a][b]:b},d.getOtherTargetXs=function(){var a=this,b=Object.keys(a.data.xs);return b.length?a.data.xs[b[0]]:null},d.getOtherTargetX=function(a){var b=this.getOtherTargetXs();return b&&a<b.length?b[a]:null},d.addXs=function(a){var b=this;Object.keys(a).forEach(function(c){b.config.data_xs[c]=a[c]})},d.hasMultipleX=function(a){return this.d3.set(Object.keys(a).map(function(b){return a[b]})).size()>1},d.isMultipleX=function(){return q(this.config.data_xs)||!this.config.data_xSort||this.hasType("scatter")},d.addName=function(a){var c,b=this;return a&&(c=b.config.data_names[a.id],a.name=c?c:a.id),a},d.getValueOnIndex=function(a,b){var c=a.filter(function(a){return a.index===b});return c.length?c[0]:null},d.updateTargetX=function(a,b){var c=this;a.forEach(function(a){a.values.forEach(function(d,e){d.x=c.generateTargetX(b[e],a.id,e)}),c.data.xs[a.id]=b})},d.updateTargetXs=function(a,b){var c=this;a.forEach(function(a){b[a.id]&&c.updateTargetX([a],b[a.id])})},d.generateTargetX=function(a,b,c){var e,d=this;return e=d.isTimeSeries()?a?d.parseDate(a):d.parseDate(d.getXValue(b,c)):d.isCustomX()&&!d.isCategorized()?h(a)?+a:d.getXValue(b,c):c},d.cloneTarget=function(a){return{id:a.id,id_org:a.id_org,values:a.values.map(function(a){return{x:a.x,value:a.value,id:a.id}})}},d.getPrevX=function(a){var b=this,c=b.getValueOnIndex(b.data.targets[0].values,a-1);return c?c.x:null},d.getNextX=function(a){var b=this,c=b.getValueOnIndex(b.data.targets[0].values,a+1);return c?c.x:null},d.getMaxDataCount=function(){var a=this;return a.d3.max(a.data.targets,function(a){return a.values.length})},d.getMaxDataCountTarget=function(a){var d,b=a.length,c=0;return b>1?a.forEach(function(a){a.values.length>c&&(d=a,c=a.values.length)}):d=b?a[0]:null,d},d.getEdgeX=function(a){var b=this;return a.length?[b.d3.min(a,function(a){return a.values[0].x}),b.d3.max(a,function(a){return a.values[a.values.length-1].x})]:[0,0]},d.mapToIds=function(a){return a.map(function(a){return a.id})},d.mapToTargetIds=function(a){var b=this;return a?j(a)?[a]:a:b.mapToIds(b.data.targets)},d.hasTarget=function(a,b){var d,c=this.mapToIds(a);for(d=0;d<c.length;d++)if(c[d]===b)return!0;return!1},d.isTargetToShow=function(a){return this.hiddenTargetIds.indexOf(a)<0},d.isLegendToShow=function(a){return this.hiddenLegendIds.indexOf(a)<0},d.filterTargetsToShow=function(a){var b=this;return a.filter(function(a){return b.isTargetToShow(a.id)})},d.mapTargetsToUniqueXs=function(a){var b=this,c=b.d3.set(b.d3.merge(a.map(function(a){return a.values.map(function(a){return a.x})}))).values();return b.isTimeSeries()?c.map(function(a){return new Date(a)}):c.map(function(a){return+a})},d.addHiddenTargetIds=function(a){this.hiddenTargetIds=this.hiddenTargetIds.concat(a)},d.removeHiddenTargetIds=function(a){this.hiddenTargetIds=this.hiddenTargetIds.filter(function(b){return a.indexOf(b)<0})},d.addHiddenLegendIds=function(a){this.hiddenLegendIds=this.hiddenLegendIds.concat(a)},d.removeHiddenLegendIds=function(a){this.hiddenLegendIds=this.hiddenLegendIds.filter(function(b){return a.indexOf(b)<0
})},d.getValuesAsIdKeyed=function(a){var b={};return a.forEach(function(a){b[a.id]=[],a.values.forEach(function(c){b[a.id].push(c.value)})}),b},d.checkValueInTargets=function(a,b){var d,e,f,c=Object.keys(a);for(d=0;d<c.length;d++)for(f=a[c[d]].values,e=0;e<f.length;e++)if(b(f[e].value))return!0;return!1},d.hasNegativeValueInTargets=function(a){return this.checkValueInTargets(a,function(a){return 0>a})},d.hasPositiveValueInTargets=function(a){return this.checkValueInTargets(a,function(a){return a>0})},d.isOrderDesc=function(){var a=this.config;return a.data_order&&"desc"===a.data_order.toLowerCase()},d.isOrderAsc=function(){var a=this.config;return a.data_order&&"asc"===a.data_order.toLowerCase()},d.orderTargets=function(a){var b=this,c=b.config,d=b.isOrderAsc(),e=b.isOrderDesc();return d||e?a.sort(function(a,b){var c=function(a,b){return a+Math.abs(b.value)},e=a.values.reduce(c,0),f=b.values.reduce(c,0);return d?f-e:e-f}):i(c.data_order)&&a.sort(c.data_order),a},d.filterByX=function(a,b){return this.d3.merge(a.map(function(a){return a.values})).filter(function(a){return 0===a.x-b})},d.filterRemoveNull=function(a){return a.filter(function(a){return h(a.value)})},d.hasDataLabel=function(){var a=this.config;return"boolean"==typeof a.data_labels&&a.data_labels?!0:"object"==typeof a.data_labels&&q(a.data_labels)?!0:!1},d.getDataLabelLength=function(a,b,c,d){var e=this,f=[0,0],g=1.3;return e.selectChart.select("svg").selectAll(".dummy").data([a,b]).enter().append("text").text(function(a){return e.formatByAxisId(c)(a)}).each(function(a,b){f[b]=this.getBoundingClientRect()[d]*g}).remove(),f},d.isNoneArc=function(a){return this.hasTarget(this.data.targets,a.id)},d.isArc=function(a){return"data"in a&&this.hasTarget(this.data.targets,a.data.id)},d.findSameXOfValues=function(a,b){var c,d=a[b].x,e=[];for(c=b-1;c>=0&&d===a[c].x;c--)e.push(a[c]);for(c=b;c<a.length&&d===a[c].x;c++)e.push(a[c]);return e},d.findClosestFromTargets=function(a,b){var d,c=this;return d=a.map(function(a){return c.findClosest(a.values,b)}),c.findClosest(d,b)},d.findClosest=function(a,b){var d,e,c=this;return a.forEach(function(a){var f=c.dist(a,b);(d>f||!d)&&(d=f,e=a)}),e},d.dist=function(a,b){var c=this,d=c.config,e="y"===c.getAxisId(a.id)?c.y:c.y2,f=d.axis_rotated?1:0,g=d.axis_rotated?0:1;return Math.pow(c.x(a.x)-b[f],2)+Math.pow(e(a.value)-b[g],2)},d.convertUrlToData=function(a,b,c,d){var e=this,f=b?b:"csv";e.d3.xhr(a,function(a,b){var g;g="json"===f?e.convertJsonToData(JSON.parse(b.response),c):"tsv"===f?e.convertTsvToData(b.response):e.convertCsvToData(b.response),d.call(e,g)})},d.convertXsvToData=function(a,b){var d,c=b.parseRows(a);return 1===c.length?(d=[{}],c[0].forEach(function(a){d[0][a]=null})):d=b.parse(a),d},d.convertCsvToData=function(a){return this.convertXsvToData(a,this.d3.csv)},d.convertTsvToData=function(a){return this.convertXsvToData(a,this.d3.tsv)},d.convertJsonToData=function(a,b){var e,f,c=this,d=[];return b?(e=b.value,b.x&&(e.push(b.x),c.config.data_x=b.x),d.push(e),a.forEach(function(a){var b=[];e.forEach(function(c){var d=k(a[c])?null:a[c];b.push(d)}),d.push(b)}),f=c.convertRowsToData(d)):(Object.keys(a).forEach(function(b){d.push([b].concat(a[b]))}),f=c.convertColumnsToData(d)),f},d.convertRowsToData=function(a){var e,f,b=a[0],c={},d=[];for(e=1;e<a.length;e++){for(c={},f=0;f<a[e].length;f++){if(k(a[e][f]))throw new Error("Source data is missing a component at ("+e+","+f+")!");c[b[f]]=a[e][f]}d.push(c)}return d},d.convertColumnsToData=function(a){var c,d,e,b=[];for(c=0;c<a.length;c++)for(e=a[c][0],d=1;d<a[c].length;d++){if(k(b[d-1])&&(b[d-1]={}),k(a[c][d]))throw new Error("Source data is missing a component at ("+c+","+d+")!");b[d-1][e]=a[c][d]}return b},d.convertDataToTargets=function(a,b){var g,c=this,d=c.config,e=c.d3.keys(a[0]).filter(c.isNotX,c),f=c.d3.keys(a[0]).filter(c.isX,c);return e.forEach(function(e){var g=c.getXKey(e);c.isCustomX()||c.isTimeSeries()?f.indexOf(g)>=0?c.data.xs[e]=(b&&c.data.xs[e]?c.data.xs[e]:[]).concat(a.map(function(a){return a[g]}).filter(h).map(function(a,b){return c.generateTargetX(a,e,b)})):d.data_x?c.data.xs[e]=c.getOtherTargetXs():q(d.data_xs)&&(c.data.xs[e]=c.getXValuesOfXKey(g,c.data.targets)):c.data.xs[e]=a.map(function(a,b){return b})}),e.forEach(function(a){if(!c.data.xs[a])throw new Error('x is not defined for id = "'+a+'".')}),g=e.map(function(b,e){var f=d.data_idConverter(b);return{id:f,id_org:b,values:a.map(function(a,g){var h=c.getXKey(b),i=a[h],j=c.generateTargetX(i,b,g);return c.isCustomX()&&c.isCategorized()&&0===e&&i&&(0===g&&(d.axis_x_categories=[]),d.axis_x_categories.push(i)),(k(a[b])||c.data.xs[b].length<=g)&&(j=void 0),{x:j,value:null===a[b]||isNaN(a[b])?null:+a[b],id:f}}).filter(function(a){return l(a.x)})}}),g.forEach(function(a){var b;d.data_xSort&&(a.values=a.values.sort(function(a,b){var c=a.x||0===a.x?a.x:1/0,d=b.x||0===b.x?b.x:1/0;return c-d})),b=0,a.values.forEach(function(a){a.index=b++}),c.data.xs[a.id].sort(function(a,b){return a-b})}),d.data_type&&c.setTargetType(c.mapToIds(g).filter(function(a){return!(a in d.data_types)}),d.data_type),g.forEach(function(a){c.addCache(a.id_org,a)}),g},d.load=function(a,b){var c=this;a&&(b.filter&&(a=a.filter(b.filter)),(b.type||b.types)&&a.forEach(function(a){c.setTargetType(a.id,b.types?b.types[a.id]:b.type)}),c.data.targets.forEach(function(b){for(var c=0;c<a.length;c++)if(b.id===a[c].id){b.values=a[c].values,a.splice(c,1);break}}),c.data.targets=c.data.targets.concat(a)),c.updateTargets(c.data.targets),c.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0}),b.done&&b.done()},d.loadFromArgs=function(a){var b=this;a.data?b.load(b.convertDataToTargets(a.data),a):a.url?b.convertUrlToData(a.url,a.mimeType,a.keys,function(c){b.load(b.convertDataToTargets(c),a)}):a.json?b.load(b.convertDataToTargets(b.convertJsonToData(a.json,a.keys)),a):a.rows?b.load(b.convertDataToTargets(b.convertRowsToData(a.rows)),a):a.columns?b.load(b.convertDataToTargets(b.convertColumnsToData(a.columns)),a):b.load(null,a)},d.unload=function(a,b){var c=this;return b||(b=function(){}),a=a.filter(function(a){return c.hasTarget(c.data.targets,a)}),a&&0!==a.length?(c.svg.selectAll(a.map(function(a){return c.selectorTarget(a)})).transition().style("opacity",0).remove().call(c.endall,b),a.forEach(function(a){c.withoutFadeIn[a]=!1,c.legend&&c.legend.selectAll("."+g.legendItem+c.getTargetSelectorSuffix(a)).remove(),c.data.targets=c.data.targets.filter(function(b){return b.id!==a})}),void 0):(b(),void 0)},d.categoryName=function(a){var b=this.config;return a<b.axis_x_categories.length?b.axis_x_categories[a]:a},d.initEventRect=function(){var a=this;a.main.select("."+g.chart).append("g").attr("class",g.eventRects).style("fill-opacity",0)},d.redrawEventRect=function(){var c,d,a=this,b=a.config,e=a.isMultipleX(),f=a.main.select("."+g.eventRects).style("cursor",b.zoom_enabled?b.axis_rotated?"ns-resize":"ew-resize":null).classed(g.eventRectsMultiple,e).classed(g.eventRectsSingle,!e);f.selectAll("."+g.eventRect).remove(),a.eventRect=f.selectAll("."+g.eventRect),e?(c=a.eventRect.data([0]),a.generateEventRectsForMultipleXs(c.enter()),a.updateEventRect(c)):(d=a.getMaxDataCountTarget(a.data.targets),f.datum(d?d.values:[]),a.eventRect=f.selectAll("."+g.eventRect),c=a.eventRect.data(function(a){return a}),a.generateEventRectsForSingleX(c.enter()),a.updateEventRect(c),c.exit().remove())},d.updateEventRect=function(a){var d,e,f,g,h,i,b=this,c=b.config;a=a||b.eventRect.data(function(a){return a}),b.isMultipleX()?(d=0,e=0,f=b.width,g=b.height):(!b.isCustomX()&&!b.isTimeSeries()||b.isCategorized()?(h=b.getEventRectWidth(),i=function(a){return b.x(a.x)-h/2}):(h=function(a){var d=b.getPrevX(a.index),e=b.getNextX(a.index),f=b.data.xs[a.id][a.index],g=(b.x(e?e:f)-b.x(d?d:f))/2;return null===d&&null===e?c.axis_rotated?b.height:b.width:0>g?0:g},i=function(a){var c=b.getPrevX(a.index),d=b.getNextX(a.index),e=b.data.xs[a.id][a.index];return null===c&&null===d?0:(b.x(e)+b.x(c?c:e))/2}),d=c.axis_rotated?0:i,e=c.axis_rotated?i:0,f=c.axis_rotated?b.width:h,g=c.axis_rotated?h:b.height),a.attr("class",b.classEvent.bind(b)).attr("x",d).attr("y",e).attr("width",f).attr("height",g)},d.generateEventRectsForSingleX=function(a){var b=this,c=b.d3,d=b.config;a.append("rect").attr("class",b.classEvent.bind(b)).style("cursor",d.data_selection_enabled&&d.data_selection_grouped?"pointer":null).on("mouseover",function(a){var e,f,c=a.index;b.dragging||b.flowing||b.hasArcType()||(e=b.data.targets.map(function(a){return b.addName(b.getValueOnIndex(a.values,c))}),f=[],Object.keys(d.data_names).forEach(function(a){for(var b=0;b<e.length;b++)if(e[b]&&e[b].id===a){f.push(e[b]),e.shift(b);break}}),e=f.concat(e),d.point_focus_expand_enabled&&b.expandCircles(c,null,!0),b.expandBars(c,null,!0),b.main.selectAll("."+g.shape+"-"+c).each(function(a){d.data_onmouseover.call(b,a)}))}).on("mouseout",function(a){var c=a.index;b.hasArcType()||(b.hideXGridFocus(),b.hideTooltip(),b.unexpandCircles(),b.unexpandBars(),b.main.selectAll("."+g.shape+"-"+c).each(function(a){d.data_onmouseout.call(b,a)}))}).on("mousemove",function(a){var e,f=a.index,h=b.svg.select("."+g.eventRect+"-"+f);b.dragging||b.flowing||b.hasArcType()||(b.isStepType(a)&&c.mouse(this)[0]<b.x(b.getXValue(a.id,f))&&(f-=1),e=b.filterTargetsToShow(b.data.targets).map(function(a){return b.addName(b.getValueOnIndex(a.values,f))}),d.tooltip_grouped&&(b.showTooltip(e,c.mouse(this)),b.showXGridFocus(e)),(!d.tooltip_grouped||d.data_selection_enabled&&!d.data_selection_grouped)&&b.main.selectAll("."+g.shape+"-"+f).each(function(){c.select(this).classed(g.EXPANDED,!0),d.data_selection_enabled&&h.style("cursor",d.data_selection_grouped?"pointer":null),d.tooltip_grouped||(b.hideXGridFocus(),b.hideTooltip(),d.data_selection_grouped||(b.unexpandCircles(f),b.unexpandBars(f)))}).filter(function(a){return"circle"===this.nodeName?b.isWithinCircle(this,b.pointSelectR(a)):"path"===this.nodeName?b.isWithinBar(this):void 0}).each(function(a){d.data_selection_enabled&&(d.data_selection_grouped||d.data_selection_isselectable(a))&&h.style("cursor","pointer"),d.tooltip_grouped||(b.showTooltip([a],c.mouse(this)),b.showXGridFocus([a]),d.point_focus_expand_enabled&&b.expandCircles(f,a.id,!0),b.expandBars(f,a.id,!0))}))}).on("click",function(a){var e=a.index;if(!b.hasArcType()&&b.toggleShape){if(b.cancelClick)return b.cancelClick=!1,void 0;b.isStepType(a)&&c.mouse(this)[0]<b.x(b.getXValue(a.id,e))&&(e-=1),b.main.selectAll("."+g.shape+"-"+e).each(function(a){(d.data_selection_grouped||b.isWithinShape(this,a))&&(b.toggleShape(this,a,e),b.config.data_onclick.call(b.api,a,this))})}}).call(c.behavior.drag().origin(Object).on("drag",function(){b.drag(c.mouse(this))}).on("dragstart",function(){b.dragstart(c.mouse(this))}).on("dragend",function(){b.dragend()})).on("dblclick.zoom",null)},d.generateEventRectsForMultipleXs=function(a){var b=this,c=b.d3,d=b.config;a.append("rect").attr("x",0).attr("y",0).attr("width",b.width).attr("height",b.height).attr("class",g.eventRect).on("mouseout",function(){b.hasArcType()||(b.hideXGridFocus(),b.hideTooltip(),b.unexpandCircles())}).on("mousemove",function(){var e,f,h,i,a=b.filterTargetsToShow(b.data.targets);b.dragging||b.hasArcType(a)||(e=c.mouse(this),f=b.findClosestFromTargets(a,e),f&&(h=b.isScatterType(f)?[f]:b.filterByX(a,f.x),i=h.map(function(a){return b.addName(a)}),b.showTooltip(i,e),d.point_focus_expand_enabled&&b.expandCircles(f.index,f.id,!0),b.showXGridFocus(i),b.dist(f,e)<100?(b.svg.select("."+g.eventRect).style("cursor","pointer"),b.mouseover||(d.data_onmouseover.call(b,f),b.mouseover=!0)):b.mouseover&&(b.svg.select("."+g.eventRect).style("cursor",null),d.data_onmouseout.call(b,f),b.mouseover=!1)))}).on("click",function(){var e,f,a=b.filterTargetsToShow(b.data.targets);b.hasArcType(a)||(e=c.mouse(this),f=b.findClosestFromTargets(a,e),f&&b.dist(f,e)<100&&b.toggleShape&&b.main.select("."+g.circles+b.getTargetSelectorSuffix(f.id)).select("."+g.circle+"-"+f.index).each(function(){(d.data_selection_grouped||b.isWithinShape(this,f))&&(b.toggleShape(this,f,f.index),b.config.data_onclick.call(b.api,f,this))}))}).call(c.behavior.drag().origin(Object).on("drag",function(){b.drag(c.mouse(this))}).on("dragstart",function(){b.dragstart(c.mouse(this))}).on("dragend",function(){b.dragend()})).on("dblclick.zoom",null)},d.dispatchEvent=function(b,c,d){var e=this,f="."+g.eventRect+(e.isMultipleX()?"":"-"+c),h=e.main.select(f).node(),i=h.getBoundingClientRect(),j=i.left+(d?d[0]:0),k=i.top+(d?d[1]:0),l=document.createEvent("MouseEvents");l.initMouseEvent(b,!0,!0,a,0,j,k,j,k,!1,!1,!1,!1,0,null),h.dispatchEvent(l)},d.getCurrentWidth=function(){var a=this,b=a.config;return b.size_width?b.size_width:a.getParentWidth()},d.getCurrentHeight=function(){var a=this,b=a.config,c=b.size_height?b.size_height:a.getParentHeight();return c>0?c:320/(a.hasType("gauge")?2:1)},d.getCurrentPaddingTop=function(){var a=this.config;return h(a.padding_top)?a.padding_top:0},d.getCurrentPaddingBottom=function(){var a=this.config;return h(a.padding_bottom)?a.padding_bottom:0},d.getCurrentPaddingLeft=function(){var a=this,b=a.config;return h(b.padding_left)?b.padding_left:b.axis_rotated?b.axis_x_show?Math.max(m(a.getAxisWidthByAxisId("x")),40):1:b.axis_y_show?m(a.getAxisWidthByAxisId("y")):1},d.getCurrentPaddingRight=function(){var a=this,b=a.config,c=10,d=a.isLegendRight?a.getLegendWidth()+20:0;return h(b.padding_right)?b.padding_right+1:b.axis_rotated?c+d:(b.axis_y2_show?m(a.getAxisWidthByAxisId("y2")):c)+d},d.getParentRectValue=function(a){for(var c,b=this.selectChart.node();b&&"BODY"!==b.tagName&&!(c=b.getBoundingClientRect()[a]);)b=b.parentNode;return c},d.getParentWidth=function(){return this.getParentRectValue("width")},d.getParentHeight=function(){var a=this.selectChart.style("height");return a.indexOf("px")>0?+a.replace("px",""):0},d.getSvgLeft=function(){var a=this,b=a.config,c=b.axis_rotated?g.axisX:g.axisY,d=a.main.select("."+c).node(),e=d?d.getBoundingClientRect():{right:0},f=a.selectChart.node().getBoundingClientRect(),h=a.hasArcType(),i=e.right-f.left-(h?0:a.getCurrentPaddingLeft());return i>0?i:0},d.getAxisWidthByAxisId=function(a){var b=this,c=b.getAxisLabelPositionById(a);return c.isInner?20+b.getMaxTickWidth(a):40+b.getMaxTickWidth(a)},d.getHorizontalAxisHeight=function(a){var b=this,c=b.config;return"x"!==a||c.axis_x_show?"x"===a&&c.axis_x_height?c.axis_x_height:"y"!==a||c.axis_y_show?"y2"!==a||c.axis_y2_show?(b.getAxisLabelPositionById(a).isInner?30:40)+("y2"===a?-10:0):b.rotated_padding_top:!c.legend_show||b.isLegendRight||b.isLegendInset?1:10:0},d.getEventRectWidth=function(){var c,d,e,f,g,h,a=this,b=a.getMaxDataCountTarget(a.data.targets);return b?(c=b.values[0],d=b.values[b.values.length-1],e=a.x(d.x)-a.x(c.x),0===e?a.config.axis_rotated?a.height:a.width:(f=a.getMaxDataCount(),g=a.hasType("bar")?(f-(a.isCategorized()?.25:1))/f:1,h=f>1?e*g/(f-1):e,1>h?1:h)):0},d.getShapeIndices=function(a){var f,g,b=this,c=b.config,d={},e=0;return b.filterTargetsToShow(b.data.targets.filter(a,b)).forEach(function(a){for(f=0;f<c.data_groups.length;f++)if(!(c.data_groups[f].indexOf(a.id)<0))for(g=0;g<c.data_groups[f].length;g++)if(c.data_groups[f][g]in d){d[a.id]=d[c.data_groups[f][g]];break}k(d[a.id])&&(d[a.id]=e++)}),d.__max__=e-1,d},d.getShapeX=function(a,b,c,d){var e=this,f=d?e.subX:e.x;return function(d){var e=d.id in c?c[d.id]:0;return d.x||0===d.x?f(d.x)-a*(b/2-e):0}},d.getShapeY=function(a){var b=this;return function(c){var d=a?b.getSubYScale(c.id):b.getYScale(c.id);return d(c.value)}},d.getShapeOffset=function(a,b,c){var d=this,e=d.orderTargets(d.filterTargetsToShow(d.data.targets.filter(a,d))),f=e.map(function(a){return a.id});return function(a,g){var h=c?d.getSubYScale(a.id):d.getYScale(a.id),i=h(0),j=i;return e.forEach(function(c){c.id!==a.id&&b[c.id]===b[a.id]&&f.indexOf(c.id)<f.indexOf(a.id)&&c.values[g].value*a.value>=0&&(j+=h(c.values[g].value)-i)}),j}},d.isWithinShape=function(a,b){var e,c=this,d=c.d3.select(a);return"circle"===a.nodeName?e=c.isStepType(b)?!0:c.isWithinCircle(a,1.5*c.pointSelectR(b)):"path"===a.nodeName&&(e=d.classed(g.bar)?c.isWithinBar(a):!0),e},d.getInterpolate=function(a){var b=this;return b.isSplineType(a)?"cardinal":b.isStepType(a)?"step-after":"linear"},d.initLine=function(){var a=this;a.main.select("."+g.chart).append("g").attr("class",g.chartLines)},d.updateTargetsForLine=function(a){var d,e,b=this,c=b.config,f=b.classChartLine.bind(b),h=b.classLines.bind(b),i=b.classAreas.bind(b),j=b.classCircles.bind(b),k=b.classFocus.bind(b);d=b.main.select("."+g.chartLines).selectAll("."+g.chartLine).data(a).attr("class",function(a){return f(a)+k(a)}),e=d.enter().append("g").attr("class",f).style("opacity",0).style("pointer-events","none"),e.append("g").attr("class",h),e.append("g").attr("class",i),e.append("g").attr("class",function(a){return b.generateClass(g.selectedCircles,a.id)}),e.append("g").attr("class",j).style("cursor",function(a){return c.data_selection_isselectable(a)?"pointer":null}),a.forEach(function(a){b.main.selectAll("."+g.selectedCircles+b.getTargetSelectorSuffix(a.id)).selectAll("."+g.selectedCircle).each(function(b){b.value=a.values[b.index].value})})},d.redrawLine=function(a){var b=this;b.mainLine=b.main.selectAll("."+g.lines).selectAll("."+g.line).data(b.lineData.bind(b)),b.mainLine.enter().append("path").attr("class",b.classLine.bind(b)).style("stroke",b.color),b.mainLine.style("opacity",b.initialOpacity.bind(b)).attr("transform",null),b.mainLine.exit().transition().duration(a).style("opacity",0).remove()},d.addTransitionForLine=function(a,b){var c=this;a.push(c.mainLine.transition().attr("d",b).style("stroke",c.color).style("opacity",1))},d.generateDrawLine=function(a,b){var c=this,d=c.config,e=c.d3.svg.line(),f=c.generateGetLinePoints(a,b),g=b?c.getSubYScale:c.getYScale,h=function(a){return(b?c.subxx:c.xx).call(c,a)},i=function(a,b){return d.data_groups.length>0?f(a,b)[0][1]:g.call(c,a.id)(a.value)};return e=d.axis_rotated?e.x(i).y(h):e.x(h).y(i),d.line_connectNull||(e=e.defined(function(a){return null!=a.value})),function(a){var l,f=d.line_connectNull?c.filterRemoveNull(a.values):a.values,h=b?c.x:c.subX,i=g.call(c,a.id),j=0,k=0;return c.isLineType(a)?l=d.data_regions[a.id]?c.lineWithRegions(f,h,i,d.data_regions[a.id]):e.interpolate(c.getInterpolate(a))(f):(f[0]&&(j=h(f[0].x),k=i(f[0].value)),l=d.axis_rotated?"M "+k+" "+j:"M "+j+" "+k),l?l:"M 0 0"}},d.generateGetLinePoints=function(a,b){var c=this,d=c.config,e=a.__max__+1,f=c.getShapeX(0,e,a,!!b),g=c.getShapeY(!!b),h=c.getShapeOffset(c.isLineType,a,!!b),i=b?c.getSubYScale:c.getYScale;return function(a,b){var e=i.call(c,a.id)(0),j=h(a,b)||e,k=f(a),l=g(a);return d.axis_rotated&&(0<a.value&&e>l||a.value<0&&l>e)&&(l=e),[[k,l-(e-j)],[k,l-(e-j)],[k,l-(e-j)],[k,l-(e-j)]]}},d.lineWithRegions=function(a,b,c,d){function x(a,b){var c;for(c=0;c<b.length;c++)if(b[c].start<a&&a<=b[c].end)return!0;return!1}var h,i,m,n,o,p,q,r,s,t,u,v,e=this,f=e.config,g=-1,j="M",w=[];if(l(d))for(h=0;h<d.length;h++)w[h]={},w[h].start=k(d[h].start)?a[0].x:e.isTimeSeries()?e.parseDate(d[h].start):d[h].start,w[h].end=k(d[h].end)?a[a.length-1].x:e.isTimeSeries()?e.parseDate(d[h].end):d[h].end;for(u=f.axis_rotated?function(a){return c(a.value)}:function(a){return b(a.x)},v=f.axis_rotated?function(a){return b(a.x)}:function(a){return c(a.value)},m=e.isTimeSeries()?function(a,d,e,f){var g=a.x.getTime(),h=d.x-a.x,i=new Date(g+h*e),j=new Date(g+h*(e+f));return"M"+b(i)+" "+c(o(e))+" "+b(j)+" "+c(o(e+f))}:function(a,d,e,f){return"M"+b(n(e),!0)+" "+c(o(e))+" "+b(n(e+f),!0)+" "+c(o(e+f))},h=0;h<a.length;h++){if(k(w)||!x(a[h].x,w))j+=" "+u(a[h])+" "+v(a[h]);else for(n=e.getScale(a[h-1].x,a[h].x,e.isTimeSeries()),o=e.getScale(a[h-1].value,a[h].value),p=b(a[h].x)-b(a[h-1].x),q=c(a[h].value)-c(a[h-1].value),r=Math.sqrt(Math.pow(p,2)+Math.pow(q,2)),s=2/r,t=2*s,i=s;1>=i;i+=t)j+=m(a[h-1],a[h],i,s);g=a[h].x}return j},d.redrawArea=function(a){var b=this,c=b.d3;b.mainArea=b.main.selectAll("."+g.areas).selectAll("."+g.area).data(b.lineData.bind(b)),b.mainArea.enter().append("path").attr("class",b.classArea.bind(b)).style("fill",b.color).style("opacity",function(){return b.orgAreaOpacity=+c.select(this).style("opacity"),0}),b.mainArea.style("opacity",b.orgAreaOpacity),b.mainArea.exit().transition().duration(a).style("opacity",0).remove()},d.addTransitionForArea=function(a,b){var c=this;a.push(c.mainArea.transition().attr("d",b).style("fill",c.color).style("opacity",c.orgAreaOpacity))},d.generateDrawArea=function(a,b){var c=this,d=c.config,e=c.d3.svg.area(),f=c.generateGetAreaPoints(a,b),g=b?c.getSubYScale:c.getYScale,h=function(a){return(b?c.subxx:c.xx).call(c,a)},i=function(a,b){return d.data_groups.length>0?f(a,b)[0][1]:g.call(c,a.id)(0)},j=function(a,b){return d.data_groups.length>0?f(a,b)[1][1]:g.call(c,a.id)(a.value)};return e=d.axis_rotated?e.x0(i).x1(j).y(h):e.x(h).y0(i).y1(j),d.line_connectNull||(e=e.defined(function(a){return null!==a.value})),function(a){var h,b=d.line_connectNull?c.filterRemoveNull(a.values):a.values,f=0,g=0;return c.isAreaType(a)?h=e.interpolate(c.getInterpolate(a))(b):(b[0]&&(f=c.x(b[0].x),g=c.getYScale(a.id)(b[0].value)),h=d.axis_rotated?"M "+g+" "+f:"M "+f+" "+g),h?h:"M 0 0"}},d.generateGetAreaPoints=function(a,b){var c=this,d=c.config,e=a.__max__+1,f=c.getShapeX(0,e,a,!!b),g=c.getShapeY(!!b),h=c.getShapeOffset(c.isAreaType,a,!!b),i=b?c.getSubYScale:c.getYScale;return function(a,b){var e=i.call(c,a.id)(0),j=h(a,b)||e,k=f(a),l=g(a);return d.axis_rotated&&(0<a.value&&e>l||a.value<0&&l>e)&&(l=e),[[k,j],[k,l-(e-j)],[k,l-(e-j)],[k,j]]}},d.redrawCircle=function(){var a=this;a.mainCircle=a.main.selectAll("."+g.circles).selectAll("."+g.circle).data(a.lineOrScatterData.bind(a)),a.mainCircle.enter().append("circle").attr("class",a.classCircle.bind(a)).attr("r",a.pointR.bind(a)).style("fill",a.color),a.mainCircle.style("opacity",a.initialOpacity.bind(a)),a.mainCircle.exit().remove()},d.addTransitionForCircle=function(a,b,c){var d=this;a.push(d.mainCircle.transition().style("opacity",d.opacityForCircle.bind(d)).style("fill",d.color).attr("cx",b).attr("cy",c)),a.push(d.main.selectAll("."+g.selectedCircle).transition().attr("cx",b).attr("cy",c))},d.circleX=function(a){return a.x||0===a.x?this.x(a.x):null},d.circleY=function(a,b){var c=this,d=c.getShapeIndices(c.isLineType),e=c.generateGetLinePoints(d);return c.config.data_groups.length>0?e(a,b)[0][1]:c.getYScale(a.id)(a.value)},d.getCircles=function(a,b){var c=this;return(b?c.main.selectAll("."+g.circles+c.getTargetSelectorSuffix(b)):c.main).selectAll("."+g.circle+(h(a)?"-"+a:""))},d.expandCircles=function(a,b,c){var d=this,e=d.pointExpandedR.bind(d);c&&d.unexpandCircles(),d.getCircles(a,b).classed(g.EXPANDED,!0).attr("r",e)},d.unexpandCircles=function(a){var b=this,c=b.pointR.bind(b);b.getCircles(a).filter(function(){return b.d3.select(this).classed(g.EXPANDED)}).classed(g.EXPANDED,!1).attr("r",c)},d.pointR=function(a){var b=this,c=b.config;return c.point_show&&!b.isStepType(a)?i(c.point_r)?c.point_r(a):c.point_r:0},d.pointExpandedR=function(a){var b=this,c=b.config;return c.point_focus_expand_enabled?c.point_focus_expand_r?c.point_focus_expand_r:1.75*b.pointR(a):b.pointR(a)},d.pointSelectR=function(a){var b=this,c=b.config;return c.point_select_r?c.point_select_r:4*b.pointR(a)},d.isWithinCircle=function(a,b){var c=this.d3,d=c.mouse(a),e=c.select(a),f=1*e.attr("cx"),g=1*e.attr("cy");return Math.sqrt(Math.pow(f-d[0],2)+Math.pow(g-d[1],2))<b},d.initBar=function(){var a=this;a.main.select("."+g.chart).append("g").attr("class",g.chartBars)},d.updateTargetsForBar=function(a){var d,e,b=this,c=b.config,f=b.classChartBar.bind(b),h=b.classBars.bind(b),i=b.classFocus.bind(b);d=b.main.select("."+g.chartBars).selectAll("."+g.chartBar).data(a).attr("class",function(a){return f(a)+i(a)}),e=d.enter().append("g").attr("class",f).style("opacity",0).style("pointer-events","none"),e.append("g").attr("class",h).style("cursor",function(a){return c.data_selection_isselectable(a)?"pointer":null})},d.redrawBar=function(a){var b=this,c=b.barData.bind(b),d=b.classBar.bind(b),e=b.initialOpacity.bind(b),f=function(a){return b.color(a.id)};b.mainBar=b.main.selectAll("."+g.bars).selectAll("."+g.bar).data(c),b.mainBar.enter().append("path").attr("class",d).style("stroke",f).style("fill",f),b.mainBar.style("opacity",e),b.mainBar.exit().transition().duration(a).style("opacity",0).remove()},d.addTransitionForBar=function(a,b){var c=this;a.push(c.mainBar.transition().attr("d",b).style("fill",c.color).style("opacity",1))},d.getBarW=function(a,b){var c=this,d=c.config,e="number"==typeof d.bar_width?d.bar_width:b?2*a.tickOffset()*d.bar_width_ratio/b:0;return d.bar_width_max&&e>d.bar_width_max?d.bar_width_max:e},d.getBars=function(a){var b=this;return b.main.selectAll("."+g.bar+(h(a)?"-"+a:""))},d.expandBars=function(a,b,c){var d=this;c&&d.unexpandBars(),d.getBars(a).classed(g.EXPANDED,!0)},d.unexpandBars=function(a){var b=this;b.getBars(a).classed(g.EXPANDED,!1)},d.generateDrawBar=function(a,b){var c=this,d=c.config,e=c.generateGetBarPoints(a,b);return function(a,b){var c=e(a,b),f=d.axis_rotated?1:0,g=d.axis_rotated?0:1,h="M "+c[0][f]+","+c[0][g]+" "+"L"+c[1][f]+","+c[1][g]+" "+"L"+c[2][f]+","+c[2][g]+" "+"L"+c[3][f]+","+c[3][g]+" "+"z";return h}},d.generateGetBarPoints=function(a,b){var c=this,d=b?c.subXAxis:c.xAxis,e=a.__max__+1,f=c.getBarW(d,e),g=c.getShapeX(f,e,a,!!b),h=c.getShapeY(!!b),i=c.getShapeOffset(c.isBarType,a,!!b),j=b?c.getSubYScale:c.getYScale;return function(a,b){var d=j.call(c,a.id)(0),e=i(a,b)||d,k=g(a),l=h(a);return c.config.axis_rotated&&(0<a.value&&d>l||a.value<0&&l>d)&&(l=d),[[k,e],[k,l-(d-e)],[k+f,l-(d-e)],[k+f,e]]}},d.isWithinBar=function(a){var b=this.d3,c=b.mouse(a),d=a.getBoundingClientRect(),e=a.pathSegList.getItem(0),f=a.pathSegList.getItem(1),g=e.x,h=Math.min(e.y,f.y),i=d.width,j=d.height,k=2,l=g-k,m=g+i+k,n=h+j+k,o=h-k;return l<c[0]&&c[0]<m&&o<c[1]&&c[1]<n},d.initText=function(){var a=this;a.main.select("."+g.chart).append("g").attr("class",g.chartTexts),a.mainText=a.d3.selectAll([])},d.updateTargetsForText=function(a){var c,d,b=this,e=b.classChartText.bind(b),f=b.classTexts.bind(b),h=b.classFocus.bind(b);c=b.main.select("."+g.chartTexts).selectAll("."+g.chartText).data(a).attr("class",function(a){return e(a)+h(a)}),d=c.enter().append("g").attr("class",e).style("opacity",0).style("pointer-events","none"),d.append("g").attr("class",f)},d.redrawText=function(a){var b=this,c=b.config,d=b.barOrLineData.bind(b),e=b.classText.bind(b);b.mainText=b.main.selectAll("."+g.texts).selectAll("."+g.text).data(d),b.mainText.enter().append("text").attr("class",e).attr("text-anchor",function(a){return c.axis_rotated?a.value<0?"end":"start":"middle"}).style("stroke","none").style("fill",function(a){return b.color(a)}).style("fill-opacity",0),b.mainText.text(function(a){return b.formatByAxisId(b.getAxisId(a.id))(a.value,a.id)}),b.mainText.exit().transition().duration(a).style("fill-opacity",0).remove()},d.addTransitionForText=function(a,b,c,d){var e=this,f=d?0:e.opacityForText.bind(e);a.push(e.mainText.transition().attr("x",b).attr("y",c).style("fill",e.color).style("fill-opacity",f))},d.getTextRect=function(a,b){var d,c=this.d3.select("body").append("svg").style("visibility","hidden");return c.selectAll(".dummy").data([a]).enter().append("text").classed(b?b:"",!0).text(a).each(function(){d=this.getBoundingClientRect()}),c.remove(),d},d.generateXYForText=function(a,b,c,d){var e=this,f=e.generateGetAreaPoints(b,!1),g=e.generateGetBarPoints(b,!1),h=e.generateGetLinePoints(c,!1),i=d?e.getXForText:e.getYForText;return function(a,b){var c=e.isAreaType(a)?f:e.isBarType(a)?g:h;return i.call(e,c(a,b),a,this)}},d.getXForText=function(a,b,c){var f,g,d=this,e=c.getBoundingClientRect();return d.config.axis_rotated?(g=d.isBarType(b)?4:6,f=a[2][1]+g*(b.value<0?-1:1)):f=d.hasType("bar")?(a[2][0]+a[0][0])/2:a[0][0],null!==b.value?f:f>d.width?d.width-e.width:f},d.getYForText=function(a,b,c){var f,d=this,e=c.getBoundingClientRect();return f=d.config.axis_rotated?(a[0][0]+a[2][0]+.6*e.height)/2:a[2][1]+(b.value<0?e.height:d.isBarType(b)?-3:-6),null!==b.value?f:f<e.height?e.height:f},d.setTargetType=function(a,b){var c=this,d=c.config;c.mapToTargetIds(a).forEach(function(a){c.withoutFadeIn[a]=b===d.data_types[a],d.data_types[a]=b}),a||(d.data_type=b)},d.hasType=function(a,b){var c=this,d=c.config.data_types,e=!1;return(b||c.data.targets).forEach(function(b){(d[b.id]&&d[b.id].indexOf(a)>=0||!(b.id in d)&&"line"===a)&&(e=!0)}),e},d.hasArcType=function(a){return this.hasType("pie",a)||this.hasType("donut",a)||this.hasType("gauge",a)},d.isLineType=function(a){var b=this.config,c=j(a)?a:a.id;return!b.data_types[c]||["line","spline","area","area-spline","step","area-step"].indexOf(b.data_types[c])>=0},d.isStepType=function(a){var b=j(a)?a:a.id;return["step","area-step"].indexOf(this.config.data_types[b])>=0},d.isSplineType=function(a){var b=j(a)?a:a.id;return["spline","area-spline"].indexOf(this.config.data_types[b])>=0},d.isAreaType=function(a){var b=j(a)?a:a.id;return["area","area-spline","area-step"].indexOf(this.config.data_types[b])>=0},d.isBarType=function(a){var b=j(a)?a:a.id;return"bar"===this.config.data_types[b]},d.isScatterType=function(a){var b=j(a)?a:a.id;return"scatter"===this.config.data_types[b]},d.isPieType=function(a){var b=j(a)?a:a.id;return"pie"===this.config.data_types[b]},d.isGaugeType=function(a){var b=j(a)?a:a.id;return"gauge"===this.config.data_types[b]},d.isDonutType=function(a){var b=j(a)?a:a.id;return"donut"===this.config.data_types[b]},d.isArcType=function(a){return this.isPieType(a)||this.isDonutType(a)||this.isGaugeType(a)},d.lineData=function(a){return this.isLineType(a)?[a]:[]},d.arcData=function(a){return this.isArcType(a.data)?[a]:[]},d.barData=function(a){return this.isBarType(a)?a.values:[]},d.lineOrScatterData=function(a){return this.isLineType(a)||this.isScatterType(a)?a.values:[]},d.barOrLineData=function(a){return this.isBarType(a)||this.isLineType(a)?a.values:[]},d.initGrid=function(){var a=this,b=a.config,c=a.d3;a.grid=a.main.append("g").attr("clip-path",a.clipPathForGrid).attr("class",g.grid),b.grid_x_show&&a.grid.append("g").attr("class",g.xgrids),b.grid_y_show&&a.grid.append("g").attr("class",g.ygrids),b.grid_focus_show&&a.grid.append("g").attr("class",g.xgridFocus).append("line").attr("class",g.xgridFocus),a.xgrid=c.selectAll([]),b.grid_lines_front||a.initGridLines()},d.initGridLines=function(){var a=this,b=a.d3;a.gridLines=a.main.append("g").attr("clip-path",a.clipPathForGrid).attr("class",g.grid+" "+g.gridLines),a.gridLines.append("g").attr("class",g.xgridLines),a.gridLines.append("g").attr("class",g.ygridLines),a.xgridLines=b.selectAll([])},d.updateXGrid=function(a){var b=this,c=b.config,d=b.d3,e=b.generateGridData(c.grid_x_type,b.x),f=b.isCategorized()?b.xAxis.tickOffset():0;b.xgridAttr=c.axis_rotated?{x1:0,x2:b.width,y1:function(a){return b.x(a)-f},y2:function(a){return b.x(a)-f}}:{x1:function(a){return b.x(a)+f},x2:function(a){return b.x(a)+f},y1:0,y2:b.height},b.xgrid=b.main.select("."+g.xgrids).selectAll("."+g.xgrid).data(e),b.xgrid.enter().append("line").attr("class",g.xgrid),a||b.xgrid.attr(b.xgridAttr).style("opacity",function(){return+d.select(this).attr(c.axis_rotated?"y1":"x1")===(c.axis_rotated?b.height:0)?0:1}),b.xgrid.exit().remove()},d.updateYGrid=function(){var a=this,b=a.config;a.ygrid=a.main.select("."+g.ygrids).selectAll("."+g.ygrid).data(a.y.ticks(b.grid_y_ticks)),a.ygrid.enter().append("line").attr("class",g.ygrid),a.ygrid.attr("x1",b.axis_rotated?a.y:0).attr("x2",b.axis_rotated?a.y:a.width).attr("y1",b.axis_rotated?0:a.y).attr("y2",b.axis_rotated?a.height:a.y),a.ygrid.exit().remove(),a.smoothLines(a.ygrid,"grid")},d.redrawGrid=function(a,b){var f,h,i,c=this,d=c.main,e=c.config;c.grid.style("visibility",c.hasArcType()?"hidden":"visible"),d.select("line."+g.xgridFocus).style("visibility","hidden"),e.grid_x_show&&c.updateXGrid(),c.xgridLines=d.select("."+g.xgridLines).selectAll("."+g.xgridLine).data(e.grid_x_lines),f=c.xgridLines.enter().append("g").attr("class",function(a){return g.xgridLine+(a["class"]?" "+a["class"]:"")
}),f.append("line").style("opacity",0),f.append("text").attr("text-anchor","end").attr("transform",e.axis_rotated?"":"rotate(-90)").attr("dx",e.axis_rotated?0:-c.margin.top).attr("dy",-5).style("opacity",0),c.xgridLines.exit().transition().duration(a).style("opacity",0).remove(),b&&e.grid_y_show&&c.updateYGrid(),b&&(c.ygridLines=d.select("."+g.ygridLines).selectAll("."+g.ygridLine).data(e.grid_y_lines),h=c.ygridLines.enter().append("g").attr("class",function(a){return g.ygridLine+(a["class"]?" "+a["class"]:"")}),h.append("line").style("opacity",0),h.append("text").attr("text-anchor","end").attr("transform",e.axis_rotated?"rotate(-90)":"").attr("dx",e.axis_rotated?0:-c.margin.top).attr("dy",-5).style("opacity",0),i=c.yv.bind(c),c.ygridLines.select("line").transition().duration(a).attr("x1",e.axis_rotated?i:0).attr("x2",e.axis_rotated?i:c.width).attr("y1",e.axis_rotated?0:i).attr("y2",e.axis_rotated?c.height:i).style("opacity",1),c.ygridLines.select("text").transition().duration(a).attr("x",e.axis_rotated?0:c.width).attr("y",i).text(function(a){return a.text}).style("opacity",1),c.ygridLines.exit().transition().duration(a).style("opacity",0).remove())},d.addTransitionForGrid=function(a){var b=this,c=b.config,d=b.xv.bind(b);a.push(b.xgridLines.select("line").transition().attr("x1",c.axis_rotated?0:d).attr("x2",c.axis_rotated?b.width:d).attr("y1",c.axis_rotated?d:b.margin.top).attr("y2",c.axis_rotated?d:b.height).style("opacity",1)),a.push(b.xgridLines.select("text").transition().attr("x",c.axis_rotated?b.width:0).attr("y",d).text(function(a){return a.text}).style("opacity",1))},d.showXGridFocus=function(a){var b=this,c=b.config,d=a.filter(function(a){return a&&h(a.value)}),e=b.main.selectAll("line."+g.xgridFocus),f=b.xx.bind(b);c.tooltip_show&&(b.hasType("scatter")||b.hasArcType()||(e.style("visibility","visible").data([d[0]]).attr(c.axis_rotated?"y1":"x1",f).attr(c.axis_rotated?"y2":"x2",f),b.smoothLines(e,"grid")))},d.hideXGridFocus=function(){this.main.select("line."+g.xgridFocus).style("visibility","hidden")},d.updateXgridFocus=function(){var a=this,b=a.config;a.main.select("line."+g.xgridFocus).attr("x1",b.axis_rotated?0:-10).attr("x2",b.axis_rotated?a.width:-10).attr("y1",b.axis_rotated?-10:0).attr("y2",b.axis_rotated?-10:a.height)},d.generateGridData=function(a,b){var e,f,h,i,c=this,d=[],j=c.main.select("."+g.axisX).selectAll(".tick").size();if("year"===a)for(e=c.getXDomain(),f=e[0].getFullYear(),h=e[1].getFullYear(),i=f;h>=i;i++)d.push(new Date(i+"-01-01 00:00:00"));else d=b.ticks(10),d.length>j&&(d=d.filter(function(a){return(""+a).indexOf(".")<0}));return d},d.getGridFilterToRemove=function(a){return a?function(b){var c=!1;return[].concat(a).forEach(function(d){("value"in d&&b.value===a.value||"class"in d&&b["class"]===a["class"])&&(c=!0)}),c}:function(){return!0}},d.removeGridLines=function(a,b){var c=this,d=c.config,e=c.getGridFilterToRemove(a),f=function(a){return!e(a)},h=b?g.xgridLines:g.ygridLines,i=b?g.xgridLine:g.ygridLine;c.main.select("."+h).selectAll("."+i).filter(e).transition().duration(d.transition_duration).style("opacity",0).remove(),b?d.grid_x_lines=d.grid_x_lines.filter(f):d.grid_y_lines=d.grid_y_lines.filter(f)},d.initTooltip=function(){var c,a=this,b=a.config;if(a.tooltip=a.selectChart.style("position","relative").append("div").style("position","absolute").style("pointer-events","none").style("z-index","10").style("display","none"),b.tooltip_init_show){if(a.isTimeSeries()&&j(b.tooltip_init_x)){for(b.tooltip_init_x=a.parseDate(b.tooltip_init_x),c=0;c<a.data.targets[0].values.length&&0!==a.data.targets[0].values[c].x-b.tooltip_init_x;c++);b.tooltip_init_x=c}a.tooltip.html(b.tooltip_contents.call(a,a.data.targets.map(function(c){return a.addName(c.values[b.tooltip_init_x])}),a.getXAxisTickFormat(),a.getYFormat(a.hasArcType()),a.color)),a.tooltip.style("top",b.tooltip_init_position.top).style("left",b.tooltip_init_position.left).style("display","block")}},d.getTooltipContent=function(a,b,c,d){var k,l,m,n,o,p,e=this,f=e.config,h=f.tooltip_format_title||b,i=f.tooltip_format_name||function(a){return a},j=f.tooltip_format_value||c;for(l=0;l<a.length;l++)a[l]&&(a[l].value||0===a[l].value)&&(k||(m=h?h(a[l].x):a[l].x,k="<table class='"+g.tooltip+"'>"+(m||0===m?"<tr><th colspan='2'>"+m+"</th></tr>":"")),o=i(a[l].name),n=j(a[l].value,a[l].ratio,a[l].id,a[l].index),p=e.levelColor?e.levelColor(a[l].value):d(a[l].id),k+="<tr class='"+g.tooltipName+"-"+a[l].id+"'>",k+="<td class='name'><span style='background-color:"+p+"'></span>"+o+"</td>",k+="<td class='value'>"+n+"</td>",k+="</tr>");return k+"</table>"},d.showTooltip=function(a,b){var e,f,g,i,j,k,l,c=this,d=c.config,m=c.hasArcType(),n=a.filter(function(a){return a&&h(a.value)});0!==n.length&&d.tooltip_show&&(c.tooltip.html(d.tooltip_contents.call(c,a,c.getXAxisTickFormat(),c.getYFormat(m),c.color)).style("display","block"),e=c.tooltip.property("offsetWidth"),f=c.tooltip.property("offsetHeight"),m?(i=c.width/2+b[0],k=c.height/2+b[1]+20):(d.axis_rotated?(g=c.getSvgLeft(),i=g+b[0]+100,j=i+e,l=c.getCurrentWidth()-c.getCurrentPaddingRight(),k=c.x(n[0].x)+20):(g=c.getSvgLeft(),i=g+c.getCurrentPaddingLeft()+c.x(n[0].x)+20,j=i+e,l=g+c.getCurrentWidth()-c.getCurrentPaddingRight(),k=b[1]+15),j>l&&(i-=j-l),k+f>c.getCurrentHeight()&&k>f+30&&(k-=f+30)),c.tooltip.style("top",k+"px").style("left",i+"px"))},d.hideTooltip=function(){this.tooltip.style("display","none")},d.initLegend=function(){var a=this;a.legend=a.svg.append("g").attr("transform",a.getTranslate("legend")),a.config.legend_show||(a.legend.style("visibility","hidden"),a.hiddenLegendIds=a.mapToIds(a.data.targets)),a.updateLegend(a.mapToIds(a.data.targets),{withTransform:!1,withTransitionForTransform:!1,withTransition:!1})},d.updateSizeForLegend=function(a,b){var c=this,d=c.config,e={top:c.isLegendTop?c.getCurrentPaddingTop()+d.legend_inset_y+5.5:c.currentHeight-a-c.getCurrentPaddingBottom()-d.legend_inset_y,left:c.isLegendLeft?c.getCurrentPaddingLeft()+d.legend_inset_x+.5:c.currentWidth-b-c.getCurrentPaddingRight()-d.legend_inset_x+.5};c.margin3={top:c.isLegendRight?0:c.isLegendInset?e.top:c.currentHeight-a,right:0/0,bottom:0,left:c.isLegendRight?c.currentWidth-b:c.isLegendInset?e.left:0}},d.transformLegend=function(a){var b=this;(a?b.legend.transition():b.legend).attr("transform",b.getTranslate("legend"))},d.updateLegendStep=function(a){this.legendStep=a},d.updateLegendItemWidth=function(a){this.legendItemWidth=a},d.updateLegendItemHeight=function(a){this.legendItemHeight=a},d.getLegendWidth=function(){var a=this;return a.config.legend_show?a.isLegendRight||a.isLegendInset?a.legendItemWidth*(a.legendStep+1):a.currentWidth:0},d.getLegendHeight=function(){var a=this,b=a.config,c=0;return b.legend_show&&(c=a.isLegendRight?a.currentHeight:a.isLegendInset?b.legend_inset_step?Math.max(20,a.legendItemHeight)*(b.legend_inset_step+1):a.height:Math.max(20,a.legendItemHeight)*(a.legendStep+1)),c},d.opacityForLegend=function(a){var b=this;return a.classed(g.legendItemHidden)?b.legendOpacityForHidden:1},d.opacityForUnfocusedLegend=function(a){var b=this;return a.classed(g.legendItemHidden)?b.legendOpacityForHidden:.3},d.toggleFocusLegend=function(a,b){var c=this;a=c.mapToTargetIds(a),c.legend.selectAll("."+g.legendItem).classed(g.legendItemFocused,function(c){return a.indexOf(c)>=0&&b}).transition().duration(100).style("opacity",function(d){var e=a.indexOf(d)>=0&&b?c.opacityForLegend:c.opacityForUnfocusedLegend;return e.call(c,c.d3.select(this))})},d.revertLegend=function(){var a=this,b=a.d3;a.legend.selectAll("."+g.legendItem).transition().duration(100).style("opacity",function(){return a.opacityForLegend(b.select(this))})},d.showLegend=function(a){var b=this,c=b.config;c.legend_show||(c.legend_show=!0,b.legend.style("visibility","visible")),b.removeHiddenLegendIds(a),b.legend.selectAll(b.selectorLegends(a)).style("visibility","visible").transition().style("opacity",function(){return b.opacityForLegend(b.d3.select(this))})},d.hideLegend=function(a){var b=this,c=b.config;c.legend_show&&p(a)&&(c.legend_show=!1,b.legend.style("visibility","hidden")),b.addHiddenLegendIds(a),b.legend.selectAll(b.selectorLegends(a)).style("opacity",0).style("visibility","hidden")},d.updateLegend=function(a,b,c){function I(b,c,f){function D(a,b){b||(u=(r-v-m)/2,s>u&&(u=(r-m)/2,v=0,B++)),A[a]=B,z[B]=d.isLegendInset?10:u,w[a]=v,v+=m}var u,C,h=0===f,i=f===a.length-1,j=d.getTextRect(b.textContent,g.legendItem),k=j.width+t+(i&&!d.isLegendRight?0:o),l=j.height+n,m=d.isLegendRight||d.isLegendInset?l:k,r=d.isLegendRight||d.isLegendInset?d.getLegendHeight():d.getLegendWidth();return h&&(v=0,B=0,p=0,q=0),e.legend_show&&!d.isLegendToShow(c)?(x[c]=y[c]=A[c]=w[c]=0,void 0):(x[c]=k,y[c]=l,(!p||k>=p)&&(p=k),(!q||l>=q)&&(q=l),C=d.isLegendRight||d.isLegendInset?q:p,e.legend_equally?(Object.keys(x).forEach(function(a){x[a]=p}),Object.keys(y).forEach(function(a){y[a]=q}),u=(r-C*a.length)/2,s>u?(v=0,B=0,a.forEach(function(a){D(a)})):D(c,!0)):D(c),void 0)}var f,h,i,j,k,m,u,C,D,F,G,H,d=this,e=d.config,n=4,o=10,p=0,q=0,s=10,t=15,v=0,w={},x={},y={},z=[0],A={},B=0,E=d.legend.selectAll("."+g.legendItemFocused).size();b=b||{},C=r(b,"withTransition",!0),D=r(b,"withTransitionForTransform",!0),d.isLegendRight?(f=function(a){return p*A[a]},j=function(a){return z[A[a]]+w[a]}):d.isLegendInset?(f=function(a){return p*A[a]+10},j=function(a){return z[A[a]]+w[a]}):(f=function(a){return z[A[a]]+w[a]},j=function(a){return q*A[a]}),h=function(a,b){return f(a,b)+14},k=function(a,b){return j(a,b)+9},i=function(a,b){return f(a,b)},m=function(a,b){return j(a,b)-5},u=d.legend.selectAll("."+g.legendItem).data(a).enter().append("g").attr("class",function(a){return d.generateClass(g.legendItem,a)}).style("visibility",function(a){return d.isLegendToShow(a)?"visible":"hidden"}).style("cursor","pointer").on("click",function(a){e.legend_item_onclick?e.legend_item_onclick.call(d,a):d.d3.event.altKey?(d.api.hide(),d.api.show(a)):d.api.toggle(a)}).on("mouseover",function(a){d.d3.select(this).classed(g.legendItemFocused,!0),d.transiting||d.api.focus(a),e.legend_item_onmouseover&&e.legend_item_onmouseover.call(d,a)}).on("mouseout",function(a){d.d3.select(this).classed(g.legendItemFocused,!1),d.transiting||d.api.revert(),e.legend_item_onmouseout&&e.legend_item_onmouseout.call(d,a)}),u.append("text").text(function(a){return l(e.data_names[a])?e.data_names[a]:a}).each(function(a,b){I(this,a,b)}).style("pointer-events","none").attr("x",d.isLegendRight||d.isLegendInset?h:-200).attr("y",d.isLegendRight||d.isLegendInset?-200:k),u.append("rect").attr("class",g.legendItemEvent).style("fill-opacity",0).attr("x",d.isLegendRight||d.isLegendInset?i:-200).attr("y",d.isLegendRight||d.isLegendInset?-200:m),u.append("rect").attr("class",g.legendItemTile).style("pointer-events","none").style("fill",d.color).attr("x",d.isLegendRight||d.isLegendInset?h:-200).attr("y",d.isLegendRight||d.isLegendInset?-200:j).attr("width",10).attr("height",10),d.isLegendInset&&0!==p&&d.legend.insert("g","."+g.legendItem).attr("class",g.legendBackground).append("rect").attr("height",d.getLegendHeight()-10).attr("width",p*(B+1)+10),F=d.legend.selectAll("text").data(a).text(function(a){return l(e.data_names[a])?e.data_names[a]:a}).each(function(a,b){I(this,a,b)}),(C?F.transition():F).attr("x",h).attr("y",k),G=d.legend.selectAll("rect."+g.legendItemEvent).data(a),(C?G.transition():G).attr("width",function(a){return x[a]}).attr("height",function(a){return y[a]}).attr("x",i).attr("y",m),H=d.legend.selectAll("rect."+g.legendItemTile).data(a),(C?H.transition():H).style("fill",d.color).attr("x",f).attr("y",j),d.legend.selectAll("."+g.legendItem).classed(g.legendItemHidden,function(a){return!d.isTargetToShow(a)}).transition().style("opacity",function(a){var b=d.d3.select(this);return d.isTargetToShow(a)?!E||b.classed(g.legendItemFocused)?d.opacityForLegend(b):d.opacityForUnfocusedLegend(b):d.legendOpacityForHidden}),d.updateLegendItemWidth(p),d.updateLegendItemHeight(q),d.updateLegendStep(B),d.updateSizes(),d.updateScales(),d.updateSvgSize(),d.transformAll(D,c)},d.initAxis=function(){var a=this,b=a.config,c=a.main;a.axes.x=c.append("g").attr("class",g.axis+" "+g.axisX).attr("clip-path",a.clipPathForXAxis).attr("transform",a.getTranslate("x")).style("visibility",b.axis_x_show?"visible":"hidden"),a.axes.x.append("text").attr("class",g.axisXLabel).attr("transform",b.axis_rotated?"rotate(-90)":"").style("text-anchor",a.textAnchorForXAxisLabel.bind(a)),a.axes.y=c.append("g").attr("class",g.axis+" "+g.axisY).attr("clip-path",a.clipPathForYAxis).attr("transform",a.getTranslate("y")).style("visibility",b.axis_y_show?"visible":"hidden"),a.axes.y.append("text").attr("class",g.axisYLabel).attr("transform",b.axis_rotated?"":"rotate(-90)").style("text-anchor",a.textAnchorForYAxisLabel.bind(a)),a.axes.y2=c.append("g").attr("class",g.axis+" "+g.axisY2).attr("transform",a.getTranslate("y2")).style("visibility",b.axis_y2_show?"visible":"hidden"),a.axes.y2.append("text").attr("class",g.axisY2Label).attr("transform",b.axis_rotated?"":"rotate(-90)").style("text-anchor",a.textAnchorForY2AxisLabel.bind(a))},d.getXAxis=function(a,b,c,d,e){var f=this,g=f.config,h={isCategory:f.isCategorized(),withOuterTick:e},i=u(f.d3,h).scale(a).orient(b);return f.isTimeSeries()&&d&&(d=d.map(function(a){return f.parseDate(a)})),i.tickFormat(c).tickValues(d),f.isCategorized()?(i.tickCentered(g.axis_x_tick_centered),p(g.axis_x_tick_culling)&&(g.axis_x_tick_culling=!1)):i.tickOffset=function(){var a=this.scale(),b=f.getEdgeX(f.data.targets),c=a(b[1])-a(b[0]),d=c?c:g.axis_rotated?f.height:f.width;return d/f.getMaxDataCount()/2},i},d.getYAxis=function(a,b,c,d,e){var f={withOuterTick:e};return u(this.d3,f).scale(a).orient(b).tickFormat(c).ticks(d)},d.getAxisId=function(a){var b=this.config;return a in b.data_axes?b.data_axes[a]:"y"},d.getXAxisTickFormat=function(){var a=this,b=a.config,c=a.isTimeSeries()?a.defaultAxisTimeFormat:a.isCategorized()?a.categoryName:function(a){return 0>a?a.toFixed(0):a};return b.axis_x_tick_format&&(i(b.axis_x_tick_format)?c=b.axis_x_tick_format:a.isTimeSeries()&&(c=function(c){return c?a.axisTimeFormat(b.axis_x_tick_format)(c):""})),i(c)?function(b){return c.call(a,b)}:c},d.getAxisLabelOptionByAxisId=function(a){var d,b=this,c=b.config;return"y"===a?d=c.axis_y_label:"y2"===a?d=c.axis_y2_label:"x"===a&&(d=c.axis_x_label),d},d.getAxisLabelText=function(a){var b=this.getAxisLabelOptionByAxisId(a);return j(b)?b:b?b.text:null},d.setAxisLabelText=function(a,b){var c=this,d=c.config,e=c.getAxisLabelOptionByAxisId(a);j(e)?"y"===a?d.axis_y_label=b:"y2"===a?d.axis_y2_label=b:"x"===a&&(d.axis_x_label=b):e&&(e.text=b)},d.getAxisLabelPosition=function(a,b){var c=this.getAxisLabelOptionByAxisId(a),d=c&&"object"==typeof c&&c.position?c.position:b;return{isInner:d.indexOf("inner")>=0,isOuter:d.indexOf("outer")>=0,isLeft:d.indexOf("left")>=0,isCenter:d.indexOf("center")>=0,isRight:d.indexOf("right")>=0,isTop:d.indexOf("top")>=0,isMiddle:d.indexOf("middle")>=0,isBottom:d.indexOf("bottom")>=0}},d.getXAxisLabelPosition=function(){return this.getAxisLabelPosition("x",this.config.axis_rotated?"inner-top":"inner-right")},d.getYAxisLabelPosition=function(){return this.getAxisLabelPosition("y",this.config.axis_rotated?"inner-right":"inner-top")},d.getY2AxisLabelPosition=function(){return this.getAxisLabelPosition("y2",this.config.axis_rotated?"inner-right":"inner-top")},d.getAxisLabelPositionById=function(a){return"y2"===a?this.getY2AxisLabelPosition():"y"===a?this.getYAxisLabelPosition():this.getXAxisLabelPosition()},d.textForXAxisLabel=function(){return this.getAxisLabelText("x")},d.textForYAxisLabel=function(){return this.getAxisLabelText("y")},d.textForY2AxisLabel=function(){return this.getAxisLabelText("y2")},d.xForAxisLabel=function(a,b){var c=this;return a?b.isLeft?0:b.isCenter?c.width/2:c.width:b.isBottom?-c.height:b.isMiddle?-c.height/2:0},d.dxForAxisLabel=function(a,b){return a?b.isLeft?"0.5em":b.isRight?"-0.5em":"0":b.isTop?"-0.5em":b.isBottom?"0.5em":"0"},d.textAnchorForAxisLabel=function(a,b){return a?b.isLeft?"start":b.isCenter?"middle":"end":b.isBottom?"start":b.isMiddle?"middle":"end"},d.xForXAxisLabel=function(){return this.xForAxisLabel(!this.config.axis_rotated,this.getXAxisLabelPosition())},d.xForYAxisLabel=function(){return this.xForAxisLabel(this.config.axis_rotated,this.getYAxisLabelPosition())},d.xForY2AxisLabel=function(){return this.xForAxisLabel(this.config.axis_rotated,this.getY2AxisLabelPosition())},d.dxForXAxisLabel=function(){return this.dxForAxisLabel(!this.config.axis_rotated,this.getXAxisLabelPosition())},d.dxForYAxisLabel=function(){return this.dxForAxisLabel(this.config.axis_rotated,this.getYAxisLabelPosition())},d.dxForY2AxisLabel=function(){return this.dxForAxisLabel(this.config.axis_rotated,this.getY2AxisLabelPosition())},d.dyForXAxisLabel=function(){var a=this,b=a.config,c=a.getXAxisLabelPosition();return b.axis_rotated?c.isInner?"1.2em":-25-a.getMaxTickWidth("x"):c.isInner?"-0.5em":b.axis_x_height?b.axis_x_height-10:"3em"},d.dyForYAxisLabel=function(){var a=this,b=a.getYAxisLabelPosition();return a.config.axis_rotated?b.isInner?"-0.5em":"3em":b.isInner?"1.2em":-20-a.getMaxTickWidth("y")},d.dyForY2AxisLabel=function(){var a=this,b=a.getY2AxisLabelPosition();return a.config.axis_rotated?b.isInner?"1.2em":"-2.2em":b.isInner?"-0.5em":30+this.getMaxTickWidth("y2")},d.textAnchorForXAxisLabel=function(){var a=this;return a.textAnchorForAxisLabel(!a.config.axis_rotated,a.getXAxisLabelPosition())},d.textAnchorForYAxisLabel=function(){var a=this;return a.textAnchorForAxisLabel(a.config.axis_rotated,a.getYAxisLabelPosition())},d.textAnchorForY2AxisLabel=function(){var a=this;return a.textAnchorForAxisLabel(a.config.axis_rotated,a.getY2AxisLabelPosition())},d.xForRotatedTickText=function(a){return 10*Math.sin(Math.PI*(a/180))},d.yForRotatedTickText=function(a){return 11.5-2.5*(a/15)*(a>0?1:-1)},d.rotateTickText=function(a,b,c){a.selectAll(".tick text").style("text-anchor",c>0?"start":"end"),b.selectAll(".tick text").attr("y",this.yForRotatedTickText(c)).attr("x",this.xForRotatedTickText(c)).attr("transform","rotate("+c+")")},d.getMaxTickWidth=function(a){var e,f,g,b=this,c=b.config,d=0;return b.svg&&(e=b.filterTargetsToShow(b.data.targets),"y"===a?(f=b.y.copy().domain(b.getYDomain(e,"y")),g=b.getYAxis(f,b.yOrient,c.axis_y_tick_format,c.axis_y_ticks)):"y2"===a?(f=b.y2.copy().domain(b.getYDomain(e,"y2")),g=b.getYAxis(f,b.y2Orient,c.axis_y2_tick_format,c.axis_y2_ticks)):(f=b.x.copy().domain(b.getXDomain(e)),g=b.getXAxis(f,b.xOrient,b.getXAxisTickFormat(),c.axis_x_tick_values?c.axis_x_tick_values:b.xAxis.tickValues())),b.d3.select("body").append("g").style("visibility","hidden").call(g).each(function(){b.d3.select(this).selectAll("text").each(function(){var a=this.getBoundingClientRect();d<a.width&&(d=a.width)})}).remove()),b.currentMaxTickWidth=0>=d?b.currentMaxTickWidth:d,b.currentMaxTickWidth},d.updateAxisLabels=function(a){var b=this,c=b.main.select("."+g.axisX+" ."+g.axisXLabel),d=b.main.select("."+g.axisY+" ."+g.axisYLabel),e=b.main.select("."+g.axisY2+" ."+g.axisY2Label);(a?c.transition():c).attr("x",b.xForXAxisLabel.bind(b)).attr("dx",b.dxForXAxisLabel.bind(b)).attr("dy",b.dyForXAxisLabel.bind(b)).text(b.textForXAxisLabel.bind(b)),(a?d.transition():d).attr("x",b.xForYAxisLabel.bind(b)).attr("dx",b.dxForYAxisLabel.bind(b)).attr("dy",b.dyForYAxisLabel.bind(b)).text(b.textForYAxisLabel.bind(b)),(a?e.transition():e).attr("x",b.xForY2AxisLabel.bind(b)).attr("dx",b.dxForY2AxisLabel.bind(b)).attr("dy",b.dyForY2AxisLabel.bind(b)).text(b.textForY2AxisLabel.bind(b))},d.getAxisPadding=function(a,b,c,d){var e="ratio"===a.unit?d:1;return h(a[b])?a[b]*e:c},d.generateTickValues=function(a,b){var e,f,g,h,j,k,l,c=this,d=a;if(b)if(e=i(b)?b():b,1===e)d=[a[0]];else if(2===e)d=[a[0],a[a.length-1]];else if(e>2){for(h=e-2,f=a[0],g=a[a.length-1],j=(g-f)/(h+1),d=[f],k=0;h>k;k++)l=+f+j*(k+1),d.push(c.isTimeSeries()?new Date(l):l);d.push(g)}return c.isTimeSeries()||(d=d.sort(function(a,b){return a-b})),d},d.generateAxisTransitions=function(a){var b=this,c=b.axes;return{axisX:a?c.x.transition().duration(a):c.x,axisY:a?c.y.transition().duration(a):c.y,axisY2:a?c.y2.transition().duration(a):c.y2,axisSubX:a?c.subx.transition().duration(a):c.subx}},d.redrawAxis=function(a,b){var c=this;c.axes.x.style("opacity",b?0:1),c.axes.y.style("opacity",b?0:1),c.axes.y2.style("opacity",b?0:1),c.axes.subx.style("opacity",b?0:1),a.axisX.call(c.xAxis),a.axisY.call(c.yAxis),a.axisY2.call(c.y2Axis),a.axisSubX.call(c.subXAxis)},d.getClipPath=function(b){var c=a.navigator.appVersion.toLowerCase().indexOf("msie 9.")>=0;return"url("+(c?"":document.URL.split("#")[0])+"#"+b+")"},d.appendClip=function(a,b){return a.append("clipPath").attr("id",b).append("rect")},d.getAxisClipX=function(a){return a?-31:-(this.margin.left-1)},d.getAxisClipY=function(a){return a?-20:-4},d.getXAxisClipX=function(){var a=this;return a.getAxisClipX(!a.config.axis_rotated)},d.getXAxisClipY=function(){var a=this;return a.getAxisClipY(!a.config.axis_rotated)},d.getYAxisClipX=function(){var a=this;return a.getAxisClipX(a.config.axis_rotated)},d.getYAxisClipY=function(){var a=this;return a.getAxisClipY(a.config.axis_rotated)},d.getAxisClipWidth=function(a){var b=this;return a?b.width+2+30+30:b.margin.left+20},d.getAxisClipHeight=function(a){var b=this,c=b.config;return a?(c.axis_x_height?c.axis_x_height:0)+80:b.height+8},d.getXAxisClipWidth=function(){var a=this;return a.getAxisClipWidth(!a.config.axis_rotated)},d.getXAxisClipHeight=function(){var a=this;return a.getAxisClipHeight(!a.config.axis_rotated)},d.getYAxisClipWidth=function(){var a=this;return a.getAxisClipWidth(a.config.axis_rotated)},d.getYAxisClipHeight=function(){var a=this;return a.getAxisClipHeight(a.config.axis_rotated)},d.initPie=function(){var a=this,b=a.d3,c=a.config;a.pie=b.layout.pie().value(function(a){return a.values.reduce(function(a,b){return a+b.value},0)}),c.data_order||a.pie.sort(null)},d.updateRadius=function(){var a=this,b=a.config,c=b.gauge_width||b.donut_width;a.radiusExpanded=Math.min(a.arcWidth,a.arcHeight)/2,a.radius=.95*a.radiusExpanded,a.innerRadiusRatio=c?(a.radius-c)/a.radius:.6,a.innerRadius=a.hasType("donut")||a.hasType("gauge")?a.radius*a.innerRadiusRatio:0},d.updateArc=function(){var a=this;a.svgArc=a.getSvgArc(),a.svgArcExpanded=a.getSvgArcExpanded(),a.svgArcExpandedSub=a.getSvgArcExpanded(.98)},d.updateAngle=function(a){var h,i,b=this,c=b.config,d=!1,e=0,f=c.gauge_min,g=c.gauge_max;return b.pie(b.filterTargetsToShow(b.data.targets)).forEach(function(b){d||b.data.id!==a.data.id||(d=!0,a=b,a.index=e),e++}),isNaN(a.endAngle)&&(a.endAngle=a.startAngle),b.isGaugeType(a.data)&&(h=Math.PI/(g-f),i=a.value<f?0:a.value<g?a.value-f:g-f,a.startAngle=-1*(Math.PI/2),a.endAngle=a.startAngle+h*i),d?a:null},d.getSvgArc=function(){var a=this,b=a.d3.svg.arc().outerRadius(a.radius).innerRadius(a.innerRadius),c=function(c,d){var e;return d?b(c):(e=a.updateAngle(c),e?b(e):"M 0 0")};return c.centroid=b.centroid,c},d.getSvgArcExpanded=function(a){var b=this,c=b.d3.svg.arc().outerRadius(b.radiusExpanded*(a?a:1)).innerRadius(b.innerRadius);return function(a){var d=b.updateAngle(a);return d?c(d):"M 0 0"}},d.getArc=function(a,b,c){return c||this.isArcType(a.data)?this.svgArc(a,b):"M 0 0"},d.transformForArcLabel=function(a){var d,e,f,g,h,b=this,c=b.updateAngle(a),i="";return c&&!b.hasType("gauge")&&(d=this.svgArc.centroid(c),e=isNaN(d[0])?0:d[0],f=isNaN(d[1])?0:d[1],g=Math.sqrt(e*e+f*f),h=b.radius&&g?(36/b.radius>.375?1.175-36/b.radius:.8)*b.radius/g:0,i="translate("+e*h+","+f*h+")"),i},d.getArcRatio=function(a){var b=this,c=b.hasType("gauge")?Math.PI:2*Math.PI;return a?(a.endAngle-a.startAngle)/c:null},d.convertToArcData=function(a){return this.addName({id:a.data.id,value:a.value,ratio:this.getArcRatio(a),index:a.index})},d.textForArcLabel=function(a){var c,d,e,f,g,b=this;return b.shouldShowArcLabel()?(c=b.updateAngle(a),d=c?c.value:null,e=b.getArcRatio(c),f=a.data.id,b.hasType("gauge")||b.meetsArcLabelThreshold(e)?(g=b.getArcLabelFormat(),g?g(d,e,f):b.defaultArcValueFormat(d,e)):""):""},d.expandArc=function(a,b){var d,e,c=this;a=c.mapToTargetIds(a),d=c.svg.selectAll(c.selectorTargets(a,"."+g.chartArc)),e=c.svg.selectAll("."+g.arc).filter(function(b){return a.indexOf(b.data.id)<0}),d.each(function(a){c.shouldExpand(a.data.id)&&c.d3.select(this).selectAll("path").transition().duration(50).attr("d",c.svgArcExpanded).transition().duration(100).attr("d",c.svgArcExpandedSub).each(function(a){c.isDonutType(a.data)})}),b||e.style("opacity",.3)},d.unexpandArc=function(a){var c,b=this;a=b.mapToTargetIds(a),c=b.svg.selectAll(b.selectorTargets(a,"."+g.chartArc)),c.selectAll("path."+g.arc).transition().duration(50).attr("d",b.svgArc),b.svg.selectAll("."+g.arc).style("opacity",1)},d.shouldExpand=function(a){var b=this,c=b.config;return b.isDonutType(a)&&c.donut_expand||b.isGaugeType(a)&&c.gauge_expand||b.isPieType(a)&&c.pie_expand},d.shouldShowArcLabel=function(){var a=this,b=a.config,c=!0;return a.hasType("donut")?c=b.donut_label_show:a.hasType("pie")&&(c=b.pie_label_show),c},d.meetsArcLabelThreshold=function(a){var b=this,c=b.config,d=b.hasType("donut")?c.donut_label_threshold:c.pie_label_threshold;return a>=d},d.getArcLabelFormat=function(){var a=this,b=a.config,c=b.pie_label_format;return a.hasType("gauge")?c=b.gauge_label_format:a.hasType("donut")&&(c=b.donut_label_format),c},d.getArcTitle=function(){var a=this;return a.hasType("donut")?a.config.donut_title:""},d.updateTargetsForArc=function(a){var d,e,b=this,c=b.main,f=b.classChartArc.bind(b),h=b.classArcs.bind(b),i=b.classFocus.bind(b);d=c.select("."+g.chartArcs).selectAll("."+g.chartArc).data(b.pie(a)).attr("class",function(a){return f(a)+i(a.data)}),e=d.enter().append("g").attr("class",f),e.append("g").attr("class",h),e.append("text").attr("dy",b.hasType("gauge")?"-0.35em":".35em").style("opacity",0).style("text-anchor","middle").style("pointer-events","none")},d.initArc=function(){var a=this;a.arcs=a.main.select("."+g.chart).append("g").attr("class",g.chartArcs).attr("transform",a.getTranslate("arc")),a.arcs.append("text").attr("class",g.chartArcsTitle).style("text-anchor","middle").text(a.getArcTitle())},d.redrawArc=function(a,b,c){var i,d=this,e=d.d3,f=d.config,h=d.main;i=h.selectAll("."+g.arcs).selectAll("."+g.arc).data(d.arcData.bind(d)),i.enter().append("path").attr("class",d.classArc.bind(d)).style("fill",function(a){return d.color(a.data)}).style("cursor",function(a){return f.data_selection_isselectable(a)?"pointer":null}).style("opacity",0).each(function(a){d.isGaugeType(a.data)&&(a.startAngle=a.endAngle=-1*(Math.PI/2)),this._current=a}).on("mouseover",function(a){var b,c;d.transiting||(b=d.updateAngle(a),c=d.convertToArcData(b),d.expandArc(b.data.id),d.toggleFocusLegend(b.data.id,!0),d.config.data_onmouseover(c,this))}).on("mousemove",function(a){var b=d.updateAngle(a),c=d.convertToArcData(b),f=[c];d.showTooltip(f,e.mouse(this))}).on("mouseout",function(a){var b,c;d.transiting||(b=d.updateAngle(a),c=d.convertToArcData(b),d.unexpandArc(b.data.id),d.revertLegend(),d.hideTooltip(),d.config.data_onmouseout(c,this))}).on("click",function(a,b){var c=d.updateAngle(a),e=d.convertToArcData(c);d.toggleShape&&d.toggleShape(this,e,b),d.config.data_onclick.call(d.api,e,this)}),i.attr("transform",function(a){return!d.isGaugeType(a.data)&&c?"scale(0)":""}).style("opacity",function(a){return a===this._current?0:1}).each(function(){d.transiting=!0}).transition().duration(a).attrTween("d",function(a){var c,b=d.updateAngle(a);return b?(isNaN(this._current.endAngle)&&(this._current.endAngle=this._current.startAngle),c=e.interpolate(this._current,b),this._current=c(0),function(a){return d.getArc(c(a),!0)}):function(){return"M 0 0"}}).attr("transform",c?"scale(1)":"").style("fill",function(a){return d.levelColor?d.levelColor(a.data.values[0].value):d.color(a.data.id)}).style("opacity",1).call(d.endall,function(){d.transiting=!1}),i.exit().transition().duration(b).style("opacity",0).remove(),h.selectAll("."+g.chartArc).select("text").style("opacity",0).attr("class",function(a){return d.isGaugeType(a.data)?g.gaugeValue:""}).text(d.textForArcLabel.bind(d)).attr("transform",d.transformForArcLabel.bind(d)).transition().duration(a).style("opacity",function(a){return d.isTargetToShow(a.data.id)&&d.isArcType(a.data)?1:0}),h.select("."+g.chartArcsTitle).style("opacity",d.hasType("donut")||d.hasType("gauge")?1:0),d.hasType("gauge")&&(d.arcs.select("."+g.chartArcsBackground).attr("d",function(){var a={data:[{value:f.gauge_max}],startAngle:-1*(Math.PI/2),endAngle:Math.PI/2};return d.getArc(a,!0,!0)}),d.arcs.select("."+g.chartArcsGaugeUnit).attr("dy",".75em").text(f.gauge_label_show?f.gauge_units:""),d.arcs.select("."+g.chartArcsGaugeMin).attr("dx",-1*(d.innerRadius+(d.radius-d.innerRadius)/2)+"px").attr("dy","1.2em").text(f.gauge_label_show?f.gauge_min:""),d.arcs.select("."+g.chartArcsGaugeMax).attr("dx",d.innerRadius+(d.radius-d.innerRadius)/2+"px").attr("dy","1.2em").text(f.gauge_label_show?f.gauge_max:""))},d.initGauge=function(){var a=this.arcs;this.hasType("gauge")&&(a.append("path").attr("class",g.chartArcsBackground),a.append("text").attr("class",g.chartArcsGaugeUnit).style("text-anchor","middle").style("pointer-events","none"),a.append("text").attr("class",g.chartArcsGaugeMin).style("text-anchor","middle").style("pointer-events","none"),a.append("text").attr("class",g.chartArcsGaugeMax).style("text-anchor","middle").style("pointer-events","none"))},d.getGaugeLabelHeight=function(){return this.config.gauge_label_show?20:0},d.initRegion=function(){var a=this;a.region=a.main.append("g").attr("clip-path",a.clipPath).attr("class",g.regions)},d.redrawRegion=function(a){var b=this,c=b.config;b.region.style("visibility",b.hasArcType()?"hidden":"visible"),b.mainRegion=b.main.select("."+g.regions).selectAll("."+g.region).data(c.regions),b.mainRegion.enter().append("g").attr("class",b.classRegion.bind(b)).append("rect").style("fill-opacity",0),b.mainRegion.exit().transition().duration(a).style("opacity",0).remove()},d.addTransitionForRegion=function(a){var b=this,c=b.regionX.bind(b),d=b.regionY.bind(b),e=b.regionWidth.bind(b),f=b.regionHeight.bind(b);a.push(b.mainRegion.selectAll("rect").transition().attr("x",c).attr("y",d).attr("width",e).attr("height",f).style("fill-opacity",function(a){return h(a.opacity)?a.opacity:.1}))},d.regionX=function(a){var d,b=this,c=b.config,e="y"===a.axis?b.y:b.y2;return d="y"===a.axis||"y2"===a.axis?c.axis_rotated?"start"in a?e(a.start):0:0:c.axis_rotated?0:"start"in a?b.x(b.isTimeSeries()?b.parseDate(a.start):a.start):0},d.regionY=function(a){var d,b=this,c=b.config,e="y"===a.axis?b.y:b.y2;return d="y"===a.axis||"y2"===a.axis?c.axis_rotated?0:"end"in a?e(a.end):0:c.axis_rotated?"start"in a?b.x(b.isTimeSeries()?b.parseDate(a.start):a.start):0:0},d.regionWidth=function(a){var e,b=this,c=b.config,d=b.regionX(a),f="y"===a.axis?b.y:b.y2;return e="y"===a.axis||"y2"===a.axis?c.axis_rotated?"end"in a?f(a.end):b.width:b.width:c.axis_rotated?b.width:"end"in a?b.x(b.isTimeSeries()?b.parseDate(a.end):a.end):b.width,d>e?0:e-d},d.regionHeight=function(a){var e,b=this,c=b.config,d=this.regionY(a),f="y"===a.axis?b.y:b.y2;return e="y"===a.axis||"y2"===a.axis?c.axis_rotated?b.height:"start"in a?f(a.start):b.height:c.axis_rotated?"end"in a?b.x(b.isTimeSeries()?b.parseDate(a.end):a.end):b.height:b.height,d>e?0:e-d},d.isRegionOnX=function(a){return!a.axis||"x"===a.axis},d.drag=function(a){var f,h,i,j,k,l,m,n,b=this,c=b.config,d=b.main,e=b.d3;b.hasArcType()||c.data_selection_enabled&&(!c.zoom_enabled||b.zoom.altDomain)&&c.data_selection_multiple&&(f=b.dragStart[0],h=b.dragStart[1],i=a[0],j=a[1],k=Math.min(f,i),l=Math.max(f,i),m=c.data_selection_grouped?b.margin.top:Math.min(h,j),n=c.data_selection_grouped?b.height:Math.max(h,j),d.select("."+g.dragarea).attr("x",k).attr("y",m).attr("width",l-k).attr("height",n-m),d.selectAll("."+g.shapes).selectAll("."+g.shape).filter(function(a){return c.data_selection_isselectable(a)
}).each(function(a,c){var i,j,o,p,q,s,d=e.select(this),f=d.classed(g.SELECTED),h=d.classed(g.INCLUDED),r=!1;if(d.classed(g.circle))i=1*d.attr("cx"),j=1*d.attr("cy"),q=b.togglePoint,r=i>k&&l>i&&j>m&&n>j;else{if(!d.classed(g.bar))return;s=t(this),i=s.x,j=s.y,o=s.width,p=s.height,q=b.togglePath,r=!(i>l||k>i+o||j>n||m>j+p)}r^h&&(d.classed(g.INCLUDED,!h),d.classed(g.SELECTED,!f),q.call(b,!f,d,a,c))}))},d.dragstart=function(a){var b=this,c=b.config;b.hasArcType()||c.data_selection_enabled&&(b.dragStart=a,b.main.select("."+g.chart).append("rect").attr("class",g.dragarea).style("opacity",.1),b.dragging=!0,b.config.data_ondragstart())},d.dragend=function(){var a=this,b=a.config;a.hasArcType()||b.data_selection_enabled&&(a.main.select("."+g.dragarea).transition().duration(100).style("opacity",0).remove(),a.main.selectAll("."+g.shape).classed(g.INCLUDED,!1),a.dragging=!1,a.config.data_ondragend())},d.selectPoint=function(a,b,c){var d=this,e=d.config,f=(e.axis_rotated?d.circleY:d.circleX).bind(d),h=(e.axis_rotated?d.circleX:d.circleY).bind(d),i=d.pointSelectR.bind(d);e.data_onselected.call(d.api,b,a.node()),d.main.select("."+g.selectedCircles+d.getTargetSelectorSuffix(b.id)).selectAll("."+g.selectedCircle+"-"+c).data([b]).enter().append("circle").attr("class",function(){return d.generateClass(g.selectedCircle,c)}).attr("cx",f).attr("cy",h).attr("stroke",function(){return d.color(b)}).attr("r",function(a){return 1.4*d.pointSelectR(a)}).transition().duration(100).attr("r",i)},d.unselectPoint=function(a,b,c){var d=this;d.config.data_onunselected(b,a.node()),d.main.select("."+g.selectedCircles+d.getTargetSelectorSuffix(b.id)).selectAll("."+g.selectedCircle+"-"+c).transition().duration(100).attr("r",0).remove()},d.togglePoint=function(a,b,c,d){a?this.selectPoint(b,c,d):this.unselectPoint(b,c,d)},d.selectPath=function(a,b){var c=this;c.config.data_onselected.call(c,b,a.node()),a.transition().duration(100).style("fill",function(){return c.d3.rgb(c.color(b)).brighter(.75)})},d.unselectPath=function(a,b){var c=this;c.config.data_onunselected.call(c,b,a.node()),a.transition().duration(100).style("fill",function(){return c.color(b)})},d.togglePath=function(a,b,c,d){a?this.selectPath(b,c,d):this.unselectPath(b,c,d)},d.getToggle=function(a,b){var d,c=this;return"circle"===a.nodeName?d=c.isStepType(b)?function(){}:c.togglePoint:"path"===a.nodeName&&(d=c.togglePath),d},d.toggleShape=function(a,b,c){var d=this,e=d.d3,f=d.config,h=e.select(a),i=h.classed(g.SELECTED),j=d.getToggle(a,b).bind(d);f.data_selection_enabled&&f.data_selection_isselectable(b)&&(f.data_selection_multiple||d.main.selectAll("."+g.shapes+(f.data_selection_grouped?d.getTargetSelectorSuffix(b.id):"")).selectAll("."+g.shape).each(function(a,b){var c=e.select(this);c.classed(g.SELECTED)&&j(!1,c.classed(g.SELECTED,!1),a,b)}),h.classed(g.SELECTED,!i),j(!i,h,b,c))},d.initBrush=function(){var a=this,b=a.d3;a.brush=b.svg.brush().on("brush",function(){a.redrawForBrush()}),a.brush.update=function(){return a.context&&a.context.select("."+g.brush).call(this),this},a.brush.scale=function(b){return a.config.axis_rotated?this.y(b):this.x(b)}},d.initSubchart=function(){var a=this,b=a.config,c=a.context=a.svg.append("g").attr("transform",a.getTranslate("context"));b.subchart_show||c.style("visibility","hidden"),c.append("g").attr("clip-path",a.clipPath).attr("class",g.chart),c.select("."+g.chart).append("g").attr("class",g.chartBars),c.select("."+g.chart).append("g").attr("class",g.chartLines),c.append("g").attr("clip-path",a.clipPath).attr("class",g.brush).call(a.brush).selectAll("rect").attr(b.axis_rotated?"width":"height",b.axis_rotated?a.width2:a.height2),a.axes.subx=c.append("g").attr("class",g.axisX).attr("transform",a.getTranslate("subx")).attr("clip-path",b.axis_rotated?"":a.clipPathForXAxis)},d.updateTargetsForSubchart=function(a){var e,f,h,i,b=this,c=b.context,d=b.config,j=b.classChartBar.bind(b),k=b.classBars.bind(b),l=b.classChartLine.bind(b),m=b.classLines.bind(b),n=b.classAreas.bind(b);d.subchart_show&&(i=c.select("."+g.chartBars).selectAll("."+g.chartBar).data(a).attr("class",j),h=i.enter().append("g").style("opacity",0).attr("class",j),h.append("g").attr("class",k),f=c.select("."+g.chartLines).selectAll("."+g.chartLine).data(a).attr("class",l),e=f.enter().append("g").style("opacity",0).attr("class",l),e.append("g").attr("class",m),e.append("g").attr("class",n))},d.redrawSubchart=function(a,b,c,d,e,f,h){var m,n,o,p,q,r,i=this,j=i.d3,k=i.context,l=i.config,s=i.barData.bind(i),t=i.lineData.bind(i),u=i.classBar.bind(i),v=i.classLine.bind(i),w=i.classArea.bind(i),x=i.initialOpacity.bind(i);l.subchart_show&&(j.event&&"zoom"===j.event.type&&i.brush.extent(i.x.orgDomain()).update(),a&&(!l.axis_rotated&&l.axis_x_tick_rotate&&i.rotateTickText(i.axes.subx,b.axisSubX,l.axis_x_tick_rotate),i.brush.empty()||i.brush.extent(i.x.orgDomain()).update(),p=i.generateDrawArea(e,!0),q=i.generateDrawBar(f,!0),r=i.generateDrawLine(h,!0),o=k.selectAll("."+g.bars).selectAll("."+g.bar).data(s),o.enter().append("path").attr("class",u).style("stroke","none").style("fill",i.color),o.style("opacity",x).transition().duration(c).attr("d",q).style("opacity",1),o.exit().transition().duration(c).style("opacity",0).remove(),m=k.selectAll("."+g.lines).selectAll("."+g.line).data(t),m.enter().append("path").attr("class",v).style("stroke",i.color),m.style("opacity",x).transition().duration(c).attr("d",r).style("opacity",1),m.exit().transition().duration(c).style("opacity",0).remove(),n=k.selectAll("."+g.areas).selectAll("."+g.area).data(t),n.enter().append("path").attr("class",w).style("fill",i.color).style("opacity",function(){return i.orgAreaOpacity=+j.select(this).style("opacity"),0}),n.style("opacity",0).transition().duration(c).attr("d",p).style("fill",i.color).style("opacity",i.orgAreaOpacity),n.exit().transition().duration(d).style("opacity",0).remove()))},d.redrawForBrush=function(){var a=this,b=a.x;a.redraw({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0}),a.config.subchart_onbrush.call(a.api,b.orgDomain())},d.transformContext=function(a,b){var d,c=this;b&&b.axisSubX?d=b.axisSubX:(d=c.context.select("."+g.axisX),a&&(d=d.transition())),c.context.attr("transform",c.getTranslate("context")),d.attr("transform",c.getTranslate("subx"))},d.getDefaultExtent=function(){var a=this,b=a.config,c=i(b.axis_x_extent)?b.axis_x_extent(a.getXDomain(a.data.targets)):b.axis_x_extent;return a.isTimeSeries()&&(c=[a.parseDate(c[0]),a.parseDate(c[1])]),c},d.initZoom=function(){var d,a=this,b=a.d3,c=a.config,e=!1;a.zoom=b.behavior.zoom().on("zoomstart",function(){a.zoom.altDomain=b.event.sourceEvent.altKey?a.x.orgDomain():null}).on("zoom",function(){d&&e&&a.zoom.translate(d),a.redrawForZoom.call(a),d=a.zoom.translate(),e="wheel"===b.event.sourceEvent.type}),a.zoom.scale=function(a){return c.axis_rotated?this.y(a):this.x(a)},a.zoom.orgScaleExtent=function(){var b=c.zoom_extent?c.zoom_extent:[1,10];return[b[0],Math.max(a.getMaxDataCount()/b[1],b[1])]},a.zoom.updateScaleExtent=function(){var b=o(a.x.orgDomain())/o(a.orgXDomain),c=this.orgScaleExtent();return this.scaleExtent([c[0]*b,c[1]*b]),this}},d.updateZoom=function(){var a=this,b=a.config.zoom_enabled?a.zoom:function(){};a.main.select("."+g.zoomRect).call(b),a.main.selectAll("."+g.eventRect).call(b)},d.redrawForZoom=function(){var a=this,b=a.d3,c=a.config,d=a.zoom,e=a.x,f=a.orgXDomain;if(c.zoom_enabled&&0!==a.filterTargetsToShow(a.data.targets).length){if("mousemove"===b.event.sourceEvent.type&&d.altDomain)return e.domain(d.altDomain),d.scale(e).updateScaleExtent(),void 0;a.isCategorized()&&e.orgDomain()[0]===f[0]&&e.domain([f[0]-1e-10,e.orgDomain()[1]]),a.redraw({withTransition:!1,withY:!1,withSubchart:!1}),"mousemove"===b.event.sourceEvent.type&&(a.cancelClick=!0),c.zoom_onzoom.call(a.api,e.orgDomain())}},d.generateColor=function(){var a=this,b=a.config,c=a.d3,d=b.data_colors,e=q(b.color_pattern)?b.color_pattern:c.scale.category10().range(),f=b.data_color,g=[];return function(a){var c,b=a.id||a;return d[b]instanceof Function?c=d[b](a):d[b]?c=d[b]:(g.indexOf(b)<0&&g.push(b),c=e[g.indexOf(b)%e.length],d[b]=c),f instanceof Function?f(c,a):c}},d.generateLevelColor=function(){var a=this,b=a.config,c=b.color_pattern,d=b.color_threshold,e="value"===d.unit,f=d.values&&d.values.length?d.values:[],g=d.max||100;return q(b.color_threshold)?function(a){var b,d,h=c[c.length-1];for(b=0;b<f.length;b++)if(d=e?a:100*a/g,d<f[b]){h=c[b];break}return h}:null},d.getYFormat=function(a){var b=this,c=a&&!b.hasType("gauge")?b.defaultArcValueFormat:b.yFormat,d=a&&!b.hasType("gauge")?b.defaultArcValueFormat:b.y2Format;return function(a,e,f){var g="y2"===b.getAxisId(f)?d:c;return g.call(b,a,e)}},d.yFormat=function(a){var b=this,c=b.config,d=c.axis_y_tick_format?c.axis_y_tick_format:b.defaultValueFormat;return d(a)},d.y2Format=function(a){var b=this,c=b.config,d=c.axis_y2_tick_format?c.axis_y2_tick_format:b.defaultValueFormat;return d(a)},d.defaultValueFormat=function(a){return h(a)?+a:""},d.defaultArcValueFormat=function(a,b){return(100*b).toFixed(1)+"%"},d.formatByAxisId=function(a){var b=this,c=b.config.data_labels,d=function(a){return h(a)?+a:""};return"function"==typeof c.format?d=c.format:"object"==typeof c.format&&c.format[a]&&(d=c.format[a]),d},d.hasCaches=function(a){for(var b=0;b<a.length;b++)if(!(a[b]in this.cache))return!1;return!0},d.addCache=function(a,b){this.cache[a]=this.cloneTarget(b)},d.getCaches=function(a){var c,b=[];for(c=0;c<a.length;c++)a[c]in this.cache&&b.push(this.cloneTarget(this.cache[a[c]]));return b};var g=d.CLASS={target:"c3-target",chart:"c3-chart",chartLine:"c3-chart-line",chartLines:"c3-chart-lines",chartBar:"c3-chart-bar",chartBars:"c3-chart-bars",chartText:"c3-chart-text",chartTexts:"c3-chart-texts",chartArc:"c3-chart-arc",chartArcs:"c3-chart-arcs",chartArcsTitle:"c3-chart-arcs-title",chartArcsBackground:"c3-chart-arcs-background",chartArcsGaugeUnit:"c3-chart-arcs-gauge-unit",chartArcsGaugeMax:"c3-chart-arcs-gauge-max",chartArcsGaugeMin:"c3-chart-arcs-gauge-min",selectedCircle:"c3-selected-circle",selectedCircles:"c3-selected-circles",eventRect:"c3-event-rect",eventRects:"c3-event-rects",eventRectsSingle:"c3-event-rects-single",eventRectsMultiple:"c3-event-rects-multiple",zoomRect:"c3-zoom-rect",brush:"c3-brush",focused:"c3-focused",defocused:"c3-defocused",region:"c3-region",regions:"c3-regions",tooltip:"c3-tooltip",tooltipName:"c3-tooltip-name",shape:"c3-shape",shapes:"c3-shapes",line:"c3-line",lines:"c3-lines",bar:"c3-bar",bars:"c3-bars",circle:"c3-circle",circles:"c3-circles",arc:"c3-arc",arcs:"c3-arcs",area:"c3-area",areas:"c3-areas",empty:"c3-empty",text:"c3-text",texts:"c3-texts",gaugeValue:"c3-gauge-value",grid:"c3-grid",gridLines:"c3-grid-lines",xgrid:"c3-xgrid",xgrids:"c3-xgrids",xgridLine:"c3-xgrid-line",xgridLines:"c3-xgrid-lines",xgridFocus:"c3-xgrid-focus",ygrid:"c3-ygrid",ygrids:"c3-ygrids",ygridLine:"c3-ygrid-line",ygridLines:"c3-ygrid-lines",axis:"c3-axis",axisX:"c3-axis-x",axisXLabel:"c3-axis-x-label",axisY:"c3-axis-y",axisYLabel:"c3-axis-y-label",axisY2:"c3-axis-y2",axisY2Label:"c3-axis-y2-label",legendBackground:"c3-legend-background",legendItem:"c3-legend-item",legendItemEvent:"c3-legend-item-event",legendItemTile:"c3-legend-item-tile",legendItemHidden:"c3-legend-item-hidden",legendItemFocused:"c3-legend-item-focused",dragarea:"c3-dragarea",EXPANDED:"_expanded_",SELECTED:"_selected_",INCLUDED:"_included_"};d.generateClass=function(a,b){return" "+a+" "+a+this.getTargetSelectorSuffix(b)},d.classText=function(a){return this.generateClass(g.text,a.index)},d.classTexts=function(a){return this.generateClass(g.texts,a.id)},d.classShape=function(a){return this.generateClass(g.shape,a.index)},d.classShapes=function(a){return this.generateClass(g.shapes,a.id)},d.classLine=function(a){return this.classShape(a)+this.generateClass(g.line,a.id)},d.classLines=function(a){return this.classShapes(a)+this.generateClass(g.lines,a.id)},d.classCircle=function(a){return this.classShape(a)+this.generateClass(g.circle,a.index)},d.classCircles=function(a){return this.classShapes(a)+this.generateClass(g.circles,a.id)},d.classBar=function(a){return this.classShape(a)+this.generateClass(g.bar,a.index)},d.classBars=function(a){return this.classShapes(a)+this.generateClass(g.bars,a.id)},d.classArc=function(a){return this.classShape(a.data)+this.generateClass(g.arc,a.data.id)},d.classArcs=function(a){return this.classShapes(a.data)+this.generateClass(g.arcs,a.data.id)},d.classArea=function(a){return this.classShape(a)+this.generateClass(g.area,a.id)},d.classAreas=function(a){return this.classShapes(a)+this.generateClass(g.areas,a.id)},d.classRegion=function(a,b){return this.generateClass(g.region,b)+" "+("class"in a?a["class"]:"")},d.classEvent=function(a){return this.generateClass(g.eventRect,a.index)},d.classTarget=function(a){var b=this,c=b.config.data_classes[a],d="";return c&&(d=" "+g.target+"-"+c),b.generateClass(g.target,a)+d},d.classFocus=function(a){return this.classFocused(a)+this.classDefocused(a)},d.classFocused=function(a){return" "+(this.focusedTargetIds.indexOf(a.id)>=0?g.focused:"")},d.classDefocused=function(a){return" "+(this.defocusedTargetIds.indexOf(a.id)>=0?g.defocused:"")},d.classChartText=function(a){return g.chartText+this.classTarget(a.id)},d.classChartLine=function(a){return g.chartLine+this.classTarget(a.id)},d.classChartBar=function(a){return g.chartBar+this.classTarget(a.id)},d.classChartArc=function(a){return g.chartArc+this.classTarget(a.data.id)},d.getTargetSelectorSuffix=function(a){return a||0===a?"-"+(a.replace?a.replace(/([^a-zA-Z0-9-_])/g,"-"):a):""},d.selectorTarget=function(a,b){return(b||"")+"."+g.target+this.getTargetSelectorSuffix(a)},d.selectorTargets=function(a,b){var c=this;return a=a||[],a.length?a.map(function(a){return c.selectorTarget(a,b)}):null},d.selectorLegend=function(a){return"."+g.legendItem+this.getTargetSelectorSuffix(a)},d.selectorLegends=function(a){var b=this;return a.length?a.map(function(a){return b.selectorLegend(a)}):null};var h=d.isValue=function(a){return a||0===a},i=d.isFunction=function(a){return"function"==typeof a},j=d.isString=function(a){return"string"==typeof a},k=d.isUndefined=function(a){return"undefined"==typeof a},l=d.isDefined=function(a){return"undefined"!=typeof a},m=d.ceil10=function(a){return 10*Math.ceil(a/10)},n=d.asHalfPixel=function(a){return Math.ceil(a)+.5},o=d.diffDomain=function(a){return a[1]-a[0]},p=d.isEmpty=function(a){return!a||j(a)&&0===a.length||"object"==typeof a&&0===Object.keys(a).length},q=d.notEmpty=function(a){return Object.keys(a).length>0},r=d.getOption=function(a,b,c){return l(a[b])?a[b]:c},s=d.hasValue=function(a,b){var c=!1;return Object.keys(a).forEach(function(d){a[d]===b&&(c=!0)}),c},t=d.getPathBox=function(a){var b=a.getBoundingClientRect(),c=[a.pathSegList.getItem(0),a.pathSegList.getItem(1)],d=c[0].x,e=Math.min(c[0].y,c[1].y);return{x:d,y:e,width:b.width,height:b.height}};c.focus=function(a){var c,b=this.internal;a=b.mapToTargetIds(a),c=b.svg.selectAll(b.selectorTargets(a.filter(b.isTargetToShow,b))),this.revert(),this.defocus(),c.classed(g.focused,!0).classed(g.defocused,!1),b.hasArcType()&&b.expandArc(a,!0),b.toggleFocusLegend(a,!0),b.focusedTargetIds=a,b.defocusedTargetIds=b.defocusedTargetIds.filter(function(b){return a.indexOf(b)<0})},c.defocus=function(a){var c,b=this.internal;a=b.mapToTargetIds(a),c=b.svg.selectAll(b.selectorTargets(a.filter(b.isTargetToShow,b))),this.revert(),c.classed(g.focused,!1).classed(g.defocused,!0),b.hasArcType()&&b.unexpandArc(a),b.toggleFocusLegend(a,!1),b.focusedTargetIds=b.focusedTargetIds.filter(function(b){return a.indexOf(b)<0}),b.defocusedTargetIds=a},c.revert=function(a){var c,b=this.internal;a=b.mapToTargetIds(a),c=b.svg.selectAll(b.selectorTargets(a.filter(b.isTargetToShow,b))),c.classed(g.focused,!1).classed(g.defocused,!1),b.hasArcType()&&b.unexpandArc(a),b.revertLegend(),b.focusedTargetIds=[],b.defocusedTargetIds=[]},c.show=function(a,b){var d,c=this.internal;a=c.mapToTargetIds(a),b=b||{},c.removeHiddenTargetIds(a),d=c.svg.selectAll(c.selectorTargets(a)),d.transition().style("opacity",1,"important").call(c.endall,function(){d.style("opacity",null).style("opacity",1).classed(g.focused,!1).classed(g.defocused,!1)}),b.withLegend&&c.showLegend(a),c.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})},c.hide=function(a,b){var d,c=this.internal;a=c.mapToTargetIds(a),b=b||{},c.addHiddenTargetIds(a),d=c.svg.selectAll(c.selectorTargets(a)),d.transition().style("opacity",0,"important").call(c.endall,function(){d.style("opacity",null).style("opacity",0).classed(g.focused,!1).classed(g.defocused,!1)}),b.withLegend&&c.hideLegend(a),c.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})},c.toggle=function(a){var b=this.internal;b.isTargetToShow(a)?this.hide(a):this.show(a)},c.zoom=function(){},c.zoom.enable=function(a){var b=this.internal;b.config.zoom_enabled=a,b.updateAndRedraw()},c.unzoom=function(){var a=this.internal;a.brush.clear().update(),a.redraw({withUpdateXDomain:!0})},c.load=function(a){var b=this.internal,c=b.config;return a.xs&&b.addXs(a.xs),"classes"in a&&Object.keys(a.classes).forEach(function(b){c.data_classes[b]=a.classes[b]}),"categories"in a&&b.isCategorized()&&(c.axis_x_categories=a.categories),"cacheIds"in a&&b.hasCaches(a.cacheIds)?(b.load(b.getCaches(a.cacheIds),a.done),void 0):("unload"in a?b.unload(b.mapToTargetIds("boolean"==typeof a.unload&&a.unload?null:a.unload),function(){b.loadFromArgs(a)}):b.loadFromArgs(a),void 0)},c.unload=function(a){var b=this.internal;a=a||{},b.unload(b.mapToTargetIds(a.ids),function(){b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0}),a.done&&a.done()})},c.flow=function(a){var c,d,g,i,j,k,o,p,b=this.internal,e=[],f=b.getMaxDataCount(),m=0,n=0;if(a.json)d=b.convertJsonToData(a.json,a.keys);else if(a.rows)d=b.convertRowsToData(a.rows);else{if(!a.columns)return;d=b.convertColumnsToData(a.columns)}c=b.convertDataToTargets(d,!0),b.data.targets.forEach(function(a){var f,g,d=!1;for(f=0;f<c.length;f++)if(a.id===c[f].id){for(d=!0,a.values[a.values.length-1]&&(n=a.values[a.values.length-1].index+1),m=c[f].values.length,g=0;m>g;g++)c[f].values[g].index=n+g,b.isTimeSeries()||(c[f].values[g].x=n+g);a.values=a.values.concat(c[f].values),c.splice(f,1);break}d||e.push(a.id)}),b.data.targets.forEach(function(a){var c,d;for(c=0;c<e.length;c++)if(a.id===e[c])for(n=a.values[a.values.length-1].index+1,d=0;m>d;d++)a.values.push({id:a.id,index:n+d,x:b.isTimeSeries()?b.getOtherTargetX(n+d):n+d,value:null})}),b.data.targets.length&&c.forEach(function(a){var c,d=[];for(c=b.data.targets[0].values[0].index;n>c;c++)d.push({id:a.id,index:c,x:b.isTimeSeries()?b.getOtherTargetX(c):c,value:null});a.values.forEach(function(a){a.index+=n,b.isTimeSeries()||(a.x+=n)}),a.values=d.concat(a.values)}),b.data.targets=b.data.targets.concat(c),g=b.getMaxDataCount(),j=b.data.targets[0],k=j.values[0],l(a.to)?(m=0,p=b.isTimeSeries()?b.parseDate(a.to):a.to,j.values.forEach(function(a){a.x<p&&m++})):l(a.length)&&(m=a.length),f?1===f&&b.isTimeSeries()&&(o=(j.values[j.values.length-1].x-k.x)/2,i=[new Date(+k.x-o),new Date(+k.x+o)],b.updateXDomain(null,!0,!0,!1,i)):(o=b.isTimeSeries()?j.values.length>1?j.values[j.values.length-1].x-k.x:k.x-b.getXDomain(b.data.targets)[0]:1,i=[k.x-o,k.x],b.updateXDomain(null,!0,!0,!1,i)),b.updateTargets(b.data.targets),b.redraw({flow:{index:k.index,length:m,duration:h(a.duration)?a.duration:b.config.transition_duration,done:a.done,orgDataCount:f},withLegend:!0,withTransition:f>1,withTrimXDomain:!1})},d.generateFlow=function(a){var b=this,c=b.config,d=b.d3;return function(){var r,t,z,e=a.targets,f=a.flow,h=a.drawBar,i=a.drawLine,j=a.drawArea,k=a.cx,l=a.cy,m=a.xv,n=a.xForText,p=a.yForText,q=a.duration,s=1,u=f.index,v=f.length,w=b.getValueOnIndex(b.data.targets[0].values,u),x=b.getValueOnIndex(b.data.targets[0].values,u+v),y=b.x.domain(),A=f.duration||q,B=f.done||function(){},C=b.generateWait(),D=b.xgrid||d.selectAll([]),E=b.xgridLines||d.selectAll([]),F=b.mainRegion||d.selectAll([]),G=b.mainText||d.selectAll([]),H=b.mainBar||d.selectAll([]),I=b.mainLine||d.selectAll([]),J=b.mainArea||d.selectAll([]),K=b.mainCircle||d.selectAll([]);b.flowing=!0,b.data.targets.forEach(function(a){a.values.splice(0,v)}),z=b.updateXDomain(e,!0,!0),b.updateXGrid&&b.updateXGrid(!0),f.orgDataCount?r=1===f.orgDataCount||w.x===x.x?b.x(y[0])-b.x(z[0]):b.isTimeSeries()?b.x(y[0])-b.x(z[0]):b.x(w.x)-b.x(x.x):1!==b.data.targets[0].values.length?r=b.x(y[0])-b.x(z[0]):b.isTimeSeries()?(w=b.getValueOnIndex(b.data.targets[0].values,0),x=b.getValueOnIndex(b.data.targets[0].values,b.data.targets[0].values.length-1),r=b.x(w.x)-b.x(x.x)):r=o(z)/2,s=o(y)/o(z),t="translate("+r+",0) scale("+s+",1)",b.hideXGridFocus(),b.hideTooltip(),d.transition().ease("linear").duration(A).each(function(){C.add(b.axes.x.transition().call(b.xAxis)),C.add(H.transition().attr("transform",t)),C.add(I.transition().attr("transform",t)),C.add(J.transition().attr("transform",t)),C.add(K.transition().attr("transform",t)),C.add(G.transition().attr("transform",t)),C.add(F.filter(b.isRegionOnX).transition().attr("transform",t)),C.add(D.transition().attr("transform",t)),C.add(E.transition().attr("transform",t))}).call(C,function(){var a,d=[],e=[],f=[];if(v){for(a=0;v>a;a++)d.push("."+g.shape+"-"+(u+a)),e.push("."+g.text+"-"+(u+a)),f.push("."+g.eventRect+"-"+(u+a));b.svg.selectAll("."+g.shapes).selectAll(d).remove(),b.svg.selectAll("."+g.texts).selectAll(e).remove(),b.svg.selectAll("."+g.eventRects).selectAll(f).remove(),b.svg.select("."+g.xgrid).remove()}D.attr("transform",null).attr(b.xgridAttr),E.attr("transform",null),E.select("line").attr("x1",c.axis_rotated?0:m).attr("x2",c.axis_rotated?b.width:m),E.select("text").attr("x",c.axis_rotated?b.width:0).attr("y",m),H.attr("transform",null).attr("d",h),I.attr("transform",null).attr("d",i),J.attr("transform",null).attr("d",j),K.attr("transform",null).attr("cx",k).attr("cy",l),G.attr("transform",null).attr("x",n).attr("y",p).style("fill-opacity",b.opacityForText.bind(b)),F.attr("transform",null),F.select("rect").filter(b.isRegionOnX).attr("x",b.regionX.bind(b)).attr("width",b.regionWidth.bind(b)),c.interaction_enabled&&b.redrawEventRect(),B(),b.flowing=!1})}},c.selected=function(a){var b=this.internal,c=b.d3;return c.merge(b.main.selectAll("."+g.shapes+b.getTargetSelectorSuffix(a)).selectAll("."+g.shape).filter(function(){return c.select(this).classed(g.SELECTED)}).map(function(a){return a.map(function(a){var b=a.__data__;return b.data?b.data:b})}))},c.select=function(a,b,c){var d=this.internal,e=d.d3,f=d.config;f.data_selection_enabled&&d.main.selectAll("."+g.shapes).selectAll("."+g.shape).each(function(h,i){var j=e.select(this),k=h.data?h.data.id:h.id,m=d.getToggle(this,h).bind(d),n=f.data_selection_grouped||!a||a.indexOf(k)>=0,o=!b||b.indexOf(i)>=0,p=j.classed(g.SELECTED);j.classed(g.line)||j.classed(g.area)||(n&&o?f.data_selection_isselectable(h)&&!p&&m(!0,j.classed(g.SELECTED,!0),h,i):l(c)&&c&&p&&m(!1,j.classed(g.SELECTED,!1),h,i))})},c.unselect=function(a,b){var c=this.internal,d=c.d3,e=c.config;e.data_selection_enabled&&c.main.selectAll("."+g.shapes).selectAll("."+g.shape).each(function(f,h){var i=d.select(this),j=f.data?f.data.id:f.id,k=c.getToggle(this,f).bind(c),l=e.data_selection_grouped||!a||a.indexOf(j)>=0,m=!b||b.indexOf(h)>=0,n=i.classed(g.SELECTED);i.classed(g.line)||i.classed(g.area)||l&&m&&e.data_selection_isselectable(f)&&n&&k(!1,i.classed(g.SELECTED,!1),f,h)})},c.transform=function(a,b){var c=this.internal,d=["pie","donut"].indexOf(a)>=0?{withTransform:!0}:null;c.transformTo(b,a,d)},d.transformTo=function(a,b,c){var d=this,e=!d.hasArcType(),f=c||{withTransitionForAxis:e};f.withTransitionForTransform=!1,d.transiting=!1,d.setTargetType(a,b),d.updateAndRedraw(f)},c.groups=function(a){var b=this.internal,c=b.config;return k(a)?c.data_groups:(c.data_groups=a,b.redraw(),c.data_groups)},c.xgrids=function(a){var b=this.internal,c=b.config;return a?(c.grid_x_lines=a,b.redraw(),c.grid_x_lines):c.grid_x_lines},c.xgrids.add=function(a){var b=this.internal;return this.xgrids(b.config.grid_x_lines.concat(a?a:[]))},c.xgrids.remove=function(a){var b=this.internal;b.removeGridLines(a,!0)},c.ygrids=function(a){var b=this.internal,c=b.config;return a?(c.grid_y_lines=a,b.redraw(),c.grid_y_lines):c.grid_y_lines},c.ygrids.add=function(a){var b=this.internal;return this.ygrids(b.config.grid_y_lines.concat(a?a:[]))},c.ygrids.remove=function(a){var b=this.internal;b.removeGridLines(a,!1)},c.regions=function(a){var b=this.internal,c=b.config;return a?(c.regions=a,b.redraw(),c.regions):c.regions},c.regions.add=function(a){var b=this.internal,c=b.config;return a?(c.regions=c.regions.concat(a),b.redraw(),c.regions):c.regions},c.regions.remove=function(a){var d,e,f,b=this.internal,c=b.config;return a=a||{},d=b.getOption(a,"duration",c.transition_duration),e=b.getOption(a,"classes",[g.region]),f=b.main.select("."+g.regions).selectAll(e.map(function(a){return"."+a})),(d?f.transition().duration(d):f).style("opacity",0).remove(),c.regions=c.regions.filter(function(a){var b=!1;return a["class"]?(a["class"].split(" ").forEach(function(a){e.indexOf(a)>=0&&(b=!0)}),!b):!0}),c.regions},c.data=function(a){var b=this.internal.data.targets.filter(function(b){return b.id===a});return b.length>0?b[0]:null},c.data.values=function(a){var b=this.data(a);return b?b.values.map(function(a){return a.value}):null},c.data.names=function(a){var b=this.internal,c=b.config;return arguments.length?(Object.keys(a).forEach(function(b){c.data_names[b]=a[b]}),b.redraw({withLegend:!0}),c.data_names):c.data_names},c.data.colors=function(a){var b=this.internal,c=b.config;return arguments.length?(Object.keys(a).forEach(function(b){c.data_colors[b]=a[b]}),b.redraw({withLegend:!0}),c.data_colors):c.data_colors},c.category=function(a,b){var c=this.internal,d=c.config;return arguments.length>1&&(d.axis_x_categories[a]=b,c.redraw()),d.axis_x_categories[a]},c.categories=function(a){var b=this.internal,c=b.config;return arguments.length?(c.axis_x_categories=a,b.redraw(),c.axis_x_categories):c.axis_x_categories},c.color=function(a){var b=this.internal;return b.color(a)},c.x=function(a){var b=this.internal;return arguments.length&&(b.updateTargetX(b.data.targets,a),b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),b.data.xs},c.xs=function(a){var b=this.internal;return arguments.length&&(b.updateTargetXs(b.data.targets,a),b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),b.data.xs},c.axis=function(){},c.axis.labels=function(a){var b=this.internal;arguments.length&&(Object.keys(a).forEach(function(c){b.setAxisLabelText(c,a[c])}),b.updateAxisLabels())},c.axis.max=function(a){var b=this.internal,c=b.config;return arguments.length?("object"==typeof a?(h(a.x)&&(c.axis_x_max=a.x),h(a.y)&&(c.axis_y_max=a.y),h(a.y2)&&(c.axis_y2_max=a.y2)):c.axis_y_max=c.axis_y2_max=a,b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0}),void 0):{x:c.axis_x_max,y:c.axis_y_max,y2:c.axis_y2_max}},c.axis.min=function(a){var b=this.internal,c=b.config;return arguments.length?("object"==typeof a?(h(a.x)&&(c.axis_x_min=a.x),h(a.y)&&(c.axis_y_min=a.y),h(a.y2)&&(c.axis_y2_min=a.y2)):c.axis_y_min=c.axis_y2_min=a,b.redraw({withUpdateOrgXDomain:!0,withUpdateXDomain:!0}),void 0):{x:c.axis_x_min,y:c.axis_y_min,y2:c.axis_y2_min}},c.axis.range=function(a){return arguments.length?(l(a.max)&&this.axis.max(a.max),l(a.min)&&this.axis.min(a.min),void 0):{max:this.axis.max(),min:this.axis.min()}},c.legend=function(){},c.legend.show=function(a){var b=this.internal;b.showLegend(b.mapToTargetIds(a)),b.updateAndRedraw({withLegend:!0})},c.legend.hide=function(a){var b=this.internal;b.hideLegend(b.mapToTargetIds(a)),b.updateAndRedraw({withLegend:!0})},c.resize=function(a){var b=this.internal,c=b.config;c.size_width=a?a.width:null,c.size_height=a?a.height:null,this.flush()},c.flush=function(){var a=this.internal;a.updateAndRedraw({withLegend:!0,withTransition:!1,withTransitionForTransform:!1})},c.destroy=function(){var b=this.internal;b.data.targets=void 0,b.data.xs={},b.selectChart.classed("c3",!1).html(""),a.onresize=null},c.tooltip=function(){},c.tooltip.show=function(a){var c,d,b=this.internal;a.mouse&&(d=a.mouse),a.data?b.isMultipleX()?(d=[b.x(a.data.x),b.getYScale(a.data.id)(a.data.value)],c=null):c=h(a.data.index)?a.data.index:b.getIndexByX(a.data.x):"undefined"!=typeof a.x?c=b.getIndexByX(a.x):"undefined"!=typeof a.index&&(c=a.index),b.dispatchEvent("mouseover",c,d),b.dispatchEvent("mousemove",c,d)},c.tooltip.hide=function(){this.internal.dispatchEvent("mouseout",0)},"function"==typeof define&&define.amd?define("c3",["d3"],b):"undefined"!=typeof exports&&"undefined"!=typeof module?module.exports=b:a.c3=b}(window);