diff --git a/c3.js b/c3.js index be86666..7c7e6e9 100644 --- a/c3.js +++ b/c3.js @@ -1,14 +1,15 @@ (function (window) { 'use strict'; - var c3 = window.c3 = {}; - var d3 = window.d3; + var c3 = {}; /* * Generate chart according to config */ c3.generate = function (config) { + var d3 = window.d3 ? window.d3 : window.require ? window.require("d3") : undefined; + var c3 = { data : {} }, cache = {}; @@ -668,6 +669,177 @@ return maxWidth; } + function categoryAxis() { + var scale = d3.scale.linear(), orient = "bottom"; + var tickMajorSize = 6, /*tickMinorSize = 6,*/ tickEndSize = 6, tickPadding = 3, tickCentered = false, tickTextNum = 10, tickOffset = 0, tickFormat = null, tickCulling = true; + var categories = []; + function axisX(selection, x) { + selection.attr("transform", function (d) { + return "translate(" + (x(d) + tickOffset) + ", 0)"; + }); + } + function axisY(selection, y) { + selection.attr("transform", function (d) { + return "translate(0," + y(d) + ")"; + }); + } + function scaleExtent(domain) { + var start = domain[0], stop = domain[domain.length - 1]; + return start < stop ? [ start, stop ] : [ stop, start ]; + } + function generateTicks(domain) { + var ticks = []; + for (var i = Math.ceil(domain[0]); i < domain[1]; i++) { + ticks.push(i); + } + if (ticks.length > 0 && ticks[0] > 0) { + ticks.unshift(ticks[0] - (ticks[1] - ticks[0])); + } + return ticks; + } + function shouldShowTickText(ticks, i) { + var length = ticks.length - 1; + return length <= tickTextNum || i % Math.ceil(length / tickTextNum) === 0; + } + function category(i) { + return i < categories.length ? categories[i] : i; + } + function formattedCategory(i) { + var c = category(i); + return tickFormat ? tickFormat(c) : c; + } + function axis(g) { + g.each(function () { + var g = d3.select(this); + var ticks = generateTicks(scale.domain()); + var tick = g.selectAll(".tick.major").data(ticks, String), + tickEnter = tick.enter().insert("g", "path").attr("class", "tick major").style("opacity", 1e-6), + tickExit = d3.transition(tick.exit()).style("opacity", 1e-6).remove(), + tickUpdate = d3.transition(tick).style("opacity", 1), + tickTransform, + tickX; + var range = scale.rangeExtent ? scale.rangeExtent() : scaleExtent(scale.range()), + path = g.selectAll(".domain").data([ 0 ]); + + path.enter().append("path").attr("class", "domain"); + + var pathUpdate = d3.transition(path); + + var scale1 = scale.copy(), scale0 = this.__chart__ || scale1; + this.__chart__ = scale1; + tickEnter.append("line"); + tickEnter.append("text"); + var lineEnter = tickEnter.select("line"), lineUpdate = tickUpdate.select("line"), text = tick.select("text"), textEnter = tickEnter.select("text"), textUpdate = tickUpdate.select("text"); + + tickOffset = (scale1(1) - scale1(0)) / 2; + tickX = tickCentered ? 0 : tickOffset; + + switch (orient) { + case "bottom": + { + tickTransform = axisX; + lineEnter.attr("y2", tickMajorSize); + textEnter.attr("y", Math.max(tickMajorSize, 0) + tickPadding); + lineUpdate.attr("x1", tickX).attr("x2", tickX).attr("y2", tickMajorSize); + textUpdate.attr("x", 0).attr("y", Math.max(tickMajorSize, 0) + tickPadding); + text.attr("dy", ".71em").style("text-anchor", "middle"); + text.text(function (i) { return shouldShowTickText(ticks, i) ? formattedCategory(i) : ""; }); + pathUpdate.attr("d", "M" + range[0] + "," + tickEndSize + "V0H" + range[1] + "V" + tickEndSize); + break; + } +/* TODO: implement + case "top": + { + tickTransform = axisX + lineEnter.attr("y2", -tickMajorSize) + textEnter.attr("y", -(Math.max(tickMajorSize, 0) + tickPadding)) + lineUpdate.attr("x2", 0).attr("y2", -tickMajorSize) + textUpdate.attr("x", 0).attr("y", -(Math.max(tickMajorSize, 0) + tickPadding)) + text.attr("dy", "0em").style("text-anchor", "middle") + pathUpdate.attr("d", "M" + range[0] + "," + -tickEndSize + "V0H" + range[1] + "V" + -tickEndSize) + break + } +*/ + case "left": + { + tickTransform = axisY; + lineEnter.attr("x2", -tickMajorSize); + textEnter.attr("x", -(Math.max(tickMajorSize, 0) + tickPadding)); + lineUpdate.attr("x2", -tickMajorSize).attr("y2", 0); + textUpdate.attr("x", -(Math.max(tickMajorSize, 0) + tickPadding)).attr("y", tickOffset); + text.attr("dy", ".32em").style("text-anchor", "end"); + text.text(function (i) { return shouldShowTickText(ticks, i) ? formattedCategory(i) : ""; }); + pathUpdate.attr("d", "M" + -tickEndSize + "," + range[0] + "H0V" + range[1] + "H" + -tickEndSize); + break; + } +/* + case "right": + { + tickTransform = axisY + lineEnter.attr("x2", tickMajorSize) + textEnter.attr("x", Math.max(tickMajorSize, 0) + tickPadding) + lineUpdate.attr("x2", tickMajorSize).attr("y2", 0) + textUpdate.attr("x", Math.max(tickMajorSize, 0) + tickPadding).attr("y", 0) + text.attr("dy", ".32em").style("text-anchor", "start") + pathUpdate.attr("d", "M" + tickEndSize + "," + range[0] + "H0V" + range[1] + "H" + tickEndSize) + break + } +*/ + } + if (scale.ticks) { + tickEnter.call(tickTransform, scale0); + tickUpdate.call(tickTransform, scale1); + tickExit.call(tickTransform, scale1); + } else { + var dx = scale1.rangeBand() / 2, x = function (d) { + return scale1(d) + dx; + }; + tickEnter.call(tickTransform, x); + tickUpdate.call(tickTransform, x); + } + }); + } + axis.scale = function (x) { + if (!arguments.length) { return scale; } + scale = x; + return axis; + }; + axis.orient = function (x) { + if (!arguments.length) { return orient; } + orient = x in {top: 1, right: 1, bottom: 1, left: 1} ? x + "" : "bottom"; + return axis; + }; + axis.categories = function (x) { + if (!arguments.length) { return categories; } + categories = x; + return axis; + }; + axis.tickCentered = function (x) { + if (!arguments.length) { return tickCentered; } + tickCentered = x; + return axis; + }; + axis.tickFormat = function (format) { + if (!arguments.length) { return tickFormat; } + tickFormat = format; + return axis; + }; + axis.tickOffset = function () { + return tickOffset; + }; + axis.ticks = function (n) { + if (!arguments.length) { return tickTextNum; } + tickTextNum = n; + return axis; + }; + axis.tickCulling = function (culling) { + if (!arguments.length) { return tickCulling; } + tickCulling = culling; + return axis; + }; + return axis; + } + //-- Arc --// pie = d3.layout.pie().value(function (d) { @@ -3538,178 +3710,6 @@ return c3; }; - function categoryAxis() { - var scale = d3.scale.linear(), orient = "bottom"; - var tickMajorSize = 6, /*tickMinorSize = 6,*/ tickEndSize = 6, tickPadding = 3, tickCentered = false, tickTextNum = 10, tickOffset = 0, tickFormat = null, tickCulling = true; - var categories = []; - function axisX(selection, x) { - selection.attr("transform", function (d) { - return "translate(" + (x(d) + tickOffset) + ", 0)"; - }); - } - function axisY(selection, y) { - selection.attr("transform", function (d) { - return "translate(0," + y(d) + ")"; - }); - } - function scaleExtent(domain) { - var start = domain[0], stop = domain[domain.length - 1]; - return start < stop ? [ start, stop ] : [ stop, start ]; - } - function generateTicks(domain) { - var ticks = []; - for (var i = Math.ceil(domain[0]); i < domain[1]; i++) { - ticks.push(i); - } - if (ticks.length > 0 && ticks[0] > 0) { - ticks.unshift(ticks[0] - (ticks[1] - ticks[0])); - } - return ticks; - } - function shouldShowTickText(ticks, i) { - var length = ticks.length - 1; - return length <= tickTextNum || i % Math.ceil(length / tickTextNum) === 0; - } - function category(i) { - return i < categories.length ? categories[i] : i; - } - function formattedCategory(i) { - var c = category(i); - return tickFormat ? tickFormat(c) : c; - } - function axis(g) { - g.each(function () { - var g = d3.select(this); - var ticks = generateTicks(scale.domain()); - var tick = g.selectAll(".tick.major").data(ticks, String), - tickEnter = tick.enter().insert("g", "path").attr("class", "tick major").style("opacity", 1e-6), - tickExit = d3.transition(tick.exit()).style("opacity", 1e-6).remove(), - tickUpdate = d3.transition(tick).style("opacity", 1), - tickTransform, - tickX; - var range = scale.rangeExtent ? scale.rangeExtent() : scaleExtent(scale.range()), - path = g.selectAll(".domain").data([ 0 ]); - - path.enter().append("path").attr("class", "domain"); - - var pathUpdate = d3.transition(path); - - var scale1 = scale.copy(), scale0 = this.__chart__ || scale1; - this.__chart__ = scale1; - tickEnter.append("line"); - tickEnter.append("text"); - var lineEnter = tickEnter.select("line"), lineUpdate = tickUpdate.select("line"), text = tick.select("text"), textEnter = tickEnter.select("text"), textUpdate = tickUpdate.select("text"); - - tickOffset = (scale1(1) - scale1(0)) / 2; - tickX = tickCentered ? 0 : tickOffset; - - switch (orient) { - case "bottom": - { - tickTransform = axisX; - lineEnter.attr("y2", tickMajorSize); - textEnter.attr("y", Math.max(tickMajorSize, 0) + tickPadding); - lineUpdate.attr("x1", tickX).attr("x2", tickX).attr("y2", tickMajorSize); - textUpdate.attr("x", 0).attr("y", Math.max(tickMajorSize, 0) + tickPadding); - text.attr("dy", ".71em").style("text-anchor", "middle"); - text.text(function (i) { return shouldShowTickText(ticks, i) ? formattedCategory(i) : ""; }); - pathUpdate.attr("d", "M" + range[0] + "," + tickEndSize + "V0H" + range[1] + "V" + tickEndSize); - } - - break; -/* TODO: implement - case "top": - { - tickTransform = axisX - lineEnter.attr("y2", -tickMajorSize) - textEnter.attr("y", -(Math.max(tickMajorSize, 0) + tickPadding)) - lineUpdate.attr("x2", 0).attr("y2", -tickMajorSize) - textUpdate.attr("x", 0).attr("y", -(Math.max(tickMajorSize, 0) + tickPadding)) - text.attr("dy", "0em").style("text-anchor", "middle") - pathUpdate.attr("d", "M" + range[0] + "," + -tickEndSize + "V0H" + range[1] + "V" + -tickEndSize) - break - } -*/ - case "left": - { - tickTransform = axisY; - lineEnter.attr("x2", -tickMajorSize); - textEnter.attr("x", -(Math.max(tickMajorSize, 0) + tickPadding)); - lineUpdate.attr("x2", -tickMajorSize).attr("y2", 0); - textUpdate.attr("x", -(Math.max(tickMajorSize, 0) + tickPadding)).attr("y", tickOffset); - text.attr("dy", ".32em").style("text-anchor", "end"); - text.text(function (i) { return shouldShowTickText(ticks, i) ? formattedCategory(i) : ""; }); - pathUpdate.attr("d", "M" + -tickEndSize + "," + range[0] + "H0V" + range[1] + "H" + -tickEndSize); - break; - } -/* - case "right": - { - tickTransform = axisY - lineEnter.attr("x2", tickMajorSize) - textEnter.attr("x", Math.max(tickMajorSize, 0) + tickPadding) - lineUpdate.attr("x2", tickMajorSize).attr("y2", 0) - textUpdate.attr("x", Math.max(tickMajorSize, 0) + tickPadding).attr("y", 0) - text.attr("dy", ".32em").style("text-anchor", "start") - pathUpdate.attr("d", "M" + tickEndSize + "," + range[0] + "H0V" + range[1] + "H" + tickEndSize) - break - } -*/ - } - if (scale.ticks) { - tickEnter.call(tickTransform, scale0); - tickUpdate.call(tickTransform, scale1); - tickExit.call(tickTransform, scale1); - } else { - var dx = scale1.rangeBand() / 2, x = function (d) { - return scale1(d) + dx; - }; - tickEnter.call(tickTransform, x); - tickUpdate.call(tickTransform, x); - } - }); - } - axis.scale = function (x) { - if (!arguments.length) { return scale; } - scale = x; - return axis; - }; - axis.orient = function (x) { - if (!arguments.length) { return orient; } - orient = x in {top: 1, right: 1, bottom: 1, left: 1} ? x + "" : "bottom"; - return axis; - }; - axis.categories = function (x) { - if (!arguments.length) { return categories; } - categories = x; - return axis; - }; - axis.tickCentered = function (x) { - if (!arguments.length) { return tickCentered; } - tickCentered = x; - return axis; - }; - axis.tickFormat = function (format) { - if (!arguments.length) { return tickFormat; } - tickFormat = format; - return axis; - }; - axis.tickOffset = function () { - return tickOffset; - }; - axis.ticks = function (n) { - if (!arguments.length) { return tickTextNum; } - tickTextNum = n; - return axis; - }; - axis.tickCulling = function (culling) { - if (!arguments.length) { return tickCulling; } - tickCulling = culling; - return axis; - }; - return axis; - } - function isValue(v) { return v || v === 0; } @@ -3720,4 +3720,11 @@ return typeof v !== 'undefined'; } + if (typeof window.define === "function" && window.define.amd) { + window.define(c3); + } else { + window.c3 = c3; + } + // TODO: module.exports + })(window); diff --git a/c3.min.js b/c3.min.js index f8d82bd..c3cae9a 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?e:0}function r(){return He?He:x()}function s(){var a=Ie?Ie:y();return a>0?a:320}function t(){return td(Be.data.targets)?0:Je?Je:Yf||!hg||mg?1:v("y")}function u(){var a=1;return td(Be.data.targets)?0:Ke?Ke:uh?_e+(qg&&!Yf?v("y2"):a):qg?vg||Yf?a:v("y2"):a}function v(a){var b=fb(a);return b.isInner?20+yb(a):40+yb(a)}function w(a){return"y"!==a||hg?"y2"!==a||qg?(fb(a).isInner?30:40)+("y2"===a?-10:0):Ah:Uf&&!uh?10:1}function x(){return+g.select(Ge).style("width").replace("px","")}function y(){return+g.select(Ge).style("height").replace("px","")}function z(a){return a?-5:-(Re.left-1)}function A(a){return a?-20:-1}function B(){return z(!Yf)}function C(){return A(!Yf)}function D(){return z(Yf)}function E(){return A(Yf)}function F(a){return a?Ue+2+4:Re.left+20}function G(a){return a?80:We+2}function H(){return F(!Yf)}function I(){return G(!Yf)}function J(){return F(Yf)}function K(){return G(Yf)}function L(){var a=Yf?We:Ue,b=Sb(),c=nc();return c>1?a*b/(c-1):a}function M(a){vh=a}function N(a){wh=a}function O(a){xh=a}function P(){return Uf?uh?wh*(vh+1):Ye:0}function Q(){return Uf?uh?Ze:xh*(vh+1):0}function R(){var a,b,c=!qf;hf=Yf?1:0,jf=Yf?We:Ue,kf=Yf?0:We,lf=Yf?Ue:1,mf=hf,nf=jf,of=Yf?0:Xe,pf=Yf?Ve:1,qf=T(hf,jf,c?void 0:qf.domain(),function(){return wf.tickOffset()}),rf=U(kf,lf),sf=U(kf,lf),tf=T(hf,jf,Nh,function(a){return a%1?0:zf.tickOffset()}),uf=U(of,pf),vf=U(of,pf),a=$(),b=_(),wf=X(qf,ph,a,b),zf=X(tf,sh,a,b),xf=Y(rf,qh,ng,pg),yf=Y(sf,rh,wg,yg),c||(Bh.scale(tf),Le&&Fh.scale(qf)),S()}function S(){df=Ab(),ef=Bb(),ff=Bb(.98)}function T(a,b,c,f){var h=(hh?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}),ih){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 U(a,b){return g.scale.linear().range([a,b])}function V(a){return"y2"===Z(a)?sf:rf}function W(a){return"y2"===Z(a)?vf:uf}function X(a,c,d,e){var f=(ih?b():g.svg.axis()).scale(a).orient(c);return f.tickFormat(d).ticks(e),ih?f.tickCentered(_f):f.tickOffset=function(){var a=Yf?We:Ue;return a*Sb()/nc()/2},ih&&f.categories($f),f}function Y(a,b,c,d){return g.svg.axis().scale(a).orient(b).tickFormat(c).ticks(d).outerTickSize(0)}function Z(a){return a in Gf?Gf[a]:"y"}function $(){var a=hh?oh:ih?wc:null;return ag&&("function"==typeof ag?a=ag:hh&&(a=function(a){return g.time.format(ag)(a)})),a}function _(){var a=nc();return bg&&a>cg?cg:a}function ab(a){return"string"==typeof a?a:a?a.text:null}function bb(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 cb(){return bb(gg,Yf?"inner-top":"inner-right")}function db(){return bb(lg,Yf?"inner-right":"inner-top")}function eb(){return bb(ug,Yf?"inner-right":"inner-top")}function fb(a){return"y2"===a?eb():"y"===a?db():cb()}function gb(){return ab(gg)}function hb(){return ab(lg)}function ib(){return ab(ug)}function jb(a,b){return a?b.isLeft?0:b.isCenter?Ue/2:Ue:b.isBottom?-We:b.isMiddle?-We/2:0}function kb(a,b){return a?b.isLeft?"0.5em":b.isRight?"-0.5em":"0":b.isTop?"-0.5em":b.isBottom?"0.5em":"0"}function lb(a,b){return a?b.isLeft?"start":b.isCenter?"middle":"end":b.isBottom?"start":b.isMiddle?"middle":"end"}function mb(){return jb(!Yf,cb())}function nb(){return jb(Yf,db())}function ob(){return jb(Yf,eb())}function pb(){return kb(!Yf,cb())}function qb(){return kb(Yf,db())}function rb(){return kb(Yf,eb())}function sb(){var a=cb();return Yf?a.isInner?"1.2em":-30-yb("x"):a.isInner?"-0.5em":"3em"}function tb(){var a=db();return Yf?a.isInner?"-0.5em":"3em":a.isInner?"1.2em":-20-yb("y")}function ub(){var a=eb();return Yf?a.isInner?"1.2em":"-2.2em":a.isInner?"-0.5em":30+yb("y2")}function vb(){return lb(!Yf,cb())}function wb(){return lb(Yf,db())}function xb(){return lb(Yf,eb())}function yb(a){var b=0;return g.selectAll("."+a+".axis .tick text").each(function(){var a=this.getBBox();b0)for(f=uc(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 Qb(a){var b,c,d,e,f,h=sc(a);if(Ff.length>0)for(f=vc(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 Rb(a){var b,d,e,f,g,h,i,j,k=rc(function(b){return Z(b.id)===a}),l="y2"===a?sg:jg,m="y2"===a?rg:ig,n=c(l)?l:Pb(k),o=c(m)?m:Qb(k),p="y2"===a?tg:kg,q=Pc()&&Yf;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&&og&&(e=c(og.top)?og.top:d,f=c(og.bottom)?og.bottom:d),"y2"===a&&xg&&(e=c(xg.top)?xg.top:d,f=c(xg.bottom)?xg.bottom:d),q&&(h=Qc(n,o),i=Xb(rf.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]))),pd(k)&&!uc(k)&&(f=n),[n-f,o+e]}function Sb(a){var b=Xb(Nh),c=Xb(qf.domain());return a||0===c?1:b/c}function Tb(a){return eg?eg:g.min(a,function(a){return g.min(a.values,function(a){return a.x})})}function Ub(a){return dg?dg:g.max(a,function(a){return g.max(a.values,function(a){return a.x})})}function Vb(a,b){var c,d,e=b[0],f=b[1],g=Math.abs(e-f);return ih?d=0:pd(a)?(c=nc(),d=c>1?g/(c-1)/2:.5):d=.01*g,d}function Wb(a){var b=[Tb(a),Ub(a)],c=b[0],d=b[1],e=Vb(a,b),f=hh?new Date(c.getTime()-e):c-e,g=hh?new Date(d.getTime()+e):d+e;return[f,g]}function Xb(a){return a[1]-a[0]}function Yb(a){for(var b=0;bd?0:d}function bc(a){return Af&&a===Af||Bf&&Jd(Bf,a)}function cc(a){return!bc(a)}function dc(a){return Af?Af:Bf?Bf[a]:null}function ec(a,b){return a in Be.data.x&&Be.data.x[a]&&Be.data.x[a][b]?Be.data.x[a][b]:b}function fc(a){Object.keys(a).forEach(function(b){Bf[b]=a[b]})}function gc(a){var b;return a&&(b=Ef[a.id],a.name=b?b:a.id),a}function hc(a){var b,c,d=a[0],e={},f=[];for(b=1;b=0?a.map(function(a){return a[c]}):Be.data.x[Object.keys(Be.data.x)[0]]}),b=c.map(function(b){var c=Df(b);return{id:c,id_org:b,values:a.map(function(a,d){var e,f=dc(b);return e=hh?a[f]instanceof Date?a[f]:Fd(a[f]):jh?a[f]?+a[f]:ec(b,d):d,a.x=e,{x:e,value:null===a[b]||isNaN(a[b])?null:+a[b],id:c}})}}),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++})}),Hf&&nd(pc(b).filter(function(a){return!(a in If)}),Hf),b.forEach(function(a){Zb(a.id_org,a)}),b}function kc(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 lc(a){return a>0&&Be.data.targets[0].values[a-1]?Be.data.targets[0].values[a-1].x:void 0}function mc(a){return a1?Be.data.targets.forEach(function(b){b.values.length>c&&(a=b,c=b.values.length)}):a=b?Be.data.targets[0]:null,a}function pc(a){return a=d(a)?Be.data.targets:a,a.map(function(a){return a.id})}function qc(a){var b,c=pc();for(b=0;ba})}function vc(a){return tc(a,function(a){return a>0})}function wc(a){return a<$f.length?$f[a]:a}function xc(a,b){return" "+a+" "+a+we(b)}function yc(a){return xc("-text",a.id)}function zc(a){return xc("-texts",a.id)}function Ac(a){return xc("-shapes",a.id)}function Bc(a){return Ac(a)+xc("-line",a.id)}function Cc(a){return Ac(a)+xc("-circles",a.id)}function Dc(a){return Ac(a)+xc("-bars",a.id)}function Ec(a){return Ac(a.data)+xc("-arc",a.data.id)}function Fc(a){return Ac(a)+xc("-area",a.id)}function Gc(a,b){return xc("-shape",b)}function Hc(a,b){return Gc(a,b)+xc("-circle",b)}function Ic(a,b){return Gc(a,b)+xc("-bar",b)}function Jc(a,b){return xc("region",b)+" "+("class"in a?a.class:"")}function Kc(a,b){return xc("event-rect",b)}function Lc(a){return Ph[a.id]?1:0}function Mc(a){var b=Oc(a);return Lc(a)*b}function Nc(a){return c(a.value)?xd(a)?.5:1:0}function Oc(a){return Pc(a)?1:0}function Pc(a){var b=a?a.id:null;return"boolean"==typeof Jf&&Jf?!0:"boolean"===Jf[b]&&Jf[b]?!0:Jf[b]&&Jf[b].show?!0:!1}function Qc(a,b){var c=[],d=1.3;return g.select("svg").selectAll(".dummy").data([a,b]).enter().append("text").text(function(a){return a}).each(function(a,b){var e=this.getBBox();c[b]=e.width*d}).remove(),c}function Rc(a){return a?qf(a.x):null}function Sc(a){return qf(hh?Fd(a.value):a.value)}function Tc(a){return rf(a.value)}function Uc(a){return tf(a.x)}function Vc(a){var b=ng?ng:function(a){return+a};return b(a)}function Wc(a,b){return(100*b).toFixed(1)+"%"}function Xc(a,b){var c,d=a[b].x,e=[];for(c=b-1;c>=0&&d===a[c].x;c--)e.push(a[c]);for(c=b;c0?g=h:f=h,g-f===1?(e=[],a[f].x&&(e=e.concat(Xc(a,f))),a[g].x&&(e=e.concat(Xc(a,g))),$c(e,b)):Yc(a,b,f,g)}function Zc(a,b){var c;return c=a.map(function(a){return Yc(a.values,b)}),$c(c,b)}function $c(a,b){var c,d;return a.forEach(function(a){var e=Kd(a,b);(c>e||!c)&&(c=e,d=a)}),d}function _c(){return Kf&&"desc"===Kf.toLowerCase()}function ad(){return Kf&&"asc"===Kf.toLowerCase()}function bd(a){var b=ad(),c=_c();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 Kf&&a.sort(Kf),a}function cd(a,b){var d,e,f,g,h,i,j,k=td(Be.data.targets),l=k?Wc:Vc,m=a.filter(function(a){return a&&c(a.value)});$g&&0!==m.length&&(Lh.html(bh(a,$(),l,nh)),d=Lh.property("offsetWidth"),e=Lh.property("offsetHeight"),k?(g=Ue/2+b[0],i=We/2+b[1]+20):(Yf?(f=q(),g=f+b[0]+100,h=g+d,j=r()-u(),i=qf(m[0].x)+20):(f=q(),g=f+t()+qf(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)),Lh.style("top",i+"px").style("left",g+"px").style("display","block"))}function dd(){Lh.style("display","none")}function ed(a){var b=a.filter(function(a){return a&&c(a.value)});$g&&(qd(Be.data.targets)||td(Be.data.targets)||Ih.selectAll("line.xgrid-focus").style("visibility","visible").data([b[0]]).attr(Yf?"y1":"x1",Rc).attr(Yf?"y2":"x2",Rc))}function fd(){Ih.select("line.xgrid-focus").style("visibility","hidden")}function gd(a){return a.x||0===a.x?qf(a.x):null}function hd(a){return V(a.id)(a.value)}function id(){var a,b,c={},e=0;return rc(wd).forEach(function(f){for(a=0;a0&&(i+=g(b.values[f].value)-h)}),i}}function md(a,b){return b?2*a.tickOffset()*.6/b:0}function nd(a,b){var c=d(a)?pc():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 be(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 ce(b){var c,d,e;if(Mh=g.select(Ge),Mh.empty())throw new Error('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');if(Mh.html(""),Be.data.x={},Be.data.targets=jc(b),o(),R(),qf.domain(g.extent(Wb(Be.data.targets))),rf.domain(Rb("y")),sf.domain(Rb("y2")),tf.domain(qf.domain()),uf.domain(rf.domain()),vf.domain(sf.domain()),Nh=qf.domain(),Bh.scale(tf),Le&&Fh.scale(qf),Gh=g.select(Ge).append("svg").attr("width",Ue+Re.left+Re.right).attr("height",We+Re.top+Re.bottom).on("mouseenter",Oe).on("mouseleave",Pe),Hh=Gh.append("defs"),Hh.append("clipPath").attr("id",fh).append("rect").attr("width",Ue).attr("height",We),Hh.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",B).attr("y",C).attr("width",H).attr("height",I),Hh.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",D).attr("y",E).attr("width",J).attr("height",K),Ih=Gh.append("g").attr("transform",th.main),Jh=Rf?Gh.append("g").attr("transform",th.context):null,Kh=Uf?Gh.append("g").attr("transform",th.legend):null,Lh=g.select(Ge).style("position","relative").append("div").style("position","absolute").style("z-index","10").style("display","none"),Ih.append("g").attr("class","x axis").attr("clip-path",Yf?"":j("xaxis-clip")).attr("transform",th.x).append("text").attr("class","-axis-x-label").attr("transform",Yf?"rotate(-90)":"").attr("dx",pb).attr("dy",sb).style("text-anchor",vb).text(gb),hg&&Ih.append("g").attr("class","y axis").attr("clip-path",Yf?j("yaxis-clip"):"").append("text").attr("class","-axis-y-label").attr("transform",Yf?"":"rotate(-90)").attr("dx",qb).attr("dy",tb).style("text-anchor",wb).text(hb),qg&&Ih.append("g").attr("class","y2 axis").attr("transform",th.y2).append("text").attr("class","-axis-y2-label").attr("transform",Yf?"":"rotate(-90)").attr("dx",rb).style("text-anchor",xb).text(ib),d=Ih.append("g").attr("clip-path",gh).attr("class","grid"),zg&&d.append("g").attr("class","xgrids"),Bg&&d.append("g").attr("class","xgrid-lines"),Hg&&d.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",Yf?0:-10).attr("x2",Yf?Ue:-10).attr("y1",Yf?-10:Re.top).attr("y2",Yf?-10:We),Cg&&d.append("g").attr("class","ygrids"),Dg&&d.append("g").attr("class","ygrid-lines"),Ih.append("g").attr("clip-path",gh).attr("class","regions"),Ih.append("g").attr("clip-path",gh).attr("class","chart"),c=Ih.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",Le?Yf?"ns-resize":"ew-resize":null),Ih.select(".chart").append("g").attr("class","chart-bars"),Ih.select(".chart").append("g").attr("class","chart-lines"),Ih.select(".chart").append("g").attr("class","chart-arcs").attr("transform",th.arc).append("text").attr("class","chart-arcs-title").style("text-anchor","middle").text(Lb()),Ih.select(".chart").append("g").attr("class","chart-texts"),Le&&Ih.insert("rect",Ne?null:"g.grid").attr("class","zoom-rect").attr("width",Ue).attr("height",We).style("opacity",0).style("cursor",Yf?"ns-resize":"ew-resize").call(Fh).on("dblclick.zoom",null),null!==fg&&Bh.extent("function"!=typeof fg?fg:fg(Wb())),Rf&&(Jh.append("g").attr("clip-path",gh).attr("class","chart"),Jh.select(".chart").append("g").attr("class","chart-bars"),Jh.select(".chart").append("g").attr("class","chart-lines"),Jh.append("g").attr("clip-path",gh).attr("class","x brush").call(Bh).selectAll("rect").attr(Yf?"width":"height",Yf?Ve:Xe),Jh.append("g").attr("class","x axis").attr("transform",th.subx).attr("clip-path",Yf?j("yaxis-clip"):"")),pe(Be.data.targets),Yf?Ih.select(".x.axis").style("opacity",0).call(wf):(Ih.select(".y.axis").style("opacity",0).call(xf),Ih.select(".y2.axis").style("opacity",0).call(yf)),oe({withTransform:!0,withLegend:!0,durationForAxis:0}),ch){if(hh&&"string"==typeof dh){for(dh=Fd(dh),e=0;e0){d=[];for(var f in Ef)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=Qd,o=c+e>f&&h>c&&j>d),o^n&&(l.classed(Fe,!n),Qf?(l.classed(Ee,!m),k(!m,l,a,b)):m?Be.unselect():Be.select([a.id],[b],!0))}))}function he(a){td(Be.data.targets)||Nf&&(kh=a,Ih.select(".chart").append("rect").attr("class","dragarea").style("opacity",.1),lh=!0)}function ie(){td(Be.data.targets)||Nf&&(Ih.select(".dragarea").transition().duration(100).style("opacity",0).remove(),Ih.selectAll(".-shape").classed(Fe,!1),lh=!1)}function je(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,C,D,E,F,G,H,I=id(),J=td(Be.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,F=w?Qe:0,G=e(a.durationForExit)?a.durationForExit:F,H=e(a.durationForAxis)?a.durationForAxis:F,A&&Uf&&ve(Be.data.targets,a),z&&(qf.domain(g.extent(Wb(Be.data.targets))),Nh=qf.domain(),Le&&Fh.scale(qf).updateScaleExtent(),tf.domain(qf.domain()),Bh.scale(tf)),y&&(qf.domain(Bh.empty()?Nh:Bh.extent()),Le&&Fh.scale(qf).updateScaleExtent()),rf.domain(Rb("y")),sf.domain(Rb("y2")),Ih.select(".x.axis").style("opacity",J?0:1).transition().duration(H).call(wf),Ih.select(".y.axis").style("opacity",J?0:1).transition().duration(H).call(xf),Ih.select(".y2.axis").style("opacity",J?0:1).transition().duration(H).call(yf),B=Yd(I),D=Zd(I,!0),E=Zd(I,!1),Ih.select(".x.axis .-axis-x-label").attr("x",mb),Ih.select(".y.axis .-axis-y-label").attr("x",nb).attr("dy",tb),Ih.select(".y2.axis .-axis-y2-label").attr("x",ob).attr("dy",ub),uf.domain(rf.domain()),vf.domain(sf.domain()),Lh.style("display","none"),Ih.select("line.xgrid-focus").style("visibility","hidden").attr("y2",We),zg){if("year"===Ag){d=[]; -for(var K=Wb(),M=K[0].getFullYear(),N=K[1].getFullYear(),O=M;N>=O;O++)d.push(new Date(O+"-01-01 00:00:00"))}else d=qf.ticks(10);b=Ih.select(".xgrids").selectAll(".xgrid").data(d),b.enter().append("line").attr("class","xgrid"),b.attr("x1",Yf?0:function(a){return qf(a)-wf.tickOffset()}).attr("x2",Yf?Ue:function(a){return qf(a)-wf.tickOffset()}).attr("y1",Yf?function(a){return qf(a)-wf.tickOffset()}:Re.top).attr("y2",Yf?function(a){return qf(a)-wf.tickOffset()}:We).style("opacity",function(){return+g.select(this).attr(Yf?"y1":"x1")===(Yf?We:0)?0:1}),b.exit().remove()}Bg&&(f=Ih.select(".xgrid-lines").selectAll(".xgrid-line").data(Bg),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",Yf?"":"rotate(-90)").attr("dx",Yf?0:-Re.top).attr("dy",-5).style("opacity",0),f.select("line").transition().duration(F).attr("x1",Yf?0:Sc).attr("x2",Yf?Ue:Sc).attr("y1",Yf?Sc:Re.top).attr("y2",Yf?Sc:We).style("opacity",1),f.select("text").transition().duration(F).attr("x",Yf?Ue:0).attr("y",Sc).text(function(a){return a.text}).style("opacity",1),f.exit().transition().duration(F).style("opacity",0).remove()),u&&Cg&&(i=Ih.select(".ygrids").selectAll(".ygrid").data(rf.ticks(Eg)),i.enter().append("line").attr("class","ygrid"),i.attr("x1",Yf?rf:0).attr("x2",Yf?rf:Ue).attr("y1",Yf?0:rf).attr("y2",Yf?We:rf),i.exit().remove()),u&&Dg&&(j=Ih.select(".ygrid-lines").selectAll(".ygrid-line").data(Dg),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",Yf?"rotate(-90)":"").attr("dx",Yf?0:-Re.top).attr("dy",-5).style("opacity",0),j.select("line").transition().duration(F).attr("x1",Yf?Tc:0).attr("x2",Yf?Tc:Ue).attr("y1",Yf?0:Tc).attr("y2",Yf?We:Tc).style("opacity",1),j.select("text").transition().duration(F).attr("x",Yf?0:Ue).attr("y",Tc).text(function(a){return a.text}).style("opacity",1),j.exit().transition().duration(F).style("opacity",0).remove()),m=Ih.selectAll(".-bars").selectAll(".-bar").data(Bd),m.enter().append("path").attr("d",B).style("stroke","none").style("opacity",0).style("fill",function(a){return nh(a.id)}).attr("class",Ic),m.style("opacity",Lc).transition().duration(F).attr("d",B).style("opacity",1),m.exit().transition().duration(G).style("opacity",0).remove(),o=Ih.selectAll(".-texts").selectAll(".-text").data(Dd),o.enter().append("text").attr("class",yc).attr("text-anchor",function(a){return Yf?a.value<0?"end":"start":"middle"}).style("stroke","none").style("fill-opacity",0).text(function(a){return Vc(a.value)}),o.style("fill-opacity",Mc).transition().duration(F).attr("x",D).attr("y",E).style("fill-opacity",Oc),o.exit().transition().duration(G).style("fill-opacity",0).remove(),Ih.selectAll(".-line").style("opacity",Lc).transition().duration(F).attr("d",Ch).style("opacity",1),Ih.selectAll(".-area").style("opacity",0).transition().duration(F).attr("d",Dh).style("opacity",Oh),l=Ih.selectAll(".-circles").selectAll(".-circle").data(Cd),l.enter().append("circle").attr("class",Hc).style("opacity",0).attr("r",Gg),l.style("opacity",Lc).transition().duration(F).style("opacity",Nc).attr("cx",Yf?hd:gd).attr("cy",Yf?gd:hd),l.exit().remove(),Ih.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=zb(a);if(!b)return function(){return"M 0 0"};var c=g.interpolate(this._current,b);return this._current=c(0),function(a){return Cb(c(a),!0)}}).attr("transform",x?"scale(1)":"").style("opacity",1),Ih.selectAll(".chart-arc").select("text").attr("transform",Db).style("opacity",0).transition().duration(F).text(Gb).style("opacity",function(a){return Ad(a.data)?1:0}),Ih.select(".chart-arcs-title").style("opacity",sd(Be.data.targets)?1:0),Rf&&(null!==g.event&&"zoom"===g.event.type&&Bh.extent(qf.orgDomain()).update(),v&&(Jh.select(".x.axis").style("opacity",J?0:1).transition().duration(F).call(zf),Bh.empty()||Bh.extent(qf.orgDomain()).update(),C=Yd(I,!0),p=Jh.selectAll(".-bars").selectAll(".-bar").data(Bd),p.enter().append("path").attr("d",C).style("stroke","none").style("fill",function(a){return nh(a.id)}).attr("class",Ic),p.style("opacity",Lc).transition().duration(F).attr("d",C).style("opacity",1),p.exit().transition().duration(F).style("opacity",0).remove(),Jh.selectAll(".-line").style("opacity",Lc).transition().duration(F).attr("d",Eh).style("opacity",1))),Ih.selectAll(".selected-circles").filter(function(a){return wd(a)}).selectAll("circle").remove(),Ih.selectAll(".selected-circle").transition().duration(F).attr("cx",Yf?hd:gd).attr("cy",Yf?gd:hd),Bf?(q=Ih.select(".event-rects").selectAll(".event-rect").data([0]),ee(q.enter()),q.attr("x",0).attr("y",0).attr("width",Ue).attr("height",We)):(jh?(t=function(a,b){var c=lc(b),d=mc(b);return(qf(d?d:a.x+50)-qf(c?c:a.x-50))/2},s=function(a,b){var c=lc(b);return(qf(a.x)+qf(c?c:a.x-50))/2}):(t=L(),s=function(a){return qf(a.x)-t/2}),r=oc(),Ih.select(".event-rects").datum(r?r.values:[]),q=Ih.select(".event-rects").selectAll(".event-rect").data(function(a){return a}),de(q.enter()),q.attr("class",Kc).attr("x",Yf?0:s).attr("y",Yf?s:0).attr("width",Yf?Ue:t).attr("height",Yf?t:We),q.exit().remove()),n=Ih.select(".regions").selectAll("rect.region").data(Zg),n.enter().append("rect").style("fill-opacity",0),n.attr("class",Jc).attr("x",Yf?0:_b).attr("y",Yf?_b:Re.top).attr("width",Yf?Ue:ac).attr("height",Yf?ac:We).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(),pc().forEach(function(a){Ph[a]=!0})}function ke(){je({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}function le(){return"mousemove"===g.event.sourceEvent.type&&Fh.altDomain?(qf.domain(Fh.altDomain),void Fh.scale(qf).updateScaleExtent()):(ih&&qf.orgDomain()[0]===Nh[0]&&qf.domain([Nh[0]-1e-10,qf.orgDomain()[1]]),je({withTransition:!1,withY:!1,withSubchart:!1}),void("mousemove"===g.event.sourceEvent.type&&(mh=!0)))}function me(){function a(){b.forEach(function(a){a()})}var b=[];return a.add=function(a){b.push(a)},a}function ne(){Gh.attr("width",Ye).attr("height",Ze),Gh.select("#"+fh).select("rect").attr("width",Ue).attr("height",We),Gh.select("#xaxis-clip").select("rect").attr("width",H),Gh.select("#yaxis-clip").select("rect").attr("width",J),Gh.select(".zoom-rect").attr("width",Ue).attr("height",We)}function oe(a){a=e(a)?a:{},a.withTransition=e(a.withTransition)?a.withTransition:!0,a.withTransform=e(a.withTransform)?a.withTransform:!1,a.withLegend=e(a.withLegend)?a.withLegend:!1,a.withUpdateXDomain=!0,a.withUpdateOrgXDomain=!0,a.durationForExit=0,o(),R(),ne(),n(a.withTransition),je(a)}function pe(a){var b,c,d,e,f,h,i,j,k,l,m,n;i=Ih.select(".chart-texts").selectAll(".chart-text").data(a),j=i.enter().append("g").attr("class",function(a){return"chart-text"+xc("target",a.id)}).style("pointer-events","none"),j.append("g").attr("class",zc).style("fill",function(a){return nh(a.id)}),e=Ih.select(".chart-bars").selectAll(".chart-bar").data(a),d=e.enter().append("g").attr("class",function(a){return"chart-bar"+xc("target",a.id)}).style("pointer-events","none"),d.append("g").attr("class",Dc).style("fill",function(a){return nh(a.id)}).style("stroke","none").style("cursor",function(a){return Pf(a)?"pointer":null}),c=Ih.select(".chart-lines").selectAll(".chart-line").data(a),b=c.enter().append("g").attr("class",function(a){return"chart-line"+xc("target",a.id)}).style("pointer-events","none"),b.append("path").attr("class",Bc).style("opacity",0).style("stroke",function(a){return nh(a.id)}),b.append("path").attr("class",Fc).style("opacity",function(){return Oh=+g.select(this).style("opacity"),0}).style("fill",function(a){return nh(a.id)}),b.append("g").attr("class",function(a){return xc("selected-circles",a.id)}),b.append("g").attr("class",Cc).style("fill",function(a){return nh(a.id)}).style("cursor",function(a){return Pf(a)?"pointer":null}),a.forEach(function(a){var b=we(a.id);Ih.selectAll(".selected-circles"+b).selectAll(".selected-circle").each(function(b){b.value=a.values[b.x].value})}),h=Ih.select(".chart-arcs").selectAll(".chart-arc").data(gf(a)),f=h.enter().append("g").attr("class",function(a){return"chart-arc target target-"+a.data.id}),f.append("path").attr("class",Ec).style("opacity",0).style("fill",function(a){return nh(a.data.id)}).style("cursor",function(a){return Pf(a)?"pointer":null}).each(function(a){this._current=a}).on("mouseover",function(a,b){var c=Fb(a),d=Nb();Hb(a.data.id),se(a.data.id),d(c,b)}).on("mousemove",function(a){var b=[Fb(a)];cd(b,g.mouse(this))}).on("mouseout",function(a,b){var c=Fb(a),d=Ob();Ib(a.data.id),ue(),dd(),d(c,b)}).on("click",function(a,b){var c=Fb(a),d=Mb();d(c,b)}),f.append("text").attr("dy",".35em").style("opacity",0).style("text-anchor","middle").style("pointer-events","none"),Rf&&(n=Jh.select(".chart-bars").selectAll(".chart-bar").data(a),m=n.enter().append("g").attr("class",function(a){return"chart-bar"+xc("target",a.id)}),m.append("g").attr("class",Dc).style("fill",function(a){return nh(a.id)}),l=Jh.select(".chart-lines").selectAll(".chart-line").data(a),k=l.enter().append("g").attr("class",function(a){return"chart-line"+xc("target",a.id)}),k.append("path").attr("class",Bc).style("opacity",0).style("stroke",function(a){return nh(a.id)})),Gh.selectAll(".target").transition().style("opacity",1)}function qe(a,b){Be.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+r)/10),i=10*Math.ceil((g.height+q)/10),j=uh?i:h,k=uh?$e:_e;c&&(v=0,B=0,s=0,t=0),x[b]=h,y[b]=i,(!s||h>=s)&&(s=h),(!t||i>=t)&&(t=i),f=uh?t:s,Xf?(Object.keys(x).forEach(function(a){x[a]=s}),Object.keys(y).forEach(function(a){y[a]=t}),e=(k-f*p.length)/2,u>e?(v=0,B=0,p.forEach(function(a){d(a)})):d(b,!0)):d(b)}var f,g,h,i,j,k,l,m,p=pc(a),q=4,r=26,s=0,t=0,u=10,v=0,w={},x={},y={},z={},A={},B=0;b=d(b)?{}:b,m=e(b.withTransition)?b.withTransition:!0,uh?(g=function(a){return s*(.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 t*(.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=Kh.selectAll(".legend-item").data(p).enter().append("g").attr("class",function(a){return xc("legend-item",a)}).style("cursor","pointer").on("click",function(a){Wf(a)}).on("mouseover",function(a){Be.focus(a)}).on("mouseout",function(){Be.revert()}),f.append("text").text(function(a){return e(Ef[a])?Ef[a]:a}).each(function(a,b){c(this,a,0===b)}).style("pointer-events","none").attr("x",uh?h:-200).attr("y",uh?-200:k),f.append("rect").attr("class","legend-item-event").style("fill-opacity",0).attr("x",uh?i:-200).attr("y",uh?-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 nh(a)}).attr("x",uh?h:-200).attr("y",uh?-200:j).attr("width",10).attr("height",10),Kh.selectAll("text").data(p).each(function(a,b){c(this,a,0===b)}).transition().duration(m?250:0).attr("x",h).attr("y",k),Kh.selectAll("rect.legend-item-event").data(p).transition().duration(m?250:0).attr("x",i).attr("y",l),Kh.selectAll("rect.legend-item-tile").data(p).transition().duration(m?250:0).attr("x",g).attr("y",j),N(s),O(t),M(B),o(),R(),ne(),n(!1)}function we(a){return a||0===a?"-"+(a.replace?a.replace(/([^a-zA-Z0-9-_])/g,"-"):a):""}function xe(a){return".target"+we(a)}function ye(a){return qc(a.id)}function ze(a){return"data"in a&&qc(a.data.id)}function Ae(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 Be={data:{}},Ce={},De="_expanded_",Ee="_selected_",Fe="_included_",Ge=i(["bindto"],"#chart"),He=i(["size","width"],null),Ie=i(["size","height"],null),Je=i(["padding","left"],null),Ke=i(["padding","right"],null),Le=i(["zoom","enabled"],!1),Me=i(["zoom","extent"],null),Ne=i(["zoom","privileged"],!1),Oe=i(["onenter"],function(){}),Pe=i(["onleave"],function(){}),Qe=i(["transition","duration"],350);h("data","data is required in config");var Re,Se,Te,Ue,Ve,We,Xe,Ye,Ze,$e,_e,af,bf,cf,df,ef,ff,gf,hf,jf,kf,lf,mf,nf,of,pf,qf,rf,sf,tf,uf,vf,wf,xf,yf,zf,Af=i(["data","x"],null),Bf=i(["data","xs"],null),Cf=i(["data","x_format"],"%Y-%m-%d"),Df=i(["data","id_converter"],function(a){return a}),Ef=i(["data","names"],{}),Ff=i(["data","groups"],[]),Gf=i(["data","axes"],{}),Hf=i(["data","type"],null),If=i(["data","types"],{}),Jf=i(["data","labels"],{}),Kf=i(["data","order"],null),Lf=i(["data","regions"],{}),Mf=i(["data","colors"],{}),Nf=i(["data","selection","enabled"],!1),Of=i(["data","selection","grouped"],!1),Pf=i(["data","selection","isselectable"],function(){return!0}),Qf=i(["data","selection","multiple"],!0),Rf=i(["subchart","show"],!1),Sf=Rf?i(["subchart","size","height"],60):0,Tf=i(["color","pattern"],null),Uf=i(["legend","show"],!0),Vf=i(["legend","position"],"bottom"),Wf=i(["legend","item","onclick"],function(){}),Xf=i(["legend","equally"],!1),Yf=i(["axis","rotated"],!1),Zf=i(["axis","x","type"],"indexed"),$f=i(["axis","x","categories"],[]),_f=i(["axis","x","tick","centered"],!1),ag=i(["axis","x","tick","format"],null),bg=i(["axis","x","tick","culling"],"categorized"===Zf?!1:!0),cg=i(["axis","x","tick","count"],10),dg=i(["axis","x","max"],null),eg=i(["axis","x","min"],null),fg=i(["axis","x","default"],null),gg=i(["axis","x","label"],null),hg=i(["axis","y","show"],!0),ig=i(["axis","y","max"],null),jg=i(["axis","y","min"],null),kg=i(["axis","y","center"],null),lg=i(["axis","y","label"],null),mg=i(["axis","y","inner"],!1),ng=i(["axis","y","tick","format"],null),og=i(["axis","y","padding"],null),pg=i(["axis","y","ticks"],10),qg=i(["axis","y2","show"],!1),rg=i(["axis","y2","max"],null),sg=i(["axis","y2","min"],null),tg=i(["axis","y2","center"],null),ug=i(["axis","y2","label"],null),vg=i(["axis","y2","inner"],!1),wg=i(["axis","y2","tick","format"],null),xg=i(["axis","y2","padding"],null),yg=i(["axis","y2","ticks"],10),zg=i(["grid","x","show"],!1),Ag=i(["grid","x","type"],"tick"),Bg=i(["grid","x","lines"],null),Cg=i(["grid","y","show"],!1),Dg=i(["grid","y","lines"],null),Eg=i(["grid","y","ticks"],10),Fg=i(["point","show"],!0),Gg=Fg?i(["point","r"],2.5):0,Hg=i(["point","focus","line","enabled"],!0),Ig=i(["point","focus","expand","enabled"],!0),Jg=i(["point","focus","expand","r"],Ig?4:Gg),Kg=i(["point","focus","select","r"],8),Lg=i(["point","onclick"],function(){}),Mg=i(["point","onselected"],function(){}),Ng=i(["point","onunselected"],function(){}),Og=i(["pie","label","show"],!0),Pg=i(["pie","label","format"],null),Qg=i(["pie","onclick"],function(){}),Rg=i(["pie","onmouseover"],function(){}),Sg=i(["pie","onmouseout"],function(){}),Tg=i(["donut","label","show"],!0),Ug=i(["donut","label","format"],null),Vg=i(["donut","title"],""),Wg=i(["donut","onclick"],function(){}),Xg=i(["donut","onmouseover"],function(){}),Yg=i(["donut","onmouseout"],function(){}),Zg=i(["regions"],[]),$g=i(["tooltip","show"],!0),_g=i(["tooltip","format","title"],null),ah=i(["tooltip","format","value"],null),bh=i(["tooltip","contents"],function(a,b,c,d){var e,f,g,h,i,j=_g?_g:b,k=ah?ah:c;for(f=0;f"+(g||0===g?""+g+"":"")),i=a[f].name,h=k(a[f].value,a[f].ratio),e+=""+i+""+h+"");return e+""}),ch=i(["tooltip","init","show"],!1),dh=i(["tooltip","init","x"],0),eh=i(["tooltip","init","position"],{top:"0px",left:"50px"}),fh=("string"==typeof Ge?Ge.replace("#",""):Ge.id)+"-clip",gh=j(fh),hh="timeseries"===Zf,ih="categorized"===Zf,jh=!hh&&(Af||Bf),kh=null,lh=!1,mh=!1,nh=Ed(Mf,Tf),oh=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)}}(),ph=Yf?"left":"bottom",qh=Yf?mg?"top":"bottom":mg?"right":"left",rh=Yf?vg?"bottom":"top":vg?"left":"right",sh=Yf?"left":"bottom",th={main:function(){return"translate("+Re.left+","+Re.top+")"},context:function(){return"translate("+Se.left+","+Se.top+")"},legend:function(){return"translate("+Te.left+","+Te.top+")"},x:function(){return"translate(0,"+(Yf?0:We)+")"},y:function(){return"translate(0,"+(Yf?We:0)+")"},y2:function(){return"translate("+(Yf?0:Ue)+","+(Yf?1:0)+")"},subx:function(){return"translate(0,"+(Yf?0:Xe)+")"},arc:function(){return"translate("+Ue/2+","+We/2+")"}},uh="right"===Vf,vh=0,wh=0,xh=0,yh=40,zh=20,Ah=5;gf=g.layout.pie().value(function(a){return a.values.reduce(function(a,b){return a+b.value},0)});var Bh,Ch=function(){var a=g.svg.line().x(Yf?function(a){return V(a.id)(a.value)}:Rc).y(Yf?Rc:function(a){return V(a.id)(a.value)});return function(b){var c,d,e=Rd(b.values);return ud(b)?(a.interpolate(vd(b)?"cardinal":"linear"),Lf[b.id]?be(e,qf,V(b.id),Lf[b.id]):a(e)):(c=qf(e[0].x),d=V(b.id)(e[0].value),Yf?"M "+d+" "+c:"M "+c+" "+d)}}(),Dh=function(){var a;return a=Yf?g.svg.area().x0(function(a){return V(a.id)(0)}).x1(function(a){return V(a.id)(a.value)}).y(Rc):g.svg.area().x(Rc).y0(function(a){return V(a.id)(0)}).y1(function(a){return V(a.id)(a.value)}),function(b){var c,d,e=Rd(b.values);return od([b],"area")||od([b],"area-spline")?(a.interpolate(vd(b)?"cardinal":"linear"),a(e)):(c=qf(e[0].x),d=V(b.id)(e[0].value),Yf?"M "+d+" "+c:"M "+c+" "+d)}}(),Eh=function(){var a=g.svg.line().x(Yf?function(a){return W(a.id)(a.value)}:Uc).y(Yf?Uc:function(a){return W(a.id)(a.value)});return function(b){var c=Rd(b.values);return ud(b)?a(c):"M "+tf(c[0].x)+" "+W(b.id)(c[0].value)}}(),Fh=function(){};Bh=g.svg.brush().on("brush",ke),Bh.update=function(){return Jh&&Jh.select(".x.brush").call(this),this},Bh.scale=function(a){return Yf?this.y(a):this.x(a)},Le&&(Fh=g.behavior.zoom().on("zoomstart",function(){Fh.altDomain=g.event.sourceEvent.altKey?qf.orgDomain():null}).on("zoom",Le?le:null),Fh.scale=function(a){return Yf?this.y(a):this.x(a)},Fh.orgScaleExtent=function(){var a=Me?Me:[1,10];return[a[0],Math.max(nc()/a[1],a[1])]},Fh.updateScaleExtent=function(){var a=Xb(qf.orgDomain())/Xb(Nh),b=this.orgScaleExtent();return this.scaleExtent([b[0]*a,b[1]*a]),this});var Gh,Hh,Ih,Jh,Kh,Lh,Mh,Nh,Oh,Ph={};if(Be.focus=function(a){function b(a){a.transition().duration(100).style("opacity",1)}var c=Gh.selectAll(xe(a)),d=c.filter(ye),e=c.filter(ze);Be.revert(),Be.defocus(),b(d.classed("focused",!0)),b(e),td(Be.data.targets)&&Hb(a,!0),se(a)},Be.defocus=function(a){function b(a){a.transition().duration(100).style("opacity",.3)}var c=Gh.selectAll(xe(a)),d=c.filter(ye),e=c.filter(ze);Be.revert(),b(d.classed("focused",!1)),b(e),td(Be.data.targets)&&Ib(a),te(a)},Be.revert=function(a){function b(a){a.transition().duration(100).style("opacity",1)}var c=Gh.selectAll(xe(a)),d=c.filter(ye),e=c.filter(ze);b(d.classed("focused",!1)),b(e),td(Be.data.targets)&&Ib(a),ue()},Be.show=function(a){Gh.selectAll(xe(a)).transition().style("opacity",1)},Be.hide=function(a){Gh.selectAll(xe(a)).transition().style("opacity",0)},Be.unzoom=function(){Bh.clear().update(),je({withUpdateXDomain:!0})},Be.load=function(a){if("function"!=typeof a.done&&(a.done=function(){}),a.xs&&fc(a.xs),"categories"in a&&ih&&($f=a.categories,wf.categories($f)),"cacheIds"in a&&Yb(a.cacheIds))return void qe($b(a.cacheIds),a.done);if("data"in a)qe(jc(a.data),a.done);else if("url"in a)g.csv(a.url,function(b,c){qe(jc(c),a.done)});else if("rows"in a)qe(jc(hc(a.rows)),a.done);else{if(!("columns"in a))throw Error("url or rows or columns is required.");qe(jc(ic(a.columns)),a.done)}},Be.unload=function(a){Be.data.targets=Be.data.targets.filter(function(b){return b.id!==a}),Gh.selectAll(xe(a)).transition().style("opacity",0).remove(),Uf&&Kh.selectAll(".legend-item"+we(a)).remove(),Be.data.targets.length>0&&je({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})},Be.selected=function(a){var b=we(a);return g.merge(Ih.selectAll(".-shapes"+b).selectAll(".-shape").filter(function(){return g.select(this).classed(Ee)}).map(function(a){return a.map(function(a){return a.__data__})}))},Be.select=function(a,b,c){Nf&&Ih.selectAll(".-shapes").selectAll(".-shape").each(function(d,f){var h="circle"===this.nodeName?Ld:Od,i="circle"===this.nodeName?Md:Pd,j=Of||!a||a.indexOf(d.id)>=0,k=!b||b.indexOf(f)>=0;j&&k?Pf(d)&&h(g.select(this).classed(Ee,!0),d,f):e(c)&&c&&i(g.select(this).classed(Ee,!1),d,f)})},Be.unselect=function(a,b){Nf&&Ih.selectAll(".-shapes").selectAll(".-shape").each(function(c,d){var e="circle"===this.nodeName?Md:Pd,f=Of||!a||a.indexOf(c.id)>=0,h=!b||b.indexOf(d)>=0;f&&h&&Pf(c)&&e(g.select(this).classed(Ee,!1),c,d)})},Be.toLine=function(a){nd(a,"line"),oe()},Be.toSpline=function(a){nd(a,"spline"),oe()},Be.toBar=function(a){nd(a,"bar"),oe()},Be.toScatter=function(a){nd(a,"scatter"),oe()},Be.toArea=function(a){nd(a,"area"),oe()},Be.toAreaSpline=function(a){nd(a,"area-spline"),oe()},Be.toPie=function(a){nd(a,"pie"),oe({withTransform:!0})},Be.toDonut=function(a){nd(a,"donut"),oe({withTransform:!0})},Be.groups=function(a){return d(a)?Ff:(Ff=a,je(),Ff)},Be.xgrids=function(a){return a?(Bg=a,je(),Bg):Bg},Be.xgrids.add=function(a){return a?Be.xgrids(Bg.concat(a)):void 0},Be.xgrids.remove=function(a){var b=Ae(a);return Be.xgrids(Bg.filter(b))},Be.ygrids=function(a){return a?(Dg=a,je(),Dg):Dg},Be.ygrids.add=function(a){return a?Be.ygrids(Dg.concat(a)):void 0},Be.ygrids.remove=function(a){var b=Ae(a);return Be.ygrids(Dg.filter(b))},Be.regions=function(a){return d(a)?Zg:(Zg=a,je(),Zg)},Be.regions.add=function(a){return d(a)?Zg:(Zg=Zg.concat(a),je(),Zg)},Be.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;Gh.selectAll("."+a).transition().duration(d).style("fill-opacity",0).remove(),Zg=Zg.filter(function(b){return b.classes.indexOf(a)<0})}),Zg},Be.data.get=function(a){var b=Be.data.getAsTarget(a);return e(b)?b.values.map(function(a){return a.value}):void 0},Be.data.getAsTarget=function(a){var b=rc(function(b){return b.id===a});return b.length>0?b[0]:void 0},Be.resize=function(a){He=a?a.width:null,Ie=a?a.height:null,oe({withLegend:!0,withTransition:!1})},Be.destroy=function(){Be.data.targets=void 0,Be.data.x={},Mh.html(""),a.onresize=null},"url"in f.data)g.csv(f.data.url,function(a,b){ce(b)});else if("rows"in f.data)ce(hc(f.data.rows));else{if(!("columns"in f.data))throw Error("url or rows or columns is required.");ce(ic(f.data.columns))}return Be}}(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={};e.generate=function(e){function f(a,b){if(!(a in e))throw Error(b)}function g(a,b){for(var c=e,d=0;d0?e:0}function p(){return He?He:v()}function q(){var a=Ie?Ie:w();return a>0?a:320}function r(){return sd(Be.data.targets)?0:Je?Je:Yf||!hg||mg?1:t("y")}function s(){var a=1;return sd(Be.data.targets)?0:Ke?Ke:uh?_e+(qg&&!Yf?t("y2"):a):qg?vg||Yf?a:t("y2"):a}function t(a){var b=db(a);return b.isInner?20+wb(a):40+wb(a)}function u(a){return"y"!==a||hg?"y2"!==a||qg?(db(a).isInner?30:40)+("y2"===a?-10:0):Ah:Uf&&!uh?10:1}function v(){return+Ae.select(Ge).style("width").replace("px","")}function w(){return+Ae.select(Ge).style("height").replace("px","")}function x(a){return a?-5:-(Re.left-1)}function y(a){return a?-20:-1}function z(){return x(!Yf)}function A(){return y(!Yf)}function B(){return x(Yf)}function C(){return y(Yf)}function D(a){return a?Ue+2+4:Re.left+20}function E(a){return a?80:We+2}function F(){return D(!Yf)}function G(){return E(!Yf)}function H(){return D(Yf)}function I(){return E(Yf)}function J(){var a=Yf?We:Ue,b=Rb(),c=mc();return c>1?a*b/(c-1):a}function K(a){vh=a}function L(a){wh=a}function M(a){xh=a}function N(){return Uf?uh?wh*(vh+1):Ye:0}function O(){return Uf?uh?Ze:xh*(vh+1):0}function P(){var a,b,c=!qf;hf=Yf?1:0,jf=Yf?We:Ue,kf=Yf?0:We,lf=Yf?Ue:1,mf=hf,nf=jf,of=Yf?0:Xe,pf=Yf?Ve:1,qf=R(hf,jf,c?void 0:qf.domain(),function(){return wf.tickOffset()}),rf=S(kf,lf),sf=S(kf,lf),tf=R(hf,jf,Nh,function(a){return a%1?0:zf.tickOffset()}),uf=S(of,pf),vf=S(of,pf),a=Y(),b=Z(),wf=V(qf,ph,a,b),zf=V(tf,sh,a,b),xf=W(rf,qh,ng,pg),yf=W(sf,rh,wg,yg),c||(Bh.scale(tf),Le&&Fh.scale(qf)),Q()}function Q(){df=zb(),ef=Ab(),ff=Ab(.98)}function R(a,b,e,f){var g=(hh?Ae.time.scale():Ae.scale.linear()).range([a,b]);if(g.orgDomain=function(){return g.domain()},d(e)&&g.domain(e),c(f)&&(f=function(){return 0}),ih){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 S(a,b){return Ae.scale.linear().range([a,b])}function T(a){return"y2"===X(a)?sf:rf}function U(a){return"y2"===X(a)?vf:uf}function V(a,b,c,d){var e=(ih?xb():Ae.svg.axis()).scale(a).orient(b);return e.tickFormat(c).ticks(d),ih?e.tickCentered(_f):e.tickOffset=function(){var a=Yf?We:Ue;return a*Rb()/mc()/2},ih&&e.categories($f),e}function W(a,b,c,d){return Ae.svg.axis().scale(a).orient(b).tickFormat(c).ticks(d).outerTickSize(0)}function X(a){return a in Gf?Gf[a]:"y"}function Y(){var a=hh?oh:ih?vc:null;return ag&&("function"==typeof ag?a=ag:hh&&(a=function(a){return Ae.time.format(ag)(a)})),a}function Z(){var a=mc();return bg&&a>cg?cg:a}function $(a){return"string"==typeof a?a:a?a.text:null}function _(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 ab(){return _(gg,Yf?"inner-top":"inner-right")}function bb(){return _(lg,Yf?"inner-right":"inner-top")}function cb(){return _(ug,Yf?"inner-right":"inner-top")}function db(a){return"y2"===a?cb():"y"===a?bb():ab()}function eb(){return $(gg)}function fb(){return $(lg)}function gb(){return $(ug)}function hb(a,b){return a?b.isLeft?0:b.isCenter?Ue/2:Ue:b.isBottom?-We:b.isMiddle?-We/2:0}function ib(a,b){return a?b.isLeft?"0.5em":b.isRight?"-0.5em":"0":b.isTop?"-0.5em":b.isBottom?"0.5em":"0"}function jb(a,b){return a?b.isLeft?"start":b.isCenter?"middle":"end":b.isBottom?"start":b.isMiddle?"middle":"end"}function kb(){return hb(!Yf,ab())}function lb(){return hb(Yf,bb())}function mb(){return hb(Yf,cb())}function nb(){return ib(!Yf,ab())}function ob(){return ib(Yf,bb())}function pb(){return ib(Yf,cb())}function qb(){var a=ab();return Yf?a.isInner?"1.2em":-30-wb("x"):a.isInner?"-0.5em":"3em"}function rb(){var a=bb();return Yf?a.isInner?"-0.5em":"3em":a.isInner?"1.2em":-20-wb("y")}function sb(){var a=cb();return Yf?a.isInner?"1.2em":"-2.2em":a.isInner?"-0.5em":30+wb("y2")}function tb(){return jb(!Yf,ab())}function ub(){return jb(Yf,bb())}function vb(){return jb(Yf,cb())}function wb(a){var b=0;return Ae.selectAll("."+a+".axis .tick text").each(function(){var a=this.getBBox();bb?[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(f=tc(a),b=0;ba?a:0}),c=1;c0||(g[d][b]+=+a)});return Ae.min(Object.keys(g).map(function(a){return Ae.min(g[a])}))}function Pb(a){var b,c,d,e,f,g=rc(a);if(Ff.length>0)for(f=uc(a),b=0;b0?a:0}),c=1;c+a||(g[d][b]+=+a)});return Ae.max(Object.keys(g).map(function(a){return Ae.max(g[a])}))}function Qb(a){var c,d,e,f,g,h,i,j,k=qc(function(b){return X(b.id)===a}),l="y2"===a?sg:jg,m="y2"===a?rg:ig,n=b(l)?l:Ob(k),o=b(m)?m:Pb(k),p="y2"===a?tg:kg,q=Oc()&&Yf;return n===o&&(0>n?o=0:n=0),c=Math.abs(o-n),d=e=f=q?0:.1*c,p&&(g=Math.max(Math.abs(n),Math.abs(o)),o=g-p,n=p-g),"y"===a&&og&&(e=b(og.top)?og.top:d,f=b(og.bottom)?og.bottom:d),"y2"===a&&xg&&(e=b(xg.top)?xg.top:d,f=b(xg.bottom)?xg.bottom:d),q&&(h=Pc(n,o),i=Wb(rf.range()),j=[h[0]/i,h[1]/i],e+=c*(j[1]/(1-j[0]-j[1])),f+=c*(j[0]/(1-j[0]-j[1]))),od(k)&&!tc(k)&&(f=n),[n-f,o+e]}function Rb(a){var b=Wb(Nh),c=Wb(qf.domain());return a||0===c?1:b/c}function Sb(a){return eg?eg:Ae.min(a,function(a){return Ae.min(a.values,function(a){return a.x})})}function Tb(a){return dg?dg:Ae.max(a,function(a){return Ae.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 ih?d=0:od(a)?(c=mc(),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=hh?new Date(c.getTime()-e):c-e,g=hh?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 ac(a){return Af&&a===Af||Bf&&Id(Bf,a)}function bc(a){return!ac(a)}function cc(a){return Af?Af:Bf?Bf[a]:null}function dc(a,b){return a in Be.data.x&&Be.data.x[a]&&Be.data.x[a][b]?Be.data.x[a][b]:b}function ec(a){Object.keys(a).forEach(function(b){Bf[b]=a[b]})}function fc(a){var b;return a&&(b=Ef[a.id],a.name=b?b:a.id),a}function gc(a){var b,c,d=a[0],e={},f=[];for(b=1;b=0?a.map(function(a){return a[c]}):Be.data.x[Object.keys(Be.data.x)[0]]}),b=c.map(function(b){var c=Df(b);return{id:c,id_org:b,values:a.map(function(a,d){var e,f=cc(b);return e=hh?a[f]instanceof Date?a[f]:Ed(a[f]):jh?a[f]?+a[f]:dc(b,d):d,a.x=e,{x:e,value:null===a[b]||isNaN(a[b])?null:+a[b],id:c}})}}),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++})}),Hf&&md(oc(b).filter(function(a){return!(a in If)}),Hf),b.forEach(function(a){Yb(a.id_org,a)}),b}function jc(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 kc(a){return a>0&&Be.data.targets[0].values[a-1]?Be.data.targets[0].values[a-1].x:void 0}function lc(a){return a1?Be.data.targets.forEach(function(b){b.values.length>c&&(a=b,c=b.values.length)}):a=b?Be.data.targets[0]:null,a}function oc(a){return a=c(a)?Be.data.targets:a,a.map(function(a){return a.id})}function pc(a){var b,c=oc();for(b=0;ba})}function uc(a){return sc(a,function(a){return a>0})}function vc(a){return a<$f.length?$f[a]:a}function wc(a,b){return" "+a+" "+a+ve(b)}function xc(a){return wc("-text",a.id)}function yc(a){return wc("-texts",a.id)}function zc(a){return wc("-shapes",a.id)}function Ac(a){return zc(a)+wc("-line",a.id)}function Bc(a){return zc(a)+wc("-circles",a.id)}function Cc(a){return zc(a)+wc("-bars",a.id)}function Dc(a){return zc(a.data)+wc("-arc",a.data.id)}function Ec(a){return zc(a)+wc("-area",a.id)}function Fc(a,b){return wc("-shape",b)}function Gc(a,b){return Fc(a,b)+wc("-circle",b)}function Hc(a,b){return Fc(a,b)+wc("-bar",b)}function Ic(a,b){return wc("region",b)+" "+("class"in a?a.class:"")}function Jc(a,b){return wc("event-rect",b)}function Kc(a){return Ph[a.id]?1:0}function Lc(a){var b=Nc(a);return Kc(a)*b}function Mc(a){return b(a.value)?wd(a)?.5:1:0}function Nc(a){return Oc(a)?1:0}function Oc(a){var b=a?a.id:null;return"boolean"==typeof Jf&&Jf?!0:"boolean"===Jf[b]&&Jf[b]?!0:Jf[b]&&Jf[b].show?!0:!1}function Pc(a,b){var c=[],d=1.3;return Ae.select("svg").selectAll(".dummy").data([a,b]).enter().append("text").text(function(a){return a}).each(function(a,b){var e=this.getBBox();c[b]=e.width*d}).remove(),c}function Qc(a){return a?qf(a.x):null}function Rc(a){return qf(hh?Ed(a.value):a.value)}function Sc(a){return rf(a.value)}function Tc(a){return tf(a.x)}function Uc(a){var b=ng?ng:function(a){return+a};return b(a)}function Vc(a,b){return(100*b).toFixed(1)+"%"}function Wc(a,b){var c,d=a[b].x,e=[];for(c=b-1;c>=0&&d===a[c].x;c--)e.push(a[c]);for(c=b;c0?g=h:f=h,g-f===1?(e=[],a[f].x&&(e=e.concat(Wc(a,f))),a[g].x&&(e=e.concat(Wc(a,g))),Zc(e,b)):Xc(a,b,f,g)}function Yc(a,b){var c;return c=a.map(function(a){return Xc(a.values,b)}),Zc(c,b)}function Zc(a,b){var c,d;return a.forEach(function(a){var e=Jd(a,b);(c>e||!c)&&(c=e,d=a)}),d}function $c(){return Kf&&"desc"===Kf.toLowerCase()}function _c(){return Kf&&"asc"===Kf.toLowerCase()}function ad(a){var b=_c(),c=$c();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 Kf&&a.sort(Kf),a}function bd(a,c){var d,e,f,g,h,i,j,k=sd(Be.data.targets),l=k?Vc:Uc,m=a.filter(function(a){return a&&b(a.value)});$g&&0!==m.length&&(Lh.html(bh(a,Y(),l,nh)),d=Lh.property("offsetWidth"),e=Lh.property("offsetHeight"),k?(g=Ue/2+c[0],i=We/2+c[1]+20):(Yf?(f=o(),g=f+c[0]+100,h=g+d,j=p()-s(),i=qf(m[0].x)+20):(f=o(),g=f+r()+qf(m[0].x)+20,h=g+d,j=f+p()-s(),i=c[1]+15),h>j&&(g-=d+60),i+e>q()&&(i-=e+30)),Lh.style("top",i+"px").style("left",g+"px").style("display","block"))}function cd(){Lh.style("display","none")}function dd(a){var c=a.filter(function(a){return a&&b(a.value)});$g&&(pd(Be.data.targets)||sd(Be.data.targets)||Ih.selectAll("line.xgrid-focus").style("visibility","visible").data([c[0]]).attr(Yf?"y1":"x1",Qc).attr(Yf?"y2":"x2",Qc))}function ed(){Ih.select("line.xgrid-focus").style("visibility","hidden")}function fd(a){return a.x||0===a.x?qf(a.x):null}function gd(a){return T(a.id)(a.value)}function hd(){var a,b,d={},e=0;return qc(vd).forEach(function(f){for(a=0;a0&&(i+=g(b.values[f].value)-h)}),i}}function ld(a,b){return b?2*a.tickOffset()*.6/b:0}function md(a,b){var d=c(a)?oc():a;"string"==typeof d&&(d=[d]);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 ae(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 be(b){var c,d,e;if(Mh=Ae.select(Ge),Mh.empty())throw new Error('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');if(Mh.html(""),Be.data.x={},Be.data.targets=ic(b),m(),P(),qf.domain(Ae.extent(Vb(Be.data.targets))),rf.domain(Qb("y")),sf.domain(Qb("y2")),tf.domain(qf.domain()),uf.domain(rf.domain()),vf.domain(sf.domain()),Nh=qf.domain(),Bh.scale(tf),Le&&Fh.scale(qf),Gh=Ae.select(Ge).append("svg").attr("width",Ue+Re.left+Re.right).attr("height",We+Re.top+Re.bottom).on("mouseenter",Oe).on("mouseleave",Pe),Hh=Gh.append("defs"),Hh.append("clipPath").attr("id",fh).append("rect").attr("width",Ue).attr("height",We),Hh.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",z).attr("y",A).attr("width",F).attr("height",G),Hh.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",B).attr("y",C).attr("width",H).attr("height",I),Ih=Gh.append("g").attr("transform",th.main),Jh=Rf?Gh.append("g").attr("transform",th.context):null,Kh=Uf?Gh.append("g").attr("transform",th.legend):null,Lh=Ae.select(Ge).style("position","relative").append("div").style("position","absolute").style("z-index","10").style("display","none"),Ih.append("g").attr("class","x axis").attr("clip-path",Yf?"":h("xaxis-clip")).attr("transform",th.x).append("text").attr("class","-axis-x-label").attr("transform",Yf?"rotate(-90)":"").attr("dx",nb).attr("dy",qb).style("text-anchor",tb).text(eb),hg&&Ih.append("g").attr("class","y axis").attr("clip-path",Yf?h("yaxis-clip"):"").append("text").attr("class","-axis-y-label").attr("transform",Yf?"":"rotate(-90)").attr("dx",ob).attr("dy",rb).style("text-anchor",ub).text(fb),qg&&Ih.append("g").attr("class","y2 axis").attr("transform",th.y2).append("text").attr("class","-axis-y2-label").attr("transform",Yf?"":"rotate(-90)").attr("dx",pb).style("text-anchor",vb).text(gb),d=Ih.append("g").attr("clip-path",gh).attr("class","grid"),zg&&d.append("g").attr("class","xgrids"),Bg&&d.append("g").attr("class","xgrid-lines"),Hg&&d.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",Yf?0:-10).attr("x2",Yf?Ue:-10).attr("y1",Yf?-10:Re.top).attr("y2",Yf?-10:We),Cg&&d.append("g").attr("class","ygrids"),Dg&&d.append("g").attr("class","ygrid-lines"),Ih.append("g").attr("clip-path",gh).attr("class","regions"),Ih.append("g").attr("clip-path",gh).attr("class","chart"),c=Ih.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",Le?Yf?"ns-resize":"ew-resize":null),Ih.select(".chart").append("g").attr("class","chart-bars"),Ih.select(".chart").append("g").attr("class","chart-lines"),Ih.select(".chart").append("g").attr("class","chart-arcs").attr("transform",th.arc).append("text").attr("class","chart-arcs-title").style("text-anchor","middle").text(Kb()),Ih.select(".chart").append("g").attr("class","chart-texts"),Le&&Ih.insert("rect",Ne?null:"g.grid").attr("class","zoom-rect").attr("width",Ue).attr("height",We).style("opacity",0).style("cursor",Yf?"ns-resize":"ew-resize").call(Fh).on("dblclick.zoom",null),null!==fg&&Bh.extent("function"!=typeof fg?fg:fg(Vb())),Rf&&(Jh.append("g").attr("clip-path",gh).attr("class","chart"),Jh.select(".chart").append("g").attr("class","chart-bars"),Jh.select(".chart").append("g").attr("class","chart-lines"),Jh.append("g").attr("clip-path",gh).attr("class","x brush").call(Bh).selectAll("rect").attr(Yf?"width":"height",Yf?Ve:Xe),Jh.append("g").attr("class","x axis").attr("transform",th.subx).attr("clip-path",Yf?h("yaxis-clip"):"")),oe(Be.data.targets),Yf?Ih.select(".x.axis").style("opacity",0).call(wf):(Ih.select(".y.axis").style("opacity",0).call(xf),Ih.select(".y2.axis").style("opacity",0).call(yf)),ne({withTransform:!0,withLegend:!0,durationForAxis:0}),ch){if(hh&&"string"==typeof dh){for(dh=Ed(dh),e=0;e0){d=[];for(var f in Ef)for(c=0;cf&&g>c&&d>h&&i>d):"rect"===this.nodeName&&(c=1*k.attr("x"),d=1*k.attr("y"),e=1*k.attr("width"),j=Pd,n=c+e>f&&g>c&&i>d),n^m&&(k.classed(Fe,!m),Qf?(k.classed(Ee,!l),j(!l,k,a,b)):l?Be.unselect():Be.select([a.id],[b],!0))}))}function ge(a){sd(Be.data.targets)||Nf&&(kh=a,Ih.select(".chart").append("rect").attr("class","dragarea").style("opacity",.1),lh=!0)}function he(){sd(Be.data.targets)||Nf&&(Ih.select(".dragarea").transition().duration(100).style("opacity",0).remove(),Ih.selectAll(".-shape").classed(Fe,!1),lh=!1)}function ie(a){var c,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H=hd(),I=sd(Be.data.targets);if(a=d(a)?a:{},t=d(a.withY)?a.withY:!0,u=d(a.withSubchart)?a.withSubchart:!0,v=d(a.withTransition)?a.withTransition:!0,w=d(a.withTransform)?a.withTransform:!1,x=d(a.withUpdateXDomain)?a.withUpdateXDomain:!1,y=d(a.withUpdateOrgXDomain)?a.withUpdateOrgXDomain:!1,z=d(a.withLegend)?a.withLegend:!1,E=v?Qe:0,F=d(a.durationForExit)?a.durationForExit:E,G=d(a.durationForAxis)?a.durationForAxis:E,z&&Uf&&ue(Be.data.targets,a),y&&(qf.domain(Ae.extent(Vb(Be.data.targets))),Nh=qf.domain(),Le&&Fh.scale(qf).updateScaleExtent(),tf.domain(qf.domain()),Bh.scale(tf)),x&&(qf.domain(Bh.empty()?Nh:Bh.extent()),Le&&Fh.scale(qf).updateScaleExtent()),rf.domain(Qb("y")),sf.domain(Qb("y2")),Ih.select(".x.axis").style("opacity",I?0:1).transition().duration(G).call(wf),Ih.select(".y.axis").style("opacity",I?0:1).transition().duration(G).call(xf),Ih.select(".y2.axis").style("opacity",I?0:1).transition().duration(G).call(yf),A=Xd(H),C=Yd(H,!0),D=Yd(H,!1),Ih.select(".x.axis .-axis-x-label").attr("x",kb),Ih.select(".y.axis .-axis-y-label").attr("x",lb).attr("dy",rb),Ih.select(".y2.axis .-axis-y2-label").attr("x",mb).attr("dy",sb),uf.domain(rf.domain()),vf.domain(sf.domain()),Lh.style("display","none"),Ih.select("line.xgrid-focus").style("visibility","hidden").attr("y2",We),zg){if("year"===Ag){e=[]; +for(var K=Vb(),L=K[0].getFullYear(),M=K[1].getFullYear(),N=L;M>=N;N++)e.push(new Date(N+"-01-01 00:00:00"))}else e=qf.ticks(10);c=Ih.select(".xgrids").selectAll(".xgrid").data(e),c.enter().append("line").attr("class","xgrid"),c.attr("x1",Yf?0:function(a){return qf(a)-wf.tickOffset()}).attr("x2",Yf?Ue:function(a){return qf(a)-wf.tickOffset()}).attr("y1",Yf?function(a){return qf(a)-wf.tickOffset()}:Re.top).attr("y2",Yf?function(a){return qf(a)-wf.tickOffset()}:We).style("opacity",function(){return+Ae.select(this).attr(Yf?"y1":"x1")===(Yf?We:0)?0:1}),c.exit().remove()}Bg&&(f=Ih.select(".xgrid-lines").selectAll(".xgrid-line").data(Bg),g=f.enter().append("g").attr("class",function(a){return"xgrid-line xgrid-line-"+(a["class"]?a["class"]:"")}),g.append("line").style("opacity",0),g.append("text").attr("text-anchor","end").attr("transform",Yf?"":"rotate(-90)").attr("dx",Yf?0:-Re.top).attr("dy",-5).style("opacity",0),f.select("line").transition().duration(E).attr("x1",Yf?0:Rc).attr("x2",Yf?Ue:Rc).attr("y1",Yf?Rc:Re.top).attr("y2",Yf?Rc:We).style("opacity",1),f.select("text").transition().duration(E).attr("x",Yf?Ue:0).attr("y",Rc).text(function(a){return a.text}).style("opacity",1),f.exit().transition().duration(E).style("opacity",0).remove()),t&&Cg&&(h=Ih.select(".ygrids").selectAll(".ygrid").data(rf.ticks(Eg)),h.enter().append("line").attr("class","ygrid"),h.attr("x1",Yf?rf:0).attr("x2",Yf?rf:Ue).attr("y1",Yf?0:rf).attr("y2",Yf?We:rf),h.exit().remove()),t&&Dg&&(i=Ih.select(".ygrid-lines").selectAll(".ygrid-line").data(Dg),j=i.enter().append("g").attr("class",function(a){return"ygrid-line ygrid-line-"+(a.class?a.class:"")}),j.append("line").style("opacity",0),j.append("text").attr("text-anchor","end").attr("transform",Yf?"rotate(-90)":"").attr("dx",Yf?0:-Re.top).attr("dy",-5).style("opacity",0),i.select("line").transition().duration(E).attr("x1",Yf?Sc:0).attr("x2",Yf?Sc:Ue).attr("y1",Yf?0:Sc).attr("y2",Yf?We:Sc).style("opacity",1),i.select("text").transition().duration(E).attr("x",Yf?0:Ue).attr("y",Sc).text(function(a){return a.text}).style("opacity",1),i.exit().transition().duration(E).style("opacity",0).remove()),l=Ih.selectAll(".-bars").selectAll(".-bar").data(Ad),l.enter().append("path").attr("d",A).style("stroke","none").style("opacity",0).style("fill",function(a){return nh(a.id)}).attr("class",Hc),l.style("opacity",Kc).transition().duration(E).attr("d",A).style("opacity",1),l.exit().transition().duration(F).style("opacity",0).remove(),n=Ih.selectAll(".-texts").selectAll(".-text").data(Cd),n.enter().append("text").attr("class",xc).attr("text-anchor",function(a){return Yf?a.value<0?"end":"start":"middle"}).style("stroke","none").style("fill-opacity",0).text(function(a){return Uc(a.value)}),n.style("fill-opacity",Lc).transition().duration(E).attr("x",C).attr("y",D).style("fill-opacity",Nc),n.exit().transition().duration(F).style("fill-opacity",0).remove(),Ih.selectAll(".-line").style("opacity",Kc).transition().duration(E).attr("d",Ch).style("opacity",1),Ih.selectAll(".-area").style("opacity",0).transition().duration(E).attr("d",Dh).style("opacity",Oh),k=Ih.selectAll(".-circles").selectAll(".-circle").data(Bd),k.enter().append("circle").attr("class",Gc).style("opacity",0).attr("r",Gg),k.style("opacity",Kc).transition().duration(E).style("opacity",Mc).attr("cx",Yf?gd:fd).attr("cy",Yf?fd:gd),k.exit().remove(),Ih.selectAll(".chart-arc").select(".-arc").attr("transform",w?"scale(0)":"").style("opacity",function(a){return a===this._current?0:1}).transition().duration(E).attrTween("d",function(a){var b=yb(a);if(!b)return function(){return"M 0 0"};var c=Ae.interpolate(this._current,b);return this._current=c(0),function(a){return Bb(c(a),!0)}}).attr("transform",w?"scale(1)":"").style("opacity",1),Ih.selectAll(".chart-arc").select("text").attr("transform",Cb).style("opacity",0).transition().duration(E).text(Fb).style("opacity",function(a){return zd(a.data)?1:0}),Ih.select(".chart-arcs-title").style("opacity",rd(Be.data.targets)?1:0),Rf&&(null!==Ae.event&&"zoom"===Ae.event.type&&Bh.extent(qf.orgDomain()).update(),u&&(Jh.select(".x.axis").style("opacity",I?0:1).transition().duration(E).call(zf),Bh.empty()||Bh.extent(qf.orgDomain()).update(),B=Xd(H,!0),o=Jh.selectAll(".-bars").selectAll(".-bar").data(Ad),o.enter().append("path").attr("d",B).style("stroke","none").style("fill",function(a){return nh(a.id)}).attr("class",Hc),o.style("opacity",Kc).transition().duration(E).attr("d",B).style("opacity",1),o.exit().transition().duration(E).style("opacity",0).remove(),Jh.selectAll(".-line").style("opacity",Kc).transition().duration(E).attr("d",Eh).style("opacity",1))),Ih.selectAll(".selected-circles").filter(function(a){return vd(a)}).selectAll("circle").remove(),Ih.selectAll(".selected-circle").transition().duration(E).attr("cx",Yf?gd:fd).attr("cy",Yf?fd:gd),Bf?(p=Ih.select(".event-rects").selectAll(".event-rect").data([0]),de(p.enter()),p.attr("x",0).attr("y",0).attr("width",Ue).attr("height",We)):(jh?(s=function(a,b){var c=kc(b),d=lc(b);return(qf(d?d:a.x+50)-qf(c?c:a.x-50))/2},r=function(a,b){var c=kc(b);return(qf(a.x)+qf(c?c:a.x-50))/2}):(s=J(),r=function(a){return qf(a.x)-s/2}),q=nc(),Ih.select(".event-rects").datum(q?q.values:[]),p=Ih.select(".event-rects").selectAll(".event-rect").data(function(a){return a}),ce(p.enter()),p.attr("class",Jc).attr("x",Yf?0:r).attr("y",Yf?r:0).attr("width",Yf?Ue:s).attr("height",Yf?s:We),p.exit().remove()),m=Ih.select(".regions").selectAll("rect.region").data(Zg),m.enter().append("rect").style("fill-opacity",0),m.attr("class",Ic).attr("x",Yf?0:$b).attr("y",Yf?$b:Re.top).attr("width",Yf?Ue:_b).attr("height",Yf?_b:We).transition().duration(E).style("fill-opacity",function(a){return b(a.opacity)?a.opacity:.1}),m.exit().transition().duration(E).style("fill-opacity",0).remove(),oc().forEach(function(a){Ph[a]=!0})}function je(){ie({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}function ke(){return"mousemove"===Ae.event.sourceEvent.type&&Fh.altDomain?(qf.domain(Fh.altDomain),void Fh.scale(qf).updateScaleExtent()):(ih&&qf.orgDomain()[0]===Nh[0]&&qf.domain([Nh[0]-1e-10,qf.orgDomain()[1]]),ie({withTransition:!1,withY:!1,withSubchart:!1}),void("mousemove"===Ae.event.sourceEvent.type&&(mh=!0)))}function le(){function a(){b.forEach(function(a){a()})}var b=[];return a.add=function(a){b.push(a)},a}function me(){Gh.attr("width",Ye).attr("height",Ze),Gh.select("#"+fh).select("rect").attr("width",Ue).attr("height",We),Gh.select("#xaxis-clip").select("rect").attr("width",F),Gh.select("#yaxis-clip").select("rect").attr("width",H),Gh.select(".zoom-rect").attr("width",Ue).attr("height",We)}function ne(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.durationForExit=0,m(),P(),me(),l(a.withTransition),ie(a)}function oe(a){var b,c,d,e,f,g,h,i,j,k,l,m;h=Ih.select(".chart-texts").selectAll(".chart-text").data(a),i=h.enter().append("g").attr("class",function(a){return"chart-text"+wc("target",a.id)}).style("pointer-events","none"),i.append("g").attr("class",yc).style("fill",function(a){return nh(a.id)}),e=Ih.select(".chart-bars").selectAll(".chart-bar").data(a),d=e.enter().append("g").attr("class",function(a){return"chart-bar"+wc("target",a.id)}).style("pointer-events","none"),d.append("g").attr("class",Cc).style("fill",function(a){return nh(a.id)}).style("stroke","none").style("cursor",function(a){return Pf(a)?"pointer":null}),c=Ih.select(".chart-lines").selectAll(".chart-line").data(a),b=c.enter().append("g").attr("class",function(a){return"chart-line"+wc("target",a.id)}).style("pointer-events","none"),b.append("path").attr("class",Ac).style("opacity",0).style("stroke",function(a){return nh(a.id)}),b.append("path").attr("class",Ec).style("opacity",function(){return Oh=+Ae.select(this).style("opacity"),0}).style("fill",function(a){return nh(a.id)}),b.append("g").attr("class",function(a){return wc("selected-circles",a.id)}),b.append("g").attr("class",Bc).style("fill",function(a){return nh(a.id)}).style("cursor",function(a){return Pf(a)?"pointer":null}),a.forEach(function(a){var b=ve(a.id);Ih.selectAll(".selected-circles"+b).selectAll(".selected-circle").each(function(b){b.value=a.values[b.x].value})}),g=Ih.select(".chart-arcs").selectAll(".chart-arc").data(gf(a)),f=g.enter().append("g").attr("class",function(a){return"chart-arc target target-"+a.data.id}),f.append("path").attr("class",Dc).style("opacity",0).style("fill",function(a){return nh(a.data.id)}).style("cursor",function(a){return Pf(a)?"pointer":null}).each(function(a){this._current=a}).on("mouseover",function(a,b){var c=Eb(a),d=Mb();Gb(a.data.id),re(a.data.id),d(c,b)}).on("mousemove",function(a){var b=[Eb(a)];bd(b,Ae.mouse(this))}).on("mouseout",function(a,b){var c=Eb(a),d=Nb();Hb(a.data.id),te(),cd(),d(c,b)}).on("click",function(a,b){var c=Eb(a),d=Lb();d(c,b)}),f.append("text").attr("dy",".35em").style("opacity",0).style("text-anchor","middle").style("pointer-events","none"),Rf&&(m=Jh.select(".chart-bars").selectAll(".chart-bar").data(a),l=m.enter().append("g").attr("class",function(a){return"chart-bar"+wc("target",a.id)}),l.append("g").attr("class",Cc).style("fill",function(a){return nh(a.id)}),k=Jh.select(".chart-lines").selectAll(".chart-line").data(a),j=k.enter().append("g").attr("class",function(a){return"chart-line"+wc("target",a.id)}),j.append("path").attr("class",Ac).style("opacity",0).style("stroke",function(a){return nh(a.id)})),Gh.selectAll(".target").transition().style("opacity",1)}function pe(a,b){Be.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+r)/10),i=10*Math.ceil((g.height+q)/10),j=uh?i:h,k=uh?$e:_e;c&&(v=0,B=0,s=0,t=0),x[b]=h,y[b]=i,(!s||h>=s)&&(s=h),(!t||i>=t)&&(t=i),f=uh?t:s,Xf?(Object.keys(x).forEach(function(a){x[a]=s}),Object.keys(y).forEach(function(a){y[a]=t}),e=(k-f*p.length)/2,u>e?(v=0,B=0,p.forEach(function(a){d(a)})):d(b,!0)):d(b)}var f,g,h,i,j,k,n,o,p=oc(a),q=4,r=26,s=0,t=0,u=10,v=0,w={},x={},y={},z={},A={},B=0;b=c(b)?{}:b,o=d(b.withTransition)?b.withTransition:!0,uh?(g=function(a){return s*(.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 t*(.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},n=function(a,b){return j(a,b)-7},f=Kh.selectAll(".legend-item").data(p).enter().append("g").attr("class",function(a){return wc("legend-item",a)}).style("cursor","pointer").on("click",function(a){Wf(a)}).on("mouseover",function(a){Be.focus(a)}).on("mouseout",function(){Be.revert()}),f.append("text").text(function(a){return d(Ef[a])?Ef[a]:a}).each(function(a,b){e(this,a,0===b)}).style("pointer-events","none").attr("x",uh?h:-200).attr("y",uh?-200:k),f.append("rect").attr("class","legend-item-event").style("fill-opacity",0).attr("x",uh?i:-200).attr("y",uh?-200:n).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 nh(a)}).attr("x",uh?h:-200).attr("y",uh?-200:j).attr("width",10).attr("height",10),Kh.selectAll("text").data(p).each(function(a,b){e(this,a,0===b)}).transition().duration(o?250:0).attr("x",h).attr("y",k),Kh.selectAll("rect.legend-item-event").data(p).transition().duration(o?250:0).attr("x",i).attr("y",n),Kh.selectAll("rect.legend-item-tile").data(p).transition().duration(o?250:0).attr("x",g).attr("y",j),L(s),M(t),K(B),m(),P(),me(),l(!1)}function ve(a){return a||0===a?"-"+(a.replace?a.replace(/([^a-zA-Z0-9-_])/g,"-"):a):""}function we(a){return".target"+ve(a)}function xe(a){return pc(a.id)}function ye(a){return"data"in a&&pc(a.data.id)}function ze(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 Ae=a.d3?a.d3:a.require?a.require("d3"):void 0,Be={data:{}},Ce={},De="_expanded_",Ee="_selected_",Fe="_included_",Ge=g(["bindto"],"#chart"),He=g(["size","width"],null),Ie=g(["size","height"],null),Je=g(["padding","left"],null),Ke=g(["padding","right"],null),Le=g(["zoom","enabled"],!1),Me=g(["zoom","extent"],null),Ne=g(["zoom","privileged"],!1),Oe=g(["onenter"],function(){}),Pe=g(["onleave"],function(){}),Qe=g(["transition","duration"],350);f("data","data is required in config");var Re,Se,Te,Ue,Ve,We,Xe,Ye,Ze,$e,_e,af,bf,cf,df,ef,ff,gf,hf,jf,kf,lf,mf,nf,of,pf,qf,rf,sf,tf,uf,vf,wf,xf,yf,zf,Af=g(["data","x"],null),Bf=g(["data","xs"],null),Cf=g(["data","x_format"],"%Y-%m-%d"),Df=g(["data","id_converter"],function(a){return a}),Ef=g(["data","names"],{}),Ff=g(["data","groups"],[]),Gf=g(["data","axes"],{}),Hf=g(["data","type"],null),If=g(["data","types"],{}),Jf=g(["data","labels"],{}),Kf=g(["data","order"],null),Lf=g(["data","regions"],{}),Mf=g(["data","colors"],{}),Nf=g(["data","selection","enabled"],!1),Of=g(["data","selection","grouped"],!1),Pf=g(["data","selection","isselectable"],function(){return!0}),Qf=g(["data","selection","multiple"],!0),Rf=g(["subchart","show"],!1),Sf=Rf?g(["subchart","size","height"],60):0,Tf=g(["color","pattern"],null),Uf=g(["legend","show"],!0),Vf=g(["legend","position"],"bottom"),Wf=g(["legend","item","onclick"],function(){}),Xf=g(["legend","equally"],!1),Yf=g(["axis","rotated"],!1),Zf=g(["axis","x","type"],"indexed"),$f=g(["axis","x","categories"],[]),_f=g(["axis","x","tick","centered"],!1),ag=g(["axis","x","tick","format"],null),bg=g(["axis","x","tick","culling"],"categorized"===Zf?!1:!0),cg=g(["axis","x","tick","count"],10),dg=g(["axis","x","max"],null),eg=g(["axis","x","min"],null),fg=g(["axis","x","default"],null),gg=g(["axis","x","label"],null),hg=g(["axis","y","show"],!0),ig=g(["axis","y","max"],null),jg=g(["axis","y","min"],null),kg=g(["axis","y","center"],null),lg=g(["axis","y","label"],null),mg=g(["axis","y","inner"],!1),ng=g(["axis","y","tick","format"],null),og=g(["axis","y","padding"],null),pg=g(["axis","y","ticks"],10),qg=g(["axis","y2","show"],!1),rg=g(["axis","y2","max"],null),sg=g(["axis","y2","min"],null),tg=g(["axis","y2","center"],null),ug=g(["axis","y2","label"],null),vg=g(["axis","y2","inner"],!1),wg=g(["axis","y2","tick","format"],null),xg=g(["axis","y2","padding"],null),yg=g(["axis","y2","ticks"],10),zg=g(["grid","x","show"],!1),Ag=g(["grid","x","type"],"tick"),Bg=g(["grid","x","lines"],null),Cg=g(["grid","y","show"],!1),Dg=g(["grid","y","lines"],null),Eg=g(["grid","y","ticks"],10),Fg=g(["point","show"],!0),Gg=Fg?g(["point","r"],2.5):0,Hg=g(["point","focus","line","enabled"],!0),Ig=g(["point","focus","expand","enabled"],!0),Jg=g(["point","focus","expand","r"],Ig?4:Gg),Kg=g(["point","focus","select","r"],8),Lg=g(["point","onclick"],function(){}),Mg=g(["point","onselected"],function(){}),Ng=g(["point","onunselected"],function(){}),Og=g(["pie","label","show"],!0),Pg=g(["pie","label","format"],null),Qg=g(["pie","onclick"],function(){}),Rg=g(["pie","onmouseover"],function(){}),Sg=g(["pie","onmouseout"],function(){}),Tg=g(["donut","label","show"],!0),Ug=g(["donut","label","format"],null),Vg=g(["donut","title"],""),Wg=g(["donut","onclick"],function(){}),Xg=g(["donut","onmouseover"],function(){}),Yg=g(["donut","onmouseout"],function(){}),Zg=g(["regions"],[]),$g=g(["tooltip","show"],!0),_g=g(["tooltip","format","title"],null),ah=g(["tooltip","format","value"],null),bh=g(["tooltip","contents"],function(a,b,c,d){var e,f,g,h,i,j=_g?_g:b,k=ah?ah:c;for(f=0;f"+(g||0===g?""+g+"":"")),i=a[f].name,h=k(a[f].value,a[f].ratio),e+=""+i+""+h+"");return e+""}),ch=g(["tooltip","init","show"],!1),dh=g(["tooltip","init","x"],0),eh=g(["tooltip","init","position"],{top:"0px",left:"50px"}),fh=("string"==typeof Ge?Ge.replace("#",""):Ge.id)+"-clip",gh=h(fh),hh="timeseries"===Zf,ih="categorized"===Zf,jh=!hh&&(Af||Bf),kh=null,lh=!1,mh=!1,nh=Dd(Mf,Tf),oh=function(){var a=[[Ae.time.format("%Y/%-m/%-d"),function(){return!0}],[Ae.time.format("%-m/%-d"),function(a){return a.getMonth()}],[Ae.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[Ae.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[Ae.time.format("%I %p"),function(a){return a.getHours()}],[Ae.time.format("%I:%M"),function(a){return a.getMinutes()}],[Ae.time.format(":%S"),function(a){return a.getSeconds()}],[Ae.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)}}(),ph=Yf?"left":"bottom",qh=Yf?mg?"top":"bottom":mg?"right":"left",rh=Yf?vg?"bottom":"top":vg?"left":"right",sh=Yf?"left":"bottom",th={main:function(){return"translate("+Re.left+","+Re.top+")"},context:function(){return"translate("+Se.left+","+Se.top+")"},legend:function(){return"translate("+Te.left+","+Te.top+")"},x:function(){return"translate(0,"+(Yf?0:We)+")"},y:function(){return"translate(0,"+(Yf?We:0)+")"},y2:function(){return"translate("+(Yf?0:Ue)+","+(Yf?1:0)+")"},subx:function(){return"translate(0,"+(Yf?0:Xe)+")"},arc:function(){return"translate("+Ue/2+","+We/2+")"}},uh="right"===Vf,vh=0,wh=0,xh=0,yh=40,zh=20,Ah=5;gf=Ae.layout.pie().value(function(a){return a.values.reduce(function(a,b){return a+b.value},0)});var Bh,Ch=function(){var a=Ae.svg.line().x(Yf?function(a){return T(a.id)(a.value)}:Qc).y(Yf?Qc:function(a){return T(a.id)(a.value)});return function(b){var c,d,e=Qd(b.values);return td(b)?(a.interpolate(ud(b)?"cardinal":"linear"),Lf[b.id]?ae(e,qf,T(b.id),Lf[b.id]):a(e)):(c=qf(e[0].x),d=T(b.id)(e[0].value),Yf?"M "+d+" "+c:"M "+c+" "+d)}}(),Dh=function(){var a;return a=Yf?Ae.svg.area().x0(function(a){return T(a.id)(0)}).x1(function(a){return T(a.id)(a.value)}).y(Qc):Ae.svg.area().x(Qc).y0(function(a){return T(a.id)(0)}).y1(function(a){return T(a.id)(a.value)}),function(b){var c,d,e=Qd(b.values);return nd([b],"area")||nd([b],"area-spline")?(a.interpolate(ud(b)?"cardinal":"linear"),a(e)):(c=qf(e[0].x),d=T(b.id)(e[0].value),Yf?"M "+d+" "+c:"M "+c+" "+d)}}(),Eh=function(){var a=Ae.svg.line().x(Yf?function(a){return U(a.id)(a.value)}:Tc).y(Yf?Tc:function(a){return U(a.id)(a.value)});return function(b){var c=Qd(b.values);return td(b)?a(c):"M "+tf(c[0].x)+" "+U(b.id)(c[0].value)}}(),Fh=function(){};Bh=Ae.svg.brush().on("brush",je),Bh.update=function(){return Jh&&Jh.select(".x.brush").call(this),this},Bh.scale=function(a){return Yf?this.y(a):this.x(a)},Le&&(Fh=Ae.behavior.zoom().on("zoomstart",function(){Fh.altDomain=Ae.event.sourceEvent.altKey?qf.orgDomain():null}).on("zoom",Le?ke:null),Fh.scale=function(a){return Yf?this.y(a):this.x(a)},Fh.orgScaleExtent=function(){var a=Me?Me:[1,10];return[a[0],Math.max(mc()/a[1],a[1])]},Fh.updateScaleExtent=function(){var a=Wb(qf.orgDomain())/Wb(Nh),b=this.orgScaleExtent();return this.scaleExtent([b[0]*a,b[1]*a]),this});var Gh,Hh,Ih,Jh,Kh,Lh,Mh,Nh,Oh,Ph={};if(Be.focus=function(a){function b(a){a.transition().duration(100).style("opacity",1)}var c=Gh.selectAll(we(a)),d=c.filter(xe),e=c.filter(ye);Be.revert(),Be.defocus(),b(d.classed("focused",!0)),b(e),sd(Be.data.targets)&&Gb(a,!0),re(a)},Be.defocus=function(a){function b(a){a.transition().duration(100).style("opacity",.3)}var c=Gh.selectAll(we(a)),d=c.filter(xe),e=c.filter(ye);Be.revert(),b(d.classed("focused",!1)),b(e),sd(Be.data.targets)&&Hb(a),se(a)},Be.revert=function(a){function b(a){a.transition().duration(100).style("opacity",1)}var c=Gh.selectAll(we(a)),d=c.filter(xe),e=c.filter(ye);b(d.classed("focused",!1)),b(e),sd(Be.data.targets)&&Hb(a),te()},Be.show=function(a){Gh.selectAll(we(a)).transition().style("opacity",1)},Be.hide=function(a){Gh.selectAll(we(a)).transition().style("opacity",0)},Be.unzoom=function(){Bh.clear().update(),ie({withUpdateXDomain:!0})},Be.load=function(a){if("function"!=typeof a.done&&(a.done=function(){}),a.xs&&ec(a.xs),"categories"in a&&ih&&($f=a.categories,wf.categories($f)),"cacheIds"in a&&Xb(a.cacheIds))return void pe(Zb(a.cacheIds),a.done);if("data"in a)pe(ic(a.data),a.done);else if("url"in a)Ae.csv(a.url,function(b,c){pe(ic(c),a.done)});else if("rows"in a)pe(ic(gc(a.rows)),a.done);else{if(!("columns"in a))throw Error("url or rows or columns is required.");pe(ic(hc(a.columns)),a.done)}},Be.unload=function(a){Be.data.targets=Be.data.targets.filter(function(b){return b.id!==a}),Gh.selectAll(we(a)).transition().style("opacity",0).remove(),Uf&&Kh.selectAll(".legend-item"+ve(a)).remove(),Be.data.targets.length>0&&ie({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})},Be.selected=function(a){var b=ve(a);return Ae.merge(Ih.selectAll(".-shapes"+b).selectAll(".-shape").filter(function(){return Ae.select(this).classed(Ee)}).map(function(a){return a.map(function(a){return a.__data__})}))},Be.select=function(a,b,c){Nf&&Ih.selectAll(".-shapes").selectAll(".-shape").each(function(e,f){var g="circle"===this.nodeName?Kd:Nd,h="circle"===this.nodeName?Ld:Od,i=Of||!a||a.indexOf(e.id)>=0,j=!b||b.indexOf(f)>=0;i&&j?Pf(e)&&g(Ae.select(this).classed(Ee,!0),e,f):d(c)&&c&&h(Ae.select(this).classed(Ee,!1),e,f)})},Be.unselect=function(a,b){Nf&&Ih.selectAll(".-shapes").selectAll(".-shape").each(function(c,d){var e="circle"===this.nodeName?Ld:Od,f=Of||!a||a.indexOf(c.id)>=0,g=!b||b.indexOf(d)>=0;f&&g&&Pf(c)&&e(Ae.select(this).classed(Ee,!1),c,d)})},Be.toLine=function(a){md(a,"line"),ne()},Be.toSpline=function(a){md(a,"spline"),ne()},Be.toBar=function(a){md(a,"bar"),ne()},Be.toScatter=function(a){md(a,"scatter"),ne()},Be.toArea=function(a){md(a,"area"),ne()},Be.toAreaSpline=function(a){md(a,"area-spline"),ne()},Be.toPie=function(a){md(a,"pie"),ne({withTransform:!0})},Be.toDonut=function(a){md(a,"donut"),ne({withTransform:!0})},Be.groups=function(a){return c(a)?Ff:(Ff=a,ie(),Ff)},Be.xgrids=function(a){return a?(Bg=a,ie(),Bg):Bg},Be.xgrids.add=function(a){return a?Be.xgrids(Bg.concat(a)):void 0},Be.xgrids.remove=function(a){var b=ze(a);return Be.xgrids(Bg.filter(b))},Be.ygrids=function(a){return a?(Dg=a,ie(),Dg):Dg},Be.ygrids.add=function(a){return a?Be.ygrids(Dg.concat(a)):void 0},Be.ygrids.remove=function(a){var b=ze(a);return Be.ygrids(Dg.filter(b))},Be.regions=function(a){return c(a)?Zg:(Zg=a,ie(),Zg)},Be.regions.add=function(a){return c(a)?Zg:(Zg=Zg.concat(a),ie(),Zg)},Be.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;Gh.selectAll("."+a).transition().duration(d).style("fill-opacity",0).remove(),Zg=Zg.filter(function(b){return b.classes.indexOf(a)<0})}),Zg},Be.data.get=function(a){var b=Be.data.getAsTarget(a);return d(b)?b.values.map(function(a){return a.value}):void 0},Be.data.getAsTarget=function(a){var b=qc(function(b){return b.id===a});return b.length>0?b[0]:void 0},Be.resize=function(a){He=a?a.width:null,Ie=a?a.height:null,ne({withLegend:!0,withTransition:!1})},Be.destroy=function(){Be.data.targets=void 0,Be.data.x={},Mh.html(""),a.onresize=null},"url"in e.data)Ae.csv(e.data.url,function(a,b){be(b)});else if("rows"in e.data)be(gc(e.data.rows));else{if(!("columns"in e.data))throw Error("url or rows or columns is required.");be(hc(e.data.columns))}return Be},"function"==typeof a.define&&a.define.amd?a.define(e):a.c3=e}(window); \ No newline at end of file