From 45ba2dbefe6124a3d71dbc18b3f26195f8512848 Mon Sep 17 00:00:00 2001 From: Masayuki Tanaka Date: Sun, 16 Mar 2014 01:23:31 +0900 Subject: [PATCH] Show legend as new line when overflow - #15 #64 --- c3.js | 180 +++++++++++++++++++++++++++++++----------------------- c3.min.js | 4 +- 2 files changed, 105 insertions(+), 79 deletions(-) diff --git a/c3.js b/c3.js index 7b9e773..8f2584c 100644 --- a/c3.js +++ b/c3.js @@ -68,7 +68,6 @@ __data_selection_isselectable = getConfig(['data', 'selection', 'isselectable'], function () { return true; }), __data_selection_multiple = getConfig(['data', 'selection', 'multiple'], true); - // subchart var __subchart_show = getConfig(['subchart', 'show'], false), __subchart_size_height = __subchart_show ? getConfig(['subchart', 'size', 'height'], 60) : 0; @@ -221,6 +220,7 @@ }; var isLegendRight = __legend_position === 'right'; + var legendStep = 0, legendItemWidth = 0, legendItemHeight = 0; /*-- Define Functions --*/ @@ -365,12 +365,20 @@ maxDataCount = getMaxDataCount(); return maxDataCount > 1 ? (base * ratio) / (maxDataCount - 1) : base; } + function updateLegndStep(step) { + legendStep = step; + } + function updateLegendItemWidth(w) { + legendItemWidth = w; + } + function updateLegendItemHeight(h) { + legendItemHeight = h; + } function getLegendWidth() { - // TODO: legend width should be an option - return __legend_show ? isLegendRight ? 150 : currentWidth : 0; + return __legend_show ? isLegendRight ? legendItemWidth * (legendStep + 1) : currentWidth : 0; } function getLegendHeight() { - return __legend_show ? isLegendRight ? currentHeight : 40 : 0; + return __legend_show ? isLegendRight ? currentHeight : legendItemHeight * (legendStep + 1) : 0; } function getLegendPaddingTop() { var xAxisLabelPositon = getXAxisLabelPosition(); @@ -1963,17 +1971,11 @@ .attr("clip-path", __axis_rotated ? getClipPath("yaxis-clip") : ""); } - /*-- Legend Region --*/ - - if (__legend_show) { - updateLegend(c3.data.targets); - } - // Set targets updateTargets(c3.data.targets); // Draw with targets - redraw({withTransform: true, withUpdateXDomain: true}); + redraw({withTransform: true, withUpdateXDomain: true, withLegend: true}); // Show tooltip if needed if (__tooltip_init_show) { @@ -1997,7 +1999,9 @@ window.onresize = generateResize(); } if (window.onresize.add) { - window.onresize.add(updateAndRedraw); + window.onresize.add(function () { + updateAndRedraw({withTransition: false, withLegend: true}); + }); } } @@ -2271,7 +2275,7 @@ var mainCircle, mainBar, mainRegion, mainText, contextBar, eventRectUpdate; var barIndices = getBarIndices(), maxDataCountTarget; var rectX, rectW; - var withY, withSubchart, withTransition, withTransform, withUpdateXDomain, withUpdateOrgXDomain; + var withY, withSubchart, withTransition, withTransform, withUpdateXDomain, withUpdateOrgXDomain, withLegend; var hideAxis = hasArcType(c3.data.targets); var drawBar, drawBarOnSub, xForText, yForText; var duration, durationForExit; @@ -2283,10 +2287,17 @@ withTransform = isDefined(options.withTransform) ? options.withTransform : false; withUpdateXDomain = isDefined(options.withUpdateXDomain) ? options.withUpdateXDomain : false; withUpdateOrgXDomain = isDefined(options.withUpdateOrgXDomain) ? options.withUpdateOrgXDomain : false; + withLegend = isDefined(options.withLegend) ? options.withLegend : false; duration = withTransition ? __transition_duration : 0; durationForExit = isDefined(options.durationForExit) ? options.durationForExit : duration; + // update legend + if (withLegend && __legend_show) { + updateLegend(c3.data.targets, options); + return; // call in updateLegend again with same options + } + if (withUpdateOrgXDomain) { x.domain(d3.extent(getXDomain(c3.data.targets))); orgXDomain = x.domain(); @@ -2640,11 +2651,6 @@ .style("fill-opacity", 0) .remove(); - // update legend - if (__legend_show) { - updateLegend(c3.data.targets, {withTransition: withTransition}); - } - // update fadein condition getTargetIds().forEach(function (id) { withoutFadeIn[id] = true; @@ -2690,10 +2696,11 @@ return callResizeFunctions; } function updateAndRedraw(options) { - var withTransition, withTransform; + var withTransition, withTransform, withLegend; options = isDefined(options) ? options : {}; - withTransition = isDefined(options.withTransition) ? options.withTransition : false; + withTransition = isDefined(options.withTransition) ? options.withTransition : true; withTransform = isDefined(options.withTransform) ? options.withTransform : false; + withLegend = isDefined(options.withLegend) ? options.withLegend : false; // Update sizes and scales updateSizes(); updateScales(); @@ -2713,7 +2720,8 @@ withTransition: withTransition, withUpdateXDomain: true, withTransform: withTransform, - durationForExit: 0 + durationForExit: 0, + withLegend: withLegend }); } @@ -2846,12 +2854,6 @@ .style("stroke", function (d) { return color(d.id); }); } - /*-- Legend --*/ - - if (__legend_show) { - updateLegend(targets); - } - /*-- Show --*/ // Fade-in each chart @@ -2877,7 +2879,7 @@ updateTargets(c3.data.targets); // Redraw with new targets - redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true}); + redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withLegend: true}); done(); } @@ -2907,58 +2909,74 @@ function updateLegend(targets, options) { var ids = getTargetIds(targets), l; var xForLegend, xForLegendText, xForLegendRect, yForLegend, yForLegendText, yForLegendRect; - var paddingTop = 4, paddingRight = 30, margin; - var totalLength = 0, offsets = {}, widths = {}, heights = {}; + var paddingTop = 4, paddingRight = 26, maxWidth, maxHeight, posMin = 10; + var totalLength = 0, offsets = {}, widths = {}, heights = {}, margins = {}, steps = {}, step = 0; var withTransition; options = isUndefined(options) ? {} : options; withTransition = isDefined(options.withTransition) ? options.withTransition : true; - function getXOffset(id, i) { - return __legend_equally ? widths[id] * i : offsets[id]; - } - function getYOffset(id, i) { - return __legend_equally ? heights[id] * i : offsets[id]; - } - function updatePositions(textElement, id) { + function updatePositions(textElement, id, reset) { var box = textElement.getBBox(), - width = Math.ceil((box.width + paddingRight) / 10) * 10, - height = Math.ceil((box.height + paddingTop) / 10) * 10, - length = isLegendRight ? height : width, + itemWidth = Math.ceil((box.width + paddingRight) / 10) * 10, + itemHeight = Math.ceil((box.height + paddingTop) / 10) * 10, + itemLength = isLegendRight ? itemHeight : itemWidth, areaLength = isLegendRight ? legendHeight : legendWidth, - maxWidth, maxHeight; + margin, maxLength; + + // MEMO: care about condifion of step, totalLength + function updateValues(id, withoutStep) { + if (!withoutStep) { + margin = (areaLength - totalLength - itemLength) / 2; + if (margin < posMin) { + margin = (areaLength - itemLength) / 2; + totalLength = 0; + step++; + } + } + steps[id] = step; + margins[step] = margin; + offsets[id] = totalLength; + totalLength += itemLength; + } - widths[id] = width; - heights[id] = height; + if (reset) { + totalLength = 0; + step = 0; + maxWidth = 0; + maxHeight = 0; + } + + widths[id] = itemWidth; + heights[id] = itemHeight; + + if (!maxWidth || itemWidth >= maxWidth) { maxWidth = itemWidth; } + if (!maxHeight || itemHeight >= maxHeight) { maxHeight = itemHeight; } + maxLength = isLegendRight ? maxHeight : maxWidth; if (__legend_equally) { - maxWidth = d3.max(Object.keys(widths).map(function (key) { return widths[key]; })); - maxHeight = d3.max(Object.keys(heights).map(function (key) { return heights[key]; })); - if (width >= maxWidth) { - Object.keys(widths).forEach(function (key) { widths[key] = width; }); - if (! isLegendRight) { - margin = (legendWidth - width * Object.keys(targets).length) / 2; - } + Object.keys(widths).forEach(function (id) { widths[id] = maxWidth; }); + Object.keys(heights).forEach(function (id) { heights[id] = maxHeight; }); + margin = (areaLength - maxLength * ids.length) / 2; + if (margin < posMin) { + totalLength = 0; + step = 0; + ids.forEach(function (id) { updateValues(id); }); } - if (height >= maxHeight) { - Object.keys(heights).forEach(function (key) { heights[key] = height; }); - if (isLegendRight) { - margin = (legendHeight - height * Object.keys(targets).length) / 2; - } + else { + updateValues(id, true); } } else { - offsets[id] = totalLength; - totalLength += length; - margin = (areaLength - totalLength) / 2; + updateValues(id); } } if (isLegendRight) { - xForLegend = function () { return legendWidth * 0.2; }; - yForLegend = function (id, i) { return margin + getYOffset(id, i); }; + xForLegend = function (id) { return maxWidth * (0.2 + steps[id]); }; + yForLegend = function (id) { return margins[steps[id]] + offsets[id]; }; } else { - xForLegend = function (id, i) { return margin + getXOffset(id, i); }; - yForLegend = function () { return legendHeight * 0.2; }; + xForLegend = function (id) { return margins[steps[id]] + offsets[id]; }; + yForLegend = function (id) { return maxHeight * (0.2 + steps[id]); }; } xForLegendText = function (id, i) { return xForLegend(id, i) + 14; }; yForLegendText = function (id, i) { return yForLegend(id, i) + 9; }; @@ -2984,10 +3002,10 @@ }); l.append('text') .text(function (id) { return isDefined(__data_names[id]) ? __data_names[id] : id; }) - .each(function (id) { updatePositions(this, id); }) + .each(function (id, i) { updatePositions(this, id, i === 0); }) .style("pointer-events", "none") .attr('x', isLegendRight ? xForLegendText : -200) - .attr('y', isLegendRight ? -200 : yForLegend); + .attr('y', isLegendRight ? -200 : yForLegendText); l.append('rect') .attr("class", "legend-item-event") .style('fill-opacity', 0) @@ -3000,13 +3018,13 @@ .style("pointer-events", "none") .style('fill', function (id) { return color(id); }) .attr('x', isLegendRight ? xForLegendText : -200) - .attr('y', isLegendRight ? -200 : yForLegendText) + .attr('y', isLegendRight ? -200 : yForLegend) .attr('width', 10) .attr('height', 10); legend.selectAll('text') .data(ids) - .each(function (id) { updatePositions(this, id); }) + .each(function (id, i) { updatePositions(this, id, i === 0); }) .transition().duration(withTransition ? 250 : 0) .attr('x', xForLegendText) .attr('y', yForLegendText); @@ -3023,6 +3041,15 @@ .attr('x', xForLegend) .attr('y', yForLegend); + // Update all to reflect change of legend + updateLegendItemWidth(maxWidth); + updateLegendItemHeight(maxHeight); + updateLegndStep(step); + updateSizes(); + updateScales(); + transformAll(false); + options.withLegend = false; + redraw(options); } /*-- Event Handling --*/ @@ -3160,11 +3187,10 @@ if (__legend_show) { svg.selectAll('.legend-item' + getTargetSelectorSuffix(targetId)).remove(); - updateLegend(c3.data.targets); } if (c3.data.targets.length > 0) { - redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true}); + redraw({withUpdateOrgXDomain: true, withUpdateXDomain: true, withLegend: true}); } }; @@ -3210,42 +3236,42 @@ c3.toLine = function (targets) { setTargetType(targets, 'line'); - updateAndRedraw({withTransition: true}); + updateAndRedraw(); }; c3.toSpline = function (targets) { setTargetType(targets, 'spline'); - updateAndRedraw({withTransition: true}); + updateAndRedraw(); }; c3.toBar = function (targets) { setTargetType(targets, 'bar'); - updateAndRedraw({withTransition: true}); + updateAndRedraw(); }; c3.toScatter = function (targets) { setTargetType(targets, 'scatter'); - updateAndRedraw({withTransition: true}); + updateAndRedraw(); }; c3.toArea = function (targets) { setTargetType(targets, 'area'); - updateAndRedraw({withTransition: true}); + updateAndRedraw(); }; c3.toAreaSpline = function (targets) { setTargetType(targets, 'area-spline'); - updateAndRedraw({withTransition: true}); + updateAndRedraw(); }; c3.toPie = function (targets) { setTargetType(targets, 'pie'); - updateAndRedraw({withTransition: true, withTransform: true}); + updateAndRedraw({withTransform: true}); }; c3.toDonut = function (targets) { setTargetType(targets, 'donut'); - updateAndRedraw({withTransition: true, withTransform: true}); + updateAndRedraw({withTransform: true}); }; c3.groups = function (groups) { @@ -3325,7 +3351,7 @@ c3.resize = function (size) { __size_width = size ? size.width : null; __size_height = size ? size.height : null; - updateAndRedraw(); + updateAndRedraw({withLegend: true, withTransition: false}); }; c3.destroy = function () { diff --git a/c3.min.js b/c3.min.js index 9a17b8c..360f991 100644 --- a/c3.min.js +++ b/c3.min.js @@ -1,2 +1,2 @@ -!function(a){"use strict";function b(){function a(a,b){a.attr("transform",function(a){return"translate("+(b(a)+q)+", 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 p>=c||b%Math.ceil(c/p)===0}function f(a){return a0?a:320}function t(){return Qc(Wd.data.targets)?0:ce?ce:Ef?1:v("y")}function u(){return Qc(Wd.data.targets)?0:de?de:Dg?ue*(If&&!rf?1.25:1):If?Mf||rf?1:v("y2"):1}function v(){var a=U();return a.isInner?40:60}function w(){return+g.select(_d).style("width").replace("px","")}function x(){return+g.select(_d).style("height").replace("px","")}function y(){return ne+2}function z(){return 80}function A(){return ke.left+20}function B(){return pe+2}function C(){var a=rf?pe:ne,b=ob(),c=Lb();return c>1?a*b/(c-1):a}function D(){return nf?Dg?150:re:0}function E(){return nf?Dg?se:40:0}function F(){var a=T();return a.isInner?5:20}function G(){var a,b;Ce=rf?1:0,De=rf?pe:ne,Ee=rf?0:pe,Fe=rf?ne:1,Ge=Ce,He=De,Ie=rf?0:qe,Je=rf?oe:1,Ke=I(Ce,De,Ke?Ke.domain():void 0,function(){return Qe.tickOffset()}),Le=J(Ee,Fe),Me=J(Ee,Fe),Ne=I(Ce,De,Sg,function(a){return a%1?0:Te.tickOffset()}),Oe=J(Ie,Je),Pe=J(Ie,Je),a=P(),b=Q(),Qe=M(Ke,yg,a,b),Te=M(Ne,Bg,a,b),Re=N(Le,zg,Ff,Hf),Se=N(Me,Ag,Nf,Pf),H()}function H(){ye=db(),ze=eb(),Ae=eb(.98)}function I(a,b,c,f){var h=(qg?g.time.scale():g.scale.linear()).range([a,b]);if(h.orgDomain=function(){return h.domain()},e(c)&&h.domain(c),d(f)&&(f=function(){return 0}),rg){var i,j=h;h=function(a){return j(a)+f(a)};for(i in j)h[i]=j[i];h.orgDomain=function(){return j.domain()},h.domain=function(a){return arguments.length?(j.domain(a),h):(a=j.domain(),[a[0],a[1]+1])}}return h}function J(a,b){return g.scale.linear().range([a,b])}function K(a){return"y2"===O(a)?Me:Le}function L(a){return"y2"===O(a)?Pe:Oe}function M(a,c,d,e){var f=(rg?b():g.svg.axis()).scale(a).orient(c);return f.tickFormat(d).ticks(e),rg?f.tickCentered(uf):f.tickOffset=function(){var a=rf?pe:ne;return a*ob()/Lb()/2},rg&&f.categories(tf),f}function N(a,b,c,d){return g.svg.axis().scale(a).orient(b).tickFormat(c).ticks(d).outerTickSize(0)}function O(a){return a in $e?$e[a]:"y"}function P(){var a=qg?xg:rg?Ub:null;return vf&&("function"==typeof vf?a=vf:qg&&(a=function(a){return g.time.format(vf)(a)})),a}function Q(){var a=Lb();return wf&&a>xf?xf:a}function R(a){return"string"==typeof a?a:a?a.text:null}function S(a,b){var c=a&&"object"==typeof a&&a.position?a.position:b;return{isInner:c.indexOf("inner")>=0,isOuter:c.indexOf("outer")>=0,isLeft:c.indexOf("left")>=0,isCenter:c.indexOf("center")>=0,isRight:c.indexOf("right")>=0,isTop:c.indexOf("top")>=0,isMiddle:c.indexOf("middle")>=0,isBottom:c.indexOf("bottom")>=0}}function T(){return S(zf,"inner-right")}function U(){return S(Df,"inner-top")}function V(){return R(zf)}function W(){return R(Df)}function X(){var a=T();return a.isLeft?0:a.isCenter?ne/2:ne}function Y(){var a=U();return a.isBottom?-pe:a.isMiddle?-pe/2:0}function Z(){var a=U();return a.isTop?"-0.5em":"0"}function $(){var a=T();return a.isInner?"-0.5em":"3.5em"}function _(){var a=U(),b=0;return g.selectAll(".y.axis .tick text").each(function(){var a=this.getBBox();b0)for(f=Sb(a),b=0;ba?a:0}),c=1;c0||(h[d][b]+=+a)});return g.min(Object.keys(h).map(function(a){return g.min(h[a])}))}function mb(a){var b,c,d,e,f,h=Qb(a);if(Ze.length>0)for(f=Tb(a),b=0;b0?a:0}),c=1;c+a||(h[d][b]+=+a)});return g.max(Object.keys(h).map(function(a){return g.max(h[a])}))}function nb(a){var b,d,e,f,g,h,i,j,k=Pb(function(b){return O(b.id)===a}),l="y2"===a?Kf:Bf,m="y2"===a?Jf:Af,n=c(l)?l:lb(k),o=c(m)?m:mb(k),p="y2"===a?Lf:Cf,q=kc()&&rf;return n===o&&(0>n?o=0:n=0),b=Math.abs(o-n),d=e=f=q?0:.1*b,p&&(g=Math.max(Math.abs(n),Math.abs(o)),o=g-p,n=p-g),"y"===a&&Gf&&(e=c(Gf.top)?Gf.top:d,f=c(Gf.bottom)?Gf.bottom:d),"y2"===a&&Of&&(e=c(Of.top)?Of.top:d,f=c(Of.bottom)?Of.bottom:d),q&&(h=lc(n,o),i=tb(Le.range()),j=[h[0]/i,h[1]/i],e+=b*(j[1]/(1-j[0]-j[1])),f+=b*(j[0]/(1-j[0]-j[1]))),Mc(k)&&!Sb(k)&&(f=n),[n-f,o+e]}function ob(a){var b=tb(Sg),c=tb(Ke.domain());return a||0===c?1:b/c}function pb(a){return g.min(a,function(a){return g.min(a.values,function(a){return a.x})})}function qb(a){return g.max(a,function(a){return g.max(a.values,function(a){return a.x})})}function rb(a,b){var c,d,e=b[0],f=b[1],g=Math.abs(e-f);return rg?d=0:Mc(a)?(c=Lb(),d=c>1?g/(c-1)/2:.5):d=.01*g,d}function sb(a){var b=[pb(a),qb(a)],c=b[0],d=b[1],e=rb(a,b),f=qg?new Date(c.getTime()-e):c-e,g=qg?new Date(d.getTime()+e):d+e;return[f,g]}function tb(a){return a[1]-a[0]}function ub(a){for(var b=0;bd?0:d}function zb(a){return Ue&&a===Ue||Ve&&ed(Ve,a)}function Ab(a){return!zb(a)}function Bb(a){return Ue?Ue:Ve?Ve[a]:null}function Cb(a,b){return a in Wd.data.x&&Wd.data.x[a]&&Wd.data.x[a][b]?Wd.data.x[a][b]:b}function Db(a){Object.keys(a).forEach(function(b){Ve[b]=a[b]})}function Eb(a){var b;return a&&(b=Ye[a.id],a.name=b?b:a.id),a}function Fb(a){var b,c,d=a[0],e={},f=[];for(b=1;b=0?b.map(function(a){return a[c]}):Wd.data.x[Object.keys(Wd.data.x)[0]]}),c=d.map(function(a){var c=Xe(a);return{id:c,id_org:a,values:b.map(function(b,d){var e,f=Bb(a);return e=qg?ad(b[f]):sg?b[f]?+b[f]:Cb(a,d):d,b.x=e,{x:e,value:null===b[a]||isNaN(b[a])?null:+b[a],id:c}})}}),c.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++})}),_e&&Kc(Nb(c).filter(function(a){return!(a in af)}),_e),c.forEach(function(a){vb(a.id_org,a)}),c)}function Ib(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 Jb(a){return a>0&&Wd.data.targets[0].values[a-1]?Wd.data.targets[0].values[a-1].x:void 0}function Kb(a){return a1?Wd.data.targets.forEach(function(b){b.values.length>c&&(a=b,c=b.values.length)}):a=b?Wd.data.targets[0]:null,a}function Nb(a){return a=d(a)?Wd.data.targets:a,a.map(function(a){return a.id})}function Ob(a){var b,c=Nb();for(b=0;ba})}function Tb(a){return Rb(a,function(a){return a>0})}function Ub(a){return a=0&&d===a[c].x;c--)e.push(a[c]);for(c=b;c0?g=h:f=h,g-f===1?(e=[],a[f].x&&(e=e.concat(sc(a,f))),a[g].x&&(e=e.concat(sc(a,g))),vc(e,b)):tc(a,b,f,g)}function uc(a,b){var c;return c=a.map(function(a){return tc(a.values,b)}),vc(c,b)}function vc(a,b){var c,d;return a.forEach(function(a){var e=fd(a,b);(c>e||!c)&&(c=e,d=a)}),d}function wc(){return cf&&"desc"===cf.toLowerCase()}function xc(){return cf&&"asc"===cf.toLowerCase()}function yc(a){var b=xc(),c=wc();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 cf&&a.sort(cf),a}function zc(a,b){var d,e,f,g,h,i,j,k=Qc(Wd.data.targets),l=k?rc:qc,m=a.filter(function(a){return a&&c(a.value)});hg&&0!==m.length&&(Qg.html(kg(a,P(),l,wg)).style("visibility","hidden").style("display","block"),d=Qg.property("offsetWidth"),e=Qg.property("offsetHeight"),k?(g=ne/2+b[0],i=pe/2+b[1]+20):(rf?(f=q(),g=f+b[0]+100,h=g+d,j=r()-u(),i=Ke(m[0].x)+20):(f=q(),g=f+t()+Ke(m[0].x)+20,h=g+d,j=f+r()-u(),i=b[1]+15),h>j&&(g-=d+60),i+e>s()&&(i-=e+30)),Qg.style("top",i+"px").style("left",g+"px").style("visibility","visible"))}function Ac(){Qg.style("display","none")}function Bc(a){var b=a.filter(function(a){return a&&c(a.value)});hg&&(Nc(Wd.data.targets)||Qc(Wd.data.targets)||Ng.selectAll("line.xgrid-focus").style("visibility","visible").data([b[0]]).attr(rf?"y1":"x1",mc).attr(rf?"y2":"x2",mc))}function Cc(){Ng.select("line.xgrid-focus").style("visibility","hidden")}function Dc(a){return a.x||0===a.x?Ke(a.x):null}function Ec(a){return K(a.id)(a.value)}function Fc(){var a,b,c={},e=0;return Pb(Tc).forEach(function(f){for(a=0;a0&&(i+=g(b.values[f].value)-h)}),i}}function Jc(a,b){return b?2*a.tickOffset()*.6/b:0}function Kc(a,b){var c=d(a)?Nb():a;"string"==typeof c&&(c=[c]);for(var e=0;e0&&i>k||a.value<0&&k>i)&&(k=i),[[j,i],[j,k-(c-i)],[j+d,k-(c-i)],[j+d,i]]}}function yd(a,b,c,f){var g,h,i,j,k,l,m,n,o,p,q,r=-1,s="M",t=[];if(e(f))for(g=0;g=h;h+=u)s+=i(a[g-1],a[g],h,o)}r=a[g].x}return s}function zd(b){var c,d,e;if(Rg=g.select(_d),Rg.empty())return void a.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');if(Rg.html(""),Wd.data.x={},Wd.data.targets=Hb(b),o(),G(),Ke.domain(g.extent(sb(Wd.data.targets))),Le.domain(nb("y")),Me.domain(nb("y2")),Ne.domain(Ke.domain()),Oe.domain(Le.domain()),Pe.domain(Me.domain()),Sg=Ke.domain(),Gg.scale(Ne),ee&&Kg.scale(Ke),Lg=g.select(_d).append("svg").attr("width",ne+ke.left+ke.right).attr("height",pe+ke.top+ke.bottom).on("mouseenter",he).on("mouseleave",ie),Mg=Lg.append("defs"),Mg.append("clipPath").attr("id",og).append("rect").attr("width",ne).attr("height",pe),Mg.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1).attr("y",-20).attr("width",y).attr("height",z),Mg.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-ke.left+1).attr("width",A).attr("height",B),Ng=Lg.append("g").attr("transform",Cg.main),Og=kf?Lg.append("g").attr("transform",Cg.context):null,Pg=nf?Lg.append("g").attr("transform",Cg.legend):null,Qg=g.select(_d).style("position","relative").append("div").style("position","absolute").style("z-index","10").style("display","none"),Ng.append("g").attr("class","x axis").attr("clip-path",rf?"":j("xaxis-clip")).attr("transform",Cg.x).append("text").attr("class","-axis-x-label").attr("dy",$).style("text-anchor",ab).text(rf?W:V),Ng.append("g").attr("class","y axis").attr("clip-path",rf?j("yaxis-clip"):"").append("text").attr("class","-axis-y-label").attr("transform","rotate(-90)").attr("dx",Z).style("text-anchor",bb).text(rf?V:W),If&&Ng.append("g").attr("class","y2 axis").attr("transform",Cg.y2),d=Ng.append("g").attr("clip-path",pg).attr("class","grid"),Qf&&d.append("g").attr("class","xgrids"),Sf&&d.append("g").attr("class","xgrid-lines"),Yf&&d.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",rf?0:-10).attr("x2",rf?ne:-10).attr("y1",rf?-10:ke.top).attr("y2",rf?-10:pe),Tf&&d.append("g").attr("class","ygrids"),Uf&&d.append("g").attr("class","ygrid-lines"),Ng.append("g").attr("clip-path",pg).attr("class","regions"),Ng.append("g").attr("clip-path",pg).attr("class","chart"),c=Ng.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",ee?rf?"ns-resize":"ew-resize":null),Ng.select(".chart").append("g").attr("class","chart-bars"),Ng.select(".chart").append("g").attr("class","chart-lines"),Ng.select(".chart").append("g").attr("class","chart-arcs").attr("transform",Cg.arc).append("text").attr("class","chart-arcs-title").style("text-anchor","middle").text(fg),Ng.select(".chart").append("g").attr("class","chart-texts"),ee&&Ng.insert("rect",ge?null:"g.grid").attr("class","zoom-rect").attr("width",ne).attr("height",pe).style("opacity",0).style("cursor",rf?"ns-resize":"ew-resize").call(Kg).on("dblclick.zoom",null),null!==yf&&Gg.extent("function"!=typeof yf?yf:yf(sb())),kf&&(Og.append("g").attr("clip-path",pg).attr("class","chart"),Og.select(".chart").append("g").attr("class","chart-bars"),Og.select(".chart").append("g").attr("class","chart-lines"),Og.append("g").attr("clip-path",pg).attr("class","x brush").call(Gg).selectAll("rect").attr(rf?"width":"height",rf?oe:qe),Og.append("g").attr("class","x axis").attr("transform",Cg.subx).attr("clip-path",rf?j("yaxis-clip"):"")),nf&&Qd(Wd.data.targets),Ld(Wd.data.targets),Gd({withTransform:!0,withUpdateXDomain:!0}),lg){if(qg&&"string"==typeof mg){for(mg=ad(mg),e=0;e0){d=[];for(var f in Ye)for(c=0;cf&&h>c&&d>i&&j>d):"rect"===this.nodeName&&(c=1*l.attr("x"),d=1*l.attr("y"),e=1*l.attr("width"),k=ld,o=c+e>f&&h>c&&j>d),o^n&&(l.classed($d,!n),l.classed(Zd,!m),k(!m,l,a,b))}))}function Ed(a){Qc(Wd.data.targets)||ff&&(tg=a,Ng.select(".chart").append("rect").attr("class","dragarea").style("opacity",.1),ug=!0)}function Fd(){Qc(Wd.data.targets)||ff&&(Ng.select(".dragarea").transition().duration(100).style("opacity",0).remove(),Ng.selectAll(".-shape").classed($d,!1),ug=!1)}function Gd(a){var b,d,f,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,D,E,F,G,H=Fc(),I=Qc(Wd.data.targets);if(a=e(a)?a:{},u=e(a.withY)?a.withY:!0,v=e(a.withSubchart)?a.withSubchart:!0,w=e(a.withTransition)?a.withTransition:!0,x=e(a.withTransform)?a.withTransform:!1,y=e(a.withUpdateXDomain)?a.withUpdateXDomain:!1,z=e(a.withUpdateOrgXDomain)?a.withUpdateOrgXDomain:!1,F=w?je:0,G=e(a.durationForExit)?a.durationForExit:F,z&&(Ke.domain(g.extent(sb(Wd.data.targets))),Sg=Ke.domain(),ee&&Kg.scale(Ke).updateScaleExtent(),Ne.domain(Ke.domain()),Gg.scale(Ne)),y&&(Ke.domain(Gg.empty()?Sg:Gg.extent()),ee&&Kg.scale(Ke).updateScaleExtent()),Le.domain(nb("y")),Me.domain(nb("y2")),Ng.select(".x.axis").style("opacity",I?0:1).transition().duration(F).call(rf?Re:Qe),Ng.select(".y.axis").style("opacity",I?0:1).transition().duration(F).call(rf?Qe:Re),Ng.select(".y2.axis").style("opacity",I?0:1).transition().call(Se),A=td(H),D=ud(H,!0),E=ud(H,!1),Ng.select(".x.axis .-axis-x-label").attr("x",X),Ng.select(".y.axis .-axis-y-label").attr("x",Y).attr("dy",_),Oe.domain(Le.domain()),Pe.domain(Me.domain()),Qg.style("display","none"),Ng.select("line.xgrid-focus").style("visibility","hidden").attr("y2",pe),Qf){if("year"===Rf){d=[];for(var J=sb(),K=J[0].getFullYear(),L=J[1].getFullYear(),M=K;L>=M;M++)d.push(new Date(M+"-01-01 00:00:00"))}else d=Ke.ticks(10);b=Ng.select(".xgrids").selectAll(".xgrid").data(d),b.enter().append("line").attr("class","xgrid"),b.attr("x1",rf?0:function(a){return Ke(a)-Qe.tickOffset()}).attr("x2",rf?ne:function(a){return Ke(a)-Qe.tickOffset()}).attr("y1",rf?function(a){return Ke(a)-Qe.tickOffset()}:ke.top).attr("y2",rf?function(a){return Ke(a)-Qe.tickOffset()}:pe).style("opacity",function(){return+g.select(this).attr(rf?"y1":"x1")===(rf?pe:0)?0:1}),b.exit().remove()}Sf&&(f=Ng.select(".xgrid-lines").selectAll(".xgrid-line").data(Sf),h=f.enter().append("g").attr("class",function(a){return"xgrid-line xgrid-line-"+(a["class"]?a["class"]:"")}),h.append("line").style("opacity",0),h.append("text").attr("text-anchor","end").attr("transform",rf?"":"rotate(-90)").attr("dx",rf?0:-ke.top).attr("dy",-5).style("opacity",0),f.select("line").transition().duration(F).attr("x1",rf?0:nc).attr("x2",rf?ne:nc).attr("y1",rf?nc:ke.top).attr("y2",rf?nc:pe).style("opacity",1),f.select("text").transition().duration(F).attr("x",rf?ne:0).attr("y",nc).text(function(a){return a.text}).style("opacity",1),f.exit().transition().duration(F).style("opacity",0).remove()),u&&Tf&&(i=Ng.select(".ygrids").selectAll(".ygrid").data(Le.ticks(Vf)),i.enter().append("line").attr("class","ygrid"),i.attr("x1",rf?Le:0).attr("x2",rf?Le:ne).attr("y1",rf?0:Le).attr("y2",rf?pe:Le),i.exit().remove()),u&&Uf&&(j=Ng.select(".ygrid-lines").selectAll(".ygrid-line").data(Uf),k=j.enter().append("g").attr("class",function(a){return"ygrid-line ygrid-line-"+(a.class?a.class:"")}),k.append("line").style("opacity",0),k.append("text").attr("text-anchor","end").attr("transform",rf?"rotate(-90)":"").attr("dx",rf?0:-ke.top).attr("dy",-5).style("opacity",0),j.select("line").transition().duration(F).attr("x1",rf?oc:0).attr("x2",rf?oc:ne).attr("y1",rf?0:oc).attr("y2",rf?pe:oc).style("opacity",1),j.select("text").transition().duration(F).attr("x",rf?0:ne).attr("y",oc).text(function(a){return a.text -}).style("opacity",1),j.exit().transition().duration(F).style("opacity",0).remove()),m=Ng.selectAll(".-bars").selectAll(".-bar").data(Yc),m.enter().append("path").attr("d",A).style("stroke","none").style("opacity",0).style("fill",function(a){return wg(a.id)}).attr("class",dc),m.style("opacity",gc).transition().duration(F).attr("d",A).style("opacity",1),m.exit().transition().duration(G).style("opacity",0).remove(),o=Ng.selectAll(".-texts").selectAll(".-text").data($c),o.enter().append("text").attr("class",Vb).attr("text-anchor",function(a){return rf?a.value<0?"end":"start":"middle"}).style("stroke","none").style("fill-opacity",0).text(function(a){return qc(a.value)}),o.style("fill-opacity",hc).transition().duration(F).attr("x",D).attr("y",E).style("fill-opacity",jc),o.exit().transition().duration(G).style("fill-opacity",0).remove(),Ng.selectAll(".-line").style("opacity",gc).transition().duration(F).attr("d",Hg).style("opacity",1),Ng.selectAll(".-area").style("opacity",0).transition().duration(F).attr("d",Ig).style("opacity",Tg),l=Ng.selectAll(".-circles").selectAll(".-circle").data(Zc),l.enter().append("circle").attr("class",cc).style("opacity",0).attr("r",Xf),l.style("opacity",gc).transition().duration(F).style("opacity",ic).attr("cx",rf?Ec:Dc).attr("cy",rf?Dc:Ec),l.exit().remove(),Ng.selectAll(".chart-arc").select(".-arc").attr("transform",x?"scale(0)":"").style("opacity",function(a){return a===this._current?0:1}).transition().duration(F).attrTween("d",function(a){var b=cb(a);if(!b)return function(){return"M 0 0"};var c=g.interpolate(this._current,b);return this._current=c(0),function(a){return fb(c(a),!0)}}).attr("transform",x?"scale(1)":"").style("opacity",1),Ng.selectAll(".chart-arc").select("text").attr("transform",gb).style("opacity",0).transition().duration(F).text(ib).style("opacity",function(a){return Xc(a.data)?1:0}),Ng.select(".chart-arcs-title").style("opacity",Pc(Wd.data.targets)?1:0),kf&&(null!==g.event&&"zoom"===g.event.type&&Gg.extent(Ke.orgDomain()).update(),v&&(Og.select(".x.axis").style("opacity",I?0:1).transition().duration(F).call(Te),Gg.empty()||Gg.extent(Ke.orgDomain()).update(),B=td(H,!0),p=Og.selectAll(".-bars").selectAll(".-bar").data(Yc),p.enter().append("path").attr("d",B).style("stroke","none").style("fill",function(a){return wg(a.id)}).attr("class",dc),p.style("opacity",gc).transition().duration(F).attr("d",B).style("opacity",1),p.exit().transition().duration(F).style("opacity",0).remove(),Og.selectAll(".-line").style("opacity",gc).transition().duration(F).attr("d",Jg).style("opacity",1))),Ng.selectAll(".selected-circles").filter(function(a){return Tc(a)}).selectAll("circle").remove(),Ng.selectAll(".selected-circle").transition().duration(F).attr("cx",rf?Ec:Dc).attr("cy",rf?Dc:Ec),Ve?(q=Ng.select(".event-rects").selectAll(".event-rect").data([0]),Bd(q.enter()),q.attr("x",0).attr("y",0).attr("width",ne).attr("height",pe)):(sg?(t=function(a,b){var c=Jb(b),d=Kb(b);return(Ke(d?d:a.x+50)-Ke(c?c:a.x-50))/2},s=function(a,b){var c=Jb(b);return(Ke(a.x)+Ke(c?c:a.x-50))/2}):(t=C(),s=function(a){return Ke(a.x)-t/2}),r=Mb(),Ng.select(".event-rects").datum(r?r.values:[]),q=Ng.select(".event-rects").selectAll(".event-rect").data(function(a){return a}),Ad(q.enter()),q.attr("class",fc).attr("x",rf?0:s).attr("y",rf?s:0).attr("width",rf?ne:t).attr("height",rf?t:pe),q.exit().remove()),n=Ng.select(".regions").selectAll("rect.region").data(gg),n.enter().append("rect").style("fill-opacity",0),n.attr("class",ec).attr("x",rf?0:xb).attr("y",rf?xb:ke.top).attr("width",rf?ne:yb).attr("height",rf?yb:pe).transition().duration(F).style("fill-opacity",function(a){return c(a.opacity)?a.opacity:.1}),n.exit().transition().duration(F).style("fill-opacity",0).remove(),nf&&Qd(Wd.data.targets,{withTransition:w}),Nb().forEach(function(a){Ug[a]=!0})}function Hd(){Gd({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}function Id(){return"mousemove"===g.event.sourceEvent.type&&Kg.altDomain?(Ke.domain(Kg.altDomain),void Kg.scale(Ke).updateScaleExtent()):(rg&&Ke.orgDomain()[0]===Sg[0]&&Ke.domain([Sg[0]-1e-10,Ke.orgDomain()[1]]),Gd({withTransition:!1,withY:!1,withSubchart:!1}),void("mousemove"===g.event.sourceEvent.type&&(vg=!0)))}function Jd(){function a(){b.forEach(function(a){a()})}var b=[];return a.add=function(a){b.push(a)},a}function Kd(a){var b,c;a=e(a)?a:{},b=e(a.withTransition)?a.withTransition:!1,c=e(a.withTransform)?a.withTransform:!1,o(),G(),Gg.scale(Ne),ee&&Kg.scale(Ke),Lg.attr("width",re).attr("height",se),Lg.select("#"+og).select("rect").attr("width",ne).attr("height",pe),Lg.select("#xaxis-clip").select("rect").attr("width",y),Lg.select(".zoom-rect").attr("width",ne).attr("height",pe),n(b),Gd({withTransition:b,withUpdateXDomain:!0,withTransform:c,durationForExit:0})}function Ld(a){var b,c,d,e,f,h,i,j,k,l,m,n;i=Ng.select(".chart-texts").selectAll(".chart-text").data(a),j=i.enter().append("g").attr("class",function(a){return"chart-text target target-"+a.id}).style("pointer-events","none"),j.append("g").attr("class",Wb).style("fill",function(a){return wg(a.id)}),e=Ng.select(".chart-bars").selectAll(".chart-bar").data(a),d=e.enter().append("g").attr("class",function(a){return"chart-bar target target-"+a.id}).style("pointer-events","none"),d.append("g").attr("class",$b).style("fill",function(a){return wg(a.id)}).style("stroke","none").style("cursor",function(a){return hf(a)?"pointer":null}),c=Ng.select(".chart-lines").selectAll(".chart-line").data(a),b=c.enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}).style("pointer-events","none"),b.append("path").attr("class",Yb).style("opacity",0).style("stroke",function(a){return wg(a.id)}),b.append("path").attr("class",ac).style("opacity",function(){return Tg=+g.select(this).style("opacity"),0}).style("fill",function(a){return wg(a.id)}),b.append("g").attr("class",function(a){return"selected-circles selected-circles-"+a.id}),b.append("g").attr("class",Zb).style("fill",function(a){return wg(a.id)}).style("cursor",function(a){return hf(a)?"pointer":null}),a.forEach(function(a){var b=Rd(a.id);Ng.selectAll(".selected-circles"+b).selectAll(".selected-circle").each(function(b){b.value=a.values[b.x].value})}),h=Ng.select(".chart-arcs").selectAll(".chart-arc").data(Be(a)),f=h.enter().append("g").attr("class",function(a){return"chart-arc target target-"+a.data.id}),f.append("path").attr("class",_b).style("opacity",0).style("fill",function(a){return wg(a.data.id)}).style("cursor",function(a){return hf(a)?"pointer":null}).each(function(a){this._current=a}).on("mouseover",function(a){jb(a.data.id),Nd(a.data.id)}).on("mousemove",function(a){var b=[Eb({id:a.data.id,value:a.value,ratio:hb(a)})];zc(b,g.mouse(this))}).on("mouseout",function(a){kb(a.data.id),Pd(),Ac()}),f.append("text").attr("dy",".35em").style("opacity",0).style("text-anchor","middle").style("pointer-events","none"),kf&&(n=Og.select(".chart-bars").selectAll(".chart-bar").data(a),m=n.enter().append("g").attr("class",function(a){return"chart-bar target target-"+a.id}),m.append("g").attr("class",$b).style("fill",function(a){return wg(a.id)}),l=Og.select(".chart-lines").selectAll(".chart-line").data(a),k=l.enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}),k.append("path").attr("class",Yb).style("opacity",0).style("stroke",function(a){return wg(a.id)})),nf&&Qd(a),Lg.selectAll(".target").transition().style("opacity",1)}function Md(a,b){Wd.data.targets.forEach(function(b){for(var c=0;c=d&&(Object.keys(w).forEach(function(a){w[a]=h}),Dg||(p=(ue-h*Object.keys(a).length)/2)),i>=e&&(Object.keys(x).forEach(function(a){x[a]=i}),Dg&&(p=(te-i*Object.keys(a).length)/2))):(v[c]=u,u+=j,p=(k-u)/2)}var i,j,k,l,m,n,o,p,q,r=Nb(a),s=4,t=30,u=0,v={},w={},x={};b=d(b)?{}:b,q=e(b.withTransition)?b.withTransition:!0,Dg?(j=function(){return.2*ue},m=function(a,b){return p+f(a,b)}):(j=function(a,b){return p+c(a,b)},m=function(){return.2*te}),k=function(a,b){return j(a,b)+14},n=function(a,b){return m(a,b)+9},l=function(a,b){return j(a,b)-4},o=function(a,b){return m(a,b)-7},i=Pg.selectAll(".legend-item").data(r).enter().append("g").attr("class",function(a){return"legend-item legend-item-"+a}).style("cursor","pointer").on("click",function(a){pf(a)}).on("mouseover",function(a){Nd(a),Wd.focus(a)}).on("mouseout",function(){Pd(),Wd.revert()}),i.append("text").text(function(a){return e(Ye[a])?Ye[a]:a}).each(function(a){h(this,a)}).style("pointer-events","none").attr("x",Dg?k:-200).attr("y",Dg?-200:m),i.append("rect").attr("class","legend-item-event").style("fill-opacity",0).attr("x",Dg?l:-200).attr("y",Dg?-200:o).attr("width",function(a){return w[a]}).attr("height",function(a){return x[a]}),i.append("rect").attr("class","legend-item-tile").style("pointer-events","none").style("fill",function(a){return wg(a)}).attr("x",Dg?k:-200).attr("y",Dg?-200:n).attr("width",10).attr("height",10),Pg.selectAll("text").data(r).each(function(a){h(this,a)}).transition().duration(q?250:0).attr("x",k).attr("y",n),Pg.selectAll("rect.legend-item-event").data(r).transition().duration(q?250:0).attr("x",l).attr("y",o),Pg.selectAll("rect.legend-item-tile").data(r).transition().duration(q?250:0).attr("x",j).attr("y",m)}function Rd(a){return a?"-"+a.replace(/\./g,"\\."):""}function Sd(a){return".target"+Rd(a)}function Td(a){return Ob(a.id)}function Ud(a){return"data"in a&&Ob(a.data.id)}function Vd(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}}var Wd={data:{}},Xd={},Yd="_expanded_",Zd="_selected_",$d="_included_",_d=i(["bindto"],"#chart"),ae=i(["size","width"],null),be=i(["size","height"],null),ce=i(["padding","left"],null),de=i(["padding","right"],null),ee=i(["zoom","enabled"],!1),fe=i(["zoom","extent"],null),ge=i(["zoom","privileged"],!1),he=i(["onenter"],function(){}),ie=i(["onleave"],function(){}),je=i(["transition","duration"],350);h("data","data is required in config");var ke,le,me,ne,oe,pe,qe,re,se,te,ue,ve,we,xe,ye,ze,Ae,Be,Ce,De,Ee,Fe,Ge,He,Ie,Je,Ke,Le,Me,Ne,Oe,Pe,Qe,Re,Se,Te,Ue=i(["data","x"],null),Ve=i(["data","xs"],null),We=i(["data","x_format"],"%Y-%m-%d"),Xe=i(["data","id_converter"],function(a){return a}),Ye=i(["data","names"],{}),Ze=i(["data","groups"],[]),$e=i(["data","axes"],{}),_e=i(["data","type"],null),af=i(["data","types"],{}),bf=i(["data","labels"],{}),cf=i(["data","order"],null),df=i(["data","regions"],{}),ef=i(["data","colors"],{}),ff=i(["data","selection","enabled"],!1),gf=i(["data","selection","grouped"],!1),hf=i(["data","selection","isselectable"],function(){return!0}),jf=i(["data","selection","multiple"],!0),kf=i(["subchart","show"],!1),lf=kf?i(["subchart","size","height"],60):0,mf=i(["color","pattern"],null),nf=i(["legend","show"],!0),of=i(["legend","position"],"bottom"),pf=i(["legend","item","onclick"],function(){}),qf=i(["legend","equally"],!1),rf=i(["axis","rotated"],!1),sf=i(["axis","x","type"],"indexed"),tf=i(["axis","x","categories"],[]),uf=i(["axis","x","tick","centered"],!1),vf=i(["axis","x","tick","format"],null),wf=i(["axis","x","tick","culling"],"categorized"===sf?!1:!0),xf=i(["axis","x","tick","count"],10),yf=i(["axis","x","default"],null),zf=i(["axis","x","label"],null),Af=i(["axis","y","max"],null),Bf=i(["axis","y","min"],null),Cf=i(["axis","y","center"],null),Df=i(["axis","y","label"],null),Ef=i(["axis","y","inner"],!1),Ff=i(["axis","y","tick","format"],null),Gf=i(["axis","y","padding"],null),Hf=i(["axis","y","ticks"],10),If=i(["axis","y2","show"],!1),Jf=i(["axis","y2","max"],null),Kf=i(["axis","y2","min"],null),Lf=i(["axis","y2","center"],null),Mf=i(["axis","y2","inner"],!1),Nf=i(["axis","y2","tick","format"],null),Of=i(["axis","y2","padding"],null),Pf=i(["axis","y2","ticks"],10),Qf=i(["grid","x","show"],!1),Rf=i(["grid","x","type"],"tick"),Sf=i(["grid","x","lines"],null),Tf=i(["grid","y","show"],!1),Uf=i(["grid","y","lines"],null),Vf=i(["grid","y","ticks"],10),Wf=i(["point","show"],!0),Xf=Wf?i(["point","r"],2.5):0,Yf=i(["point","focus","line","enabled"],!0),Zf=i(["point","focus","expand","enabled"],!0),$f=i(["point","focus","expand","r"],Zf?4:Xf),_f=i(["point","focus","select","r"],8),ag=i(["point","onclick"],function(){}),bg=i(["point","onselected"],function(){}),cg=i(["point","onunselected"],function(){}),dg=i(["arc","label","show"],!0),eg=i(["arc","label","format"],null),fg=i(["arc","title"],""),gg=i(["regions"],[]),hg=i(["tooltip","show"],!0),ig=i(["tooltip","format","title"],null),jg=i(["tooltip","format","value"],null),kg=i(["tooltip","contents"],function(a,b,c,d){var e,f,g,h,i,j=ig?ig:b,k=jg?jg:c;for(f=0;f"+(g?""+g+"":"")),i=a[f].name,h=k(a[f].value,a[f].ratio),e+=""+i+""+h+"");return e+""}),lg=i(["tooltip","init","show"],!1),mg=i(["tooltip","init","x"],0),ng=i(["tooltip","init","position"],{top:"0px",left:"50px"}),og=_d.replace("#","")+"-clip",pg=j(og),qg="timeseries"===sf,rg="categorized"===sf,sg=!qg&&(Ue||Ve),tg=null,ug=!1,vg=!1,wg=_c(ef,mf),xg=function(){var a=[[g.time.format("%Y/%-m/%-d"),function(){return!0}],[g.time.format("%-m/%-d"),function(a){return a.getMonth()}],[g.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[g.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[g.time.format("%I %p"),function(a){return a.getHours()}],[g.time.format("%I:%M"),function(a){return a.getMinutes()}],[g.time.format(":%S"),function(a){return a.getSeconds()}],[g.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)}}(),yg=rf?"left":"bottom",zg=rf?Ef?"top":"bottom":Ef?"right":"left",Ag=rf?Mf?"bottom":"top":Mf?"left":"right",Bg=rf?"left":"bottom",Cg={main:function(){return"translate("+ke.left+","+ke.top+")"},context:function(){return"translate("+le.left+","+le.top+")"},legend:function(){return"translate("+me.left+","+me.top+")"},y2:function(){return"translate("+(rf?0:ne)+","+(rf?1:0)+")"},x:function(){return"translate(0,"+pe+")"},subx:function(){return"translate(0,"+(rf?0:qe)+")"},arc:function(){return"translate("+ne/2+","+pe/2+")"}},Dg="right"===of,Eg=40,Fg=20;Be=g.layout.pie().value(function(a){return a.values.reduce(function(a,b){return a+b.value},0)});var Gg,Hg=function(){var a=g.svg.line().x(rf?function(a){return K(a.id)(a.value)}:mc).y(rf?mc:function(a){return K(a.id)(a.value)});return function(b){var c,d,e=md(b.values);return Rc(b)?(a.interpolate(Sc(b)?"cardinal":"linear"),df[b.id]?yd(e,Ke,K(b.id),df[b.id]):a(e)):(c=Ke(e[0].x),d=K(b.id)(e[0].value),rf?"M "+d+" "+c:"M "+c+" "+d)}}(),Ig=function(){var a;return a=rf?g.svg.area().x0(function(a){return K(a.id)(0)}).x1(function(a){return K(a.id)(a.value)}).y(mc):g.svg.area().x(mc).y0(function(a){return K(a.id)(0)}).y1(function(a){return K(a.id)(a.value)}),function(b){var c,d,e=md(b.values);return Lc([b],"area")||Lc([b],"area-spline")?(a.interpolate(Sc(b)?"cardinal":"linear"),a(e)):(c=Ke(e[0].x),d=K(b.id)(e[0].value),rf?"M "+d+" "+c:"M "+c+" "+d)}}(),Jg=function(){var a=g.svg.line().x(rf?function(a){return L(a.id)(a.value)}:pc).y(rf?pc:function(a){return L(a.id)(a.value)});return function(b){var c=md(b.values);return Rc(b)?a(c):"M "+Ne(c[0].x)+" "+L(b.id)(c[0].value)}}(),Kg=function(){};Gg=g.svg.brush().on("brush",Hd),Gg.update=function(){return Og&&Og.select(".x.brush").call(this),this},Gg.scale=function(a){return rf?this.y(a):this.x(a)},ee&&(Kg=g.behavior.zoom().on("zoomstart",function(){Kg.altDomain=g.event.sourceEvent.altKey?Ke.orgDomain():null}).on("zoom",ee?Id:null),Kg.scale=function(a){return rf?this.y(a):this.x(a)},Kg.orgScaleExtent=function(){var a=fe?fe:[1,10];return[a[0],Math.max(Lb()/a[1],a[1])]},Kg.updateScaleExtent=function(){var a=tb(Ke.orgDomain())/tb(Sg),b=this.orgScaleExtent();return this.scaleExtent([b[0]*a,b[1]*a]),this});var Lg,Mg,Ng,Og,Pg,Qg,Rg,Sg,Tg,Ug={};if(Wd.focus=function(a){function b(a){a.transition().duration(100).style("opacity",1)}var c=Lg.selectAll(Sd(a)),d=c.filter(Td),e=c.filter(Ud);Wd.revert(),Wd.defocus(),b(d.classed("focused",!0)),b(e),Qc(Wd.data.targets)&&jb(a,!0),Nd(a)},Wd.defocus=function(a){function b(a){a.transition().duration(100).style("opacity",.3)}var c=Lg.selectAll(Sd(a)),d=c.filter(Td),e=c.filter(Ud);Wd.revert(),b(d.classed("focused",!1)),b(e),Qc(Wd.data.targets)&&kb(a),Od(a)},Wd.revert=function(a){function b(a){a.transition().duration(100).style("opacity",1)}var c=Lg.selectAll(Sd(a)),d=c.filter(Td),e=c.filter(Ud);b(d.classed("focused",!1)),b(e),Qc(Wd.data.targets)&&kb(a),Pd()},Wd.show=function(a){Lg.selectAll(Sd(a)).transition().style("opacity",1)},Wd.hide=function(a){Lg.selectAll(Sd(a)).transition().style("opacity",0)},Wd.unzoom=function(){Gg.clear().update(),Gd({withUpdateXDomain:!0})},Wd.load=function(a){if("function"!=typeof a.done&&(a.done=function(){}),a.xs&&Db(a.xs),"categories"in a&&rg&&(tf=a.categories,Qe.categories(tf)),"cacheIds"in a&&ub(a.cacheIds))return void Md(wb(a.cacheIds),a.done);if("data"in a)Md(Hb(a.data),a.done);else if("url"in a)g.csv(a.url,function(b,c){Md(Hb(c),a.done)});else if("rows"in a)Md(Hb(Fb(a.rows)),a.done);else{if(!("columns"in a))throw Error("url or rows or columns is required.");Md(Hb(Gb(a.columns)),a.done)}},Wd.unload=function(a){Wd.data.targets=Wd.data.targets.filter(function(b){return b.id!==a}),Lg.selectAll(Sd(a)).transition().style("opacity",0).remove(),nf&&(Lg.selectAll(".legend-item"+Rd(a)).remove(),Qd(Wd.data.targets)),Wd.data.targets.length>0&&Gd({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})},Wd.selected=function(a){var b=Rd(a);return g.merge(Ng.selectAll(".-shapes"+b).selectAll(".-shape").filter(function(){return g.select(this).classed(Zd)}).map(function(a){return a.map(function(a){return a.__data__})}))},Wd.select=function(a,b,c){ff&&Ng.selectAll(".-shapes").selectAll(".-shape").each(function(d,f){var h="circle"===this.nodeName?gd:jd,i="circle"===this.nodeName?hd:kd,j=gf||!a||a.indexOf(d.id)>=0,k=!b||b.indexOf(f)>=0;j&&k?hf(d)&&h(g.select(this).classed(Zd,!0),d,f):e(c)&&c&&i(g.select(this).classed(Zd,!1),d,f)})},Wd.unselect=function(a,b){ff&&Ng.selectAll(".-shapes").selectAll(".-shape").each(function(c,d){var e="circle"===this.nodeName?hd:kd,f=gf||!a||a.indexOf(c.id)>=0,h=!b||b.indexOf(d)>=0;f&&h&&hf(c)&&e(g.select(this).classed(Zd,!1),c,d)})},Wd.toLine=function(a){Kc(a,"line"),Kd({withTransition:!0})},Wd.toSpline=function(a){Kc(a,"spline"),Kd({withTransition:!0})},Wd.toBar=function(a){Kc(a,"bar"),Kd({withTransition:!0})},Wd.toScatter=function(a){Kc(a,"scatter"),Kd({withTransition:!0})},Wd.toArea=function(a){Kc(a,"area"),Kd({withTransition:!0})},Wd.toAreaSpline=function(a){Kc(a,"area-spline"),Kd({withTransition:!0})},Wd.toPie=function(a){Kc(a,"pie"),Kd({withTransition:!0,withTransform:!0})},Wd.toDonut=function(a){Kc(a,"donut"),Kd({withTransition:!0,withTransform:!0})},Wd.groups=function(a){return d(a)?Ze:(Ze=a,Gd(),Ze)},Wd.xgrids=function(a){return a?(Sf=a,Gd(),Sf):Sf},Wd.xgrids.add=function(a){return a?Wd.xgrids(Sf.concat(a)):void 0},Wd.xgrids.remove=function(a){var b=Vd(a);return Wd.xgrids(Sf.filter(b))},Wd.ygrids=function(a){return a?(Uf=a,Gd(),Uf):Uf},Wd.ygrids.add=function(a){return a?Wd.ygrids(Uf.concat(a)):void 0},Wd.ygrids.remove=function(a){var b=Vd(a);return Wd.ygrids(Uf.filter(b))},Wd.regions=function(a){return d(a)?gg:(gg=a,Gd(),gg)},Wd.regions.add=function(a){return d(a)?gg:(gg=gg.concat(a),Gd(),gg)},Wd.regions.remove=function(a,b){var d=[].concat(a);return b=e(b)?b:{},d.forEach(function(a){var d=c(b.duration)?b.duration:0;Lg.selectAll("."+a).transition().duration(d).style("fill-opacity",0).remove(),gg=gg.filter(function(b){return b.classes.indexOf(a)<0})}),gg},Wd.data.get=function(a){var b=Wd.data.getAsTarget(a);return e(b)?b.values.map(function(a){return a.value}):void 0},Wd.data.getAsTarget=function(a){var b=Pb(function(b){return b.id===a});return b.length>0?b[0]:void 0},Wd.resize=function(a){ae=a?a.width:null,be=a?a.height:null,Kd()},Wd.destroy=function(){Wd.data.targets=void 0,Wd.data.x={},Rg.html(""),a.onresize=null},"url"in f.data)g.csv(f.data.url,function(a,b){zd(b)});else if("rows"in f.data)zd(Fb(f.data.rows));else{if(!("columns"in f.data))throw Error("url or rows or columns is required.");zd(Gb(f.data.columns))}return Wd}}(window); \ No newline at end of file +!function(a){"use strict";function b(){function a(a,b){a.attr("transform",function(a){return"translate("+(b(a)+q)+", 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 p>=c||b%Math.ceil(c/p)===0}function f(a){return a0?a:320}function t(){return Tc(Zd.data.targets)?0:fe?fe:Hf?1:v("y")}function u(){return Tc(Zd.data.targets)?0:ge?ge:Gg?xe*(Lf&&!uf?1.25:1):Lf?Pf||uf?1:v("y2"):1}function v(){var a=X();return a.isInner?40:60}function w(){return+g.select(ce).style("width").replace("px","")}function x(){return+g.select(ce).style("height").replace("px","")}function y(){return qe+2}function z(){return 80}function A(){return ne.left+20}function B(){return se+2}function C(){var a=uf?se:qe,b=rb(),c=Ob();return c>1?a*b/(c-1):a}function D(a){Hg=a}function E(a){Ig=a}function F(a){Jg=a}function G(){return qf?Gg?Ig*(Hg+1):ue:0}function H(){return qf?Gg?ve:Jg*(Hg+1):0}function I(){var a=W();return a.isInner?5:20}function J(){var a,b;Fe=uf?1:0,Ge=uf?se:qe,He=uf?0:se,Ie=uf?qe:1,Je=Fe,Ke=Ge,Le=uf?0:te,Me=uf?re:1,Ne=L(Fe,Ge,Ne?Ne.domain():void 0,function(){return Te.tickOffset()}),Oe=M(He,Ie),Pe=M(He,Ie),Qe=L(Fe,Ge,Yg,function(a){return a%1?0:We.tickOffset()}),Re=M(Le,Me),Se=M(Le,Me),a=S(),b=T(),Te=P(Ne,Bg,a,b),We=P(Qe,Eg,a,b),Ue=Q(Oe,Cg,If,Kf),Ve=Q(Pe,Dg,Qf,Sf),K()}function K(){Be=gb(),Ce=hb(),De=hb(.98)}function L(a,b,c,f){var h=(tg?g.time.scale():g.scale.linear()).range([a,b]);if(h.orgDomain=function(){return h.domain()},e(c)&&h.domain(c),d(f)&&(f=function(){return 0}),ug){var i,j=h;h=function(a){return j(a)+f(a)};for(i in j)h[i]=j[i];h.orgDomain=function(){return j.domain()},h.domain=function(a){return arguments.length?(j.domain(a),h):(a=j.domain(),[a[0],a[1]+1])}}return h}function M(a,b){return g.scale.linear().range([a,b])}function N(a){return"y2"===R(a)?Pe:Oe}function O(a){return"y2"===R(a)?Se:Re}function P(a,c,d,e){var f=(ug?b():g.svg.axis()).scale(a).orient(c);return f.tickFormat(d).ticks(e),ug?f.tickCentered(xf):f.tickOffset=function(){var a=uf?se:qe;return a*rb()/Ob()/2},ug&&f.categories(wf),f}function Q(a,b,c,d){return g.svg.axis().scale(a).orient(b).tickFormat(c).ticks(d).outerTickSize(0)}function R(a){return a in bf?bf[a]:"y"}function S(){var a=tg?Ag:ug?Xb:null;return yf&&("function"==typeof yf?a=yf:tg&&(a=function(a){return g.time.format(yf)(a)})),a}function T(){var a=Ob();return zf&&a>Af?Af:a}function U(a){return"string"==typeof a?a:a?a.text:null}function V(a,b){var c=a&&"object"==typeof a&&a.position?a.position:b;return{isInner:c.indexOf("inner")>=0,isOuter:c.indexOf("outer")>=0,isLeft:c.indexOf("left")>=0,isCenter:c.indexOf("center")>=0,isRight:c.indexOf("right")>=0,isTop:c.indexOf("top")>=0,isMiddle:c.indexOf("middle")>=0,isBottom:c.indexOf("bottom")>=0}}function W(){return V(Cf,"inner-right")}function X(){return V(Gf,"inner-top")}function Y(){return U(Cf)}function Z(){return U(Gf)}function $(){var a=W();return a.isLeft?0:a.isCenter?qe/2:qe}function _(){var a=X();return a.isBottom?-se:a.isMiddle?-se/2:0}function ab(){var a=X();return a.isTop?"-0.5em":"0"}function bb(){var a=W();return a.isInner?"-0.5em":"3.5em"}function cb(){var a=X(),b=0;return g.selectAll(".y.axis .tick text").each(function(){var a=this.getBBox();b0)for(f=Vb(a),b=0;ba?a:0}),c=1;c0||(h[d][b]+=+a)});return g.min(Object.keys(h).map(function(a){return g.min(h[a])}))}function pb(a){var b,c,d,e,f,h=Tb(a);if(af.length>0)for(f=Wb(a),b=0;b0?a:0}),c=1;c+a||(h[d][b]+=+a)});return g.max(Object.keys(h).map(function(a){return g.max(h[a])}))}function qb(a){var b,d,e,f,g,h,i,j,k=Sb(function(b){return R(b.id)===a}),l="y2"===a?Nf:Ef,m="y2"===a?Mf:Df,n=c(l)?l:ob(k),o=c(m)?m:pb(k),p="y2"===a?Of:Ff,q=nc()&&uf;return n===o&&(0>n?o=0:n=0),b=Math.abs(o-n),d=e=f=q?0:.1*b,p&&(g=Math.max(Math.abs(n),Math.abs(o)),o=g-p,n=p-g),"y"===a&&Jf&&(e=c(Jf.top)?Jf.top:d,f=c(Jf.bottom)?Jf.bottom:d),"y2"===a&&Rf&&(e=c(Rf.top)?Rf.top:d,f=c(Rf.bottom)?Rf.bottom:d),q&&(h=oc(n,o),i=wb(Oe.range()),j=[h[0]/i,h[1]/i],e+=b*(j[1]/(1-j[0]-j[1])),f+=b*(j[0]/(1-j[0]-j[1]))),Pc(k)&&!Vb(k)&&(f=n),[n-f,o+e]}function rb(a){var b=wb(Yg),c=wb(Ne.domain());return a||0===c?1:b/c}function sb(a){return g.min(a,function(a){return g.min(a.values,function(a){return a.x})})}function tb(a){return g.max(a,function(a){return g.max(a.values,function(a){return a.x})})}function ub(a,b){var c,d,e=b[0],f=b[1],g=Math.abs(e-f);return ug?d=0:Pc(a)?(c=Ob(),d=c>1?g/(c-1)/2:.5):d=.01*g,d}function vb(a){var b=[sb(a),tb(a)],c=b[0],d=b[1],e=ub(a,b),f=tg?new Date(c.getTime()-e):c-e,g=tg?new Date(d.getTime()+e):d+e;return[f,g]}function wb(a){return a[1]-a[0]}function xb(a){for(var b=0;bd?0:d}function Cb(a){return Xe&&a===Xe||Ye&&hd(Ye,a)}function Db(a){return!Cb(a)}function Eb(a){return Xe?Xe:Ye?Ye[a]:null}function Fb(a,b){return a in Zd.data.x&&Zd.data.x[a]&&Zd.data.x[a][b]?Zd.data.x[a][b]:b}function Gb(a){Object.keys(a).forEach(function(b){Ye[b]=a[b]})}function Hb(a){var b;return a&&(b=_e[a.id],a.name=b?b:a.id),a}function Ib(a){var b,c,d=a[0],e={},f=[];for(b=1;b=0?b.map(function(a){return a[c]}):Zd.data.x[Object.keys(Zd.data.x)[0]]}),c=d.map(function(a){var c=$e(a);return{id:c,id_org:a,values:b.map(function(b,d){var e,f=Eb(a);return e=tg?dd(b[f]):vg?b[f]?+b[f]:Fb(a,d):d,b.x=e,{x:e,value:null===b[a]||isNaN(b[a])?null:+b[a],id:c}})}}),c.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++})}),cf&&Nc(Qb(c).filter(function(a){return!(a in df)}),cf),c.forEach(function(a){yb(a.id_org,a)}),c)}function Lb(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 Mb(a){return a>0&&Zd.data.targets[0].values[a-1]?Zd.data.targets[0].values[a-1].x:void 0}function Nb(a){return a1?Zd.data.targets.forEach(function(b){b.values.length>c&&(a=b,c=b.values.length)}):a=b?Zd.data.targets[0]:null,a}function Qb(a){return a=d(a)?Zd.data.targets:a,a.map(function(a){return a.id})}function Rb(a){var b,c=Qb();for(b=0;ba})}function Wb(a){return Ub(a,function(a){return a>0})}function Xb(a){return a=0&&d===a[c].x;c--)e.push(a[c]);for(c=b;c0?g=h:f=h,g-f===1?(e=[],a[f].x&&(e=e.concat(vc(a,f))),a[g].x&&(e=e.concat(vc(a,g))),yc(e,b)):wc(a,b,f,g)}function xc(a,b){var c;return c=a.map(function(a){return wc(a.values,b)}),yc(c,b)}function yc(a,b){var c,d;return a.forEach(function(a){var e=id(a,b);(c>e||!c)&&(c=e,d=a)}),d}function zc(){return ff&&"desc"===ff.toLowerCase()}function Ac(){return ff&&"asc"===ff.toLowerCase()}function Bc(a){var b=Ac(),c=zc();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 ff&&a.sort(ff),a}function Cc(a,b){var d,e,f,g,h,i,j,k=Tc(Zd.data.targets),l=k?uc:tc,m=a.filter(function(a){return a&&c(a.value)});kg&&0!==m.length&&(Wg.html(ng(a,S(),l,zg)).style("visibility","hidden").style("display","block"),d=Wg.property("offsetWidth"),e=Wg.property("offsetHeight"),k?(g=qe/2+b[0],i=se/2+b[1]+20):(uf?(f=q(),g=f+b[0]+100,h=g+d,j=r()-u(),i=Ne(m[0].x)+20):(f=q(),g=f+t()+Ne(m[0].x)+20,h=g+d,j=f+r()-u(),i=b[1]+15),h>j&&(g-=d+60),i+e>s()&&(i-=e+30)),Wg.style("top",i+"px").style("left",g+"px").style("visibility","visible"))}function Dc(){Wg.style("display","none")}function Ec(a){var b=a.filter(function(a){return a&&c(a.value)});kg&&(Qc(Zd.data.targets)||Tc(Zd.data.targets)||Tg.selectAll("line.xgrid-focus").style("visibility","visible").data([b[0]]).attr(uf?"y1":"x1",pc).attr(uf?"y2":"x2",pc))}function Fc(){Tg.select("line.xgrid-focus").style("visibility","hidden")}function Gc(a){return a.x||0===a.x?Ne(a.x):null}function Hc(a){return N(a.id)(a.value)}function Ic(){var a,b,c={},e=0;return Sb(Wc).forEach(function(f){for(a=0;a0&&(i+=g(b.values[f].value)-h)}),i}}function Mc(a,b){return b?2*a.tickOffset()*.6/b:0}function Nc(a,b){var c=d(a)?Qb():a;"string"==typeof c&&(c=[c]);for(var e=0;e0&&i>k||a.value<0&&k>i)&&(k=i),[[j,i],[j,k-(c-i)],[j+d,k-(c-i)],[j+d,i]]}}function Bd(a,b,c,f){var g,h,i,j,k,l,m,n,o,p,q,r=-1,s="M",t=[];if(e(f))for(g=0;g=h;h+=u)s+=i(a[g-1],a[g],h,o)}r=a[g].x}return s}function Cd(b){var c,d,e;if(Xg=g.select(ce),Xg.empty())return void a.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');if(Xg.html(""),Zd.data.x={},Zd.data.targets=Kb(b),o(),J(),Ne.domain(g.extent(vb(Zd.data.targets))),Oe.domain(qb("y")),Pe.domain(qb("y2")),Qe.domain(Ne.domain()),Re.domain(Oe.domain()),Se.domain(Pe.domain()),Yg=Ne.domain(),Mg.scale(Qe),he&&Qg.scale(Ne),Rg=g.select(ce).append("svg").attr("width",qe+ne.left+ne.right).attr("height",se+ne.top+ne.bottom).on("mouseenter",ke).on("mouseleave",le),Sg=Rg.append("defs"),Sg.append("clipPath").attr("id",rg).append("rect").attr("width",qe).attr("height",se),Sg.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1).attr("y",-20).attr("width",y).attr("height",z),Sg.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-ne.left+1).attr("width",A).attr("height",B),Tg=Rg.append("g").attr("transform",Fg.main),Ug=nf?Rg.append("g").attr("transform",Fg.context):null,Vg=qf?Rg.append("g").attr("transform",Fg.legend):null,Wg=g.select(ce).style("position","relative").append("div").style("position","absolute").style("z-index","10").style("display","none"),Tg.append("g").attr("class","x axis").attr("clip-path",uf?"":j("xaxis-clip")).attr("transform",Fg.x).append("text").attr("class","-axis-x-label").attr("dy",bb).style("text-anchor",db).text(uf?Z:Y),Tg.append("g").attr("class","y axis").attr("clip-path",uf?j("yaxis-clip"):"").append("text").attr("class","-axis-y-label").attr("transform","rotate(-90)").attr("dx",ab).style("text-anchor",eb).text(uf?Y:Z),Lf&&Tg.append("g").attr("class","y2 axis").attr("transform",Fg.y2),d=Tg.append("g").attr("clip-path",sg).attr("class","grid"),Tf&&d.append("g").attr("class","xgrids"),Vf&&d.append("g").attr("class","xgrid-lines"),_f&&d.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",uf?0:-10).attr("x2",uf?qe:-10).attr("y1",uf?-10:ne.top).attr("y2",uf?-10:se),Wf&&d.append("g").attr("class","ygrids"),Xf&&d.append("g").attr("class","ygrid-lines"),Tg.append("g").attr("clip-path",sg).attr("class","regions"),Tg.append("g").attr("clip-path",sg).attr("class","chart"),c=Tg.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",he?uf?"ns-resize":"ew-resize":null),Tg.select(".chart").append("g").attr("class","chart-bars"),Tg.select(".chart").append("g").attr("class","chart-lines"),Tg.select(".chart").append("g").attr("class","chart-arcs").attr("transform",Fg.arc).append("text").attr("class","chart-arcs-title").style("text-anchor","middle").text(ig),Tg.select(".chart").append("g").attr("class","chart-texts"),he&&Tg.insert("rect",je?null:"g.grid").attr("class","zoom-rect").attr("width",qe).attr("height",se).style("opacity",0).style("cursor",uf?"ns-resize":"ew-resize").call(Qg).on("dblclick.zoom",null),null!==Bf&&Mg.extent("function"!=typeof Bf?Bf:Bf(vb())),nf&&(Ug.append("g").attr("clip-path",sg).attr("class","chart"),Ug.select(".chart").append("g").attr("class","chart-bars"),Ug.select(".chart").append("g").attr("class","chart-lines"),Ug.append("g").attr("clip-path",sg).attr("class","x brush").call(Mg).selectAll("rect").attr(uf?"width":"height",uf?re:te),Ug.append("g").attr("class","x axis").attr("transform",Fg.subx).attr("clip-path",uf?j("yaxis-clip"):"")),Od(Zd.data.targets),Jd({withTransform:!0,withUpdateXDomain:!0,withLegend:!0}),og){if(tg&&"string"==typeof pg){for(pg=dd(pg),e=0;e0){d=[];for(var f in _e)for(c=0;cf&&h>c&&d>i&&j>d):"rect"===this.nodeName&&(c=1*l.attr("x"),d=1*l.attr("y"),e=1*l.attr("width"),k=od,o=c+e>f&&h>c&&j>d),o^n&&(l.classed(be,!n),l.classed(ae,!m),k(!m,l,a,b))}))}function Hd(a){Tc(Zd.data.targets)||jf&&(wg=a,Tg.select(".chart").append("rect").attr("class","dragarea").style("opacity",.1),xg=!0)}function Id(){Tc(Zd.data.targets)||jf&&(Tg.select(".dragarea").transition().duration(100).style("opacity",0).remove(),Tg.selectAll(".-shape").classed(be,!1),xg=!1)}function Jd(a){var b,d,f,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,D,E,F,G,H,I=Ic(),J=Tc(Zd.data.targets);if(a=e(a)?a:{},u=e(a.withY)?a.withY:!0,v=e(a.withSubchart)?a.withSubchart:!0,w=e(a.withTransition)?a.withTransition:!0,x=e(a.withTransform)?a.withTransform:!1,y=e(a.withUpdateXDomain)?a.withUpdateXDomain:!1,z=e(a.withUpdateOrgXDomain)?a.withUpdateOrgXDomain:!1,A=e(a.withLegend)?a.withLegend:!1,G=w?me:0,H=e(a.durationForExit)?a.durationForExit:G,A&&qf)return void Td(Zd.data.targets,a);if(z&&(Ne.domain(g.extent(vb(Zd.data.targets))),Yg=Ne.domain(),he&&Qg.scale(Ne).updateScaleExtent(),Qe.domain(Ne.domain()),Mg.scale(Qe)),y&&(Ne.domain(Mg.empty()?Yg:Mg.extent()),he&&Qg.scale(Ne).updateScaleExtent()),Oe.domain(qb("y")),Pe.domain(qb("y2")),Tg.select(".x.axis").style("opacity",J?0:1).transition().duration(G).call(uf?Ue:Te),Tg.select(".y.axis").style("opacity",J?0:1).transition().duration(G).call(uf?Te:Ue),Tg.select(".y2.axis").style("opacity",J?0:1).transition().call(Ve),B=wd(I),E=xd(I,!0),F=xd(I,!1),Tg.select(".x.axis .-axis-x-label").attr("x",$),Tg.select(".y.axis .-axis-y-label").attr("x",_).attr("dy",cb),Re.domain(Oe.domain()),Se.domain(Pe.domain()),Wg.style("display","none"),Tg.select("line.xgrid-focus").style("visibility","hidden").attr("y2",se),Tf){if("year"===Uf){d=[];for(var K=vb(),L=K[0].getFullYear(),M=K[1].getFullYear(),N=L;M>=N;N++)d.push(new Date(N+"-01-01 00:00:00"))}else d=Ne.ticks(10);b=Tg.select(".xgrids").selectAll(".xgrid").data(d),b.enter().append("line").attr("class","xgrid"),b.attr("x1",uf?0:function(a){return Ne(a)-Te.tickOffset()}).attr("x2",uf?qe:function(a){return Ne(a)-Te.tickOffset()}).attr("y1",uf?function(a){return Ne(a)-Te.tickOffset()}:ne.top).attr("y2",uf?function(a){return Ne(a)-Te.tickOffset()}:se).style("opacity",function(){return+g.select(this).attr(uf?"y1":"x1")===(uf?se:0)?0:1}),b.exit().remove()}Vf&&(f=Tg.select(".xgrid-lines").selectAll(".xgrid-line").data(Vf),h=f.enter().append("g").attr("class",function(a){return"xgrid-line xgrid-line-"+(a["class"]?a["class"]:"")}),h.append("line").style("opacity",0),h.append("text").attr("text-anchor","end").attr("transform",uf?"":"rotate(-90)").attr("dx",uf?0:-ne.top).attr("dy",-5).style("opacity",0),f.select("line").transition().duration(G).attr("x1",uf?0:qc).attr("x2",uf?qe:qc).attr("y1",uf?qc:ne.top).attr("y2",uf?qc:se).style("opacity",1),f.select("text").transition().duration(G).attr("x",uf?qe:0).attr("y",qc).text(function(a){return a.text}).style("opacity",1),f.exit().transition().duration(G).style("opacity",0).remove()),u&&Wf&&(i=Tg.select(".ygrids").selectAll(".ygrid").data(Oe.ticks(Yf)),i.enter().append("line").attr("class","ygrid"),i.attr("x1",uf?Oe:0).attr("x2",uf?Oe:qe).attr("y1",uf?0:Oe).attr("y2",uf?se:Oe),i.exit().remove()),u&&Xf&&(j=Tg.select(".ygrid-lines").selectAll(".ygrid-line").data(Xf),k=j.enter().append("g").attr("class",function(a){return"ygrid-line ygrid-line-"+(a.class?a.class:"")}),k.append("line").style("opacity",0),k.append("text").attr("text-anchor","end").attr("transform",uf?"rotate(-90)":"").attr("dx",uf?0:-ne.top).attr("dy",-5).style("opacity",0),j.select("line").transition().duration(G).attr("x1",uf?rc:0).attr("x2",uf?rc:qe).attr("y1",uf?0:rc).attr("y2",uf?se:rc).style("opacity",1),j.select("text").transition().duration(G).attr("x",uf?0:qe).attr("y",rc).text(function(a){return a.text +}).style("opacity",1),j.exit().transition().duration(G).style("opacity",0).remove()),m=Tg.selectAll(".-bars").selectAll(".-bar").data(_c),m.enter().append("path").attr("d",B).style("stroke","none").style("opacity",0).style("fill",function(a){return zg(a.id)}).attr("class",gc),m.style("opacity",jc).transition().duration(G).attr("d",B).style("opacity",1),m.exit().transition().duration(H).style("opacity",0).remove(),o=Tg.selectAll(".-texts").selectAll(".-text").data(bd),o.enter().append("text").attr("class",Yb).attr("text-anchor",function(a){return uf?a.value<0?"end":"start":"middle"}).style("stroke","none").style("fill-opacity",0).text(function(a){return tc(a.value)}),o.style("fill-opacity",kc).transition().duration(G).attr("x",E).attr("y",F).style("fill-opacity",mc),o.exit().transition().duration(H).style("fill-opacity",0).remove(),Tg.selectAll(".-line").style("opacity",jc).transition().duration(G).attr("d",Ng).style("opacity",1),Tg.selectAll(".-area").style("opacity",0).transition().duration(G).attr("d",Og).style("opacity",Zg),l=Tg.selectAll(".-circles").selectAll(".-circle").data(ad),l.enter().append("circle").attr("class",fc).style("opacity",0).attr("r",$f),l.style("opacity",jc).transition().duration(G).style("opacity",lc).attr("cx",uf?Hc:Gc).attr("cy",uf?Gc:Hc),l.exit().remove(),Tg.selectAll(".chart-arc").select(".-arc").attr("transform",x?"scale(0)":"").style("opacity",function(a){return a===this._current?0:1}).transition().duration(G).attrTween("d",function(a){var b=fb(a);if(!b)return function(){return"M 0 0"};var c=g.interpolate(this._current,b);return this._current=c(0),function(a){return ib(c(a),!0)}}).attr("transform",x?"scale(1)":"").style("opacity",1),Tg.selectAll(".chart-arc").select("text").attr("transform",jb).style("opacity",0).transition().duration(G).text(lb).style("opacity",function(a){return $c(a.data)?1:0}),Tg.select(".chart-arcs-title").style("opacity",Sc(Zd.data.targets)?1:0),nf&&(null!==g.event&&"zoom"===g.event.type&&Mg.extent(Ne.orgDomain()).update(),v&&(Ug.select(".x.axis").style("opacity",J?0:1).transition().duration(G).call(We),Mg.empty()||Mg.extent(Ne.orgDomain()).update(),D=wd(I,!0),p=Ug.selectAll(".-bars").selectAll(".-bar").data(_c),p.enter().append("path").attr("d",D).style("stroke","none").style("fill",function(a){return zg(a.id)}).attr("class",gc),p.style("opacity",jc).transition().duration(G).attr("d",D).style("opacity",1),p.exit().transition().duration(G).style("opacity",0).remove(),Ug.selectAll(".-line").style("opacity",jc).transition().duration(G).attr("d",Pg).style("opacity",1))),Tg.selectAll(".selected-circles").filter(function(a){return Wc(a)}).selectAll("circle").remove(),Tg.selectAll(".selected-circle").transition().duration(G).attr("cx",uf?Hc:Gc).attr("cy",uf?Gc:Hc),Ye?(q=Tg.select(".event-rects").selectAll(".event-rect").data([0]),Ed(q.enter()),q.attr("x",0).attr("y",0).attr("width",qe).attr("height",se)):(vg?(t=function(a,b){var c=Mb(b),d=Nb(b);return(Ne(d?d:a.x+50)-Ne(c?c:a.x-50))/2},s=function(a,b){var c=Mb(b);return(Ne(a.x)+Ne(c?c:a.x-50))/2}):(t=C(),s=function(a){return Ne(a.x)-t/2}),r=Pb(),Tg.select(".event-rects").datum(r?r.values:[]),q=Tg.select(".event-rects").selectAll(".event-rect").data(function(a){return a}),Dd(q.enter()),q.attr("class",ic).attr("x",uf?0:s).attr("y",uf?s:0).attr("width",uf?qe:t).attr("height",uf?t:se),q.exit().remove()),n=Tg.select(".regions").selectAll("rect.region").data(jg),n.enter().append("rect").style("fill-opacity",0),n.attr("class",hc).attr("x",uf?0:Ab).attr("y",uf?Ab:ne.top).attr("width",uf?qe:Bb).attr("height",uf?Bb:se).transition().duration(G).style("fill-opacity",function(a){return c(a.opacity)?a.opacity:.1}),n.exit().transition().duration(G).style("fill-opacity",0).remove(),Qb().forEach(function(a){$g[a]=!0})}function Kd(){Jd({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}function Ld(){return"mousemove"===g.event.sourceEvent.type&&Qg.altDomain?(Ne.domain(Qg.altDomain),void Qg.scale(Ne).updateScaleExtent()):(ug&&Ne.orgDomain()[0]===Yg[0]&&Ne.domain([Yg[0]-1e-10,Ne.orgDomain()[1]]),Jd({withTransition:!1,withY:!1,withSubchart:!1}),void("mousemove"===g.event.sourceEvent.type&&(yg=!0)))}function Md(){function a(){b.forEach(function(a){a()})}var b=[];return a.add=function(a){b.push(a)},a}function Nd(a){var b,c,d;a=e(a)?a:{},b=e(a.withTransition)?a.withTransition:!0,c=e(a.withTransform)?a.withTransform:!1,d=e(a.withLegend)?a.withLegend:!1,o(),J(),Mg.scale(Qe),he&&Qg.scale(Ne),Rg.attr("width",ue).attr("height",ve),Rg.select("#"+rg).select("rect").attr("width",qe).attr("height",se),Rg.select("#xaxis-clip").select("rect").attr("width",y),Rg.select(".zoom-rect").attr("width",qe).attr("height",se),n(b),Jd({withTransition:b,withUpdateXDomain:!0,withTransform:c,durationForExit:0,withLegend:d})}function Od(a){var b,c,d,e,f,h,i,j,k,l,m,n;i=Tg.select(".chart-texts").selectAll(".chart-text").data(a),j=i.enter().append("g").attr("class",function(a){return"chart-text target target-"+a.id}).style("pointer-events","none"),j.append("g").attr("class",Zb).style("fill",function(a){return zg(a.id)}),e=Tg.select(".chart-bars").selectAll(".chart-bar").data(a),d=e.enter().append("g").attr("class",function(a){return"chart-bar target target-"+a.id}).style("pointer-events","none"),d.append("g").attr("class",bc).style("fill",function(a){return zg(a.id)}).style("stroke","none").style("cursor",function(a){return lf(a)?"pointer":null}),c=Tg.select(".chart-lines").selectAll(".chart-line").data(a),b=c.enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}).style("pointer-events","none"),b.append("path").attr("class",_b).style("opacity",0).style("stroke",function(a){return zg(a.id)}),b.append("path").attr("class",dc).style("opacity",function(){return Zg=+g.select(this).style("opacity"),0}).style("fill",function(a){return zg(a.id)}),b.append("g").attr("class",function(a){return"selected-circles selected-circles-"+a.id}),b.append("g").attr("class",ac).style("fill",function(a){return zg(a.id)}).style("cursor",function(a){return lf(a)?"pointer":null}),a.forEach(function(a){var b=Ud(a.id);Tg.selectAll(".selected-circles"+b).selectAll(".selected-circle").each(function(b){b.value=a.values[b.x].value})}),h=Tg.select(".chart-arcs").selectAll(".chart-arc").data(Ee(a)),f=h.enter().append("g").attr("class",function(a){return"chart-arc target target-"+a.data.id}),f.append("path").attr("class",cc).style("opacity",0).style("fill",function(a){return zg(a.data.id)}).style("cursor",function(a){return lf(a)?"pointer":null}).each(function(a){this._current=a}).on("mouseover",function(a){mb(a.data.id),Qd(a.data.id)}).on("mousemove",function(a){var b=[Hb({id:a.data.id,value:a.value,ratio:kb(a)})];Cc(b,g.mouse(this))}).on("mouseout",function(a){nb(a.data.id),Sd(),Dc()}),f.append("text").attr("dy",".35em").style("opacity",0).style("text-anchor","middle").style("pointer-events","none"),nf&&(n=Ug.select(".chart-bars").selectAll(".chart-bar").data(a),m=n.enter().append("g").attr("class",function(a){return"chart-bar target target-"+a.id}),m.append("g").attr("class",bc).style("fill",function(a){return zg(a.id)}),l=Ug.select(".chart-lines").selectAll(".chart-line").data(a),k=l.enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}),k.append("path").attr("class",_b).style("opacity",0).style("stroke",function(a){return zg(a.id)})),Rg.selectAll(".target").transition().style("opacity",1)}function Pd(a,b){Zd.data.targets.forEach(function(b){for(var c=0;ce&&(e=(k-j)/2,v=0,B++)),A[a]=B,z[B]=e,w[a]=v,v+=j}var e,f,g=a.getBBox(),h=10*Math.ceil((g.width+t)/10),i=10*Math.ceil((g.height+s)/10),j=Gg?i:h,k=Gg?we:xe;c&&(v=0,B=0,m=0,p=0),x[b]=h,y[b]=i,(!m||h>=m)&&(m=h),(!p||i>=p)&&(p=i),f=Gg?p:m,tf?(Object.keys(x).forEach(function(a){x[a]=m}),Object.keys(y).forEach(function(a){y[a]=p}),e=(k-f*r.length)/2,u>e?(v=0,B=0,r.forEach(function(a){d(a)})):d(b,!0)):d(b)}var f,g,h,i,j,k,l,m,p,q,r=Qb(a),s=4,t=26,u=10,v=0,w={},x={},y={},z={},A={},B=0;b=d(b)?{}:b,q=e(b.withTransition)?b.withTransition:!0,Gg?(g=function(a){return m*(.2+A[a])},j=function(a){return z[A[a]]+w[a]}):(g=function(a){return z[A[a]]+w[a]},j=function(a){return p*(.2+A[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},f=Vg.selectAll(".legend-item").data(r).enter().append("g").attr("class",function(a){return"legend-item legend-item-"+a}).style("cursor","pointer").on("click",function(a){sf(a)}).on("mouseover",function(a){Qd(a),Zd.focus(a)}).on("mouseout",function(){Sd(),Zd.revert()}),f.append("text").text(function(a){return e(_e[a])?_e[a]:a}).each(function(a,b){c(this,a,0===b)}).style("pointer-events","none").attr("x",Gg?h:-200).attr("y",Gg?-200:k),f.append("rect").attr("class","legend-item-event").style("fill-opacity",0).attr("x",Gg?i:-200).attr("y",Gg?-200:l).attr("width",function(a){return x[a]}).attr("height",function(a){return y[a]}),f.append("rect").attr("class","legend-item-tile").style("pointer-events","none").style("fill",function(a){return zg(a)}).attr("x",Gg?h:-200).attr("y",Gg?-200:j).attr("width",10).attr("height",10),Vg.selectAll("text").data(r).each(function(a,b){c(this,a,0===b)}).transition().duration(q?250:0).attr("x",h).attr("y",k),Vg.selectAll("rect.legend-item-event").data(r).transition().duration(q?250:0).attr("x",i).attr("y",l),Vg.selectAll("rect.legend-item-tile").data(r).transition().duration(q?250:0).attr("x",g).attr("y",j),E(m),F(p),D(B),o(),J(),n(!1),b.withLegend=!1,Jd(b)}function Ud(a){return a?"-"+a.replace(/\./g,"\\."):""}function Vd(a){return".target"+Ud(a)}function Wd(a){return Rb(a.id)}function Xd(a){return"data"in a&&Rb(a.data.id)}function Yd(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}}var Zd={data:{}},$d={},_d="_expanded_",ae="_selected_",be="_included_",ce=i(["bindto"],"#chart"),de=i(["size","width"],null),ee=i(["size","height"],null),fe=i(["padding","left"],null),ge=i(["padding","right"],null),he=i(["zoom","enabled"],!1),ie=i(["zoom","extent"],null),je=i(["zoom","privileged"],!1),ke=i(["onenter"],function(){}),le=i(["onleave"],function(){}),me=i(["transition","duration"],350);h("data","data is required in config");var ne,oe,pe,qe,re,se,te,ue,ve,we,xe,ye,ze,Ae,Be,Ce,De,Ee,Fe,Ge,He,Ie,Je,Ke,Le,Me,Ne,Oe,Pe,Qe,Re,Se,Te,Ue,Ve,We,Xe=i(["data","x"],null),Ye=i(["data","xs"],null),Ze=i(["data","x_format"],"%Y-%m-%d"),$e=i(["data","id_converter"],function(a){return a}),_e=i(["data","names"],{}),af=i(["data","groups"],[]),bf=i(["data","axes"],{}),cf=i(["data","type"],null),df=i(["data","types"],{}),ef=i(["data","labels"],{}),ff=i(["data","order"],null),gf=i(["data","regions"],{}),hf=i(["data","colors"],{}),jf=i(["data","selection","enabled"],!1),kf=i(["data","selection","grouped"],!1),lf=i(["data","selection","isselectable"],function(){return!0}),mf=i(["data","selection","multiple"],!0),nf=i(["subchart","show"],!1),of=nf?i(["subchart","size","height"],60):0,pf=i(["color","pattern"],null),qf=i(["legend","show"],!0),rf=i(["legend","position"],"bottom"),sf=i(["legend","item","onclick"],function(){}),tf=i(["legend","equally"],!1),uf=i(["axis","rotated"],!1),vf=i(["axis","x","type"],"indexed"),wf=i(["axis","x","categories"],[]),xf=i(["axis","x","tick","centered"],!1),yf=i(["axis","x","tick","format"],null),zf=i(["axis","x","tick","culling"],"categorized"===vf?!1:!0),Af=i(["axis","x","tick","count"],10),Bf=i(["axis","x","default"],null),Cf=i(["axis","x","label"],null),Df=i(["axis","y","max"],null),Ef=i(["axis","y","min"],null),Ff=i(["axis","y","center"],null),Gf=i(["axis","y","label"],null),Hf=i(["axis","y","inner"],!1),If=i(["axis","y","tick","format"],null),Jf=i(["axis","y","padding"],null),Kf=i(["axis","y","ticks"],10),Lf=i(["axis","y2","show"],!1),Mf=i(["axis","y2","max"],null),Nf=i(["axis","y2","min"],null),Of=i(["axis","y2","center"],null),Pf=i(["axis","y2","inner"],!1),Qf=i(["axis","y2","tick","format"],null),Rf=i(["axis","y2","padding"],null),Sf=i(["axis","y2","ticks"],10),Tf=i(["grid","x","show"],!1),Uf=i(["grid","x","type"],"tick"),Vf=i(["grid","x","lines"],null),Wf=i(["grid","y","show"],!1),Xf=i(["grid","y","lines"],null),Yf=i(["grid","y","ticks"],10),Zf=i(["point","show"],!0),$f=Zf?i(["point","r"],2.5):0,_f=i(["point","focus","line","enabled"],!0),ag=i(["point","focus","expand","enabled"],!0),bg=i(["point","focus","expand","r"],ag?4:$f),cg=i(["point","focus","select","r"],8),dg=i(["point","onclick"],function(){}),eg=i(["point","onselected"],function(){}),fg=i(["point","onunselected"],function(){}),gg=i(["arc","label","show"],!0),hg=i(["arc","label","format"],null),ig=i(["arc","title"],""),jg=i(["regions"],[]),kg=i(["tooltip","show"],!0),lg=i(["tooltip","format","title"],null),mg=i(["tooltip","format","value"],null),ng=i(["tooltip","contents"],function(a,b,c,d){var e,f,g,h,i,j=lg?lg:b,k=mg?mg:c;for(f=0;f"+(g?""+g+"":"")),i=a[f].name,h=k(a[f].value,a[f].ratio),e+=""+i+""+h+"");return e+""}),og=i(["tooltip","init","show"],!1),pg=i(["tooltip","init","x"],0),qg=i(["tooltip","init","position"],{top:"0px",left:"50px"}),rg=ce.replace("#","")+"-clip",sg=j(rg),tg="timeseries"===vf,ug="categorized"===vf,vg=!tg&&(Xe||Ye),wg=null,xg=!1,yg=!1,zg=cd(hf,pf),Ag=function(){var a=[[g.time.format("%Y/%-m/%-d"),function(){return!0}],[g.time.format("%-m/%-d"),function(a){return a.getMonth()}],[g.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[g.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[g.time.format("%I %p"),function(a){return a.getHours()}],[g.time.format("%I:%M"),function(a){return a.getMinutes()}],[g.time.format(":%S"),function(a){return a.getSeconds()}],[g.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)}}(),Bg=uf?"left":"bottom",Cg=uf?Hf?"top":"bottom":Hf?"right":"left",Dg=uf?Pf?"bottom":"top":Pf?"left":"right",Eg=uf?"left":"bottom",Fg={main:function(){return"translate("+ne.left+","+ne.top+")"},context:function(){return"translate("+oe.left+","+oe.top+")"},legend:function(){return"translate("+pe.left+","+pe.top+")"},y2:function(){return"translate("+(uf?0:qe)+","+(uf?1:0)+")"},x:function(){return"translate(0,"+se+")"},subx:function(){return"translate(0,"+(uf?0:te)+")"},arc:function(){return"translate("+qe/2+","+se/2+")"}},Gg="right"===rf,Hg=0,Ig=0,Jg=0,Kg=40,Lg=20;Ee=g.layout.pie().value(function(a){return a.values.reduce(function(a,b){return a+b.value},0)});var Mg,Ng=function(){var a=g.svg.line().x(uf?function(a){return N(a.id)(a.value)}:pc).y(uf?pc:function(a){return N(a.id)(a.value)});return function(b){var c,d,e=pd(b.values);return Uc(b)?(a.interpolate(Vc(b)?"cardinal":"linear"),gf[b.id]?Bd(e,Ne,N(b.id),gf[b.id]):a(e)):(c=Ne(e[0].x),d=N(b.id)(e[0].value),uf?"M "+d+" "+c:"M "+c+" "+d)}}(),Og=function(){var a;return a=uf?g.svg.area().x0(function(a){return N(a.id)(0)}).x1(function(a){return N(a.id)(a.value)}).y(pc):g.svg.area().x(pc).y0(function(a){return N(a.id)(0)}).y1(function(a){return N(a.id)(a.value)}),function(b){var c,d,e=pd(b.values);return Oc([b],"area")||Oc([b],"area-spline")?(a.interpolate(Vc(b)?"cardinal":"linear"),a(e)):(c=Ne(e[0].x),d=N(b.id)(e[0].value),uf?"M "+d+" "+c:"M "+c+" "+d)}}(),Pg=function(){var a=g.svg.line().x(uf?function(a){return O(a.id)(a.value)}:sc).y(uf?sc:function(a){return O(a.id)(a.value)});return function(b){var c=pd(b.values);return Uc(b)?a(c):"M "+Qe(c[0].x)+" "+O(b.id)(c[0].value)}}(),Qg=function(){};Mg=g.svg.brush().on("brush",Kd),Mg.update=function(){return Ug&&Ug.select(".x.brush").call(this),this},Mg.scale=function(a){return uf?this.y(a):this.x(a)},he&&(Qg=g.behavior.zoom().on("zoomstart",function(){Qg.altDomain=g.event.sourceEvent.altKey?Ne.orgDomain():null}).on("zoom",he?Ld:null),Qg.scale=function(a){return uf?this.y(a):this.x(a)},Qg.orgScaleExtent=function(){var a=ie?ie:[1,10];return[a[0],Math.max(Ob()/a[1],a[1])]},Qg.updateScaleExtent=function(){var a=wb(Ne.orgDomain())/wb(Yg),b=this.orgScaleExtent();return this.scaleExtent([b[0]*a,b[1]*a]),this});var Rg,Sg,Tg,Ug,Vg,Wg,Xg,Yg,Zg,$g={};if(Zd.focus=function(a){function b(a){a.transition().duration(100).style("opacity",1)}var c=Rg.selectAll(Vd(a)),d=c.filter(Wd),e=c.filter(Xd);Zd.revert(),Zd.defocus(),b(d.classed("focused",!0)),b(e),Tc(Zd.data.targets)&&mb(a,!0),Qd(a)},Zd.defocus=function(a){function b(a){a.transition().duration(100).style("opacity",.3)}var c=Rg.selectAll(Vd(a)),d=c.filter(Wd),e=c.filter(Xd);Zd.revert(),b(d.classed("focused",!1)),b(e),Tc(Zd.data.targets)&&nb(a),Rd(a)},Zd.revert=function(a){function b(a){a.transition().duration(100).style("opacity",1)}var c=Rg.selectAll(Vd(a)),d=c.filter(Wd),e=c.filter(Xd);b(d.classed("focused",!1)),b(e),Tc(Zd.data.targets)&&nb(a),Sd()},Zd.show=function(a){Rg.selectAll(Vd(a)).transition().style("opacity",1)},Zd.hide=function(a){Rg.selectAll(Vd(a)).transition().style("opacity",0)},Zd.unzoom=function(){Mg.clear().update(),Jd({withUpdateXDomain:!0})},Zd.load=function(a){if("function"!=typeof a.done&&(a.done=function(){}),a.xs&&Gb(a.xs),"categories"in a&&ug&&(wf=a.categories,Te.categories(wf)),"cacheIds"in a&&xb(a.cacheIds))return void Pd(zb(a.cacheIds),a.done);if("data"in a)Pd(Kb(a.data),a.done);else if("url"in a)g.csv(a.url,function(b,c){Pd(Kb(c),a.done)});else if("rows"in a)Pd(Kb(Ib(a.rows)),a.done);else{if(!("columns"in a))throw Error("url or rows or columns is required.");Pd(Kb(Jb(a.columns)),a.done)}},Zd.unload=function(a){Zd.data.targets=Zd.data.targets.filter(function(b){return b.id!==a}),Rg.selectAll(Vd(a)).transition().style("opacity",0).remove(),qf&&Rg.selectAll(".legend-item"+Ud(a)).remove(),Zd.data.targets.length>0&&Jd({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})},Zd.selected=function(a){var b=Ud(a);return g.merge(Tg.selectAll(".-shapes"+b).selectAll(".-shape").filter(function(){return g.select(this).classed(ae)}).map(function(a){return a.map(function(a){return a.__data__})}))},Zd.select=function(a,b,c){jf&&Tg.selectAll(".-shapes").selectAll(".-shape").each(function(d,f){var h="circle"===this.nodeName?jd:md,i="circle"===this.nodeName?kd:nd,j=kf||!a||a.indexOf(d.id)>=0,k=!b||b.indexOf(f)>=0;j&&k?lf(d)&&h(g.select(this).classed(ae,!0),d,f):e(c)&&c&&i(g.select(this).classed(ae,!1),d,f)})},Zd.unselect=function(a,b){jf&&Tg.selectAll(".-shapes").selectAll(".-shape").each(function(c,d){var e="circle"===this.nodeName?kd:nd,f=kf||!a||a.indexOf(c.id)>=0,h=!b||b.indexOf(d)>=0;f&&h&&lf(c)&&e(g.select(this).classed(ae,!1),c,d)})},Zd.toLine=function(a){Nc(a,"line"),Nd()},Zd.toSpline=function(a){Nc(a,"spline"),Nd()},Zd.toBar=function(a){Nc(a,"bar"),Nd()},Zd.toScatter=function(a){Nc(a,"scatter"),Nd()},Zd.toArea=function(a){Nc(a,"area"),Nd()},Zd.toAreaSpline=function(a){Nc(a,"area-spline"),Nd()},Zd.toPie=function(a){Nc(a,"pie"),Nd({withTransform:!0})},Zd.toDonut=function(a){Nc(a,"donut"),Nd({withTransform:!0})},Zd.groups=function(a){return d(a)?af:(af=a,Jd(),af)},Zd.xgrids=function(a){return a?(Vf=a,Jd(),Vf):Vf},Zd.xgrids.add=function(a){return a?Zd.xgrids(Vf.concat(a)):void 0},Zd.xgrids.remove=function(a){var b=Yd(a);return Zd.xgrids(Vf.filter(b))},Zd.ygrids=function(a){return a?(Xf=a,Jd(),Xf):Xf},Zd.ygrids.add=function(a){return a?Zd.ygrids(Xf.concat(a)):void 0},Zd.ygrids.remove=function(a){var b=Yd(a);return Zd.ygrids(Xf.filter(b))},Zd.regions=function(a){return d(a)?jg:(jg=a,Jd(),jg)},Zd.regions.add=function(a){return d(a)?jg:(jg=jg.concat(a),Jd(),jg)},Zd.regions.remove=function(a,b){var d=[].concat(a);return b=e(b)?b:{},d.forEach(function(a){var d=c(b.duration)?b.duration:0;Rg.selectAll("."+a).transition().duration(d).style("fill-opacity",0).remove(),jg=jg.filter(function(b){return b.classes.indexOf(a)<0})}),jg},Zd.data.get=function(a){var b=Zd.data.getAsTarget(a);return e(b)?b.values.map(function(a){return a.value}):void 0},Zd.data.getAsTarget=function(a){var b=Sb(function(b){return b.id===a});return b.length>0?b[0]:void 0},Zd.resize=function(a){de=a?a.width:null,ee=a?a.height:null,Nd({withLegend:!0,withTransition:!1})},Zd.destroy=function(){Zd.data.targets=void 0,Zd.data.x={},Xg.html(""),a.onresize=null},"url"in f.data)g.csv(f.data.url,function(a,b){Cd(b)});else if("rows"in f.data)Cd(Ib(f.data.rows));else{if(!("columns"in f.data))throw Error("url or rows or columns is required.");Cd(Jb(f.data.columns))}return Zd}}(window); \ No newline at end of file