diff --git a/c3.js b/c3.js index 84ce3cd..38a4353 100644 --- a/c3.js +++ b/c3.js @@ -71,7 +71,7 @@ var d3 = window.d3 ? window.d3 : window.require ? window.require("d3") : undefined; - var c3 = { data : {}, axis: {} }, + var c3 = { data : {}, axis: {}, legend: {} }, cache = {}; /*-- Handle Config --*/ @@ -295,7 +295,7 @@ }; })(); - var hiddenTargetIds = []; + var hiddenTargetIds = [], hiddenLegendIds = []; /*-- Set Chart Params --*/ @@ -329,10 +329,11 @@ return "url(" + document.URL.split('#')[0] + "#" + id + ")"; } - function transformMain() { + function transformMain(withTransition) { + var duration = withTransition !== false ? 250 : 0; main.attr("transform", translate.main); - main.select('.' + CLASS.axisX).attr("transform", translate.x); - main.select('.' + CLASS.axisY).attr("transform", translate.y); + main.select('.' + CLASS.axisX).transition().duration(duration).attr("transform", translate.x); + main.select('.' + CLASS.axisY).transition().duration(duration).attr("transform", translate.y); main.select('.' + CLASS.axisY2).attr("transform", translate.y2); main.select('.' + CLASS.chartArcs).attr("transform", translate.arc); } @@ -1460,6 +1461,9 @@ function isTargetToShow(targetId) { return hiddenTargetIds.indexOf(targetId) < 0; } + function isLegendToShow(targetId) { + return hiddenLegendIds.indexOf(targetId) < 0; + } function filterTargetsToShow(targets) { return targets.filter(function (t) { return isTargetToShow(t.id); }); } @@ -1499,6 +1503,12 @@ function removeHiddenTargetIds(targetIds) { hiddenTargetIds = hiddenTargetIds.filter(function (id) { return targetIds.indexOf(id) < 0; }); } + function addHiddenLegendIds(targetIds) { + hiddenLegendIds = hiddenLegendIds.concat(targetIds); + } + function removeHiddenLegendIds(targetIds) { + hiddenLegendIds = hiddenLegendIds.filter(function (id) { return targetIds.indexOf(id) < 0; }); + } function getValuesAsIdKeyed(targets) { var ys = {}; targets.forEach(function (t) { @@ -1552,6 +1562,8 @@ } function selectorTarget(id) { return '.' + CLASS.target + getTargetSelectorSuffix(id); } function selectorTargets(ids) { return ids.map(function (id) { return selectorTarget(id); }); } + function selectorLegend(id) { return '.' + CLASS.legendItem + getTargetSelectorSuffix(id); } + function selectorLegends(ids) { return ids.map(function (id) { return selectorLegend(id); }); } function initialOpacity(d) { return d.value !== null && withoutFadeIn[d.id] ? 1 : 0; @@ -2400,6 +2412,10 @@ .style("z-index", "10") .style("display", "none"); + // MEMO: call here to update legend box and tranlate for all + // MEMO: translate will be upated by this, so transform not needed in updateLegend() + updateLegend(mapToIds(c3.data.targets), {withTransform: false, withTransitionForTransform: false}); + /*-- Main Region --*/ // Add Axis @@ -2418,6 +2434,7 @@ main.append("g") .attr("class", CLASS.axisY) .attr("clip-path", __axis_rotated ? clipPathForYAxis : "") + .attr("transform", translate.y) .append("text") .attr("class", CLASS.axisYLabel) .attr("transform", __axis_rotated ? "" : "rotate(-90)") @@ -2561,7 +2578,7 @@ } // Draw with targets - updateAndRedraw({withTransform: true, withLegend: true, withTransitionForAxis: false}); + redraw({withTransform: true, withUpdateXDomain: true, withUpdateOrgXDomain: true, withTransitionForAxis: false}); // Show tooltip if needed if (__tooltip_init_show) { @@ -2879,11 +2896,11 @@ } function redraw(options) { - var xgrid, xgridData, xgridLines, xgridLine, ygrid, ygridLines, ygridLine; + var xaxis, yaxis, xgrid, xgridData, xgridLines, xgridLine, ygrid, ygridLines, ygridLine; var mainCircle, mainBar, mainRegion, mainText, contextBar, eventRectUpdate; var barIndices = getBarIndices(), maxDataCountTarget; var rectX, rectW; - var withY, withSubchart, withTransition, withTransitionForExit, withTransitionForAxis, withTransform, withUpdateXDomain, withUpdateOrgXDomain, withLegend; + var withY, withSubchart, withTransition, withTransitionForExit, withTransitionForAxis, withTransitionForHorizontalAxis, withTransform, withUpdateXDomain, withUpdateOrgXDomain, withLegend; var hideAxis = hasArcType(c3.data.targets); var drawBar, drawBarOnSub, xForText, yForText; var duration, durationForExit, durationForAxis; @@ -2905,6 +2922,7 @@ withTransitionForExit = isDefined(options.withTransitionForExit) ? options.withTransitionForExit : withTransition; withTransitionForAxis = isDefined(options.withTransitionForAxis) ? options.withTransitionForAxis : withTransition; + withTransitionForHorizontalAxis = isDefined(options.withTransitionForHorizontalAxis) ? options.withTransitionForHorizontalAxis : withTransition; duration = withTransition ? __transition_duration : 0; durationForExit = withTransitionForExit ? duration : 0; @@ -2912,7 +2930,7 @@ // update legend and transform each g if (withLegend && __legend_show) { - updateLegend(c3.data.targets, options); + updateLegend(mapToIds(c3.data.targets), options); } if (withUpdateOrgXDomain) { @@ -2927,19 +2945,30 @@ if (withUpdateXDomain) { x.domain(brush.empty() ? orgXDomain : brush.extent()); if (__zoom_enabled) { zoom.scale(x).updateScaleExtent(); } - // update axis tick values according to options, except for scatter plot - if (! hasScatterType(targetsToShow)) { // TODO: fix this - tickValues = generateTickValues(mapTargetsToUniqueXs(targetsToShow)).sort(); - xAxis.tickValues(tickValues); - subXAxis.tickValues(tickValues); - } } y.domain(getYDomain(targetsToShow, 'y')); y2.domain(getYDomain(targetsToShow, 'y2')); - // axis - main.select('.' + CLASS.axisX).style("opacity", hideAxis ? 0 : 1).transition().duration(durationForAxis).call(xAxis); - main.select('.' + CLASS.axisY).style("opacity", hideAxis ? 0 : 1).transition().duration(durationForAxis).call(yAxis); + // update axis tick values according to options, except for scatter plot + if (! hasScatterType(targetsToShow)) { // TODO: fix this + tickValues = generateTickValues(mapTargetsToUniqueXs(targetsToShow)).sort(); + xAxis.tickValues(tickValues); + subXAxis.tickValues(tickValues); + } + + // x axis + xaxis = main.select('.' + CLASS.axisX).style("opacity", hideAxis ? 0 : 1); + if (__axis_rotated || withTransitionForHorizontalAxis) { + xaxis = xaxis.transition().duration(durationForAxis); + } + xaxis.call(xAxis); + // y axis + yaxis = main.select('.' + CLASS.axisY).style("opacity", hideAxis ? 0 : 1); + if (!__axis_rotated || withTransitionForHorizontalAxis) { + yaxis = yaxis.transition().duration(durationForAxis); + } + yaxis.call(yAxis); + // y2 axis main.select('.' + CLASS.axisY2).style("opacity", hideAxis ? 0 : 1).transition().duration(durationForAxis).call(yAxis2); // show/hide if manual culling needed @@ -3343,10 +3372,12 @@ } function updateAndRedraw(options) { - options = isDefined(options) ? options : {}; + options = options || {}; + // same with redraw options.withTransition = isDefined(options.withTransition) ? options.withTransition : true; options.withTransform = isDefined(options.withTransform) ? options.withTransform : false; options.withLegend = isDefined(options.withLegend) ? options.withLegend : false; + // NOT same with redraw options.withUpdateXDomain = true; options.withUpdateOrgXDomain = true; options.withTransitionForExit = false; @@ -3578,7 +3609,7 @@ var legendItem, isTarget, notTarget; if (!__legend_show) { return; } legendItem = legend.selectAll('.' + CLASS.legendItem); - isTarget = function (d) { return !id || d === id; }; + isTarget = function (d) { return (!id || d === id); }; notTarget = function (d) { return !isTarget(d); }; legendItem.filter(notTarget).transition().duration(100).style('opacity', focus ? 0.3 : 1); legendItem.filter(isTarget).transition().duration(100).style('opacity', focus ? 1 : 0.3); @@ -3595,16 +3626,32 @@ .transition().duration(100) .style('opacity', 1); } + function showLegend(targetIds) { + removeHiddenLegendIds(targetIds); + legend.selectAll(selectorLegends(targetIds)) + .style('visibility', 'visible') + .transition() + .style('opacity', 1); + updateLegend(mapToIds(c3.data.targets)); + } + function hideLegend(targetIds) { + addHiddenLegendIds(targetIds); + legend.selectAll(selectorLegends(targetIds)) + .style('opacity', 0) + .style('visibility', 'hidden'); + updateLegend(mapToIds(c3.data.targets)); + } - function updateLegend(targets, options) { - var ids = mapToIds(targets), l; + function updateLegend(targetIds, options) { var xForLegend, xForLegendText, xForLegendRect, yForLegend, yForLegendText, yForLegendRect; var paddingTop = 4, paddingRight = 26, maxWidth = 0, maxHeight = 0, posMin = 10; - var totalLength = 0, offsets = {}, widths = {}, heights = {}, margins = {}, steps = {}, step = 0; - var withTransition; + var l, totalLength = 0, offsets = {}, widths = {}, heights = {}, margins = [0], steps = {}, step = 0; + var withTransition, withTransitionForTransform, withTransformAll; options = isUndefined(options) ? {} : options; withTransition = isDefined(options.withTransition) ? options.withTransition : true; + withTransitionForTransform = isDefined(options.withTransitionForTransform) ? options.withTransitionForTransform : true; + withTransformAll = isDefined(options.withTransformAll) ? options.withTransformAll : true; function updatePositions(textElement, id, reset) { var box = textElement.getBBox(), @@ -3637,6 +3684,11 @@ maxHeight = 0; } + if (!isLegendToShow(id)) { + widths[id] = heights[id] = steps[id] = offsets[id] = 0; + return; + } + widths[id] = itemWidth; heights[id] = itemHeight; @@ -3647,11 +3699,11 @@ if (__legend_equally) { Object.keys(widths).forEach(function (id) { widths[id] = maxWidth; }); Object.keys(heights).forEach(function (id) { heights[id] = maxHeight; }); - margin = (areaLength - maxLength * ids.length) / 2; + margin = (areaLength - maxLength * targetIds.length) / 2; if (margin < posMin) { totalLength = 0; step = 0; - ids.forEach(function (id) { updateValues(id); }); + targetIds.forEach(function (id) { updateValues(id); }); } else { updateValues(id, true); @@ -3675,7 +3727,7 @@ // Define g for legend area l = legend.selectAll('.' + CLASS.legendItem) - .data(ids) + .data(targetIds) .enter().append('g') .attr('class', function (id) { return generateClass(CLASS.legendItem, id); }) .style('cursor', 'pointer') @@ -3711,7 +3763,7 @@ .attr('height', 10); legend.selectAll('text') - .data(ids) + .data(targetIds) .text(function (id) { return isDefined(__data_names[id]) ? __data_names[id] : id; }) // MEMO: needed for update .each(function (id, i) { updatePositions(this, id, i === 0); }) .transition().duration(withTransition ? 250 : 0) @@ -3719,13 +3771,13 @@ .attr('y', yForLegendText); legend.selectAll('rect.' + CLASS.legendItemEvent) - .data(ids) + .data(targetIds) .transition().duration(withTransition ? 250 : 0) .attr('x', xForLegendRect) .attr('y', yForLegendRect); legend.selectAll('rect.' + CLASS.legendItemTile) - .data(ids) + .data(targetIds) .transition().duration(withTransition ? 250 : 0) .attr('x', xForLegend) .attr('y', yForLegend); @@ -3739,7 +3791,9 @@ updateScales(); updateSvgSize(); // Update g positions - transformAll(false); + if (withTransformAll) { + transformAll(withTransitionForTransform); + } } /*-- Event Handling --*/ @@ -3809,22 +3863,36 @@ revertLegend(); }; - c3.show = function (targetIds) { + c3.show = function (targetIds, options) { targetIds = mapToTargetIds(targetIds); + options = options || {}; + removeHiddenTargetIds(targetIds); svg.selectAll(selectorTargets(targetIds)) .transition() .style('opacity', 1); - redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withLegend: false}); + + if (options.withLegend) { + showLegend(targetIds); + } + + redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withTransitionForHorizontalAxis: false}); }; - c3.hide = function (targetIds) { + c3.hide = function (targetIds, options) { targetIds = mapToTargetIds(targetIds); + options = options || {}; + addHiddenTargetIds(targetIds); svg.selectAll(selectorTargets(targetIds)) .transition() .style('opacity', 0); - redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withLegend: false}); + + if (options.withLegend) { + hideLegend(targetIds); + } + + redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withTransitionForHorizontalAxis: false}); }; c3.toggle = function (targetId) { @@ -4025,7 +4093,7 @@ Object.keys(names).forEach(function (id) { __data_names[id] = names[id]; }); - updateLegend(c3.data.targets, {withTransition: true}); + updateLegend(mapToIds(c3.data.targets), {withTransition: true}); return __data_names; }; @@ -4082,6 +4150,17 @@ } }; + c3.legend.show = function (targetIds) { + if (!__legend_show) { return; } + showLegend(mapToTargetIds(targetIds)); + redraw({withTransitionForHorizontalAxis: false}); + }; + c3.legend.hide = function (targetIds) { + if (!__legend_show) { return; } + hideLegend(mapToTargetIds(targetIds)); + redraw({withTransitionForHorizontalAxis: false}); + }; + c3.resize = function (size) { __size_width = size ? size.width : null; __size_height = size ? size.height : null; diff --git a/c3.min.js b/c3.min.js index ba6055a..d34dd25 100644 --- a/c3.min.js +++ b/c3.min.js @@ -1,2 +1,3 @@ -!function(a){"use strict";function b(a){return a||0===a}function c(a){return"undefined"==typeof a}function d(a){return"undefined"!=typeof a}var e={version:"0.1.28"},f={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",selectedCircle:"c3-selected-circle",selectedCircles:"c3-selected-circles",eventRect:"c3-event-rect",eventRects:"c3-event-rects",zoomRect:"c3-zoom-rect",brush:"c3-brush",focused:"c3-focused",region:"c3-region",regions:"c3-regions",tooltip:"c3-tooltip",tooltipName:"c3-tooltip-name",shape:"c3-shape",shapes:"c3-shapes",line:"c3-line",bar:"c3-bar",bars:"c3-bars",circle:"c3-circle",circles:"c3-circles",arc:"c3-arc",area:"c3-area",text:"c3-text",texts:"c3-texts",grid:"c3-grid",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",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",legendItem:"c3-legend-item",legendItemEvent:"c3-legend-item-event",legendItemTile:"c3-legend-item-tile",dragarea:"c3-dragarea",EXPANDED:"_expanded_",SELECTED:"_selected_",INCLUDED:"_included_"};e.generate=function(e){function g(a,b){if(!(a in e))throw Error(b)}function h(a,b){var c,d,f,g=e;for(c=0;cnf&&(nf=0),0>pf&&(pf=0),lf={top:yg?kf.top:sf-sg-(ci?0:tf),right:0/0,bottom:20+(ci?0:tf),left:yg?gi:kf.left},of=yg?kf.left-gi-hi:nf,qf=yg?pf:sf-lf.top-lf.bottom,0>of&&(of=0),0>qf&&(qf=0),mf={top:ci?0:sf-tf,right:0/0,bottom:0,left:ci?rf-uf:0},p(),ci&&Md(Ye.data.targets)&&(mf.left=nf/2+wf)}function o(){qi.select("line."+f.xgridFocus).attr("x1",yg?0:-10).attr("x2",yg?nf:-10).attr("y1",yg?-10:kf.top).attr("y2",yg?-10:pf)}function p(){wf=pf/2,vf=.95*wf,xf=Ld(Ye.data.targets)?.6*vf:0}function q(){var a=yg?f.axisX:f.axisY,b=Xe.select("."+a).node(),c=b?b.getBoundingClientRect():{right:0},d=Xe.select($e).node().getBoundingClientRect(),e=c.right-d.left-t();return e>0?e:0}function r(){return _e?_e:x()}function s(){var a=af?af:y();return a>0?a:320}function t(){return Md(Ye.data.targets)?0:bf?bf:yg||!Lg||Qg?1:v("y")}function u(){var a=1;return Md(Ye.data.targets)?0:cf?cf:ci?uf+(Ug&&!yg?v("y2"):a):Ug?Zg||yg?a:v("y2"):a}function v(a){var b=gb(a);return b.isInner?20+zb(a):40+zb(a)}function w(a){return"y"!==a||Lg?"y2"!==a||Ug?(gb(a).isInner?30:40)+("y2"===a?-10:0):ii:ug&&!ci?10:1}function x(){return+Xe.select($e).style("width").replace("px","")}function y(){return+Xe.select($e).style("height").replace("px","")}function z(a){return a?-5:-(kf.left-1)}function A(a){return a?-20:-1}function B(){return z(!yg)}function C(){return A(!yg)}function D(){return z(yg)}function E(){return A(yg)}function F(a){return a?nf+2+4:kf.left+20}function G(a){return a?80:pf+2}function H(){return F(!yg)}function I(){return G(!yg)}function J(){return F(yg)}function K(){return G(yg)}function L(){var a=yg?pf:nf,b=tc(),c=Vb()*(Id(Ye.data.targets)?(b-(Ph?.25:1))/b:.98);return b>1?a*c/(b-1):a}function M(a){di=a}function N(a){ei=a}function O(a){fi=a}function P(){return ug?ci?ei*(di+1):rf:0}function Q(){return ug?ci?sf:fi*(di+1):0}function R(){var a,b=!Kf;Cf=yg?1:0,Df=yg?pf:nf,Ef=yg?0:pf,Ff=yg?nf:1,Gf=Cf,Hf=Df,If=yg?0:qf,Jf=yg?of:1,Kf=T(Cf,Df,b?void 0:Kf.domain(),function(){return Qf.tickOffset()}),Lf=U(Ef,Ff),Mf=U(Ef,Ff),Nf=T(Cf,Df,vi,function(a){return a%1?0:Tf.tickOffset()}),Of=U(If,Jf),Pf=U(If,Jf),a=$(),Qf=X(Kf,Zh,a),Tf=X(Nf,ai,a),Rf=Y(Lf,$h,Rg,Tg),Sf=Y(Mf,_h,$g,ah),b||(ji.scale(Nf),df&&ni.scale(Kf)),S()}function S(){yf=Db(),zf=Eb(),Af=Eb(.98)}function T(a,b,e,f){var g=(Oh?Xe.time.scale():Xe.scale.linear()).range([a,b]);if(g.orgDomain=function(){return g.domain()},d(e)&&g.domain(e),c(f)&&(f=function(){return 0}),Ph){var h,i=g;g=function(a){return i(a)+f(a)};for(h in i)g[h]=i[h];g.orgDomain=function(){return i.domain()},g.domain=function(a){return arguments.length?(i.domain(a),g):(a=i.domain(),[a[0],a[1]+1])}}return g}function U(a,b){return Xe.scale.linear().range([a,b])}function V(a){return"y2"===Z(a)?Mf:Lf}function W(a){return"y2"===Z(a)?Pf:Of}function X(a,b,c){var d=(Ph?Bb():Xe.svg.axis()).scale(a).orient(b);return d.tickFormat(c),Ph?d.tickCentered(Bg):d.tickOffset=function(){var a=yg?pf:nf;return a*Vb()/tc()/2},Ph&&d.categories(Ag),d}function Y(a,b,c,d){return Xe.svg.axis().scale(a).orient(b).tickFormat(c).ticks(d).outerTickSize(0)}function Z(a){return a in $f?$f[a]:"y"}function $(){var a=Oh?Xh:Ph?Jc:function(a){return 0>a?a.toFixed(0):a};return Cg&&("function"==typeof Cg?a=Cg:Oh&&(a=function(a){return Xe.time.format(Cg)(a)})),a}function _(a){var b;return"y"===a?b=Pg:"y2"===a?b=Yg:"x"===a&&(b=Kg),b}function ab(a){var b=_(a);return"string"==typeof b?b:b?b.text:null}function bb(a,b){var c=_(a);"string"==typeof c?"y"===a?Pg=b:"y2"===a?Yg=b:"x"===a&&(Kg=b):c&&(c.text=b)}function cb(a,b){var c=_(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}}function db(){return cb("x",yg?"inner-top":"inner-right")}function eb(){return cb("y",yg?"inner-right":"inner-top")}function fb(){return cb("y2",yg?"inner-right":"inner-top")}function gb(a){return"y2"===a?fb():"y"===a?eb():db()}function hb(){return ab("x")}function ib(){return ab("y")}function jb(){return ab("y2")}function kb(a,b){return a?b.isLeft?0:b.isCenter?nf/2:nf:b.isBottom?-pf:b.isMiddle?-pf/2:0}function lb(a,b){return a?b.isLeft?"0.5em":b.isRight?"-0.5em":"0":b.isTop?"-0.5em":b.isBottom?"0.5em":"0"}function mb(a,b){return a?b.isLeft?"start":b.isCenter?"middle":"end":b.isBottom?"start":b.isMiddle?"middle":"end"}function nb(){return kb(!yg,db())}function ob(){return kb(yg,eb())}function pb(){return kb(yg,fb())}function qb(){return lb(!yg,db())}function rb(){return lb(yg,eb())}function sb(){return lb(yg,fb())}function tb(){var a=db();return yg?a.isInner?"1.2em":-30-zb("x"):a.isInner?"-0.5em":"3em"}function ub(){var a=eb();return yg?a.isInner?"-0.5em":"3em":a.isInner?"1.2em":-20-zb("y")}function vb(){var a=fb();return yg?a.isInner?"1.2em":"-2.2em":a.isInner?"-0.5em":30+zb("y2")}function wb(){return mb(!yg,db())}function xb(){return mb(yg,eb())}function yb(){return mb(yg,fb())}function zb(a){var b=0,c="x"===a?f.axisX:"y"===a?f.axisY:f.axisY2;return Xe.selectAll("."+c+" .tick text").each(function(){var a=this.getBBox();bb?20:b}function Ab(){qi.select("."+f.axisX+" ."+f.axisXLabel).attr("x",nb).text(hb),qi.select("."+f.axisY+" ."+f.axisYLabel).attr("x",ob).attr("dy",ub).text(ib),qi.select("."+f.axisY2+" ."+f.axisY2Label).attr("x",pb).attr("dy",vb).text(jb)}function Bb(){function a(a,b){a.attr("transform",function(a){return"translate("+(b(a)+p)+", 0)"})}function b(a,b){a.attr("transform",function(a){return"translate(0,"+b(a)+")"})}function c(a){var b=a[0],c=a[a.length-1];return c>b?[b,c]:[c,b]}function d(a){for(var b=[],c=Math.ceil(a[0]);c0&&b[0]>0&&b.unshift(b[0]-(b[1]-b[0])),b}function e(a,b){var c=a.length-1;return o>=c||b%Math.ceil(c/o)===0}function f(a){return a0)for(g=Hc(a),b=0;b=0}),0!==e.length)for(d=e[0],g&&i[d]&&i[d].forEach(function(a,b){i[d][b]=0>a?a:0}),c=1;c0||(i[d][b]+=+a)});return Xe.min(Object.keys(i).map(function(a){return Xe.min(i[a])}))}function Tb(a){var b,c,d,e,f,g,h=vc(a),i=Fc(a);if(Zf.length>0)for(g=Ic(a),b=0;b=0}),0!==e.length)for(d=e[0],g&&i[d]&&i[d].forEach(function(a,b){i[d][b]=a>0?a:0}),c=1;c+a||(i[d][b]+=+a)});return Xe.max(Object.keys(i).map(function(a){return Xe.max(i[a])}))}function Ub(a,c){var d,e,f,g,h,i,j,k,l=a.filter(function(a){return Z(a.id)===c}),m="y2"===c?Wg:Ng,n="y2"===c?Vg:Mg,o=b(m)?m:Sb(l),p=b(n)?n:Tb(l),q="y2"===c?Xg:Og,r=dd()&&yg;return 0===l.length?"y2"===c?Mf.domain():Lf.domain():(o===p&&(0>o?p=0:o=0),d=Math.abs(p-o),e=f=g=r?0:.1*d,q&&(h=Math.max(Math.abs(o),Math.abs(p)),p=h-q,o=q-h),r&&(i=ed(o,p),j=$b(Lf.range()),k=[i[0]/j,i[1]/j],f+=d*(k[1]/(1-k[0]-k[1])),g+=d*(k[0]/(1-k[0]-k[1]))),"y"===c&&Sg&&(f=b(Sg.top)?Sg.top:e,g=b(Sg.bottom)?Sg.bottom:e),"y2"===c&&_g&&(f=b(_g.top)?_g.top:e,g=b(_g.bottom)?_g.bottom:e),Id(l)&&!Hc(l)&&(g=o),[o-g,p+f])}function Vb(a){var b=$b(vi),c=$b(Kf.domain());return a||0===c?1:b/c}function Wb(a){return Ig?Ig:Xe.min(a,function(a){return Xe.min(a.values,function(a){return a.x})})}function Xb(a){return Hg?Hg:Xe.max(a,function(a){return Xe.max(a.values,function(a){return a.x})})}function Yb(a,b){var c,d,e=b[0],f=b[1],g=Math.abs(e-f);return Ph?d=0:Id(a)?(c=tc(),d=c>1?g/(c-1)/2:.5):d=.01*g,d}function Zb(a){var b=[Wb(a),Xb(a)],c=b[0],d=b[1],e=Yb(a,b),f=Oh?new Date(c.getTime()-e):c-e,g=Oh?new Date(d.getTime()+e):d+e;return[f,g]}function $b(a){return a[1]-a[0]}function _b(a){for(var b=0;bd?0:d}function ec(a){return Uf&&a===Uf||ae(Vf)&&be(Vf,a)}function fc(a){return!ec(a)}function gc(a){return Uf?Uf:ae(Vf)?Vf[a]:null}function hc(a,b){return a in Ye.data.x&&Ye.data.x[a]&&Ye.data.x[a][b]?Ye.data.x[a][b]:b}function ic(a){Object.keys(a).forEach(function(b){Vf[b]=a[b]})}function jc(a){var b;return a&&(b=Yf[a.id],a.name=b?b:a.id),a}function kc(a,b){a.forEach(function(a){a.values.forEach(function(c,d){c.x=mc(b[d],a.id,d)}),Ye.data.x[a.id]=b})}function lc(a,b){a.forEach(function(a){b[a.id]&&kc([a],b[a.id])})}function mc(a,b,c){var d;return d=Oh?a?a instanceof Date?a:Yd(a):Yd(hc(b,c)):Qh&&!Ph?a?+a:hc(b,c):c}function nc(a){var b,c,d=a[0],e={},f=[];for(b=1;b=0&&(Ye.data.x[b]=a.map(function(a){return a[c]})):Ye.data.x[b]=a.map(function(a,b){return b})}),c.forEach(function(a){if(!Ye.data.x[a])throw new Error('x is not defined for id = "'+a+'".')}),b=c.map(function(b,c){var d=Xf(b);return{id:d,id_org:b,values:a.map(function(a,e){var f=gc(b),g=a[f],h=mc(g,b,e);return Qh&&Ph&&0===c&&g&&(0===e&&(Ag=[]),Ag.push(g)),"undefined"==typeof a[b]&&(h=void 0),{x:h,value:null===a[b]||isNaN(a[b])?null:+a[b],id:d}}).filter(function(a){return"undefined"!=typeof a.x})}}),b.forEach(function(a){var b;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++})}),_f&&Gd(vc(b).filter(function(a){return!(a in ag)}),_f),b.forEach(function(a){ac(a.id_org,a)}),b}function qc(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}})}}function rc(a){return a>0&&Ye.data.targets[0].values[a-1]?Ye.data.targets[0].values[a-1].x:void 0}function sc(a){return a1?Ye.data.targets.forEach(function(b){b.values.length>c&&(a=b,c=b.values.length)}):a=b?Ye.data.targets[0]:null,a}function vc(a){return a.map(function(a){return a.id})}function wc(a){return a?"string"==typeof a?[a]:a:vc(Ye.data.targets)}function xc(a,b){var c,d=vc(a);for(c=0;c2){for(e=b-2,c=a[0],d=a[a.length-1],f=(d-c)/(e+1),i=[c],g=0;e>g;g++)h=+c+f*(g+1),i.push(Oh?new Date(h):h);i.push(d)}return i}function Dc(a){Yh=Yh.concat(a)}function Ec(a){Yh=Yh.filter(function(b){return a.indexOf(b)<0})}function Fc(a){var b={};return a.forEach(function(a){b[a.id]=[],a.values.forEach(function(c){b[a.id].push(c.value)})}),b}function Gc(a,b){var c,d,e,f=Object.keys(a);for(c=0;ca})}function Ic(a){return Gc(a,function(a){return a>0})}function Jc(a){return a=0&&d===a[c].x;c--)e.push(a[c]);for(c=b;c0?g=h:f=h,g-f===1||0===f&&0===g?(e=[],a[f].x&&(e=e.concat(md(a,f))),a[g].x&&(e=e.concat(md(a,g))),pd(e,b)):nd(a,b,f,g)}function od(a,b){var c;return c=a.map(function(a){return nd(a.values,b)}),pd(c,b)}function pd(a,b){var c,d;return a.forEach(function(a){var e=ce(a,b);(c>e||!c)&&(c=e,d=a)}),d}function qd(a,b){return Xe.merge(a.map(function(a){return a.values})).filter(function(a){return a.x===b})}function rd(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}}function sd(){return cg&&"desc"===cg.toLowerCase()}function td(){return cg&&"asc"===cg.toLowerCase()}function ud(a){var b=td(),c=sd();return b||c?a.sort(function(a,c){var d=function(a,b){return a+Math.abs(b.value)},e=a.values.reduce(d,0),f=c.values.reduce(d,0);return b?f-e:e-f}):"function"==typeof cg&&a.sort(cg),a}function vd(a,c){var d,e,f,g,h,i,j,k=Md(Ye.data.targets),l=k?gd:fd,m=a.filter(function(a){return a&&b(a.value)});Bh&&0!==m.length&&(ti.html(Eh(a,$(),l,Wh)).style("display","block"),d=ti.property("offsetWidth"),e=ti.property("offsetHeight"),k?(g=nf/2+c[0],i=pf/2+c[1]+20):(yg?(f=q(),g=f+c[0]+100,h=g+d,j=r()-u(),i=Kf(m[0].x)+20):(f=q(),g=f+t()+Kf(m[0].x)+20,h=g+d,j=f+r()-u(),i=c[1]+15),h>j&&(g-=d+60),i+e>s()&&(i-=e+30)),ti.style("top",i+"px").style("left",g+"px"))}function wd(){ti.style("display","none")}function xd(a){var c=a.filter(function(a){return a&&b(a.value)});Bh&&(Jd(Ye.data.targets)||Md(Ye.data.targets)||qi.selectAll("line."+f.xgridFocus).style("visibility","visible").data([c[0]]).attr(yg?"y1":"x1",id).attr(yg?"y2":"x2",id))}function yd(){qi.select("line."+f.xgridFocus).style("visibility","hidden")}function zd(a){return a.x||0===a.x?Kf(a.x):null}function Ad(a){return V(a.id)(a.value)}function Bd(){var a,b,d={},e=0;return Ac(yc(Pd)).forEach(function(f){for(a=0;a0&&(i+=g(b.values[f].value)-h)}),i}}function Fd(a,b){return nh?nh:b?2*a.tickOffset()*oh/b:0}function Gd(a,b){wc(a).forEach(function(a){xi[a]=b===ag[a],ag[a]=b})}function Hd(a,b){var c=!1;return a.forEach(function(a){ag[a.id]===b&&(c=!0),a.id in ag||"line"!==b||(c=!0)}),c}function Id(a){return Hd(a,"bar")}function Jd(a){return Hd(a,"scatter")}function Kd(a){return Hd(a,"pie")}function Ld(a){return Hd(a,"donut")}function Md(a){return Kd(a)||Ld(a)}function Nd(a){var b="string"==typeof a?a:a.id;return!(b in ag)||"line"===ag[b]||"spline"===ag[b]||"area"===ag[b]||"area-spline"===ag[b]}function Od(a){var b="string"==typeof a?a:a.id;return"spline"===ag[b]||"area-spline"===ag[b]}function Pd(a){var b="string"==typeof a?a:a.id;return"bar"===ag[b]}function Qd(a){var b="string"==typeof a?a:a.id;return"scatter"===ag[b]}function Rd(a){var b="string"==typeof a?a:a.id;return"pie"===ag[b]}function Sd(a){var b="string"==typeof a?a:a.id;return"donut"===ag[b]}function Td(a){return Rd(a)||Sd(a)}function Ud(a){return Pd(a)?a.values:[]}function Vd(a){return Nd(a)||Qd(a)?a.values:[]}function Wd(a){return Pd(a)||Nd(a)?a.values:[]}function Xd(a,b,c){var d=[];return function(e){var f,g=e.id||e;return a[g]instanceof Function?f=a[g](e):g in a?f=a[g]:(d.indexOf(g)<0&&d.push(g),f=b[d.indexOf(g)%b.length]),c instanceof Function?c(f,e):f}}function Yd(b){var c;if(!b)throw Error(b+" can not be parsed as d3.time with format "+Wf+". Maybe 'x' of this data is not defined. See data.x or data.xs option.");try{c=Wf?Xe.time.format(Wf).parse(b):new Date(b)}catch(d){c=void 0}return c||a.console.error("Failed to parse x '"+b+"' to Date with format "+Wf),c}function Zd(a,b){var c=Xe.mouse(a),d=Xe.select(a),e=1*d.attr("cx"),f=1*d.attr("cy");return Math.sqrt(Math.pow(e-c[0],2)+Math.pow(f-c[1],2))0}function be(a,b){var c=!1;return Object.keys(a).forEach(function(d){a[d]===b&&(c=!0)}),c}function ce(a,b){var c="y"===Z(a.id)?Lf:Mf,d=yg?1:0,e=yg?0:1;return Math.pow(Kf(a.x)-b[d],2)+Math.pow(c(a.value)-b[e],2)}function de(a,b){var c=0;a.each(function(){++c}).each("end",function(){--c||b.apply(this,arguments)})}function ee(a,b,c){ng(b,a.node()),qi.select("."+f.selectedCircles+Yc(b.id)).selectAll("."+f.selectedCircle+"-"+c).data([b]).enter().append("circle").attr("class",function(){return Kc(f.selectedCircle,c)}).attr("cx",yg?Ad:zd).attr("cy",yg?zd:Ad).attr("stroke",function(){return Wh(b)}).attr("r",1.4*mh).transition().duration(100).attr("r",mh)}function fe(a,b,c){og(b,a.node()),qi.select("."+f.selectedCircles+Yc(b.id)).selectAll("."+f.selectedCircle+"-"+c).transition().duration(100).attr("r",0).remove()}function ge(a,b,c,d){a?ee(b,c,d):fe(b,c,d)}function he(a,b){ng(b,a.node()),a.transition().duration(100).style("fill",function(){return Xe.rgb(Wh(b)).darker(1)})}function ie(a,b){og(b,a.node()),a.transition().duration(100).style("fill",function(){return Wh(b)})}function je(a,b,c,d){a?he(b,c,d):ie(b,c,d)}function ke(a){return a.filter(function(a){return b(a.value)})}function le(a,c){return(c?qi.selectAll("."+f.circles+Yc(c)):qi).selectAll("."+f.circle+(b(a)?"-"+a:""))}function me(a,b){le(a,b).classed(f.EXPANDED,!0).attr("r",lh)}function ne(a){le(a).filter(function(){return Xe.select(this).classed(f.EXPANDED)}).classed(f.EXPANDED,!1).attr("r",ih)}function oe(a){return qi.selectAll("."+f.bar+(b(a)?"-"+a:""))}function pe(a){oe(a).classed(f.EXPANDED,!0)}function qe(a){oe(a).classed(f.EXPANDED,!1)}function re(a,b){var c=ve(a,b);return function(a,b){var d=c(a,b),e=yg?1:0,f=yg?0:1,g="M "+d[0][e]+","+d[0][f]+" L"+d[1][e]+","+d[1][f]+" L"+d[2][e]+","+d[2][f]+" L"+d[3][e]+","+d[3][f]+" z";return g}}function se(a,b){var c=ve(a,!1),d=b?te:ue;return function(a,b){return d(c(a,b),a,this)}}function te(a,b){var c;return yg?(c=Pd(b)?4:6,a[2][1]+c*(b.value<0?-1:1)):a[0][0]+(a[2][0]-a[0][0])/2}function ue(a,b,c){var d=c.getBBox();return yg?(a[0][0]+a[2][0]+.6*d.height)/2:a[2][1]+(b.value<0?d.height:Pd(b)?-3:-6)}function ve(a,b){var c=a.__max__+1,d=Fd(Qf,c),e=Cd(d,c,a,!!b),f=Dd(!!b),g=Ed(a,!!b),h=b?W:V;return function(a,b){var c=h(a.id)(0),i=g(a,b)||c,j=e(a),k=f(a);return yg&&(a.value>0&&i>k||a.value<0&&k>i)&&(k=i),[[j,i],[j,k-(c-i)],[j+d,k-(c-i)],[j+d,i]]}}function we(a,b,e,f){var g,h,i,j,k,l,m,n,o,p,q,r=-1,s="M",t=[];if(d(f))for(g=0;g=h;h+=u)s+=i(a[g-1],a[g],h,o)}r=a[g].x}return s}function xe(b){var c,d,e;if(ui=Xe.select($e),ui.empty())throw new Error('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');if(ui.html(""),ui.classed("c3",!0),Ye.data.x={},Ye.data.targets=pc(b),n(),R(),Kf.domain(Xe.extent(Zb(Ye.data.targets))),Lf.domain(Ub(Ye.data.targets,"y")),Mf.domain(Ub(Ye.data.targets,"y2")),Nf.domain(Kf.domain()),Of.domain(Lf.domain()),Pf.domain(Mf.domain()),vi=Kf.domain(),ji.scale(Nf),df&&ni.scale(Kf),oi=ui.append("svg").attr("width",nf+kf.left+kf.right).attr("height",pf+kf.top+kf.bottom).on("mouseenter",gf).on("mouseleave",hf),pi=oi.append("defs"),pi.append("clipPath").attr("id",Ih).append("rect").attr("width",nf).attr("height",pf),pi.append("clipPath").attr("id",Jh).append("rect").attr("x",B).attr("y",C).attr("width",H).attr("height",I),pi.append("clipPath").attr("id",Kh).append("rect").attr("x",D).attr("y",E).attr("width",J).attr("height",K),qi=oi.append("g").attr("transform",bi.main),ri=rg?oi.append("g").attr("transform",bi.context):null,si=ug?oi.append("g").attr("transform",bi.legend):null,ti=Xe.select($e).style("position","relative").append("div").style("position","absolute").style("pointer-events","none").style("z-index","10").style("display","none"),qi.append("g").attr("class",f.axisX).attr("clip-path",yg?"":Mh).attr("transform",bi.x).append("text").attr("class",f.axisXLabel).attr("transform",yg?"rotate(-90)":"").attr("dx",qb).attr("dy",tb).style("text-anchor",wb),Lg&&qi.append("g").attr("class",f.axisY).attr("clip-path",yg?Nh:"").append("text").attr("class",f.axisYLabel).attr("transform",yg?"":"rotate(-90)").attr("dx",rb).attr("dy",ub).style("text-anchor",xb),Ug&&qi.append("g").attr("class",f.axisY2).attr("transform",bi.y2).append("text").attr("class",f.axisY2Label).attr("transform",yg?"":"rotate(-90)").attr("dx",sb).style("text-anchor",yb),d=qi.append("g").attr("clip-path",Lh).attr("class",f.grid),bh&&d.append("g").attr("class",f.xgrids),ae(dh)&&d.append("g").attr("class",f.xgridLines),jh&&d.append("g").attr("class",f.xgridFocus).append("line").attr("class",f.xgridFocus),eh&&d.append("g").attr("class",f.ygrids),ae(fh)&&d.append("g").attr("class",f.ygridLines),qi.append("g").attr("clip-path",Lh).attr("class",f.regions),qi.append("g").attr("clip-path",Lh).attr("class",f.chart),c=qi.select("."+f.chart).append("g").attr("class",f.eventRects).style("fill-opacity",0).style("cursor",df?yg?"ns-resize":"ew-resize":null),qi.select("."+f.chart).append("g").attr("class",f.chartBars),qi.select("."+f.chart).append("g").attr("class",f.chartLines),qi.select("."+f.chart).append("g").attr("class",f.chartArcs).attr("transform",bi.arc).append("text").attr("class",f.chartArcsTitle).style("text-anchor","middle").text(Ob()),qi.select("."+f.chart).append("g").attr("class",f.chartTexts),df&&qi.insert("rect",ff?null:"g."+f.grid).attr("class",f.zoomRect).attr("width",nf).attr("height",pf).style("opacity",0).style("cursor",yg?"ns-resize":"ew-resize").call(ni).on("dblclick.zoom",null),Jg&&ji.extent("function"!=typeof Jg?Jg:Jg(Zb())),rg&&(ri.append("g").attr("clip-path",Lh).attr("class",f.chart),ri.select("."+f.chart).append("g").attr("class",f.chartBars),ri.select("."+f.chart).append("g").attr("class",f.chartLines),ri.append("g").attr("clip-path",Lh).attr("class",f.brush).call(ji).selectAll("rect").attr(yg?"width":"height",yg?of:qf),ri.append("g").attr("class",f.axisX).attr("transform",bi.subx).attr("clip-path",yg?"":Mh)),Ke(Ye.data.targets),yg?qi.select("."+f.axisX).style("opacity",0).call(Qf):(qi.select("."+f.axisY).style("opacity",0).call(Rf),qi.select("."+f.axisY2).style("opacity",0).call(Sf)),Je({withTransform:!0,withLegend:!0,withTransitionForAxis:!1}),Fh){if(Oh&&"string"==typeof Gh){for(Gh=Yd(Gh),e=0;e0){d=[];for(var g in Yf)for(c=0;cg&&h>c&&d>i&&j>d):"path"===this.nodeName&&(m=rd(this),c=m.x,d=m.y,e=m.width,k=m.height,l=je,q=!(c>h||g>c+e||d>j||i>d+k)),q^p&&(n.classed(f.INCLUDED,!p),n.classed(f.SELECTED,!o),l(!o,n,a,b))}))}function Ce(a){Md(Ye.data.targets)||gg&&(Rh=a,qi.select("."+f.chart).append("rect").attr("class",f.dragarea).style("opacity",.1),Sh=!0,pg())}function De(){Md(Ye.data.targets)||gg&&(qi.select("."+f.dragarea).transition().duration(100).style("opacity",0).remove(),qi.selectAll("."+f.shape).classed(f.INCLUDED,!1),Sh=!1,qg())}function Ee(a){var c,e,g,h,i,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,M,N,O,P=Bd(),Q=Md(Ye.data.targets),R=Ac(Ye.data.targets);if(0!==R.length){if(a=d(a)?a:{},v=d(a.withY)?a.withY:!0,w=d(a.withSubchart)?a.withSubchart:!0,x=d(a.withTransition)?a.withTransition:!0,A=d(a.withTransform)?a.withTransform:!1,B=d(a.withUpdateXDomain)?a.withUpdateXDomain:!1,C=d(a.withUpdateOrgXDomain)?a.withUpdateOrgXDomain:!1,D=d(a.withLegend)?a.withLegend:!1,y=d(a.withTransitionForExit)?a.withTransitionForExit:x,z=d(a.withTransitionForAxis)?a.withTransitionForAxis:x,I=x?jf:0,J=y?I:0,K=z?I:0,D&&ug&&Se(Ye.data.targets,a),C&&(Kf.domain(Xe.extent(Zb(R))),vi=Kf.domain(),df&&ni.scale(Kf).updateScaleExtent(),Nf.domain(Kf.domain()),ji.scale(Nf)),B&&(Kf.domain(ji.empty()?vi:ji.extent()),df&&ni.scale(Kf).updateScaleExtent(),Jd(R)||(M=Cc(Bc(R)).sort(),Qf.tickValues(M),Tf.tickValues(M))),Lf.domain(Ub(R,"y")),Mf.domain(Ub(R,"y2")),qi.select("."+f.axisX).style("opacity",Q?0:1).transition().duration(K).call(Qf),qi.select("."+f.axisY).style("opacity",Q?0:1).transition().duration(K).call(Rf),qi.select("."+f.axisY2).style("opacity",Q?0:1).transition().duration(K).call(Sf),B&&Dg&&M){for(N=1;N=V;V++)e.push(new Date(V+"-01-01 00:00:00"))}else e=Kf.ticks(10);c=qi.select("."+f.xgrids).selectAll("."+f.xgrid).data(e),c.enter().append("line").attr("class",f.xgrid),c.attr("x1",yg?0:function(a){return Kf(a)-Qf.tickOffset()}).attr("x2",yg?nf:function(a){return Kf(a)-Qf.tickOffset()}).attr("y1",yg?function(a){return Kf(a)-Qf.tickOffset()}:kf.top).attr("y2",yg?function(a){return Kf(a)-Qf.tickOffset()}:pf).style("opacity",function(){return+Xe.select(this).attr(yg?"y1":"x1")===(yg?pf:0)?0:1}),c.exit().remove()}ae(dh)&&(g=qi.select("."+f.xgridLines).selectAll("."+f.xgridLine).data(dh),h=g.enter().append("g").attr("class",function(a){return f.xgridLine+(a.class?a.class:"")}),h.append("line").style("opacity",0),h.append("text").attr("text-anchor","end").attr("transform",yg?"":"rotate(-90)").attr("dx",yg?0:-kf.top).attr("dy",-5).style("opacity",0),g.select("line").transition().duration(I).attr("x1",yg?0:jd).attr("x2",yg?nf:jd).attr("y1",yg?jd:kf.top).attr("y2",yg?jd:pf).style("opacity",1),g.select("text").transition().duration(I).attr("x",yg?nf:0).attr("y",jd).text(function(a){return a.text}).style("opacity",1),g.exit().transition().duration(I).style("opacity",0).remove()),v&&eh&&(i=qi.select("."+f.ygrids).selectAll("."+f.ygrid).data(Lf.ticks(gh)),i.enter().append("line").attr("class",f.ygrid),i.attr("x1",yg?Lf:0).attr("x2",yg?Lf:nf).attr("y1",yg?0:Lf).attr("y2",yg?pf:Lf),i.exit().remove()),v&&ae(fh)&&(j=qi.select("."+f.ygridLines).selectAll("."+f.ygridLine).data(fh),k=j.enter().append("g").attr("class",function(a){return f.ygridLine+(a.class?a.class:"")}),k.append("line").style("opacity",0),k.append("text").attr("text-anchor","end").attr("transform",yg?"rotate(-90)":"").attr("dx",yg?0:-kf.top).attr("dy",-5).style("opacity",0),j.select("line").transition().duration(I).attr("x1",yg?kd:0).attr("x2",yg?kd:nf).attr("y1",yg?0:kd).attr("y2",yg?pf:kd).style("opacity",1),j.select("text").transition().duration(I).attr("x",yg?0:nf).attr("y",kd).text(function(a){return a.text}).style("opacity",1),j.exit().transition().duration(I).style("opacity",0).remove()),m=qi.selectAll("."+f.bars).selectAll("."+f.bar).data(Ud),m.enter().append("path").attr("d",E).style("stroke","none").style("opacity",0).style("fill",function(a){return Wh(a)}).attr("class",Sc),m.style("opacity",_c).transition().duration(I).attr("d",E).style("opacity",1),m.exit().transition().duration(J).style("opacity",0).remove(),p=qi.selectAll("."+f.texts).selectAll("."+f.text).data(Wd),p.enter().append("text").attr("class",Lc).attr("text-anchor",function(a){return yg?a.value<0?"end":"start":"middle"}).style("stroke","none").style("fill-opacity",0),p.text(function(a){return hd(a.id)(a.value)}).style("fill-opacity",ad).transition().duration(I).attr("x",G).attr("y",H).style("fill-opacity",cd),p.exit().transition().duration(J).style("fill-opacity",0).remove(),qi.selectAll("."+f.line).style("opacity",_c).transition().duration(I).attr("d",ki).style("opacity",1),qi.selectAll("."+f.area).style("opacity",0).transition().duration(I).attr("d",li).style("opacity",wi),l=qi.selectAll("."+f.circles).selectAll("."+f.circle).data(Vd),l.enter().append("circle").attr("class",Qc).style("opacity",0).attr("r",ih),l.style("opacity",_c).transition().duration(I).style("opacity",bd).attr("cx",yg?Ad:zd).attr("cy",yg?zd:Ad),l.exit().remove(),qi.selectAll("."+f.chartArc).select("."+f.arc).attr("transform",A?"scale(0)":"").style("opacity",function(a){return a===this._current?0:1}).transition().duration(I).attrTween("d",function(a){var b,c=Cb(a);return c?(b=Xe.interpolate(this._current,c),this._current=b(0),function(a){return Fb(b(a),!0)}):function(){return"M 0 0"}}).attr("transform",A?"scale(1)":"").style("opacity",1),qi.selectAll("."+f.chartArc).select("text").attr("transform",Gb).style("opacity",0).transition().duration(I).text(Jb).style("opacity",function(a){return zc(a.data.id)&&Td(a.data)?1:0}),qi.select("."+f.chartArcsTitle).style("opacity",Ld(Ye.data.targets)?1:0),rg&&(null!==Xe.event&&"zoom"===Xe.event.type&&ji.extent(Kf.orgDomain()).update(),w&&(ri.select("."+f.axisX).style("opacity",Q?0:1).transition().duration(I).call(Tf),ji.empty()||ji.extent(Kf.orgDomain()).update(),F=re(P,!0),q=ri.selectAll("."+f.bars).selectAll("."+f.bar).data(Ud),q.enter().append("path").attr("d",F).style("stroke","none").style("fill",function(a){return Wh(a)}).attr("class",Sc),q.style("opacity",_c).transition().duration(I).attr("d",F).style("opacity",1),q.exit().transition().duration(I).style("opacity",0).remove(),ri.selectAll("."+f.line).style("opacity",_c).transition().duration(I).attr("d",mi).style("opacity",1))),qi.selectAll("."+f.selectedCircles).filter(function(a){return Pd(a)}).selectAll("circle").remove(),qi.selectAll("."+f.selectedCircle).transition().duration(I).attr("cx",yg?Ad:zd).attr("cy",yg?zd:Ad),ae(Vf)?(r=qi.select("."+f.eventRects).selectAll("."+f.eventRect).data([0]),ze(r.enter()),r.attr("x",0).attr("y",0).attr("width",nf).attr("height",pf)):(Qh&&!Ph?(u=function(a,b){var c=rc(b),d=sc(b),e=Ye.data.x[a.id][b];return(Kf(d?d:e+50)-Kf(c?c:e-50))/2},t=function(a,b){var c=rc(b),d=Ye.data.x[a.id][b];return(Kf(d)+Kf(c?c:d-50))/2}):(u=L(),t=function(a){return Kf(a.x)-u/2}),s=uc(),qi.select("."+f.eventRects).datum(s?s.values:[]),r=qi.select("."+f.eventRects).selectAll("."+f.eventRect).data(function(a){return a}),ye(r.enter()),r.attr("class",Xc).attr("x",yg?0:t).attr("y",yg?t:0).attr("width",yg?nf:u).attr("height",yg?u:pf),r.exit().remove()),n=qi.select("."+f.regions).selectAll("rect."+f.region).data(Ah),n.enter().append("rect").style("fill-opacity",0),n.attr("class",Wc).attr("x",yg?0:cc).attr("y",yg?cc:kf.top).attr("width",yg?nf:dc).attr("height",yg?dc:pf).transition().duration(I).style("fill-opacity",function(a){return b(a.opacity)?a.opacity:.1}),n.exit().transition().duration(I).style("fill-opacity",0).remove(),vc(Ye.data.targets).forEach(function(a){xi[a]=!0})}}function Fe(){Ee({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}function Ge(){return"mousemove"===Xe.event.sourceEvent.type&&ni.altDomain?(Kf.domain(ni.altDomain),void ni.scale(Kf).updateScaleExtent()):(Ph&&Kf.orgDomain()[0]===vi[0]&&Kf.domain([vi[0]-1e-10,Kf.orgDomain()[1]]),Ee({withTransition:!1,withY:!1,withSubchart:!1}),void("mousemove"===Xe.event.sourceEvent.type&&(Th=!0)))}function He(){function a(){b.forEach(function(a){a()})}var b=[];return a.add=function(a){b.push(a)},a}function Ie(){oi.attr("width",rf).attr("height",sf),oi.select("#"+Ih).select("rect").attr("width",nf).attr("height",pf),oi.select("#"+Jh).select("rect").attr("width",H),oi.select("#"+Kh).select("rect").attr("width",J),oi.select("."+f.zoomRect).attr("width",nf).attr("height",pf)}function Je(a){a=d(a)?a:{},a.withTransition=d(a.withTransition)?a.withTransition:!0,a.withTransform=d(a.withTransform)?a.withTransform:!1,a.withLegend=d(a.withLegend)?a.withLegend:!1,a.withUpdateXDomain=!0,a.withUpdateOrgXDomain=!0,a.withTransitionForExit=!1,n(),R(),Ie(),m(a.withTransition),Ee(a)}function Ke(a){var b,c,d,e,g,h,i,j,k,l,m,n;i=qi.select("."+f.chartTexts).selectAll("."+f.chartText).data(a),j=i.enter().append("g").attr("class",function(a){return f.chartText+Kc(f.target,a.id)}).style("pointer-events","none"),j.append("g").attr("class",Mc).style("fill",function(a){return Wh(a)}),e=qi.select("."+f.chartBars).selectAll("."+f.chartBar).data(a),d=e.enter().append("g").attr("class",function(a){return f.chartBar+Kc(f.target,a.id)}).style("pointer-events","none"),d.append("g").attr("class",Tc).style("fill",function(a){return Wh(a)}).style("stroke","none").style("cursor",function(a){return ig(a)?"pointer":null}),c=qi.select("."+f.chartLines).selectAll("."+f.chartLine).data(a),b=c.enter().append("g").attr("class",function(a){return f.chartLine+Kc(f.target,a.id)}).style("pointer-events","none"),b.append("path").attr("class",Pc).style("opacity",0).style("stroke",function(a){return Wh(a)}),b.append("path").attr("class",Vc).style("opacity",function(){return wi=+Xe.select(this).style("opacity"),0}).style("fill",function(a){return Wh(a)}),b.append("g").attr("class",function(a){return Kc(f.selectedCircles,a.id)}),b.append("g").attr("class",Rc).style("fill",function(a){return Wh(a)}).style("cursor",function(a){return ig(a)?"pointer":null}),a.forEach(function(a){qi.selectAll("."+f.selectedCircles+Yc(a.id)).selectAll("."+f.selectedCircle).each(function(b,c){b.value=a.values[c].value})}),h=qi.select("."+f.chartArcs).selectAll("."+f.chartArc).data(Bf(a)),g=h.enter().append("g").attr("class",function(a){return f.chartArc+Kc(f.target,a.data.id)}),g.append("path").attr("class",Uc).style("opacity",0).style("fill",function(a){return Wh(a.data)}).style("cursor",function(a){return ig(a)?"pointer":null}).each(function(a){this._current=a}).on("mouseover",function(a,b){var c=Cb(a),d=Ib(c),e=Qb();Kb(c.data.id),Pe(c.data.id),e(d,b)}).on("mousemove",function(a){var b=Cb(a),c=[Ib(b)];vd(c,Xe.mouse(this))}).on("mouseout",function(a,b){var c=Cb(a),d=Ib(c),e=Rb();Lb(c.data.id),Re(),wd(),e(d,b)}).on("click",function(a,b){var c=Cb(a),d=Ib(c),e=Pb();e(d,b)}),g.append("text").attr("dy",".35em").style("opacity",0).style("text-anchor","middle").style("pointer-events","none"),rg&&(n=ri.select("."+f.chartBars).selectAll("."+f.chartBar).data(a),m=n.enter().append("g").attr("class",function(a){return f.chartBar+Kc(f.target,a.id)}),m.append("g").attr("class",Tc).style("fill",function(a){return Wh(a)}),l=ri.select("."+f.chartLines).selectAll("."+f.chartLine).data(a),k=l.enter().append("g").attr("class",function(a){return f.chartLine+Kc(f.target,a.id)}),k.append("path").attr("class",Pc).style("opacity",0).style("stroke",function(a){return Wh(a)})),oi.selectAll("."+f.target).filter(function(a){return zc(a.id)}).transition().style("opacity",1)}function Le(a,b){Ye.data.targets.forEach(function(b){for(var c=0;ce&&(e=(k-j)/2,w=0,C++)),B[a]=C,A[C]=e,x[a]=w,w+=j}var e,f,g=a.getBBox(),h=10*Math.ceil((g.width+s)/10),i=10*Math.ceil((g.height+r)/10),j=ci?i:h,k=ci?tf:uf;c&&(w=0,C=0,t=0,u=0),y[b]=h,z[b]=i,(!t||h>=t)&&(t=h),(!u||i>=u)&&(u=i),f=ci?u:t,xg?(Object.keys(y).forEach(function(a){y[a]=t}),Object.keys(z).forEach(function(a){z[a]=u}),e=(k-f*q.length)/2,v>e?(w=0,C=0,q.forEach(function(a){d(a)})):d(b,!0)):d(b)}var g,h,i,j,k,l,o,p,q=vc(a),r=4,s=26,t=0,u=0,v=10,w=0,x={},y={},z={},A={},B={},C=0;b=c(b)?{}:b,p=d(b.withTransition)?b.withTransition:!0,ci?(h=function(a){return t*(.2+B[a])},k=function(a){return A[B[a]]+x[a]}):(h=function(a){return A[B[a]]+x[a]},k=function(a){return u*(.2+B[a])}),i=function(a,b){return h(a,b)+14},l=function(a,b){return k(a,b)+9},j=function(a,b){return h(a,b)-4},o=function(a,b){return k(a,b)-7},g=si.selectAll("."+f.legendItem).data(q).enter().append("g").attr("class",function(a){return Kc(f.legendItem,a)}).style("cursor","pointer").on("click",function(a){"function"==typeof wg?wg(a):Ye.toggle(a)}).on("mouseover",function(a){Ye.focus(a)}).on("mouseout",function(){Ye.revert()}),g.append("text").text(function(a){return d(Yf[a])?Yf[a]:a}).each(function(a,b){e(this,a,0===b)}).style("pointer-events","none").attr("x",ci?i:-200).attr("y",ci?-200:l),g.append("rect").attr("class",f.legendItemEvent).style("fill-opacity",0).attr("x",ci?j:-200).attr("y",ci?-200:o).attr("width",function(a){return y[a]}).attr("height",function(a){return z[a]}),g.append("rect").attr("class",f.legendItemTile).style("pointer-events","none").style("fill",function(a){return Wh(a)}).attr("x",ci?i:-200).attr("y",ci?-200:k).attr("width",10).attr("height",10),si.selectAll("text").data(q).text(function(a){return d(Yf[a])?Yf[a]:a}).each(function(a,b){e(this,a,0===b)}).transition().duration(p?250:0).attr("x",i).attr("y",l),si.selectAll("rect."+f.legendItemEvent).data(q).transition().duration(p?250:0).attr("x",j).attr("y",o),si.selectAll("rect."+f.legendItemTile).data(q).transition().duration(p?250:0).attr("x",h).attr("y",k),N(t),O(u),M(C),n(),R(),Ie(),m(!1)}function Te(a){return xc(Ye.data.targets,a.id)}function Ue(a){return"data"in a&&xc(Ye.data.targets,a.data.id)}function Ve(a){var b=a&&a.value?a.value:null,c=a&&a["class"]?a["class"]:null;return b?function(a){return a.value!==b}:c?function(a){return a["class"]!==c}:function(){return!0}}function We(a,b,c){var d=!Md(Ye.data.targets);Gd(a,b),Je(c?c:{withTransitionForAxis:d})}var Xe=a.d3?a.d3:a.require?a.require("d3"):void 0,Ye={data:{},axis:{}},Ze={},$e=h(["bindto"],"#chart"),_e=h(["size","width"]),af=h(["size","height"]),bf=h(["padding","left"]),cf=h(["padding","right"]),df=h(["zoom","enabled"],!1),ef=h(["zoom","extent"]),ff=h(["zoom","privileged"],!1),gf=h(["onenter"],function(){}),hf=h(["onleave"],function(){}),jf=h(["transition","duration"],350);g("data","data is required in config");var kf,lf,mf,nf,of,pf,qf,rf,sf,tf,uf,vf,wf,xf,yf,zf,Af,Bf,Cf,Df,Ef,Ff,Gf,Hf,If,Jf,Kf,Lf,Mf,Nf,Of,Pf,Qf,Rf,Sf,Tf,Uf=h(["data","x"]),Vf=h(["data","xs"],{}),Wf=h(["data","x_format"]),Xf=h(["data","id_converter"],function(a){return a}),Yf=h(["data","names"],{}),Zf=h(["data","groups"],[]),$f=h(["data","axes"],{}),_f=h(["data","type"]),ag=h(["data","types"],{}),bg=h(["data","labels"],{}),cg=h(["data","order"]),dg=h(["data","regions"],{}),eg=h(["data","color"]),fg=h(["data","colors"],{}),gg=h(["data","selection","enabled"],!1),hg=h(["data","selection","grouped"],!1),ig=h(["data","selection","isselectable"],function(){return!0}),jg=h(["data","selection","multiple"],!0),kg=h(["data","onclick"],function(){}),lg=h(["data","onenter"],function(){}),mg=h(["data","onleave"],function(){}),ng=h(["data","onselected"],function(){}),og=h(["data","onunselected"],function(){}),pg=h(["data","ondragstart"],function(){}),qg=h(["data","ondragend"],function(){}),rg=h(["subchart","show"],!1),sg=rg?h(["subchart","size","height"],60):0,tg=h(["color","pattern"],[]),ug=h(["legend","show"],!0),vg=h(["legend","position"],"bottom"),wg=h(["legend","item","onclick"]),xg=h(["legend","equally"],!1),yg=h(["axis","rotated"],!1),zg=h(["axis","x","type"],"indexed"),Ag=h(["axis","x","categories"],[]),Bg=h(["axis","x","tick","centered"],!1),Cg=h(["axis","x","tick","format"]),Dg=h(["axis","x","tick","culling"],{}),Eg=h(["axis","x","tick","culling","max"],"categorized"===zg?1/0:10),Fg=h(["axis","x","tick","count"]),Gg=h(["axis","x","tick","fit"],!1),Hg=h(["axis","x","max"]),Ig=h(["axis","x","min"]),Jg=h(["axis","x","default"]),Kg=h(["axis","x","label"],{}),Lg=h(["axis","y","show"],!0),Mg=h(["axis","y","max"]),Ng=h(["axis","y","min"]),Og=h(["axis","y","center"]),Pg=h(["axis","y","label"],{}),Qg=h(["axis","y","inner"],!1),Rg=h(["axis","y","tick","format"]),Sg=h(["axis","y","padding"],{}),Tg=h(["axis","y","ticks"],10),Ug=h(["axis","y2","show"],!1),Vg=h(["axis","y2","max"]),Wg=h(["axis","y2","min"]),Xg=h(["axis","y2","center"]),Yg=h(["axis","y2","label"],{}),Zg=h(["axis","y2","inner"],!1),$g=h(["axis","y2","tick","format"]),_g=h(["axis","y2","padding"],{}),ah=h(["axis","y2","ticks"],10),bh=h(["grid","x","show"],!1),ch=h(["grid","x","type"],"tick"),dh=h(["grid","x","lines"],[]),eh=h(["grid","y","show"],!1),fh=h(["grid","y","lines"],[]),gh=h(["grid","y","ticks"],10),hh=h(["point","show"],!0),ih=hh?h(["point","r"],2.5):0,jh=h(["point","focus","line","enabled"],!0),kh=h(["point","focus","expand","enabled"],!0),lh=h(["point","focus","expand","r"],kh?4:ih),mh=h(["point","focus","select","r"],8),nh=h(["bar","width"]),oh=h(["bar","width","ratio"],.6),ph=h(["pie","label","show"],!0),qh=h(["pie","label","format"]),rh=h(["pie","onclick"],function(){}),sh=h(["pie","onmouseover"],function(){}),th=h(["pie","onmouseout"],function(){}),uh=h(["donut","label","show"],!0),vh=h(["donut","label","format"]),wh=h(["donut","title"],""),xh=h(["donut","onclick"],function(){}),yh=h(["donut","onmouseover"],function(){}),zh=h(["donut","onmouseout"],function(){}),Ah=h(["regions"],[]),Bh=h(["tooltip","show"],!0),Ch=h(["tooltip","format","title"]),Dh=h(["tooltip","format","value"]),Eh=h(["tooltip","contents"],function(a,b,c,d){var e,g,h,i,j,k=Ch?Ch:b,l=Dh?Dh:c;for(g=0;g"+(h||0===h?""+h+"":"")),j=a[g].name,i=l(a[g].value,a[g].ratio),e+="",e+=""+j+"",e+=""+i+"",e+="");return e+""}),Fh=h(["tooltip","init","show"],!1),Gh=h(["tooltip","init","x"],0),Hh=h(["tooltip","init","position"],{top:"0px",left:"50px"}),Ih=("string"==typeof $e?$e.replace("#",""):$e.id)+"-clip",Jh=Ih+"-xaxis",Kh=Ih+"-yaxis",Lh=i(Ih),Mh=i(Mh),Nh=i(Nh),Oh="timeseries"===zg,Ph="categorized"===zg,Qh=!Oh&&(Uf||ae(Vf)),Rh=null,Sh=!1,Th=!1,Uh=!1,Vh=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Wh=Xd(fg,ae(tg)?tg:Vh,eg),Xh=function(){var a=[[Xe.time.format("%Y/%-m/%-d"),function(){return!0}],[Xe.time.format("%-m/%-d"),function(a){return a.getMonth()}],[Xe.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[Xe.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[Xe.time.format("%I %p"),function(a){return a.getHours()}],[Xe.time.format("%I:%M"),function(a){return a.getMinutes()}],[Xe.time.format(":%S"),function(a){return a.getSeconds()}],[Xe.time.format(".%L"),function(a){return a.getMilliseconds()}]];return function(b){for(var c=a.length-1,d=a[c];!d[1](b);)d=a[--c];return d[0](b)}}(),Yh=[],Zh=yg?"left":"bottom",$h=yg?Qg?"top":"bottom":Qg?"right":"left",_h=yg?Zg?"bottom":"top":Zg?"left":"right",ai=yg?"left":"bottom",bi={main:function(){return"translate("+kf.left+","+kf.top+")"},context:function(){return"translate("+lf.left+","+lf.top+")"},legend:function(){return"translate("+mf.left+","+mf.top+")"},x:function(){return"translate(0,"+(yg?0:pf)+")"},y:function(){return"translate(0,"+(yg?pf:0)+")"},y2:function(){return"translate("+(yg?0:nf)+","+(yg?1:0)+")"},subx:function(){return"translate(0,"+(yg?0:qf)+")"},arc:function(){return"translate("+nf/2+","+pf/2+")"}},ci="right"===vg,di=0,ei=0,fi=0,gi=30,hi=30,ii=5;Bf=Xe.layout.pie().value(function(a){return a.values.reduce(function(a,b){return a+b.value},0)});var ji,ki=function(){var a=Xe.svg.line().x(yg?function(a){return V(a.id)(a.value)}:id).y(yg?id:function(a){return V(a.id)(a.value)});return function(b){var c,d,e=ke(b.values);return Nd(b)?(a.interpolate(Od(b)?"cardinal":"linear"),dg[b.id]?we(e,Kf,V(b.id),dg[b.id]):a(e)):(c=Kf(e[0].x),d=V(b.id)(e[0].value),yg?"M "+d+" "+c:"M "+c+" "+d)}}(),li=function(){var a;return a=yg?Xe.svg.area().x0(function(a){return V(a.id)(0)}).x1(function(a){return V(a.id)(a.value)}).y(id):Xe.svg.area().x(id).y0(function(a){return V(a.id)(0)}).y1(function(a){return V(a.id)(a.value)}),function(b){var c,d,e=ke(b.values);return Hd([b],"area")||Hd([b],"area-spline")?(a.interpolate(Od(b)?"cardinal":"linear"),a(e)):(c=Kf(e[0].x),d=V(b.id)(e[0].value),yg?"M "+d+" "+c:"M "+c+" "+d)}}(),mi=function(){var a=Xe.svg.line().x(yg?function(a){return W(a.id)(a.value)}:ld).y(yg?ld:function(a){return W(a.id)(a.value)});return function(b){var c=ke(b.values);return Nd(b)?a(c):"M "+Nf(c[0].x)+" "+W(b.id)(c[0].value)}}(),ni=function(){};ji=Xe.svg.brush().on("brush",Fe),ji.update=function(){return ri&&ri.select("."+f.brush).call(this),this},ji.scale=function(a){return yg?this.y(a):this.x(a)},df&&(ni=Xe.behavior.zoom().on("zoomstart",function(){ni.altDomain=Xe.event.sourceEvent.altKey?Kf.orgDomain():null}).on("zoom",df?Ge:null),ni.scale=function(a){return yg?this.y(a):this.x(a)},ni.orgScaleExtent=function(){var a=ef?ef:[1,10];return[a[0],Math.max(tc()/a[1],a[1])]},ni.updateScaleExtent=function(){var a=$b(Kf.orgDomain())/$b(vi),b=this.orgScaleExtent();return this.scaleExtent([b[0]*a,b[1]*a]),this});var oi,pi,qi,ri,si,ti,ui,vi,wi,xi={};if(Ye.focus=function(a){function b(a){Ac(a).transition().duration(100).style("opacity",1)}var c=oi.selectAll(Zc(a)),d=c.filter(Te),e=c.filter(Ue);Ye.revert(),Ye.defocus(),b(d.classed(f.focused,!0)),b(e),Md(Ye.data.targets)&&Kb(a,!0),Pe(a)},Ye.defocus=function(a){function b(a){Ac(a).transition().duration(100).style("opacity",.3)}var c=oi.selectAll(Zc(a)),d=c.filter(Te),e=c.filter(Ue);Ye.revert(),b(d.classed(f.focused,!1)),b(e),Md(Ye.data.targets)&&Lb(a),Qe(a)},Ye.revert=function(a){function b(a){Ac(a).transition().duration(100).style("opacity",1)}var c=oi.selectAll(Zc(a)),d=c.filter(Te),e=c.filter(Ue);b(d.classed(f.focused,!1)),b(e),Md(Ye.data.targets)&&Lb(a),Re()},Ye.show=function(a){a=wc(a),Ec(a),oi.selectAll($c(a)).transition().style("opacity",1),Ee({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!1})},Ye.hide=function(a){a=wc(a),Dc(a),oi.selectAll($c(a)).transition().style("opacity",0),Ee({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!1})},Ye.toggle=function(a){zc(a)?Ye.hide(a):Ye.show(a)},Ye.unzoom=function(){ji.clear().update(),Ee({withUpdateXDomain:!0})},Ye.load=function(a){return a.xs&&ic(a.xs),"categories"in a&&Ph&&(Ag=a.categories,Qf.categories(Ag)),"cacheIds"in a&&_b(a.cacheIds)?void Le(bc(a.cacheIds),a.done):void("unload"in a?Ne(wc("boolean"==typeof a.unload&&a.unload?null:a.unload),function(){Me(a)}):Me(a))},Ye.unload=function(a){Ne(wc(a),function(){Ee({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})})},Ye.selected=function(a){return Xe.merge(qi.selectAll("."+f.shapes+Yc(a)).selectAll("."+f.shape).filter(function(){return Xe.select(this).classed(f.SELECTED)}).map(function(a){return a.map(function(a){return a.__data__})}))},Ye.select=function(a,b,c){gg&&qi.selectAll("."+f.shapes).selectAll("."+f.shape).each(function(e,g){var h=Xe.select(this),i="circle"===this.nodeName?ee:he,j="circle"===this.nodeName?fe:ie,k=hg||!a||a.indexOf(e.id)>=0,l=!b||b.indexOf(g)>=0,m=h.classed(f.SELECTED);k&&l?ig(e)&&!m&&i(h.classed(f.SELECTED,!0),e,g):d(c)&&c&&m&&j(h.classed(f.SELECTED,!1),e,g)})},Ye.unselect=function(a,b){gg&&qi.selectAll("."+f.shapes).selectAll("."+f.shape).each(function(c,d){var e=Xe.select(this),g="circle"===this.nodeName?fe:ie,h=hg||!a||a.indexOf(c.id)>=0,i=!b||b.indexOf(d)>=0,j=e.classed(f.SELECTED);h&&i&&ig(c)&&j&&g(e.classed(f.SELECTED,!1),c,d)})},Ye.toLine=function(a){We(a,"line")},Ye.toSpline=function(a){We(a,"spline")},Ye.toBar=function(a){We(a,"bar")},Ye.toScatter=function(a){We(a,"scatter")},Ye.toArea=function(a){We(a,"area")},Ye.toAreaSpline=function(a){We(a,"area-spline")},Ye.toPie=function(a){We(a,"pie",{withTransform:!0})},Ye.toDonut=function(a){We(a,"donut",{withTransform:!0})},Ye.groups=function(a){return c(a)?Zf:(Zf=a,Ee(),Zf)},Ye.xgrids=function(a){return a?(dh=a,Ee(),dh):dh},Ye.xgrids.add=function(a){return a?Ye.xgrids(dh.concat(a)):void 0},Ye.xgrids.remove=function(a){var b=Ve(a);return Ye.xgrids(dh.filter(b))},Ye.ygrids=function(a){return a?(fh=a,Ee(),fh):fh},Ye.ygrids.add=function(a){return a?Ye.ygrids(fh.concat(a)):void 0},Ye.ygrids.remove=function(a){var b=Ve(a);return Ye.ygrids(fh.filter(b))},Ye.regions=function(a){return c(a)?Ah:(Ah=a,Ee(),Ah)},Ye.regions.add=function(a){return c(a)?Ah:(Ah=Ah.concat(a),Ee(),Ah)},Ye.regions.remove=function(a,c){var e=[].concat(a);return c=d(c)?c:{},e.forEach(function(a){var d=b(c.duration)?c.duration:0;oi.selectAll("."+a).transition().duration(d).style("fill-opacity",0).remove(),Ah=Ah.filter(function(b){return b.classes.indexOf(a)<0})}),Ah},Ye.data.get=function(a){var b=Ye.data.getAsTarget(a);return d(b)?b.values.map(function(a){return a.value}):void 0},Ye.data.getAsTarget=function(a){var b=yc(function(b){return b.id===a});return b.length>0?b[0]:void 0},Ye.data.names=function(a){return arguments.length?(Object.keys(a).forEach(function(b){Yf[b]=a[b]}),Se(Ye.data.targets,{withTransition:!0}),Yf):Yf},Ye.x=function(a){return arguments.length&&(kc(Ye.data.targets,a),Ee({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),Ye.data.x},Ye.xs=function(a){return arguments.length&&(lc(Ye.data.targets,a),Ee({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),Ye.data.x},Ye.axis.labels=function(a){arguments.length&&(Object.keys(a).forEach(function(b){bb(b,a[b])}),Ab())},Ye.axis.max=function(a){arguments.length&&("object"==typeof a?(b(a.y)&&(Mg=+a.y),b(a.y2)&&(Vg=+a.y2)):Mg=Vg=+a,Ee())},Ye.axis.min=function(a){arguments.length&&("object"==typeof a?(b(a.y)&&(Ng=+a.y),b(a.y2)&&(Wg=+a.y2)):Ng=Wg=+a,Ee())},Ye.axis.range=function(a){arguments.length&&("undefined"!=typeof a.max&&Ye.axis.max(a.max),"undefined"!=typeof a.min&&Ye.axis.min(a.min))},Ye.resize=function(a){_e=a?a.width:null,af=a?a.height:null,Je({withLegend:!0,withTransition:!1})},Ye.destroy=function(){Ye.data.targets=void 0,Ye.data.x={},ui.html(""),a.onresize=null},"url"in e.data)Xe.csv(e.data.url,function(a,b){xe(b)});else if("rows"in e.data)xe(nc(e.data.rows));else{if(!("columns"in e.data))throw Error("url or rows or columns is required.");xe(oc(e.data.columns))}return Ye},"function"==typeof a.define&&a.define.amd?a.define("c3",["d3"],e):a.c3=e}(window); \ No newline at end of file +!function(a){"use strict";function b(a){return a||0===a}function c(a){return"undefined"==typeof a}function d(a){return"undefined"!=typeof a}var e={version:"0.1.28"},f={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",selectedCircle:"c3-selected-circle",selectedCircles:"c3-selected-circles",eventRect:"c3-event-rect",eventRects:"c3-event-rects",zoomRect:"c3-zoom-rect",brush:"c3-brush",focused:"c3-focused",region:"c3-region",regions:"c3-regions",tooltip:"c3-tooltip",tooltipName:"c3-tooltip-name",shape:"c3-shape",shapes:"c3-shapes",line:"c3-line",bar:"c3-bar",bars:"c3-bars",circle:"c3-circle",circles:"c3-circles",arc:"c3-arc",area:"c3-area",text:"c3-text",texts:"c3-texts",grid:"c3-grid",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",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",legendItem:"c3-legend-item",legendItemEvent:"c3-legend-item-event",legendItemTile:"c3-legend-item-tile",dragarea:"c3-dragarea",EXPANDED:"_expanded_",SELECTED:"_selected_",INCLUDED:"_included_"};e.generate=function(e){function g(a,b){if(!(a in e))throw Error(b)}function h(a,b){var c,d,f,g=e;for(c=0;cuf&&(uf=0),0>wf&&(wf=0),sf={top:Fg?rf.top:zf-zg-(ki?0:Af),right:0/0,bottom:20+(ki?0:Af),left:Fg?oi:rf.left},vf=Fg?rf.left-oi-pi:uf,xf=Fg?wf:zf-sf.top-sf.bottom,0>vf&&(vf=0),0>xf&&(xf=0),tf={top:ki?0:zf-Af,right:0/0,bottom:0,left:ki?yf-Bf:0},p(),ki&&Rd(df.data.targets)&&(tf.left=uf/2+Df)}function o(){yi.select("line."+f.xgridFocus).attr("x1",Fg?0:-10).attr("x2",Fg?uf:-10).attr("y1",Fg?-10:rf.top).attr("y2",Fg?-10:wf)}function p(){Df=wf/2,Cf=.95*Df,Ef=Qd(df.data.targets)?.6*Cf:0}function q(){var a=Fg?f.axisX:f.axisY,b=cf.select("."+a).node(),c=b?b.getBoundingClientRect():{right:0},d=cf.select(ff).node().getBoundingClientRect(),e=c.right-d.left-t();return e>0?e:0}function r(){return gf?gf:x()}function s(){var a=hf?hf:y();return a>0?a:320}function t(){return Rd(df.data.targets)?0:jf?jf:Fg||!Sg||Xg?1:v("y")}function u(){var a=1;return Rd(df.data.targets)?0:kf?kf:ki?Bf+(_g&&!Fg?v("y2"):a):_g?eh||Fg?a:v("y2"):a}function v(a){var b=gb(a);return b.isInner?20+zb(a):40+zb(a)}function w(a){return"y"!==a||Sg?"y2"!==a||_g?(gb(a).isInner?30:40)+("y2"===a?-10:0):qi:Bg&&!ki?10:1}function x(){return+cf.select(ff).style("width").replace("px","")}function y(){return+cf.select(ff).style("height").replace("px","")}function z(a){return a?-5:-(rf.left-1)}function A(a){return a?-20:-1}function B(){return z(!Fg)}function C(){return A(!Fg)}function D(){return z(Fg)}function E(){return A(Fg)}function F(a){return a?uf+2+4:rf.left+20}function G(a){return a?80:wf+2}function H(){return F(!Fg)}function I(){return G(!Fg)}function J(){return F(Fg)}function K(){return G(Fg)}function L(){var a=Fg?wf:uf,b=tc(),c=Vb()*(Nd(df.data.targets)?(b-(Wh?.25:1))/b:.98);return b>1?a*c/(b-1):a}function M(a){li=a}function N(a){mi=a}function O(a){ni=a}function P(){return Bg?ki?mi*(li+1):yf:0}function Q(){return Bg?ki?zf:ni*(li+1):0}function R(){var a,b=!Rf;Jf=Fg?1:0,Kf=Fg?wf:uf,Lf=Fg?0:wf,Mf=Fg?uf:1,Nf=Jf,Of=Kf,Pf=Fg?0:xf,Qf=Fg?vf:1,Rf=T(Jf,Kf,b?void 0:Rf.domain(),function(){return Xf.tickOffset()}),Sf=U(Lf,Mf),Tf=U(Lf,Mf),Uf=T(Jf,Kf,Di,function(a){return a%1?0:$f.tickOffset()}),Vf=U(Pf,Qf),Wf=U(Pf,Qf),a=$(),Xf=X(Rf,fi,a),$f=X(Uf,ii,a),Yf=Y(Sf,gi,Yg,$g),Zf=Y(Tf,hi,fh,hh),b||(ri.scale(Uf),lf&&vi.scale(Rf)),S()}function S(){Ff=Db(),Gf=Eb(),Hf=Eb(.98)}function T(a,b,e,f){var g=(Vh?cf.time.scale():cf.scale.linear()).range([a,b]);if(g.orgDomain=function(){return g.domain()},d(e)&&g.domain(e),c(f)&&(f=function(){return 0}),Wh){var h,i=g;g=function(a){return i(a)+f(a)};for(h in i)g[h]=i[h];g.orgDomain=function(){return i.domain()},g.domain=function(a){return arguments.length?(i.domain(a),g):(a=i.domain(),[a[0],a[1]+1])}}return g}function U(a,b){return cf.scale.linear().range([a,b])}function V(a){return"y2"===Z(a)?Tf:Sf}function W(a){return"y2"===Z(a)?Wf:Vf}function X(a,b,c){var d=(Wh?Bb():cf.svg.axis()).scale(a).orient(b);return d.tickFormat(c),Wh?d.tickCentered(Ig):d.tickOffset=function(){var a=Fg?wf:uf;return a*Vb()/tc()/2},Wh&&d.categories(Hg),d}function Y(a,b,c,d){return cf.svg.axis().scale(a).orient(b).tickFormat(c).ticks(d).outerTickSize(0)}function Z(a){return a in fg?fg[a]:"y"}function $(){var a=Vh?ci:Wh?Mc:function(a){return 0>a?a.toFixed(0):a};return Jg&&("function"==typeof Jg?a=Jg:Vh&&(a=function(a){return cf.time.format(Jg)(a)})),a}function _(a){var b;return"y"===a?b=Wg:"y2"===a?b=dh:"x"===a&&(b=Rg),b}function ab(a){var b=_(a);return"string"==typeof b?b:b?b.text:null}function bb(a,b){var c=_(a);"string"==typeof c?"y"===a?Wg=b:"y2"===a?dh=b:"x"===a&&(Rg=b):c&&(c.text=b)}function cb(a,b){var c=_(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}}function db(){return cb("x",Fg?"inner-top":"inner-right")}function eb(){return cb("y",Fg?"inner-right":"inner-top")}function fb(){return cb("y2",Fg?"inner-right":"inner-top")}function gb(a){return"y2"===a?fb():"y"===a?eb():db()}function hb(){return ab("x")}function ib(){return ab("y")}function jb(){return ab("y2")}function kb(a,b){return a?b.isLeft?0:b.isCenter?uf/2:uf:b.isBottom?-wf:b.isMiddle?-wf/2:0}function lb(a,b){return a?b.isLeft?"0.5em":b.isRight?"-0.5em":"0":b.isTop?"-0.5em":b.isBottom?"0.5em":"0"}function mb(a,b){return a?b.isLeft?"start":b.isCenter?"middle":"end":b.isBottom?"start":b.isMiddle?"middle":"end"}function nb(){return kb(!Fg,db())}function ob(){return kb(Fg,eb())}function pb(){return kb(Fg,fb())}function qb(){return lb(!Fg,db())}function rb(){return lb(Fg,eb())}function sb(){return lb(Fg,fb())}function tb(){var a=db();return Fg?a.isInner?"1.2em":-30-zb("x"):a.isInner?"-0.5em":"3em"}function ub(){var a=eb();return Fg?a.isInner?"-0.5em":"3em":a.isInner?"1.2em":-20-zb("y")}function vb(){var a=fb();return Fg?a.isInner?"1.2em":"-2.2em":a.isInner?"-0.5em":30+zb("y2")}function wb(){return mb(!Fg,db())}function xb(){return mb(Fg,eb())}function yb(){return mb(Fg,fb())}function zb(a){var b=0,c="x"===a?f.axisX:"y"===a?f.axisY:f.axisY2;return cf.selectAll("."+c+" .tick text").each(function(){var a=this.getBBox();bb?20:b}function Ab(){yi.select("."+f.axisX+" ."+f.axisXLabel).attr("x",nb).text(hb),yi.select("."+f.axisY+" ."+f.axisYLabel).attr("x",ob).attr("dy",ub).text(ib),yi.select("."+f.axisY2+" ."+f.axisY2Label).attr("x",pb).attr("dy",vb).text(jb)}function Bb(){function a(a,b){a.attr("transform",function(a){return"translate("+(b(a)+p)+", 0)"})}function b(a,b){a.attr("transform",function(a){return"translate(0,"+b(a)+")"})}function c(a){var b=a[0],c=a[a.length-1];return c>b?[b,c]:[c,b]}function d(a){for(var b=[],c=Math.ceil(a[0]);c0&&b[0]>0&&b.unshift(b[0]-(b[1]-b[0])),b}function e(a,b){var c=a.length-1;return o>=c||b%Math.ceil(c/o)===0}function f(a){return a0)for(g=Kc(a),b=0;b=0}),0!==e.length)for(d=e[0],g&&i[d]&&i[d].forEach(function(a,b){i[d][b]=0>a?a:0}),c=1;c0||(i[d][b]+=+a)});return cf.min(Object.keys(i).map(function(a){return cf.min(i[a])}))}function Tb(a){var b,c,d,e,f,g,h=vc(a),i=Ic(a);if(eg.length>0)for(g=Lc(a),b=0;b=0}),0!==e.length)for(d=e[0],g&&i[d]&&i[d].forEach(function(a,b){i[d][b]=a>0?a:0}),c=1;c+a||(i[d][b]+=+a)});return cf.max(Object.keys(i).map(function(a){return cf.max(i[a])}))}function Ub(a,c){var d,e,f,g,h,i,j,k,l=a.filter(function(a){return Z(a.id)===c}),m="y2"===c?bh:Ug,n="y2"===c?ah:Tg,o=b(m)?m:Sb(l),p=b(n)?n:Tb(l),q="y2"===c?ch:Vg,r=id()&&Fg;return 0===l.length?"y2"===c?Tf.domain():Sf.domain():(o===p&&(0>o?p=0:o=0),d=Math.abs(p-o),e=f=g=r?0:.1*d,q&&(h=Math.max(Math.abs(o),Math.abs(p)),p=h-q,o=q-h),r&&(i=jd(o,p),j=$b(Sf.range()),k=[i[0]/j,i[1]/j],f+=d*(k[1]/(1-k[0]-k[1])),g+=d*(k[0]/(1-k[0]-k[1]))),"y"===c&&Zg&&(f=b(Zg.top)?Zg.top:e,g=b(Zg.bottom)?Zg.bottom:e),"y2"===c&&gh&&(f=b(gh.top)?gh.top:e,g=b(gh.bottom)?gh.bottom:e),Nd(l)&&!Kc(l)&&(g=o),[o-g,p+f])}function Vb(a){var b=$b(Di),c=$b(Rf.domain());return a||0===c?1:b/c}function Wb(a){return Pg?Pg:cf.min(a,function(a){return cf.min(a.values,function(a){return a.x})})}function Xb(a){return Og?Og:cf.max(a,function(a){return cf.max(a.values,function(a){return a.x})})}function Yb(a,b){var c,d,e=b[0],f=b[1],g=Math.abs(e-f);return Wh?d=0:Nd(a)?(c=tc(),d=c>1?g/(c-1)/2:.5):d=.01*g,d}function Zb(a){var b=[Wb(a),Xb(a)],c=b[0],d=b[1],e=Yb(a,b),f=Vh?new Date(c.getTime()-e):c-e,g=Vh?new Date(d.getTime()+e):d+e;return[f,g]}function $b(a){return a[1]-a[0]}function _b(a){for(var b=0;bd?0:d}function ec(a){return _f&&a===_f||fe(ag)&&ge(ag,a)}function fc(a){return!ec(a)}function gc(a){return _f?_f:fe(ag)?ag[a]:null}function hc(a,b){return a in df.data.x&&df.data.x[a]&&df.data.x[a][b]?df.data.x[a][b]:b}function ic(a){Object.keys(a).forEach(function(b){ag[b]=a[b]})}function jc(a){var b;return a&&(b=dg[a.id],a.name=b?b:a.id),a}function kc(a,b){a.forEach(function(a){a.values.forEach(function(c,d){c.x=mc(b[d],a.id,d)}),df.data.x[a.id]=b})}function lc(a,b){a.forEach(function(a){b[a.id]&&kc([a],b[a.id])})}function mc(a,b,c){var d;return d=Vh?a?a instanceof Date?a:be(a):be(hc(b,c)):Xh&&!Wh?a?+a:hc(b,c):c}function nc(a){var b,c,d=a[0],e={},f=[];for(b=1;b=0&&(df.data.x[b]=a.map(function(a){return a[c]})):df.data.x[b]=a.map(function(a,b){return b})}),c.forEach(function(a){if(!df.data.x[a])throw new Error('x is not defined for id = "'+a+'".')}),b=c.map(function(b,c){var d=cg(b);return{id:d,id_org:b,values:a.map(function(a,e){var f=gc(b),g=a[f],h=mc(g,b,e);return Xh&&Wh&&0===c&&g&&(0===e&&(Hg=[]),Hg.push(g)),"undefined"==typeof a[b]&&(h=void 0),{x:h,value:null===a[b]||isNaN(a[b])?null:+a[b],id:d}}).filter(function(a){return"undefined"!=typeof a.x})}}),b.forEach(function(a){var b;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++})}),gg&&Ld(vc(b).filter(function(a){return!(a in hg)}),gg),b.forEach(function(a){ac(a.id_org,a)}),b}function qc(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}})}}function rc(a){return a>0&&df.data.targets[0].values[a-1]?df.data.targets[0].values[a-1].x:void 0}function sc(a){return a1?df.data.targets.forEach(function(b){b.values.length>c&&(a=b,c=b.values.length)}):a=b?df.data.targets[0]:null,a}function vc(a){return a.map(function(a){return a.id})}function wc(a){return a?"string"==typeof a?[a]:a:vc(df.data.targets)}function xc(a,b){var c,d=vc(a);for(c=0;c2){for(e=b-2,c=a[0],d=a[a.length-1],f=(d-c)/(e+1),i=[c],g=0;e>g;g++)h=+c+f*(g+1),i.push(Vh?new Date(h):h);i.push(d)}return i}function Ec(a){di=di.concat(a)}function Fc(a){di=di.filter(function(b){return a.indexOf(b)<0})}function Gc(a){ei=ei.concat(a)}function Hc(a){ei=ei.filter(function(b){return a.indexOf(b)<0})}function Ic(a){var b={};return a.forEach(function(a){b[a.id]=[],a.values.forEach(function(c){b[a.id].push(c.value)})}),b}function Jc(a,b){var c,d,e,f=Object.keys(a);for(c=0;ca})}function Lc(a){return Jc(a,function(a){return a>0})}function Mc(a){return a=0&&d===a[c].x;c--)e.push(a[c]);for(c=b;c0?g=h:f=h,g-f===1||0===f&&0===g?(e=[],a[f].x&&(e=e.concat(rd(a,f))),a[g].x&&(e=e.concat(rd(a,g))),ud(e,b)):sd(a,b,f,g)}function td(a,b){var c;return c=a.map(function(a){return sd(a.values,b)}),ud(c,b)}function ud(a,b){var c,d;return a.forEach(function(a){var e=he(a,b);(c>e||!c)&&(c=e,d=a)}),d}function vd(a,b){return cf.merge(a.map(function(a){return a.values})).filter(function(a){return a.x===b})}function wd(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}}function xd(){return jg&&"desc"===jg.toLowerCase()}function yd(){return jg&&"asc"===jg.toLowerCase()}function zd(a){var b=yd(),c=xd();return b||c?a.sort(function(a,c){var d=function(a,b){return a+Math.abs(b.value)},e=a.values.reduce(d,0),f=c.values.reduce(d,0);return b?f-e:e-f}):"function"==typeof jg&&a.sort(jg),a}function Ad(a,c){var d,e,f,g,h,i,j,k=Rd(df.data.targets),l=k?ld:kd,m=a.filter(function(a){return a&&b(a.value)});Ih&&0!==m.length&&(Bi.html(Lh(a,$(),l,bi)).style("display","block"),d=Bi.property("offsetWidth"),e=Bi.property("offsetHeight"),k?(g=uf/2+c[0],i=wf/2+c[1]+20):(Fg?(f=q(),g=f+c[0]+100,h=g+d,j=r()-u(),i=Rf(m[0].x)+20):(f=q(),g=f+t()+Rf(m[0].x)+20,h=g+d,j=f+r()-u(),i=c[1]+15),h>j&&(g-=d+60),i+e>s()&&(i-=e+30)),Bi.style("top",i+"px").style("left",g+"px"))}function Bd(){Bi.style("display","none")}function Cd(a){var c=a.filter(function(a){return a&&b(a.value)});Ih&&(Od(df.data.targets)||Rd(df.data.targets)||yi.selectAll("line."+f.xgridFocus).style("visibility","visible").data([c[0]]).attr(Fg?"y1":"x1",nd).attr(Fg?"y2":"x2",nd))}function Dd(){yi.select("line."+f.xgridFocus).style("visibility","hidden")}function Ed(a){return a.x||0===a.x?Rf(a.x):null}function Fd(a){return V(a.id)(a.value)}function Gd(){var a,b,d={},e=0;return Bc(yc(Ud)).forEach(function(f){for(a=0;a0&&(i+=g(b.values[f].value)-h)}),i}}function Kd(a,b){return uh?uh:b?2*a.tickOffset()*vh/b:0}function Ld(a,b){wc(a).forEach(function(a){Fi[a]=b===hg[a],hg[a]=b})}function Md(a,b){var c=!1;return a.forEach(function(a){hg[a.id]===b&&(c=!0),a.id in hg||"line"!==b||(c=!0)}),c}function Nd(a){return Md(a,"bar")}function Od(a){return Md(a,"scatter")}function Pd(a){return Md(a,"pie")}function Qd(a){return Md(a,"donut")}function Rd(a){return Pd(a)||Qd(a)}function Sd(a){var b="string"==typeof a?a:a.id;return!(b in hg)||"line"===hg[b]||"spline"===hg[b]||"area"===hg[b]||"area-spline"===hg[b]}function Td(a){var b="string"==typeof a?a:a.id;return"spline"===hg[b]||"area-spline"===hg[b]}function Ud(a){var b="string"==typeof a?a:a.id;return"bar"===hg[b]}function Vd(a){var b="string"==typeof a?a:a.id;return"scatter"===hg[b]}function Wd(a){var b="string"==typeof a?a:a.id;return"pie"===hg[b]}function Xd(a){var b="string"==typeof a?a:a.id;return"donut"===hg[b]}function Yd(a){return Wd(a)||Xd(a)}function Zd(a){return Ud(a)?a.values:[]}function $d(a){return Sd(a)||Vd(a)?a.values:[]}function _d(a){return Ud(a)||Sd(a)?a.values:[]}function ae(a,b,c){var d=[];return function(e){var f,g=e.id||e;return a[g]instanceof Function?f=a[g](e):g in a?f=a[g]:(d.indexOf(g)<0&&d.push(g),f=b[d.indexOf(g)%b.length]),c instanceof Function?c(f,e):f}}function be(b){var c;if(!b)throw Error(b+" can not be parsed as d3.time with format "+bg+". Maybe 'x' of this data is not defined. See data.x or data.xs option.");try{c=bg?cf.time.format(bg).parse(b):new Date(b)}catch(d){c=void 0}return c||a.console.error("Failed to parse x '"+b+"' to Date with format "+bg),c}function ce(a,b){var c=cf.mouse(a),d=cf.select(a),e=1*d.attr("cx"),f=1*d.attr("cy");return Math.sqrt(Math.pow(e-c[0],2)+Math.pow(f-c[1],2))0}function ge(a,b){var c=!1;return Object.keys(a).forEach(function(d){a[d]===b&&(c=!0)}),c}function he(a,b){var c="y"===Z(a.id)?Sf:Tf,d=Fg?1:0,e=Fg?0:1;return Math.pow(Rf(a.x)-b[d],2)+Math.pow(c(a.value)-b[e],2)}function ie(a,b){var c=0;a.each(function(){++c}).each("end",function(){--c||b.apply(this,arguments)})}function je(a,b,c){ug(b,a.node()),yi.select("."+f.selectedCircles+_c(b.id)).selectAll("."+f.selectedCircle+"-"+c).data([b]).enter().append("circle").attr("class",function(){return Nc(f.selectedCircle,c)}).attr("cx",Fg?Fd:Ed).attr("cy",Fg?Ed:Fd).attr("stroke",function(){return bi(b)}).attr("r",1.4*th).transition().duration(100).attr("r",th)}function ke(a,b,c){vg(b,a.node()),yi.select("."+f.selectedCircles+_c(b.id)).selectAll("."+f.selectedCircle+"-"+c).transition().duration(100).attr("r",0).remove()}function le(a,b,c,d){a?je(b,c,d):ke(b,c,d)}function me(a,b){ug(b,a.node()),a.transition().duration(100).style("fill",function(){return cf.rgb(bi(b)).darker(1)})}function ne(a,b){vg(b,a.node()),a.transition().duration(100).style("fill",function(){return bi(b)})}function oe(a,b,c,d){a?me(b,c,d):ne(b,c,d)}function pe(a){return a.filter(function(a){return b(a.value)})}function qe(a,c){return(c?yi.selectAll("."+f.circles+_c(c)):yi).selectAll("."+f.circle+(b(a)?"-"+a:""))}function re(a,b){qe(a,b).classed(f.EXPANDED,!0).attr("r",sh)}function se(a){qe(a).filter(function(){return cf.select(this).classed(f.EXPANDED)}).classed(f.EXPANDED,!1).attr("r",ph)}function te(a){return yi.selectAll("."+f.bar+(b(a)?"-"+a:""))}function ue(a){te(a).classed(f.EXPANDED,!0)}function ve(a){te(a).classed(f.EXPANDED,!1)}function we(a,b){var c=Ae(a,b);return function(a,b){var d=c(a,b),e=Fg?1:0,f=Fg?0:1,g="M "+d[0][e]+","+d[0][f]+" L"+d[1][e]+","+d[1][f]+" L"+d[2][e]+","+d[2][f]+" L"+d[3][e]+","+d[3][f]+" z";return g}}function xe(a,b){var c=Ae(a,!1),d=b?ye:ze;return function(a,b){return d(c(a,b),a,this)}}function ye(a,b){var c;return Fg?(c=Ud(b)?4:6,a[2][1]+c*(b.value<0?-1:1)):a[0][0]+(a[2][0]-a[0][0])/2}function ze(a,b,c){var d=c.getBBox();return Fg?(a[0][0]+a[2][0]+.6*d.height)/2:a[2][1]+(b.value<0?d.height:Ud(b)?-3:-6)}function Ae(a,b){var c=a.__max__+1,d=Kd(Xf,c),e=Hd(d,c,a,!!b),f=Id(!!b),g=Jd(a,!!b),h=b?W:V;return function(a,b){var c=h(a.id)(0),i=g(a,b)||c,j=e(a),k=f(a);return Fg&&(a.value>0&&i>k||a.value<0&&k>i)&&(k=i),[[j,i],[j,k-(c-i)],[j+d,k-(c-i)],[j+d,i]]}}function Be(a,b,e,f){var g,h,i,j,k,l,m,n,o,p,q,r=-1,s="M",t=[];if(d(f))for(g=0;g=h;h+=u)s+=i(a[g-1],a[g],h,o)}r=a[g].x}return s}function Ce(b){var c,d,e;if(Ci=cf.select(ff),Ci.empty())throw new Error('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');if(Ci.html(""),Ci.classed("c3",!0),df.data.x={},df.data.targets=pc(b),n(),R(),Rf.domain(cf.extent(Zb(df.data.targets))),Sf.domain(Ub(df.data.targets,"y")),Tf.domain(Ub(df.data.targets,"y2")),Uf.domain(Rf.domain()),Vf.domain(Sf.domain()),Wf.domain(Tf.domain()),Di=Rf.domain(),ri.scale(Uf),lf&&vi.scale(Rf),wi=Ci.append("svg").attr("width",uf+rf.left+rf.right).attr("height",wf+rf.top+rf.bottom).on("mouseenter",of).on("mouseleave",pf),xi=wi.append("defs"),xi.append("clipPath").attr("id",Ph).append("rect").attr("width",uf).attr("height",wf),xi.append("clipPath").attr("id",Qh).append("rect").attr("x",B).attr("y",C).attr("width",H).attr("height",I),xi.append("clipPath").attr("id",Rh).append("rect").attr("x",D).attr("y",E).attr("width",J).attr("height",K),yi=wi.append("g").attr("transform",ji.main),zi=yg?wi.append("g").attr("transform",ji.context):null,Ai=Bg?wi.append("g").attr("transform",ji.legend):null,Bi=cf.select(ff).style("position","relative").append("div").style("position","absolute").style("pointer-events","none").style("z-index","10").style("display","none"),Ze(vc(df.data.targets),{withTransform:!1,withTransitionForTransform:!1}),yi.append("g").attr("class",f.axisX).attr("clip-path",Fg?"":Th).attr("transform",ji.x).append("text").attr("class",f.axisXLabel).attr("transform",Fg?"rotate(-90)":"").attr("dx",qb).attr("dy",tb).style("text-anchor",wb),Sg&&yi.append("g").attr("class",f.axisY).attr("clip-path",Fg?Uh:"").attr("transform",ji.y).append("text").attr("class",f.axisYLabel).attr("transform",Fg?"":"rotate(-90)").attr("dx",rb).attr("dy",ub).style("text-anchor",xb),_g&&yi.append("g").attr("class",f.axisY2).attr("transform",ji.y2).append("text").attr("class",f.axisY2Label).attr("transform",Fg?"":"rotate(-90)").attr("dx",sb).style("text-anchor",yb),d=yi.append("g").attr("clip-path",Sh).attr("class",f.grid),ih&&d.append("g").attr("class",f.xgrids),fe(kh)&&d.append("g").attr("class",f.xgridLines),qh&&d.append("g").attr("class",f.xgridFocus).append("line").attr("class",f.xgridFocus),lh&&d.append("g").attr("class",f.ygrids),fe(mh)&&d.append("g").attr("class",f.ygridLines),yi.append("g").attr("clip-path",Sh).attr("class",f.regions),yi.append("g").attr("clip-path",Sh).attr("class",f.chart),c=yi.select("."+f.chart).append("g").attr("class",f.eventRects).style("fill-opacity",0).style("cursor",lf?Fg?"ns-resize":"ew-resize":null),yi.select("."+f.chart).append("g").attr("class",f.chartBars),yi.select("."+f.chart).append("g").attr("class",f.chartLines),yi.select("."+f.chart).append("g").attr("class",f.chartArcs).attr("transform",ji.arc).append("text").attr("class",f.chartArcsTitle).style("text-anchor","middle").text(Ob()),yi.select("."+f.chart).append("g").attr("class",f.chartTexts),lf&&yi.insert("rect",nf?null:"g."+f.grid).attr("class",f.zoomRect).attr("width",uf).attr("height",wf).style("opacity",0).style("cursor",Fg?"ns-resize":"ew-resize").call(vi).on("dblclick.zoom",null),Qg&&ri.extent("function"!=typeof Qg?Qg:Qg(Zb())),yg&&(zi.append("g").attr("clip-path",Sh).attr("class",f.chart),zi.select("."+f.chart).append("g").attr("class",f.chartBars),zi.select("."+f.chart).append("g").attr("class",f.chartLines),zi.append("g").attr("clip-path",Sh).attr("class",f.brush).call(ri).selectAll("rect").attr(Fg?"width":"height",Fg?vf:xf),zi.append("g").attr("class",f.axisX).attr("transform",ji.subx).attr("clip-path",Fg?"":Th)),Pe(df.data.targets),Fg?yi.select("."+f.axisX).style("opacity",0).call(Xf):(yi.select("."+f.axisY).style("opacity",0).call(Yf),yi.select("."+f.axisY2).style("opacity",0).call(Zf)),Je({withTransform:!0,withUpdateXDomain:!0,withUpdateOrgXDomain:!0,withTransitionForAxis:!1}),Mh){if(Vh&&"string"==typeof Nh){for(Nh=be(Nh),e=0;e0){d=[];for(var g in dg)for(c=0;cg&&h>c&&d>i&&j>d):"path"===this.nodeName&&(m=wd(this),c=m.x,d=m.y,e=m.width,k=m.height,l=oe,q=!(c>h||g>c+e||d>j||i>d+k)),q^p&&(n.classed(f.INCLUDED,!p),n.classed(f.SELECTED,!o),l(!o,n,a,b))}))}function He(a){Rd(df.data.targets)||ng&&(Yh=a,yi.select("."+f.chart).append("rect").attr("class",f.dragarea).style("opacity",.1),Zh=!0,wg())}function Ie(){Rd(df.data.targets)||ng&&(yi.select("."+f.dragarea).transition().duration(100).style("opacity",0).remove(),yi.selectAll("."+f.shape).classed(f.INCLUDED,!1),Zh=!1,xg())}function Je(a){var c,e,g,h,i,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,M,N,O,P,Q,R,S=Gd(),T=Rd(df.data.targets),U=Bc(df.data.targets);if(0!==U.length){if(a=d(a)?a:{},x=d(a.withY)?a.withY:!0,y=d(a.withSubchart)?a.withSubchart:!0,z=d(a.withTransition)?a.withTransition:!0,D=d(a.withTransform)?a.withTransform:!1,E=d(a.withUpdateXDomain)?a.withUpdateXDomain:!1,F=d(a.withUpdateOrgXDomain)?a.withUpdateOrgXDomain:!1,G=d(a.withLegend)?a.withLegend:!1,A=d(a.withTransitionForExit)?a.withTransitionForExit:z,B=d(a.withTransitionForAxis)?a.withTransitionForAxis:z,C=d(a.withTransitionForHorizontalAxis)?a.withTransitionForHorizontalAxis:z,M=z?qf:0,N=A?M:0,O=B?M:0,G&&Bg&&Ze(vc(df.data.targets),a),F&&(Rf.domain(cf.extent(Zb(U))),Di=Rf.domain(),lf&&vi.scale(Rf).updateScaleExtent(),Uf.domain(Rf.domain()),ri.scale(Uf)),E&&(Rf.domain(ri.empty()?Di:ri.extent()),lf&&vi.scale(Rf).updateScaleExtent()),Sf.domain(Ub(U,"y")),Tf.domain(Ub(U,"y2")),Od(U)||(P=Dc(Cc(U)).sort(),Xf.tickValues(P),$f.tickValues(P)),c=yi.select("."+f.axisX).style("opacity",T?0:1),(Fg||C)&&(c=c.transition().duration(O)),c.call(Xf),e=yi.select("."+f.axisY).style("opacity",T?0:1),(!Fg||C)&&(e=e.transition().duration(O)),e.call(Yf),yi.select("."+f.axisY2).style("opacity",T?0:1).transition().duration(O).call(Zf),E&&Kg&&P){for(Q=1;Q=Y;Y++)h.push(new Date(Y+"-01-01 00:00:00"))}else h=Rf.ticks(10);g=yi.select("."+f.xgrids).selectAll("."+f.xgrid).data(h),g.enter().append("line").attr("class",f.xgrid),g.attr("x1",Fg?0:function(a){return Rf(a)-Xf.tickOffset()}).attr("x2",Fg?uf:function(a){return Rf(a)-Xf.tickOffset()}).attr("y1",Fg?function(a){return Rf(a)-Xf.tickOffset()}:rf.top).attr("y2",Fg?function(a){return Rf(a)-Xf.tickOffset()}:wf).style("opacity",function(){return+cf.select(this).attr(Fg?"y1":"x1")===(Fg?wf:0)?0:1}),g.exit().remove()}fe(kh)&&(i=yi.select("."+f.xgridLines).selectAll("."+f.xgridLine).data(kh),j=i.enter().append("g").attr("class",function(a){return f.xgridLine+(a.class?a.class:"")}),j.append("line").style("opacity",0),j.append("text").attr("text-anchor","end").attr("transform",Fg?"":"rotate(-90)").attr("dx",Fg?0:-rf.top).attr("dy",-5).style("opacity",0),i.select("line").transition().duration(M).attr("x1",Fg?0:od).attr("x2",Fg?uf:od).attr("y1",Fg?od:rf.top).attr("y2",Fg?od:wf).style("opacity",1),i.select("text").transition().duration(M).attr("x",Fg?uf:0).attr("y",od).text(function(a){return a.text}).style("opacity",1),i.exit().transition().duration(M).style("opacity",0).remove()),x&&lh&&(k=yi.select("."+f.ygrids).selectAll("."+f.ygrid).data(Sf.ticks(nh)),k.enter().append("line").attr("class",f.ygrid),k.attr("x1",Fg?Sf:0).attr("x2",Fg?Sf:uf).attr("y1",Fg?0:Sf).attr("y2",Fg?wf:Sf),k.exit().remove()),x&&fe(mh)&&(l=yi.select("."+f.ygridLines).selectAll("."+f.ygridLine).data(mh),m=l.enter().append("g").attr("class",function(a){return f.ygridLine+(a.class?a.class:"")}),m.append("line").style("opacity",0),m.append("text").attr("text-anchor","end").attr("transform",Fg?"rotate(-90)":"").attr("dx",Fg?0:-rf.top).attr("dy",-5).style("opacity",0),l.select("line").transition().duration(M).attr("x1",Fg?pd:0).attr("x2",Fg?pd:uf).attr("y1",Fg?0:pd).attr("y2",Fg?wf:pd).style("opacity",1),l.select("text").transition().duration(M).attr("x",Fg?0:uf).attr("y",pd).text(function(a){return a.text}).style("opacity",1),l.exit().transition().duration(M).style("opacity",0).remove()),p=yi.selectAll("."+f.bars).selectAll("."+f.bar).data(Zd),p.enter().append("path").attr("d",H).style("stroke","none").style("opacity",0).style("fill",function(a){return bi(a)}).attr("class",Vc),p.style("opacity",ed).transition().duration(M).attr("d",H).style("opacity",1),p.exit().transition().duration(N).style("opacity",0).remove(),r=yi.selectAll("."+f.texts).selectAll("."+f.text).data(_d),r.enter().append("text").attr("class",Oc).attr("text-anchor",function(a){return Fg?a.value<0?"end":"start":"middle"}).style("stroke","none").style("fill-opacity",0),r.text(function(a){return md(a.id)(a.value)}).style("fill-opacity",fd).transition().duration(M).attr("x",J).attr("y",K).style("fill-opacity",hd),r.exit().transition().duration(N).style("fill-opacity",0).remove(),yi.selectAll("."+f.line).style("opacity",ed).transition().duration(M).attr("d",si).style("opacity",1),yi.selectAll("."+f.area).style("opacity",0).transition().duration(M).attr("d",ti).style("opacity",Ei),n=yi.selectAll("."+f.circles).selectAll("."+f.circle).data($d),n.enter().append("circle").attr("class",Tc).style("opacity",0).attr("r",ph),n.style("opacity",ed).transition().duration(M).style("opacity",gd).attr("cx",Fg?Fd:Ed).attr("cy",Fg?Ed:Fd),n.exit().remove(),yi.selectAll("."+f.chartArc).select("."+f.arc).attr("transform",D?"scale(0)":"").style("opacity",function(a){return a===this._current?0:1}).transition().duration(M).attrTween("d",function(a){var b,c=Cb(a);return c?(b=cf.interpolate(this._current,c),this._current=b(0),function(a){return Fb(b(a),!0)}):function(){return"M 0 0"}}).attr("transform",D?"scale(1)":"").style("opacity",1),yi.selectAll("."+f.chartArc).select("text").attr("transform",Gb).style("opacity",0).transition().duration(M).text(Jb).style("opacity",function(a){return zc(a.data.id)&&Yd(a.data)?1:0}),yi.select("."+f.chartArcsTitle).style("opacity",Qd(df.data.targets)?1:0),yg&&(null!==cf.event&&"zoom"===cf.event.type&&ri.extent(Rf.orgDomain()).update(),y&&(zi.select("."+f.axisX).style("opacity",T?0:1).transition().duration(M).call($f),ri.empty()||ri.extent(Rf.orgDomain()).update(),I=we(S,!0),s=zi.selectAll("."+f.bars).selectAll("."+f.bar).data(Zd),s.enter().append("path").attr("d",I).style("stroke","none").style("fill",function(a){return bi(a)}).attr("class",Vc),s.style("opacity",ed).transition().duration(M).attr("d",I).style("opacity",1),s.exit().transition().duration(M).style("opacity",0).remove(),zi.selectAll("."+f.line).style("opacity",ed).transition().duration(M).attr("d",ui).style("opacity",1))),yi.selectAll("."+f.selectedCircles).filter(function(a){return Ud(a)}).selectAll("circle").remove(),yi.selectAll("."+f.selectedCircle).transition().duration(M).attr("cx",Fg?Fd:Ed).attr("cy",Fg?Ed:Fd),fe(ag)?(t=yi.select("."+f.eventRects).selectAll("."+f.eventRect).data([0]),Ee(t.enter()),t.attr("x",0).attr("y",0).attr("width",uf).attr("height",wf)):(Xh&&!Wh?(w=function(a,b){var c=rc(b),d=sc(b),e=df.data.x[a.id][b];return(Rf(d?d:e+50)-Rf(c?c:e-50))/2},v=function(a,b){var c=rc(b),d=df.data.x[a.id][b];return(Rf(d)+Rf(c?c:d-50))/2}):(w=L(),v=function(a){return Rf(a.x)-w/2}),u=uc(),yi.select("."+f.eventRects).datum(u?u.values:[]),t=yi.select("."+f.eventRects).selectAll("."+f.eventRect).data(function(a){return a}),De(t.enter()),t.attr("class",$c).attr("x",Fg?0:v).attr("y",Fg?v:0).attr("width",Fg?uf:w).attr("height",Fg?w:wf),t.exit().remove()),q=yi.select("."+f.regions).selectAll("rect."+f.region).data(Hh),q.enter().append("rect").style("fill-opacity",0),q.attr("class",Zc).attr("x",Fg?0:cc).attr("y",Fg?cc:rf.top).attr("width",Fg?uf:dc).attr("height",Fg?dc:wf).transition().duration(M).style("fill-opacity",function(a){return b(a.opacity)?a.opacity:.1}),q.exit().transition().duration(M).style("fill-opacity",0).remove(),vc(df.data.targets).forEach(function(a){Fi[a]=!0})}}function Ke(){Je({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}function Le(){return"mousemove"===cf.event.sourceEvent.type&&vi.altDomain?(Rf.domain(vi.altDomain),void vi.scale(Rf).updateScaleExtent()):(Wh&&Rf.orgDomain()[0]===Di[0]&&Rf.domain([Di[0]-1e-10,Rf.orgDomain()[1]]),Je({withTransition:!1,withY:!1,withSubchart:!1}),void("mousemove"===cf.event.sourceEvent.type&&($h=!0)))}function Me(){function a(){b.forEach(function(a){a()})}var b=[];return a.add=function(a){b.push(a)},a}function Ne(){wi.attr("width",yf).attr("height",zf),wi.select("#"+Ph).select("rect").attr("width",uf).attr("height",wf),wi.select("#"+Qh).select("rect").attr("width",H),wi.select("#"+Rh).select("rect").attr("width",J),wi.select("."+f.zoomRect).attr("width",uf).attr("height",wf)}function Oe(a){a=a||{},a.withTransition=d(a.withTransition)?a.withTransition:!0,a.withTransform=d(a.withTransform)?a.withTransform:!1,a.withLegend=d(a.withLegend)?a.withLegend:!1,a.withUpdateXDomain=!0,a.withUpdateOrgXDomain=!0,a.withTransitionForExit=!1,n(),R(),Ne(),m(a.withTransition),Je(a)}function Pe(a){var b,c,d,e,g,h,i,j,k,l,m,n;i=yi.select("."+f.chartTexts).selectAll("."+f.chartText).data(a),j=i.enter().append("g").attr("class",function(a){return f.chartText+Nc(f.target,a.id)}).style("pointer-events","none"),j.append("g").attr("class",Pc).style("fill",function(a){return bi(a)}),e=yi.select("."+f.chartBars).selectAll("."+f.chartBar).data(a),d=e.enter().append("g").attr("class",function(a){return f.chartBar+Nc(f.target,a.id)}).style("pointer-events","none"),d.append("g").attr("class",Wc).style("fill",function(a){return bi(a)}).style("stroke","none").style("cursor",function(a){return pg(a)?"pointer":null}),c=yi.select("."+f.chartLines).selectAll("."+f.chartLine).data(a),b=c.enter().append("g").attr("class",function(a){return f.chartLine+Nc(f.target,a.id)}).style("pointer-events","none"),b.append("path").attr("class",Sc).style("opacity",0).style("stroke",function(a){return bi(a)}),b.append("path").attr("class",Yc).style("opacity",function(){return Ei=+cf.select(this).style("opacity"),0}).style("fill",function(a){return bi(a)}),b.append("g").attr("class",function(a){return Nc(f.selectedCircles,a.id)}),b.append("g").attr("class",Uc).style("fill",function(a){return bi(a)}).style("cursor",function(a){return pg(a)?"pointer":null}),a.forEach(function(a){yi.selectAll("."+f.selectedCircles+_c(a.id)).selectAll("."+f.selectedCircle).each(function(b,c){b.value=a.values[c].value})}),h=yi.select("."+f.chartArcs).selectAll("."+f.chartArc).data(If(a)),g=h.enter().append("g").attr("class",function(a){return f.chartArc+Nc(f.target,a.data.id)}),g.append("path").attr("class",Xc).style("opacity",0).style("fill",function(a){return bi(a.data)}).style("cursor",function(a){return pg(a)?"pointer":null}).each(function(a){this._current=a}).on("mouseover",function(a,b){var c=Cb(a),d=Ib(c),e=Qb();Kb(c.data.id),Ue(c.data.id),e(d,b)}).on("mousemove",function(a){var b=Cb(a),c=[Ib(b)];Ad(c,cf.mouse(this))}).on("mouseout",function(a,b){var c=Cb(a),d=Ib(c),e=Rb();Lb(c.data.id),We(),Bd(),e(d,b)}).on("click",function(a,b){var c=Cb(a),d=Ib(c),e=Pb();e(d,b)}),g.append("text").attr("dy",".35em").style("opacity",0).style("text-anchor","middle").style("pointer-events","none"),yg&&(n=zi.select("."+f.chartBars).selectAll("."+f.chartBar).data(a),m=n.enter().append("g").attr("class",function(a){return f.chartBar+Nc(f.target,a.id)}),m.append("g").attr("class",Wc).style("fill",function(a){return bi(a)}),l=zi.select("."+f.chartLines).selectAll("."+f.chartLine).data(a),k=l.enter().append("g").attr("class",function(a){return f.chartLine+Nc(f.target,a.id)}),k.append("path").attr("class",Sc).style("opacity",0).style("stroke",function(a){return bi(a)})),wi.selectAll("."+f.target).filter(function(a){return zc(a.id)}).transition().style("opacity",1)}function Qe(a,b){df.data.targets.forEach(function(b){for(var c=0;cf&&(f=(l-k)/2,x=0,D++)),C[a]=D,B[D]=f,y[a]=x,x+=k}var f,g,h=b.getBBox(),i=10*Math.ceil((h.width+t)/10),j=10*Math.ceil((h.height+s)/10),k=ki?j:i,l=ki?Af:Bf;return d&&(x=0,D=0,u=0,v=0),Ac(c)?(z[c]=i,A[c]=j,(!u||i>=u)&&(u=i),(!v||j>=v)&&(v=j),g=ki?v:u,void(Eg?(Object.keys(z).forEach(function(a){z[a]=u}),Object.keys(A).forEach(function(a){A[a]=v}),f=(l-g*a.length)/2,w>f?(x=0,D=0,a.forEach(function(a){e(a)})):e(c,!0)):e(c))):void(z[c]=A[c]=C[c]=y[c]=0)}var g,h,i,j,k,l,o,p,q,r,s=4,t=26,u=0,v=0,w=10,x=0,y={},z={},A={},B=[0],C={},D=0;b=c(b)?{}:b,p=d(b.withTransition)?b.withTransition:!0,q=d(b.withTransitionForTransform)?b.withTransitionForTransform:!0,r=d(b.withTransformAll)?b.withTransformAll:!0,ki?(g=function(a){return u*(.2+C[a])},j=function(a){return B[C[a]]+y[a]}):(g=function(a){return B[C[a]]+y[a]},j=function(a){return v*(.2+C[a])}),h=function(a,b){return g(a,b)+14},k=function(a,b){return j(a,b)+9},i=function(a,b){return g(a,b)-4},l=function(a,b){return j(a,b)-7},o=Ai.selectAll("."+f.legendItem).data(a).enter().append("g").attr("class",function(a){return Nc(f.legendItem,a)}).style("cursor","pointer").on("click",function(a){"function"==typeof Dg?Dg(a):df.toggle(a)}).on("mouseover",function(a){df.focus(a)}).on("mouseout",function(){df.revert()}),o.append("text").text(function(a){return d(dg[a])?dg[a]:a}).each(function(a,b){e(this,a,0===b)}).style("pointer-events","none").attr("x",ki?h:-200).attr("y",ki?-200:k),o.append("rect").attr("class",f.legendItemEvent).style("fill-opacity",0).attr("x",ki?i:-200).attr("y",ki?-200:l).attr("width",function(a){return z[a]}).attr("height",function(a){return A[a]}),o.append("rect").attr("class",f.legendItemTile).style("pointer-events","none").style("fill",function(a){return bi(a)}).attr("x",ki?h:-200).attr("y",ki?-200:j).attr("width",10).attr("height",10),Ai.selectAll("text").data(a).text(function(a){return d(dg[a])?dg[a]:a}).each(function(a,b){e(this,a,0===b)}).transition().duration(p?250:0).attr("x",h).attr("y",k),Ai.selectAll("rect."+f.legendItemEvent).data(a).transition().duration(p?250:0).attr("x",i).attr("y",l),Ai.selectAll("rect."+f.legendItemTile).data(a).transition().duration(p?250:0).attr("x",g).attr("y",j),N(u),O(v),M(D),n(),R(),Ne(),r&&m(q)}function $e(a){return xc(df.data.targets,a.id)}function _e(a){return"data"in a&&xc(df.data.targets,a.data.id)}function af(a){var b=a&&a.value?a.value:null,c=a&&a["class"]?a["class"]:null;return b?function(a){return a.value!==b}:c?function(a){return a["class"]!==c}:function(){return!0}}function bf(a,b,c){var d=!Rd(df.data.targets);Ld(a,b),Oe(c?c:{withTransitionForAxis:d})}var cf=a.d3?a.d3:a.require?a.require("d3"):void 0,df={data:{},axis:{},legend:{}},ef={},ff=h(["bindto"],"#chart"),gf=h(["size","width"]),hf=h(["size","height"]),jf=h(["padding","left"]),kf=h(["padding","right"]),lf=h(["zoom","enabled"],!1),mf=h(["zoom","extent"]),nf=h(["zoom","privileged"],!1),of=h(["onenter"],function(){}),pf=h(["onleave"],function(){}),qf=h(["transition","duration"],350);g("data","data is required in config");var rf,sf,tf,uf,vf,wf,xf,yf,zf,Af,Bf,Cf,Df,Ef,Ff,Gf,Hf,If,Jf,Kf,Lf,Mf,Nf,Of,Pf,Qf,Rf,Sf,Tf,Uf,Vf,Wf,Xf,Yf,Zf,$f,_f=h(["data","x"]),ag=h(["data","xs"],{}),bg=h(["data","x_format"]),cg=h(["data","id_converter"],function(a){return a}),dg=h(["data","names"],{}),eg=h(["data","groups"],[]),fg=h(["data","axes"],{}),gg=h(["data","type"]),hg=h(["data","types"],{}),ig=h(["data","labels"],{}),jg=h(["data","order"]),kg=h(["data","regions"],{}),lg=h(["data","color"]),mg=h(["data","colors"],{}),ng=h(["data","selection","enabled"],!1),og=h(["data","selection","grouped"],!1),pg=h(["data","selection","isselectable"],function(){return!0}),qg=h(["data","selection","multiple"],!0),rg=h(["data","onclick"],function(){}),sg=h(["data","onenter"],function(){}),tg=h(["data","onleave"],function(){}),ug=h(["data","onselected"],function(){}),vg=h(["data","onunselected"],function(){}),wg=h(["data","ondragstart"],function(){}),xg=h(["data","ondragend"],function(){}),yg=h(["subchart","show"],!1),zg=yg?h(["subchart","size","height"],60):0,Ag=h(["color","pattern"],[]),Bg=h(["legend","show"],!0),Cg=h(["legend","position"],"bottom"),Dg=h(["legend","item","onclick"]),Eg=h(["legend","equally"],!1),Fg=h(["axis","rotated"],!1),Gg=h(["axis","x","type"],"indexed"),Hg=h(["axis","x","categories"],[]),Ig=h(["axis","x","tick","centered"],!1),Jg=h(["axis","x","tick","format"]),Kg=h(["axis","x","tick","culling"],{}),Lg=h(["axis","x","tick","culling","max"],"categorized"===Gg?1/0:10),Mg=h(["axis","x","tick","count"]),Ng=h(["axis","x","tick","fit"],!1),Og=h(["axis","x","max"]),Pg=h(["axis","x","min"]),Qg=h(["axis","x","default"]),Rg=h(["axis","x","label"],{}),Sg=h(["axis","y","show"],!0),Tg=h(["axis","y","max"]),Ug=h(["axis","y","min"]),Vg=h(["axis","y","center"]),Wg=h(["axis","y","label"],{}),Xg=h(["axis","y","inner"],!1),Yg=h(["axis","y","tick","format"]),Zg=h(["axis","y","padding"],{}),$g=h(["axis","y","ticks"],10),_g=h(["axis","y2","show"],!1),ah=h(["axis","y2","max"]),bh=h(["axis","y2","min"]),ch=h(["axis","y2","center"]),dh=h(["axis","y2","label"],{}),eh=h(["axis","y2","inner"],!1),fh=h(["axis","y2","tick","format"]),gh=h(["axis","y2","padding"],{}),hh=h(["axis","y2","ticks"],10),ih=h(["grid","x","show"],!1),jh=h(["grid","x","type"],"tick"),kh=h(["grid","x","lines"],[]),lh=h(["grid","y","show"],!1),mh=h(["grid","y","lines"],[]),nh=h(["grid","y","ticks"],10),oh=h(["point","show"],!0),ph=oh?h(["point","r"],2.5):0,qh=h(["point","focus","line","enabled"],!0),rh=h(["point","focus","expand","enabled"],!0),sh=h(["point","focus","expand","r"],rh?4:ph),th=h(["point","focus","select","r"],8),uh=h(["bar","width"]),vh=h(["bar","width","ratio"],.6),wh=h(["pie","label","show"],!0),xh=h(["pie","label","format"]),yh=h(["pie","onclick"],function(){}),zh=h(["pie","onmouseover"],function(){}),Ah=h(["pie","onmouseout"],function(){}),Bh=h(["donut","label","show"],!0),Ch=h(["donut","label","format"]),Dh=h(["donut","title"],""),Eh=h(["donut","onclick"],function(){}),Fh=h(["donut","onmouseover"],function(){}),Gh=h(["donut","onmouseout"],function(){}),Hh=h(["regions"],[]),Ih=h(["tooltip","show"],!0),Jh=h(["tooltip","format","title"]),Kh=h(["tooltip","format","value"]),Lh=h(["tooltip","contents"],function(a,b,c,d){var e,g,h,i,j,k=Jh?Jh:b,l=Kh?Kh:c;for(g=0;g"+(h||0===h?""+h+"":"")),j=a[g].name,i=l(a[g].value,a[g].ratio),e+="",e+=""+j+"",e+=""+i+"",e+="");return e+""}),Mh=h(["tooltip","init","show"],!1),Nh=h(["tooltip","init","x"],0),Oh=h(["tooltip","init","position"],{top:"0px",left:"50px"}),Ph=("string"==typeof ff?ff.replace("#",""):ff.id)+"-clip",Qh=Ph+"-xaxis",Rh=Ph+"-yaxis",Sh=i(Ph),Th=i(Th),Uh=i(Uh),Vh="timeseries"===Gg,Wh="categorized"===Gg,Xh=!Vh&&(_f||fe(ag)),Yh=null,Zh=!1,$h=!1,_h=!1,ai=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],bi=ae(mg,fe(Ag)?Ag:ai,lg),ci=function(){var a=[[cf.time.format("%Y/%-m/%-d"),function(){return!0}],[cf.time.format("%-m/%-d"),function(a){return a.getMonth()}],[cf.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[cf.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[cf.time.format("%I %p"),function(a){return a.getHours()}],[cf.time.format("%I:%M"),function(a){return a.getMinutes()}],[cf.time.format(":%S"),function(a){return a.getSeconds()}],[cf.time.format(".%L"),function(a){return a.getMilliseconds()}]];return function(b){for(var c=a.length-1,d=a[c];!d[1](b);)d=a[--c];return d[0](b)}}(),di=[],ei=[],fi=Fg?"left":"bottom",gi=Fg?Xg?"top":"bottom":Xg?"right":"left",hi=Fg?eh?"bottom":"top":eh?"left":"right",ii=Fg?"left":"bottom",ji={main:function(){return"translate("+rf.left+","+rf.top+")"},context:function(){return"translate("+sf.left+","+sf.top+")"},legend:function(){return"translate("+tf.left+","+tf.top+")"},x:function(){return"translate(0,"+(Fg?0:wf)+")"},y:function(){return"translate(0,"+(Fg?wf:0)+")"},y2:function(){return"translate("+(Fg?0:uf)+","+(Fg?1:0)+")"},subx:function(){return"translate(0,"+(Fg?0:xf)+")"},arc:function(){return"translate("+uf/2+","+wf/2+")"}},ki="right"===Cg,li=0,mi=0,ni=0,oi=30,pi=30,qi=5;If=cf.layout.pie().value(function(a){return a.values.reduce(function(a,b){return a+b.value},0)});var ri,si=function(){var a=cf.svg.line().x(Fg?function(a){return V(a.id)(a.value)}:nd).y(Fg?nd:function(a){return V(a.id)(a.value)});return function(b){var c,d,e=pe(b.values);return Sd(b)?(a.interpolate(Td(b)?"cardinal":"linear"),kg[b.id]?Be(e,Rf,V(b.id),kg[b.id]):a(e)):(c=Rf(e[0].x),d=V(b.id)(e[0].value),Fg?"M "+d+" "+c:"M "+c+" "+d)}}(),ti=function(){var a;return a=Fg?cf.svg.area().x0(function(a){return V(a.id)(0)}).x1(function(a){return V(a.id)(a.value)}).y(nd):cf.svg.area().x(nd).y0(function(a){return V(a.id)(0)}).y1(function(a){return V(a.id)(a.value)}),function(b){var c,d,e=pe(b.values);return Md([b],"area")||Md([b],"area-spline")?(a.interpolate(Td(b)?"cardinal":"linear"),a(e)):(c=Rf(e[0].x),d=V(b.id)(e[0].value),Fg?"M "+d+" "+c:"M "+c+" "+d)}}(),ui=function(){var a=cf.svg.line().x(Fg?function(a){return W(a.id)(a.value)}:qd).y(Fg?qd:function(a){return W(a.id)(a.value)});return function(b){var c=pe(b.values);return Sd(b)?a(c):"M "+Uf(c[0].x)+" "+W(b.id)(c[0].value)}}(),vi=function(){};ri=cf.svg.brush().on("brush",Ke),ri.update=function(){return zi&&zi.select("."+f.brush).call(this),this},ri.scale=function(a){return Fg?this.y(a):this.x(a)},lf&&(vi=cf.behavior.zoom().on("zoomstart",function(){vi.altDomain=cf.event.sourceEvent.altKey?Rf.orgDomain():null}).on("zoom",lf?Le:null),vi.scale=function(a){return Fg?this.y(a):this.x(a)},vi.orgScaleExtent=function(){var a=mf?mf:[1,10];return[a[0],Math.max(tc()/a[1],a[1])]},vi.updateScaleExtent=function(){var a=$b(Rf.orgDomain())/$b(Di),b=this.orgScaleExtent();return this.scaleExtent([b[0]*a,b[1]*a]),this});var wi,xi,yi,zi,Ai,Bi,Ci,Di,Ei,Fi={};if(df.focus=function(a){function b(a){Bc(a).transition().duration(100).style("opacity",1)}var c=wi.selectAll(ad(a)),d=c.filter($e),e=c.filter(_e);df.revert(),df.defocus(),b(d.classed(f.focused,!0)),b(e),Rd(df.data.targets)&&Kb(a,!0),Ue(a)},df.defocus=function(a){function b(a){Bc(a).transition().duration(100).style("opacity",.3)}var c=wi.selectAll(ad(a)),d=c.filter($e),e=c.filter(_e);df.revert(),b(d.classed(f.focused,!1)),b(e),Rd(df.data.targets)&&Lb(a),Ve(a)},df.revert=function(a){function b(a){Bc(a).transition().duration(100).style("opacity",1)}var c=wi.selectAll(ad(a)),d=c.filter($e),e=c.filter(_e);b(d.classed(f.focused,!1)),b(e),Rd(df.data.targets)&&Lb(a),We()},df.show=function(a,b){a=wc(a),b=b||{},Fc(a),wi.selectAll(bd(a)).transition().style("opacity",1),b.withLegend&&Ye(a),Je({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withTransitionForHorizontalAxis:!1})},df.hide=function(a,b){a=wc(a),b=b||{},Ec(a),wi.selectAll(bd(a)).transition().style("opacity",0),b.withLegend&&Ye(a),Je({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withTransitionForHorizontalAxis:!1})},df.toggle=function(a){zc(a)?df.hide(a):df.show(a)},df.unzoom=function(){ri.clear().update(),Je({withUpdateXDomain:!0})},df.load=function(a){return a.xs&&ic(a.xs),"categories"in a&&Wh&&(Hg=a.categories,Xf.categories(Hg)),"cacheIds"in a&&_b(a.cacheIds)?void Qe(bc(a.cacheIds),a.done):void("unload"in a?Se(wc("boolean"==typeof a.unload&&a.unload?null:a.unload),function(){Re(a)}):Re(a))},df.unload=function(a){Se(wc(a),function(){Je({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})})},df.selected=function(a){return cf.merge(yi.selectAll("."+f.shapes+_c(a)).selectAll("."+f.shape).filter(function(){return cf.select(this).classed(f.SELECTED)}).map(function(a){return a.map(function(a){return a.__data__})}))},df.select=function(a,b,c){ng&&yi.selectAll("."+f.shapes).selectAll("."+f.shape).each(function(e,g){var h=cf.select(this),i="circle"===this.nodeName?je:me,j="circle"===this.nodeName?ke:ne,k=og||!a||a.indexOf(e.id)>=0,l=!b||b.indexOf(g)>=0,m=h.classed(f.SELECTED);k&&l?pg(e)&&!m&&i(h.classed(f.SELECTED,!0),e,g):d(c)&&c&&m&&j(h.classed(f.SELECTED,!1),e,g)})},df.unselect=function(a,b){ng&&yi.selectAll("."+f.shapes).selectAll("."+f.shape).each(function(c,d){var e=cf.select(this),g="circle"===this.nodeName?ke:ne,h=og||!a||a.indexOf(c.id)>=0,i=!b||b.indexOf(d)>=0,j=e.classed(f.SELECTED);h&&i&&pg(c)&&j&&g(e.classed(f.SELECTED,!1),c,d)})},df.toLine=function(a){bf(a,"line")},df.toSpline=function(a){bf(a,"spline")},df.toBar=function(a){bf(a,"bar")},df.toScatter=function(a){bf(a,"scatter")},df.toArea=function(a){bf(a,"area")},df.toAreaSpline=function(a){bf(a,"area-spline")},df.toPie=function(a){bf(a,"pie",{withTransform:!0})},df.toDonut=function(a){bf(a,"donut",{withTransform:!0})},df.groups=function(a){return c(a)?eg:(eg=a,Je(),eg)},df.xgrids=function(a){return a?(kh=a,Je(),kh):kh},df.xgrids.add=function(a){return a?df.xgrids(kh.concat(a)):void 0},df.xgrids.remove=function(a){var b=af(a);return df.xgrids(kh.filter(b))},df.ygrids=function(a){return a?(mh=a,Je(),mh):mh},df.ygrids.add=function(a){return a?df.ygrids(mh.concat(a)):void 0},df.ygrids.remove=function(a){var b=af(a);return df.ygrids(mh.filter(b))},df.regions=function(a){return c(a)?Hh:(Hh=a,Je(),Hh)},df.regions.add=function(a){return c(a)?Hh:(Hh=Hh.concat(a),Je(),Hh)},df.regions.remove=function(a,c){var e=[].concat(a);return c=d(c)?c:{},e.forEach(function(a){var d=b(c.duration)?c.duration:0;wi.selectAll("."+a).transition().duration(d).style("fill-opacity",0).remove(),Hh=Hh.filter(function(b){return b.classes.indexOf(a)<0})}),Hh},df.data.get=function(a){var b=df.data.getAsTarget(a);return d(b)?b.values.map(function(a){return a.value}):void 0},df.data.getAsTarget=function(a){var b=yc(function(b){return b.id===a});return b.length>0?b[0]:void 0},df.data.names=function(a){return arguments.length?(Object.keys(a).forEach(function(b){dg[b]=a[b]}),Ze(vc(df.data.targets),{withTransition:!0}),dg):dg},df.x=function(a){return arguments.length&&(kc(df.data.targets,a),Je({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),df.data.x},df.xs=function(a){return arguments.length&&(lc(df.data.targets,a),Je({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),df.data.x},df.axis.labels=function(a){arguments.length&&(Object.keys(a).forEach(function(b){bb(b,a[b])}),Ab())},df.axis.max=function(a){arguments.length&&("object"==typeof a?(b(a.y)&&(Tg=+a.y),b(a.y2)&&(ah=+a.y2)):Tg=ah=+a,Je())},df.axis.min=function(a){arguments.length&&("object"==typeof a?(b(a.y)&&(Ug=+a.y),b(a.y2)&&(bh=+a.y2)):Ug=bh=+a,Je())},df.axis.range=function(a){arguments.length&&("undefined"!=typeof a.max&&df.axis.max(a.max),"undefined"!=typeof a.min&&df.axis.min(a.min)) +},df.legend.show=function(a){Bg&&(Xe(wc(a)),Je({withTransitionForHorizontalAxis:!1}))},df.legend.hide=function(a){Bg&&(Ye(wc(a)),Je({withTransitionForHorizontalAxis:!1}))},df.resize=function(a){gf=a?a.width:null,hf=a?a.height:null,Oe({withLegend:!0,withTransition:!1})},df.destroy=function(){df.data.targets=void 0,df.data.x={},Ci.html(""),a.onresize=null},"url"in e.data)cf.csv(e.data.url,function(a,b){Ce(b)});else if("rows"in e.data)Ce(nc(e.data.rows));else{if(!("columns"in e.data))throw Error("url or rows or columns is required.");Ce(oc(e.data.columns))}return df},"function"==typeof a.define&&a.define.amd?a.define("c3",["d3"],e):a.c3=e}(window); \ No newline at end of file