Browse Source

Add dount chart - #10

pull/34/merge
Masayuki Tanaka 11 years ago
parent
commit
dd83fa7213
  1. 36
      c3.js
  2. 172
      c3.min.js

36
c3.js

@ -177,7 +177,7 @@
/*-- Set Chart Params --*/
var margin, margin2, margin3, width, width2, height, height2, height3, currentWidth, currentHeight;
var radius, radiusExpanded, svgArc, svgArcExpanded, svgArcExpandedSub, pie;
var radius, radiusExpanded, innerRadius, svgArc, svgArcExpanded, svgArcExpandedSub, pie;
var xMin, xMax, yMin, yMax, subXMin, subXMax, subYMin, subYMax;
var x, y, y2, subX, subY, subY2, xAxis, yAxis, yAxis2, subXAxis;
@ -238,6 +238,7 @@
radiusExpanded = height / 2;
radius = radiusExpanded * 0.95;
innerRadius = hasDountType(c3.data.targets) ? radius * 0.6 : 0;
}
function getCurrentWidth() {
return __size_width === null ? getParentWidth() : __size_width;
@ -408,7 +409,7 @@
}
function getSvgArc() {
var arc = d3.svg.arc().outerRadius(radius).innerRadius(0),
var arc = d3.svg.arc().outerRadius(radius).innerRadius(innerRadius),
newArc = function (d, withoutUpdate) {
var updated;
if (withoutUpdate) { return arc(d); } // for interpolate
@ -420,7 +421,7 @@
return newArc;
}
function getSvgArcExpanded(rate) {
var arc = d3.svg.arc().outerRadius(radiusExpanded * (rate ? rate : 1)).innerRadius(0);
var arc = d3.svg.arc().outerRadius(radiusExpanded * (rate ? rate : 1)).innerRadius(innerRadius);
return function (d) {
var updated = updateAngle(d);
return updated ? arc(updated) : "M 0 0";
@ -709,6 +710,11 @@
});
});
// set target types
if (__data_type) {
setTargetType(getTargetIds(targets).filter(function (id) { return ! (id in __data_types); }), __data_type);
}
// cache as original id keyed
targets.forEach(function (d) {
addCache(d.id_org, d);
@ -1035,9 +1041,15 @@
function hasScatterType(targets) {
return hasType(targets, 'scatter');
}
function hasArcType(targets) {
function hasPieType(targets) {
return hasType(targets, 'pie');
}
function hasDountType(targets) {
return hasType(targets, 'dount');
}
function hasArcType(targets) {
return hasPieType(targets) || hasDountType(targets);
}
function isLineType(d) {
var id = (typeof d === 'string') ? d : d.id;
return !(id in __data_types) || __data_types[id] === 'line' || __data_types[id] === 'spline' || __data_types[id] === 'area' || __data_types[id] === 'area-spline';
@ -1056,7 +1068,7 @@
}
function isArcType(d) {
var id = (typeof d === 'string') ? d : d.id;
return __data_types[id] === 'pie';
return __data_types[id] === 'pie' || __data_types[id] === 'dount';
}
/* not used
function lineData(d) {
@ -1920,7 +1932,7 @@
var barIndices = getBarIndices(), barTargetsNum = barIndices.__max__ + 1, maxDataCountTarget;
var rectX, rectW;
var withY, withSubchart, withTransition, withUpdateXDomain, withUpdateOrgXDomain;
var isPieChart;
var hideAxis = hasArcType(c3.data.targets);
var duration;
options = isDefined(options) ? options : {};
@ -1929,7 +1941,6 @@
withTransition = isDefined(options.withTransition) ? options.withTransition : true;
withUpdateXDomain = isDefined(options.withUpdateXDomain) ? options.withUpdateXDomain : false;
withUpdateOrgXDomain = isDefined(options.withUpdateOrgXDomain) ? options.withUpdateOrgXDomain : false;
isPieChart = hasArcType(c3.data.targets);
duration = withTransition ? 250 : 0;
@ -1950,9 +1961,9 @@
y2.domain(getYDomain('y2'));
// axis
main.select(".x.axis").transition().duration(__axis_rotated ? duration : 0).call(__axis_rotated ? yAxis : xAxis).style("opacity", isPieChart ? 0 : 1);
main.select(".y.axis").transition().duration(__axis_rotated ? 0 : duration).call(__axis_rotated ? xAxis : yAxis).style("opacity", isPieChart ? 0 : 1);
main.select(".y2.axis").transition().call(yAxis2).style("opacity", isPieChart ? 0 : 1);
main.select(".x.axis").transition().duration(__axis_rotated ? duration : 0).call(__axis_rotated ? yAxis : xAxis).style("opacity", hideAxis ? 0 : 1);
main.select(".y.axis").transition().duration(__axis_rotated ? 0 : duration).call(__axis_rotated ? xAxis : yAxis).style("opacity", hideAxis ? 0 : 1);
main.select(".y2.axis").transition().call(yAxis2).style("opacity", hideAxis ? 0 : 1);
// Update label position
main.select(".x.axis .-axis-x-label").attr("x", width);
@ -2314,11 +2325,6 @@
/*-- Main --*/
// Set data type if data.type is specified
if (__data_type) {
setTargetType(getTargetIds(targets).filter(function (id) { return ! (id in __data_types); }), __data_type);
}
//-- Bar --//
mainBarUpdate = main.select('.chart-bars')
.selectAll('.chart-bar')

172
c3.min.js vendored

@ -1,86 +1,86 @@
(function(P){function kd(){function u(d,f){d.attr("transform",function(d){return"translate("+(f(d)+ca)+", 0)"})}function x(d,f){d.attr("transform",function(d){return"translate(0,"+f(d)+")"})}function P(d){var f=d[0];d=d[d.length-1];return f<d?[f,d]:[d,f]}function Da(d){for(var f=[],r=Math.ceil(d[0]);r<d[1];r++)f.push(r);0<f.length&&0<f[0]&&f.unshift(f[0]-(f[1]-f[0]));return f}function Ea(d){d=d<da.length?da[d]:d;return N?N(d):d}function n(n){n.each(function(){var n=d.select(this),ia=Da(r.domain()),
R=n.selectAll(".tick.major").data(ia,String),S=R.enter().insert("g","path").attr("class","tick major").style("opacity",1E-6),T=d.transition(R.exit()).style("opacity",1E-6).remove(),w=d.transition(R).style("opacity",1),F,N=r.rangeExtent?r.rangeExtent():P(r.range()),n=n.selectAll(".domain").data([0]);n.enter().append("path").attr("class","domain");var n=d.transition(n),y=r.copy(),da=this.__chart__||y;this.__chart__=y;S.append("line");S.append("text");var ja=S.select("line"),Va=w.select("line"),ka=R.select("text"),
Wa=S.select("text"),Xa=w.select("text");ca=(y(1)-y(0))/2;R=qa?0:ca;switch(A){case "bottom":F=u;ja.attr("y2",O);Wa.attr("y",Math.max(O,0)+f);Va.attr("x1",R).attr("x2",R).attr("y2",O);Xa.attr("x",0).attr("y",Math.max(O,0)+f);ka.attr("dy",".71em").style("text-anchor","middle");ka.text(function(d){return ia.length<X||0===d%Math.ceil(ia.length/X)?Ea(d):""});n.attr("d","M"+N[0]+","+Y+"V0H"+N[1]+"V"+Y);break;case "left":F=x,ja.attr("x2",-O),Wa.attr("x",-(Math.max(O,0)+f)),Va.attr("x2",-O).attr("y2",0),Xa.attr("x",
-(Math.max(O,0)+f)).attr("y",ca),ka.attr("dy",".32em").style("text-anchor","end"),ka.text(function(d){return ia.length<X||0===d%Math.ceil(ia.length/X)?Ea(d):""}),n.attr("d","M"+-Y+","+N[0]+"H0V"+N[1]+"H"+-Y)}if(r.ticks)S.call(F,da),w.call(F,y),T.call(F,y);else{var Ya=y.rangeBand()/2,T=function(d){return y(d)+Ya};S.call(F,T);w.call(F,T)}})}var r=d.scale.linear(),A="bottom",O=6,Y=6,f=3,qa=!1,X=10,ca=0,N=null,da=[];n.scale=function(d){if(!arguments.length)return r;r=d;return n};n.orient=function(d){if(!arguments.length)return A;
A=d in{top:1,right:1,bottom:1,left:1}?d+"":"bottom";return n};n.categories=function(d){if(!arguments.length)return da;da=d;return n};n.tickCentered=function(d){if(!arguments.length)return qa;qa=d;return n};n.tickTextNum=function(d){if(!arguments.length)return X;X=d;return n};n.tickFormat=function(d){if(!arguments.length)return N;N=d;return n};n.tickOffset=function(){return ca};n.ticks=function(){};return n}function x(d){return"undefined"===typeof d}function u(d){return"undefined"!==typeof d}var yb=
P.c3={},d=P.d3;yb.generate=function(ba){var fc,gc,Da,Ea,n,r,A,O,Y;function f(a,b){for(var c=ba,e=0;e<a.length;e++){if(!(a[e]in c))return b;c=c[a[e]]}return c}function qa(){zb=null===Za?ca():Za;ra=X();r=0;A=(g?Ab+jc:0)+($a?$a:ab?1:40);O=20+(g?0:Ab)+la;Y=bb?bb:Bb?cb||g?1:40:20;p=zb-A-Y;t=ra-r-O;Da=g?r:ra-Ab-la;Ea=g?kc:A;n=20+la;Cb=g?A-kc-jc:p;db=g?t:ra-Da-n;fc=ra-la;gc=A;Db=t/2;eb=0.95*Db}function X(){var a=null===lc?+d.select(sa).style("height").replace("px",""):lc;return 0<a?a:320}function ca(){return+d.select(sa).style("width").replace("px",
"")}function N(){return p+2+A+Y}function da(){return 40}function ia(){return A+20}function yb(){return t-r+2}function ld(){var a=g?t:p,b=ta(U)/ta(m.domain()),c=fb();return 1<c?a*b/(c-1):a}function R(){Eb=g?1:0;Fb=g?t:p;Gb=g?0:t;Hb=g?p:1;Ib=g?0:db;Jb=g?Cb:1;m=S(Eb,Fb,u(m)?m.domain():void 0,function(){return J.tickOffset()});z=T(Gb,Hb,u(z)?z.domain():void 0);Z=T(Gb,Hb,u(Z)?Z.domain():void 0);V=S(Eb,Fb,u(U)?U:void 0,function(a){return 0===a%1?gb.tickOffset():0});hb=T(Ib,Jb);ib=T(Ib,Jb);J=hc(m,md);ua=
d.svg.axis().scale(z).orient(nd);jb=d.svg.axis().scale(Z).orient(od);gb=hc(V,pd);kb=Va();mc=ka();nc=ka(0.98)}function S(a,b,c,e){var k=(B?d.time.scale():d.scale.linear()).range([a,b]);k.orgDomain=function(){return k.domain()};u(c)&&k.domain(c);x(e)&&(e=function(){return 0});if(ea){var G=k,f,k=function(a){return G(a)+e(a)};for(f in G)k[f]=G[f];k.orgDomain=function(){return G.domain()};k.domain=function(a){if(!arguments.length)return a=G.domain(),[a[0],a[1]+1];G.domain(a);return k}}return k}function T(a,
b){return d.scale.linear().range([a,b])}function w(a){return"y2"===y(a)?Z:z}function F(a){return"y2"===y(a)?ib:hb}function hc(a,b){var c=(ea?kd():d.svg.axis()).scale(a).orient(b);c.tickFormat(ic());ea?c.categories(Fa).tickCentered(qd):c.tickOffset=function(){return 0};return c}function y(a){return a in oc?oc[a]:"y"}function ic(){var a=B?rd:ea?sd:function(a){return a};lb&&(a="function"===typeof lb?lb:B?function(a){return d.time.format(lb)(a)}:a);return a}function ja(a){var b=!1;Kb(h.data.targets).forEach(function(c){b||
c.data.id!==a.data.id||(b=!0,a=c)});return b?a:null}function Va(){var a=d.svg.arc().outerRadius(eb).innerRadius(0),b=function(b,e){var k;return e?a(b):(k=ja(b))?a(k):"M 0 0"};b.centroid=a.centroid;return b}function ka(a){var b=d.svg.arc().outerRadius(Db*(a?a:1)).innerRadius(0);return function(a){return(a=ja(a))?b(a):"M 0 0"}}function Wa(a){a=ja(a);var b,c;b="";a&&(b=kb.centroid(a),a=b[0],b=b[1],c=Math.sqrt(a*a+b*b),b="translate("+0.8*(a/c)*eb+","+0.8*(b/c)*eb+")");return b}function Xa(a){return(100*
(a.endAngle-a.startAngle)/(2*Math.PI)).toFixed(1)+"%"}function Ya(a,b){var c=q.selectAll(".chart-arc.target"+(a?"-"+a:"")),e=q.selectAll(".-arc").filter(function(b){return b.data.id!==a});c.selectAll("path").transition().duration(50).attr("d",mc).transition().duration(100).attr("d",nc);b||e.style("opacity",0.3)}function xb(a){q.selectAll(".chart-arc.target"+(a?"-"+a:"")).selectAll("path").transition().duration(50).attr("d",kb);q.selectAll(".-arc").style("opacity",1)}function td(a){var b=pc(a),c,e,
k,G;if(0<s.length)for(G=qc(a),a=0;a<s.length;a++)for(e=s[a][0],G&&b[e]&&b[e].forEach(function(a,c){b[e][c]=0>a?a:0}),c=1;c<s[a].length;c++)k=s[a][c],b[k]&&b[k].forEach(function(a,c){y(k)!==y(e)||!b[e]||G&&0<+a||(b[e][c]+=+a)});return d.min(Object.keys(b).map(function(a){return d.min(b[a])}))}function ud(a){var b=pc(a),c,e,k,G;if(0<s.length)for(G=vd(a),a=0;a<s.length;a++)for(e=s[a][0],G&&b[e]&&b[e].forEach(function(a,c){b[e][c]=0<a?a:0}),c=1;c<s[a].length;c++)k=s[a][c],b[k]&&b[k].forEach(function(a,
c){y(k)!==y(e)||!b[e]||G&&0>+a||(b[e][c]+=+a)});return d.max(Object.keys(b).map(function(a){return d.max(b[a])}))}function mb(a){var b=nb(function(b){return y(b.id)===a}),c="y2"===a?wd:xd,e="y2"===a?yd:zd,c=c?c:td(b),e=e?e:ud(b),k=0.1*Math.abs(e-c),d=k,f=k,g="y2"===a?Ad:Bd;g&&(c=Math.max(Math.abs(c),Math.abs(e)),e=c-g,c=g-c);"y"===a&&Ga&&(d=Ga.top?Ga.top:k,f=Ga.bottom?Ga.bottom:k);"y2"===a&&Ha&&(d=Ha.top?Ha.top:k,f=Ha.bottom?Ha.bottom:k);Ia(b,"bar")&&!qc(b)&&(f=c);return[c-f,e+d]}function Cd(a){return d.min(a,
function(a){return d.min(a.values,function(a){return a.x})})}function Dd(a){return d.max(a,function(a){return d.max(a.values,function(a){return a.x})})}function ob(a){var b=[Cd(a),Dd(a)];a=b[0];var b=b[1],c=ea?0:0.01*Math.abs(a-b);a=B?new Date(a.getTime()-c):a-c;b=B?new Date(b.getTime()+c):b+c;return[a,b]}function ta(a){return a[1]-a[0]}function Ed(a){for(var b=0;b<a.length;b++)if(!(a[b]in pb))return!1;return!0}function Fd(a){for(var b=[],c=0;c<a.length;c++)a[c]in pb&&b.push(rc(pb[a[c]]));return b}
function Lb(a){return"start"in a?m(B?ma(a.start):a.start):0}function sc(a){var b=Lb(a);a=("end"in a?m(B?ma(a.end):a.end):p)-b;return 0>a?0:a}function tc(a){return na&&a===na||$&&Gd($,a)}function Hd(a){return!tc(a)}function Id(a){Object.keys(a).forEach(function(b){$[b]=a[b]})}function qb(a){var b;a&&(b=Ja[a.id],a.name=b?b:a.id);return a}function uc(a){var b=a[0],c={},e=[],k,d;for(k=1;k<a.length;k++){c={};for(d=0;d<a[k].length;d++)c[b[d]]=a[k][d];e.push(c)}return e}function vc(a){var b=[],c,e,k;for(c=
0;c<a.length;c++)for(k=a[c][0],e=1;e<a[c].length;e++)x(b[e-1])&&(b[e-1]={}),b[e-1][k]=a[c][e];return b}function Ka(a){var b=d.keys(a[0]).filter(Hd),c=d.keys(a[0]).filter(tc);if(B&&0===c.length)return P.alert('data.x or data.xs must be specified when axis.x.type == "timeseries"'),[];Mb&&b.forEach(function(b){var k=na?na:$?$[b]:null;0<=c.indexOf(k)?h.data.x[b]=a.map(function(a){return a[k]}):h.data.x[b]=h.data.x[Object.keys(h.data.x)[0]]});b=b.map(function(b){var c=Jd(b);return{id:c,id_org:b,values:a.map(function(a,
d){var f;f=na?na:$?$[b]:null;f=B?ma(a[f]):Mb?a[f]?a[f]:b in h.data.x&&h.data.x[b]&&h.data.x[b][d]?h.data.x[b][d]:d:d;a.x=f;return{x:f,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){return(a.x||0===a.x?a.x:Infinity)-(b.x||0===b.x?b.x:Infinity)});b=0;a.values.forEach(function(a){a.index=b++})});b.forEach(function(a){pb[a.id_org]=rc(a)});return b}function rc(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 wc(a){return 0<a&&h.data.targets[0].values[a-1]?h.data.targets[0].values[a-1].x:void 0}function fb(){return d.max(h.data.targets,function(a){return a.values.length})}function Kd(){var a=h.data.targets.length,b=0,c;1<a?h.data.targets.forEach(function(a){a.values.length>b&&(c=a,b=a.values.length)}):c=a?h.data.targets[0]:null;return c}function rb(a){a=x(a)?h.data.targets:a;return a.map(function(a){return a.id})}function xc(a){var b=rb(),c;for(c=0;c<b.length;c++)if(b[c]===
a)return!0;return!1}function nb(a){return u(a)?h.data.targets.filter(a):h.data.targets}function pc(a){var b={};a.forEach(function(a){b[a.id]=[];a.values.forEach(function(e){b[a.id].push(e.value)})});return b}function yc(a,b){var c=Object.keys(a),e,k,d;for(e=0;e<c.length;e++)for(d=a[c[e]].values,k=0;k<d.length;k++)if(b(d[k].value))return!0;return!1}function qc(a){return yc(a,function(a){return 0>a})}function vd(a){return yc(a,function(a){return 0<a})}function sd(a){return a<Fa.length?Fa[a]:a}function La(a){return"-shapes -shapes-"+
a.id}function zc(a){return La(a)+" -line -line-"+a.id}function Ld(a){return La(a)+" -circles -circles-"+a.id}function Ac(a){return La(a)+" -bars -bars-"+a.id}function Md(a){return La(a.data)+" -arc -arc-"+a.data.id}function Nd(a){return La(a)+" -area -area-"+a.id}function Od(a,b){return"-shape -shape-"+b+" -circle -circle-"+b}function Bc(a,b){return"-shape -shape-"+b+" -bar -bar-"+b}function Pd(a,b){return"region region-"+b+" "+("classes"in a?[].concat(a.classes).join(" "):"")}function Cc(a,b){return"event-rect event-rect-"+
b}function Qd(a){return a.value?Dc(a)?0.5:1:0}function va(a){return m(a.x)}function Ma(a){return m(B?ma(a.value):a.value)}function Na(a){return z(a.value)}function Ec(a){return V(a.x)}function Fc(a,b){var c,e=a[b].x,k=[];for(c=b-1;0<=c&&e===a[c].x;c--)k.push(a[c]);for(c=b;c<a.length&&e===a[c].x;c++)k.push(a[c]);return k}function Gc(a,b,c,e){c=c?c:0;e=e?e:a.length-1;var k=Math.floor((e-c)/2)+c;0<m(a[k].x)-b[0]?e=k:c=k;return 1===e-c?(k=[],a[c].x&&(k=k.concat(Fc(a,c))),a[e].x&&(k=k.concat(Fc(a,e))),
Hc(k,b)):Gc(a,b,c,e)}function Ic(a,b){var c;c=a.map(function(a){return Gc(a.values,b)});return Hc(c,b)}function Hc(a,b){var c,e;a.forEach(function(a){var d=Nb(a,b);if(d<c||!c)c=d,e=a});return e}function Jc(a,b){var c,e,k,d,f;0!==a.filter(function(a){return a.value}).length&&(W.html(Kc(a)).style("visibility","hidden").style("display","block"),c=W.property("offsetWidth"),e=W.property("offsetHeight"),g?d=b[0]:(k=q.property("offsetLeft"),d=k+($a?$a:ab?1:40)+m(a[0].x)+20,f=d+c,k=k+(null===Za?ca():Za)-
(bb?bb:Bb?cb||g?1:40:20),f>k&&(d-=c+30)),c=b[1]+15+e<X()?b[1]+15:b[1]-e,W.style("top",c+"px").style("left",d+"px").style("visibility","visible"))}function Lc(a){Ia(h.data.targets,"scatter")||C(h.data.targets)||l.selectAll("line.xgrid-focus").style("visibility","visible").data([a]).attr(g?"y1":"x1",va).attr(g?"y2":"x2",va)}function Mc(){l.select("line.xgrid-focus").style("visibility","hidden")}function wa(a){return a.x||0===a.x?m(a.x):null}function xa(a){return w(a.id)(a.value)}function Rd(){var a=
{},b=0,c,e;nb(sb).forEach(function(k){for(c=0;c<s.length;c++)if(!(0>s[c].indexOf(k.id)))for(e=0;e<s[c].length;e++)if(s[c][e]in a){a[k.id]=a[s[c][e]];break}x(a[k.id])&&(a[k.id]=b++)});a.__max__=b-1;return a}function Sd(a,b,c,e){var k=e?V:m;return b?function(e){var d=e.id in c?c[e.id]:0;return e.x||0===e.x?k(e.x)-a*(b/2-d):0}:function(){return 0}}function Td(a){return function(b){return(a?F(b.id):w(b.id))(b.value)}}function Ud(a,b){var c=Object.keys(a);return function(e,k){var d=b?F(e.id):w(e.id),f=
d(0),g=f;nb(sb).forEach(function(b){b.id!==e.id&&a[b.id]===a[e.id]&&c.indexOf(b.id)<c.indexOf(e.id)&&0<b.values[k].value*e.value&&(g+=d(b.values[k].value)-f)});return g}}function Oa(a,b){var c=x(a)?rb():a;"string"===typeof c&&(c=[c]);for(var e=0;e<c.length;e++)H[c[e]]=b}function Ia(a,b){var c=!1;a.forEach(function(a){H[a.id]===b&&(c=!0);a.id in H||"line"!==b||(c=!0)});return c}function C(a){return Ia(a,"pie")}function Ob(a){a="string"===typeof a?a:a.id;return!(a in H)||"line"===H[a]||"spline"===H[a]||
"area"===H[a]||"area-spline"===H[a]}function Nc(a){a="string"===typeof a?a:a.id;return"spline"===H[a]||"area-spline"===H[a]}function sb(a){return"bar"===H["string"===typeof a?a:a.id]}function Dc(a){return"scatter"===H["string"===typeof a?a:a.id]}function Oc(a){return"pie"===H["string"===typeof a?a:a.id]}function Pc(a){return sb(a)?a.values:[]}function Vd(a){return Ob(a)||Dc(a)?a.values:[]}function ma(a){var b;if(!a)throw Error(a+" can not be parsed as d3.time with format "+Pb+". Maybe 'x' of this data is not defined. See data.x or data.xs option.");
b=d.time.format(Pb).parse(a);if(!b)throw Error("Failed to parse '"+a+"' with format "+Pb);return b}function Qc(a,b){var c=d.mouse(a),e=d.select(a),k=1*e.attr("cx"),e=1*e.attr("cy");return Math.sqrt(Math.pow(k-c[0],2)+Math.pow(e-c[1],2))<b}function Rc(a){var b=d.mouse(a),c=d.select(a);a=1*c.attr("x");var e=1*c.attr("y"),c=1*c.attr("width");return a-10<b[0]&&b[0]<a+c+10&&e-10<b[1]}function Wd(a,b){var c;for(c=0;c<b.length;c++)if(b[c].start<a&&a<=b[c].end)return!0;return!1}function Gd(a,b){var c=!1;
Object.keys(a).forEach(function(e){a[e]===b&&(c=!0)});return c}function Nb(a,b){return Math.pow(m(a.x)-b[0],2)+Math.pow(z(a.value)-b[1],2)}function Sc(a,b,c){Xd(a,b);l.select(".selected-circles-"+b.id).selectAll(".selected-circle-"+c).data([b]).enter().append("circle").attr("class",function(){return"selected-circle selected-circle-"+c}).attr("cx",g?xa:wa).attr("cy",g?wa:xa).attr("stroke",function(){return K(b.id)}).attr("r",1.4*Pa).transition().duration(100).attr("r",Pa)}function Qb(a,b,c){Yd(a,b);
l.select(".selected-circles-"+b.id).selectAll(".selected-circle-"+c).transition().duration(100).attr("r",0).remove()}function Tc(a,b,c,e){a?Sc(b,c,e):Qb(b,c,e)}function Zd(){}function Uc(){}function Vc(a,b,c,e){}function Rb(a){return a.filter(function(a){return null!==a.value})}function Sb(a,b){return(b?l.selectAll(".-circles-"+b):l).selectAll(".-circle"+(a||0===a?"-"+a:""))}function Tb(a){Sb(a).filter(function(){return d.select(this).classed(aa)}).classed(aa,!1).attr("r",Ub)}function Wc(a){return l.selectAll(".-bar"+
(a||0===a?"-"+a:""))}function $d(a,b,c,e){var d,f,h="M",l,m,ya,n,r,p=[];if(u(e))for(d=0;d<e.length;d++)p[d]={},x(e[d].start)?p[d].start=a[0].x:p[d].start=B?ma(e[d].start):e[d].start,x(e[d].end)?p[d].end=a[a.length-1].x:p[d].end=B?ma(e[d].end):e[d].end;n=g?function(a){return c(a.value)}:function(a){return b(a.x)};r=g?function(a){return b(a.x)}:function(a){return c(a.value)};e=B?function(a,e,d,k){var f=a.x.getTime();a=e.x-a.x;e=new Date(f+a*(d+k));return"M"+b(new Date(f+a*d))+" "+c(m(d))+" "+b(e)+" "+
c(m(d+k))}:function(a,e,d,k){return"M"+b(l(d))+" "+c(m(d))+" "+b(l(d+k))+" "+c(m(d+k))};for(d=0;d<a.length;d++)if(x(p)||!Wd(a[d].x,p))h+=" "+n(a[d])+" "+r(a[d]);else{l=S(a[d-1].x,a[d].x);m=T(a[d-1].value,a[d].value);f=b(a[d].x)-b(a[d-1].x);ya=c(a[d].value)-c(a[d-1].value);f=Math.sqrt(Math.pow(f,2)+Math.pow(ya,2));ya=2/f;var q=2*ya;for(f=ya;1>=f;f+=q)h+=e(a[d-1],a[d],f,ya)}return h}function Vb(a){var b;tb=d.select(sa);if(tb.empty())P.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');
else{tb.html("");h.data.x={};h.data.targets=Ka(a);qa();R();m.domain(d.extent(ob(h.data.targets)));z.domain(mb("y"));Z.domain(mb("y2"));V.domain(m.domain());hb.domain(z.domain());ib.domain(Z.domain());J.ticks(10>a.length?a.length:10);ua.ticks(ae).outerTickSize(0).tickFormat(be);jb.ticks(ce).outerTickSize(0).tickFormat(de);U=m.domain();L.scale(V);oa&&D.scale(m);q=d.select(sa).append("svg").attr("width",p+A+Y).attr("height",t+r+O).on("mouseenter",ee).on("mouseleave",fe);ub=q.append("defs");ub.append("clipPath").attr("id",
Wb).append("rect").attr("y",r).attr("width",p).attr("height",t-r);ub.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1-A).attr("y",-20).attr("width",N).attr("height",da);ub.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-A+1).attr("y",r-1).attr("width",ia).attr("height",yb);l=q.append("g").attr("transform",M.main);E=za?q.append("g").attr("transform",M.context):null;Aa=Ba?q.append("g").attr("transform",M.legend):null;W=d.select(sa).style("position","relative").append("div").style("position",
"absolute").style("z-index","10").style("display","none");l.append("g").attr("class","x axis").attr("clip-path",g?"":"url(#xaxis-clip)").attr("transform",M.x).call(g?ua:J).append("text").attr("class","-axis-x-label").attr("x",p).attr("dy","-.5em").style("text-anchor","end").text(ge);l.append("g").attr("class","y axis").attr("clip-path",g?"url(#yaxis-clip)":"").call(g?J:ua).append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(he);Bb&&
l.append("g").attr("class","y2 axis").attr("transform",M.y2).call(jb);a=l.append("g").attr("clip-path",Qa).attr("class","grid");Xc&&a.append("g").attr("class","xgrids");Xb&&(b=a.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(Xb).enter().append("g").attr("class","xgrid-line"),b.append("line").attr("class",function(a){return""+a["class"]}),b.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",g?"":"rotate(-90)").attr("dx",g?
0:-r).attr("dy",-5).text(function(a){return a.text}));ie&&a.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",g?0:-10).attr("x2",g?p:-10).attr("y1",g?-10:r).attr("y2",g?-10:t);Yc&&a.append("g").attr("class","ygrids");Yb&&(a=a.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(Yb).enter().append("g").attr("class","ygrid-line"),a.append("line").attr("class",function(a){return""+a["class"]}),a.append("text").attr("class",function(a){return""+
a["class"]}).attr("text-anchor","end").attr("transform",g?"rotate(-90)":"").attr("dx",g?0:-r).attr("dy",-5).text(function(a){return a.text}));l.append("g").attr("clip-path",Qa).attr("class","regions");l.append("g").attr("clip-path",Qa).attr("class","chart");l.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",oa?"ew-resize":null);l.select(".chart").append("g").attr("class","chart-bars");l.select(".chart").append("g").attr("class","chart-lines");l.select(".chart").append("g").attr("class",
"chart-arcs").attr("transform",M.arc);if(oa)l.insert("rect",je?null:"g.grid").attr("class","zoom-rect").attr("width",p).attr("height",t).style("opacity",0).style("cursor","ew-resize").call(D).on("dblclick.zoom",null);null!==vb&&L.extent("function"!==typeof vb?vb:vb(ob()));za&&(E.append("g").attr("clip-path",Qa).attr("class","chart"),E.select(".chart").append("g").attr("class","chart-bars"),E.select(".chart").append("g").attr("class","chart-lines"),E.append("g").attr("clip-path",Qa).attr("class","x brush").call(L).selectAll("rect").attr(g?
"width":"height",g?Cb:db),E.append("g").attr("class","x axis").attr("transform",M.subx).attr("clip-path",g?"url(#yaxis-clip)":"").call(gb));Ba&&wb(h.data.targets);Zc(h.data.targets);I({withTransition:!1,withUpdateXDomain:!0});if(ke){if(B&&"string"===typeof Ca){Ca=ma(Ca);for(a=0;a<h.data.targets[0].values.length&&0!==h.data.targets[0].values[a].x-Ca;a++);Ca=a}W.html(Kc(h.data.targets.map(function(a){return qb(a.values[Ca])})));W.style("top",$c.top).style("left",$c.left).style("display","block")}null==
P.onresize&&(P.onresize=le());P.onresize.add&&P.onresize.add(me)}}function ne(a){a.append("rect").attr("class",Cc).style("cursor",fa&&pa?"pointer":null).on("mouseover",function(a,c){if(!Ra&&!C(h.data.targets)){var e=h.data.targets.map(function(a){return qb(a.values[c])}),d,f;if(0<Object.keys(Ja).length){f=[];for(var g in Ja)for(d=0;d<e.length;d++)if(e[d].id===g){f.push(e[d]);e.shift(d);break}e=f.concat(e)}Zb&&Sb(c,void 0).classed(aa,!0).attr("r",$b);Wc(c).classed(aa,!1);Lc(e[0])}}).on("mouseout",
function(a,c){C(h.data.targets)||(Mc(),W.style("display","none"),Tb(c),Wc(void 0).classed(aa,!1))}).on("mousemove",function(a,c){var e;Ra||C(h.data.targets)||(e=h.data.targets.map(function(a){return qb(a.values[c])}),Jc(e,d.mouse(this)),fa&&(pa||l.selectAll(".-shape-"+c).filter(function(a){return ga(a)}).each(function(){var a=d.select(this).classed(aa,!0);"circle"===this.nodeName&&a.attr("r",$b);q.select(".event-rect-"+c).style("cursor",null)}).filter(function(){var a=d.select(this);if("circle"===
this.nodeName)return Qc(this,Pa);if("rect"===this.nodeName)return Rc(this,a.attr("x"),a.attr("y"))}).each(function(){var a=d.select(this);a.classed(aa)||(a.classed(aa,!0),"circle"===this.nodeName&&a.attr("r",Pa));q.select(".event-rect-"+c).style("cursor","pointer")})))}).on("click",function(a,c){C(h.data.targets)||(ac?ac=!1:l.selectAll(".-shape-"+c).each(function(a){ad(this,a,c)}))}).call(d.behavior.drag().origin(Object).on("drag",function(){bd(d.mouse(this))}).on("dragstart",function(){cd(d.mouse(this))}).on("dragend",
function(){dd()})).call(D).on("dblclick.zoom",null)}function oe(a){a.append("rect").attr("x",0).attr("y",0).attr("width",p).attr("height",t).attr("class","event-rect").on("mouseout",function(){C(h.data.targets)||(Mc(),W.style("display","none"),Tb())}).on("mousemove",function(){var a,c,e;Ra||C(h.data.targets)||(a=d.mouse(this),c=Ic(h.data.targets,a),e=[qb(c)],Jc(e,a),Zb&&(Tb(),Sb(c.index,c.id).classed(aa,!0).attr("r",$b)),Lc(e[0]),100>Nb(c,a)?q.select(".event-rect").style("cursor","pointer"):q.select(".event-rect").style("cursor",
null))}).on("click",function(){var a,c;C(h.data.targets)||(a=d.mouse(this),c=Ic(h.data.targets,a),100>Nb(c,a)&&l.select(".-circles-"+c.id).select(".-circle-"+c.index).each(function(){ad(this,c,c.index)}))}).call(d.behavior.drag().origin(Object).on("drag",function(){bd(d.mouse(this))}).on("dragstart",function(){cd(d.mouse(this))}).on("dragend",function(){dd()})).call(D).on("dblclick.zoom",null)}function ad(a,b,c){var e=d.select(a),f=e.classed(ha),g=!1,h;"circle"===a.nodeName?(g=Qc(a,1.5*Pa),h=Tc):
"rect"===a.nodeName&&(g=Rc(a),h=Vc);if(pa||g)fa&&ga(b)&&(e.classed(ha,!f),h(!f,e,b,c)),pe(b,e)}function bd(a){var b,c,e,f,g,m,p;C(h.data.targets)||!fa||oa&&!D.altDomain||(b=bc[0],c=bc[1],e=a[0],a=a[1],f=Math.min(b,e),g=Math.max(b,e),m=pa?r:Math.min(c,a),p=pa?t:Math.max(c,a),l.select(".dragarea").attr("x",f).attr("y",m).attr("width",g-f).attr("height",p-m),l.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return ga(a)}).each(function(a,b){var c=d.select(this),e=c.classed(ha),h=c.classed(cc),
l,n,r,q;l=!1;"circle"===this.nodeName?(l=1*c.attr("cx"),n=1*c.attr("cy"),q=Tc,l=f<l&&l<g&&m<n&&n<p):"rect"===this.nodeName&&(l=1*c.attr("x"),n=1*c.attr("y"),r=1*c.attr("width"),q=Vc,l=f<l+r&&l<g&&n<p);l^h&&(c.classed(cc,!h),c.classed(ha,!e),q(!e,c,a,b))}))}function cd(a){!C(h.data.targets)&&fa&&(bc=a,l.select(".chart").append("rect").attr("class","dragarea").style("opacity",0.1),Ra=!0)}function dd(){!C(h.data.targets)&&fa&&(l.select(".dragarea").transition().duration(100).style("opacity",0).remove(),
l.selectAll(".-shape").classed(cc,!1),Ra=!1)}function I(a){var b,c,e,f=Rd(),n=f.__max__+1,q,v,s;a=u(a)?a:{};c=u(a.withY)?a.withY:!0;e=u(a.withSubchart)?a.withSubchart:!0;v=u(a.withTransition)?a.withTransition:!0;b=u(a.withUpdateXDomain)?a.withUpdateXDomain:!1;a=u(a.withUpdateOrgXDomain)?a.withUpdateOrgXDomain:!1;s=C(h.data.targets);v=v?250:0;a&&(m.domain(d.extent(ob(h.data.targets))),U=m.domain(),D.scale(m).updateScaleExtent(),V.domain(m.domain()),L.scale(V));b&&(m.domain(L.empty()?U:L.extent()),
oa&&D.scale(m).updateScaleExtent());z.domain(mb("y"));Z.domain(mb("y2"));l.select(".x.axis").transition().duration(g?v:0).call(g?ua:J).style("opacity",s?0:1);l.select(".y.axis").transition().duration(g?0:v).call(g?J:ua).style("opacity",s?0:1);l.select(".y2.axis").transition().call(jb).style("opacity",s?0:1);l.select(".x.axis .-axis-x-label").attr("x",p);hb.domain(z.domain());ib.domain(Z.domain());W.style("display","none");l.select("line.xgrid-focus").style("visibility","hidden").attr("y2",t);if(Xc){if("year"===
qe)for(b=[],s=ob(),a=s[0].getFullYear(),s=s[1].getFullYear();a<=s;a++)b.push(new Date(a+"-01-01 00:00:00"));else b=m.ticks(10);b=l.select(".xgrids").selectAll(".xgrid").data(b);b.enter().append("line").attr("class","xgrid");b.attr("x1",g?0:function(a){return m(a)-J.tickOffset()}).attr("x2",g?p:function(a){return m(a)-J.tickOffset()}).attr("y1",g?function(a){return m(a)-J.tickOffset()}:r).attr("y2",g?function(a){return m(a)-J.tickOffset()}:t).style("opacity",function(){return+d.select(this).attr(g?
"y1":"x1")===(g?t:0)?0:1});b.exit().remove()}Xb&&(b=l.selectAll(".xgrid-lines"),b.selectAll("line").transition().duration(v).attr("x1",g?0:Ma).attr("x2",g?p:Ma).attr("y1",g?Ma:r).attr("y2",g?Ma:t),b.selectAll("text").attr("x",g?p:0).attr("y",Ma));c&&Yc&&(b=l.select(".ygrids").selectAll(".ygrid").data(z.ticks(10)),b.enter().append("line").attr("class","ygrid"),b.attr("x1",g?z:0).attr("x2",g?z:p).attr("y1",g?0:z).attr("y2",g?t:z),b.exit().remove());c&&Yb&&(c=l.select(".ygrid-lines"),c.selectAll("line").transition().duration(v).attr("x1",
g?Na:0).attr("x2",g?Na:p).attr("y1",g?0:Na).attr("y2",g?t:Na),c.selectAll("text").attr("x",g?0:p).attr("y",Na));c=function(a){var b=ea?n?1.2*J.tickOffset()/n:0:0.6*((g?t:p)*(a?1:ta(U)/ta(m.domain()))/(fb()-1)),c=Sd(b,n,f,!!a),e=Td(!!a),d=Ud(f,!!a),h=a?F:w;return function(a,f){var k=h(a.id)(0),l=d(a,f)||k,k=[[c(a),l],[c(a),e(a)-(k-l)],[c(a)+b,e(a)-(k-l)],[c(a)+b,l]],l=g?1:0,m=g?0:1;return"M "+k[0][l]+","+k[0][m]+" L"+k[1][l]+","+k[1][m]+" L"+k[2][l]+","+k[2][m]+" L"+k[3][l]+","+k[3][m]+" z"}};b=l.selectAll(".-bars").selectAll(".-bar").data(Pc);
b.enter().append("path").attr("d",c(!1)).style("stroke","none").style("opacity",0).style("fill",function(a){return K(a.id)}).attr("class",Bc);b.transition().duration(v).attr("d",c(!1)).style("opacity",1);b.exit().transition().duration(v).style("opacity",0).remove();l.selectAll(".chart-line").select(".-line").transition().duration(v).attr("d",re);l.selectAll(".-area").transition().duration(v).attr("d",se);b=l.selectAll(".-circles").selectAll(".-circle").data(Vd);b.enter().append("circle").attr("class",
Od).attr("r",Ub);b.transition().duration(v).style("opacity",Qd).attr("cx",g?xa:wa).attr("cy",g?wa:xa);b.exit().remove();l.selectAll(".chart-arc").select(".-arc").style("opacity",function(a){return a===this._current?0:1}).transition().duration(v).attrTween("d",function(a){a=ja(a);if(!a)return function(){return"M 0 0"};var b=d.interpolate(this._current,a);this._current=b(0);return function(a){a=b(a);return Oc(a.data)?kb(a,!0):"M 0 0"}}).style("opacity",1);l.selectAll(".chart-arc").select("text").attr("transform",
Wa).attr("opacity",0).transition().duration(v).text(Xa).attr("opacity",function(a){return Oc(a.data)?1:0});za&&(null!==d.event&&"zoom"===d.event.type&&L.extent(m.orgDomain()).update(),e&&(E.select(".x.axis").transition().duration(g?v:0).call(gb),L.empty()||L.extent(m.orgDomain()).update(),e=E.selectAll(".-bars").selectAll(".-bar").data(Pc),e.enter().append("path").attr("d",c(!0)).style("stroke","none").style("fill",function(a){return K(a.id)}).attr("class",Bc),e.style("opacity",0).transition().duration(v).attr("d",
c(!0)).style("opacity",1),e.exit().transition().duration(v).style("opacity",0).remove(),E.selectAll(".-line").transition().duration(v).attr("d",te)));l.selectAll(".selected-circles").filter(function(a){return sb(a)}).selectAll("circle").remove();l.selectAll(".selected-circle").transition().duration(v).attr("cx",g?xa:wa).attr("cy",g?wa:xa);$?(c=l.select(".event-rects").selectAll(".event-rect").data([0]),oe(c.enter()),c.attr("x",0).attr("y",0).attr("width",p).attr("height",t)):(Mb?(q=function(a,b){var c=
wc(b),e=b<fb()-1?h.data.targets[0].values[b+1].x:void 0;return(m(e?e:a.x+50)-m(c?c:a.x-50))/2},e=function(a,b){var c=wc(b);return(m(a.x)+m(c?c:a.x-50))/2}):(q=ld(),e=function(a){return m(a.x)-q/2}),c=Kd(),l.select(".event-rects").datum(c?c.values:[]),c=l.select(".event-rects").selectAll(".event-rect").data(function(a){return a}),ne(c.enter()),c.attr("class",Cc).attr("x",g?0:e).attr("y",g?e:0).attr("width",g?p:q).attr("height",g?q:t),c.exit().remove());e=l.select(".regions").selectAll("rect.region").data(Q);
e.enter().append("rect");e.attr("class",Pd).attr("x",g?0:Lb).attr("y",g?Lb:r).attr("width",g?p:sc).attr("height",g?sc:t).style("fill-opacity",function(a){return u(a.opacity)?a.opacity:0.1});e.exit().transition().duration(v).style("fill-opacity",0).remove()}function ue(){"mousemove"===d.event.sourceEvent.type&&D.altDomain?(m.domain(D.altDomain),D.scale(m).updateScaleExtent()):(ea&&m.orgDomain()[0]===U[0]&&m.domain([U[0]-1E-10,m.orgDomain()[1]]),I({withTransition:!1,withY:!1,withSubchart:!1}),"mousemove"===
d.event.sourceEvent.type&&(ac=!0))}function le(){function a(){b.forEach(function(a){a()})}var b=[];a.add=function(a){b.push(a)};return a}function me(){qa();R();L.scale(V);oa&&D.scale(m);q.attr("width",zb).attr("height",ra);q.select("#"+Wb).select("rect").attr("width",p).attr("height",t);q.select("#xaxis-clip").select("rect").attr("width",N);q.select(".zoom-rect").attr("width",p).attr("height",t);l.select(".x.axis").attr("transform",M.x);l.select(".y2.axis").attr("transform",M.y2);l.select(".chart-arcs").attr("transform",
M.arc);za&&(E.attr("transform",M.context),E.select(".x.axis").attr("transform",M.subx));Ba&&(Aa.attr("transform",M.legend),wb(h.data.targets,{withTransition:!1}));I({withTransition:!1,withUpdateXDomain:!0})}function Zc(a){var b;ed&&Oa(rb(a).filter(function(a){return!(a in H)}),ed);l.select(".chart-bars").selectAll(".chart-bar").data(a).enter().append("g").attr("class",function(a){return"chart-bar target target-"+a.id}).style("pointer-events","none").style("opacity",0).append("g").attr("class",Ac).style("fill",
function(a){return K(a.id)}).style("stroke",function(a){return K(a.id)}).style("stroke-width",0).style("cursor",function(a){return ga(a)?"pointer":null});b=l.select(".chart-lines").selectAll(".chart-line").data(a).enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}).style("pointer-events","none").style("opacity",0);b.append("path").attr("class",zc).style("stroke",function(a){return K(a.id)});b.append("path").attr("class",Nd).style("fill",function(a){return K(a.id)});
b.append("g").attr("class",function(a){return"selected-circles selected-circles-"+a.id});b.append("g").attr("class",Ld).style("fill",function(a){return K(a.id)}).style("cursor",function(a){return ga(a)?"pointer":null});a.forEach(function(a){l.selectAll(".selected-circles-"+a.id).selectAll(".selected-circle").each(function(b){b.value=a.values[b.x].value})});b=l.select(".chart-arcs").selectAll(".chart-arc").data(Kb(a)).enter().append("g").attr("class",function(a){return"chart-arc target target-"+a.data.id}).style("opacity",
0);b.append("path").attr("class",Md).style("fill",function(a){return K(a.data.id)}).style("cursor",function(a){return ga(a)?"pointer":null}).each(function(a){this._current=a}).on("mouseover",function(a){Ya(a.data.id);fd(a.data.id)}).on("mouseout",function(a){xb(a.data.id);gd()});b.append("text").attr("dy",".35em").style("text-anchor","middle").style("pointer-events","none");za&&(b=E.select(".chart-bars").selectAll(".chart-bar").data(a),b=b.enter().append("g").attr("class",function(a){return"chart-bar target target-"+
a.id}).style("opacity",0),b.append("g").attr("class",Ac).style("fill",function(a){return K(a.id)}),b=E.select(".chart-lines").selectAll(".chart-line").data(a),b=b.enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}).style("opacity",0),b.append("path").attr("class",zc).style("stroke",function(a){return K(a.id)}));Ba&&wb(a);q.selectAll(".target").transition().style("opacity",1)}function Sa(a,b){h.data.targets.forEach(function(b){for(var e=0;e<a.length;e++)if(b.id===
a[e].id){b.values=a[e].values;a.splice(e,1);break}});h.data.targets=h.data.targets.concat(a);Zc(h.data.targets);I({withUpdateOrgXDomain:!0,withUpdateXDomain:!0});b()}function fd(a){q.selectAll(".legend-item").filter(function(b){return b!==a}).transition().duration(100).style("opacity",0.3)}function gd(){q.selectAll(".legend-item").transition().duration(100).style("opacity",1)}function wb(a,b){var c=rb(a),e,d=p/2-Ta*Object.keys(a).length/2,f;b=x(b)?{}:b;f=u(b.withTransition)?b.withTransition:!0;e=
Aa.selectAll(".legend-item").data(c).enter().append("g").attr("class",function(a){return"legend-item legend-item-"+a}).style("cursor","pointer").on("click",function(a){ve(a)}).on("mouseover",function(a){fd(a);h.focus(a)}).on("mouseout",function(){gd();h.revert()});e.append("rect").attr("class","legend-item-event").style("fill-opacity",0).attr("x",-200).attr("y",function(){return la/2-16}).attr("width",Ta).attr("height",24);e.append("rect").attr("class","legend-item-tile").style("pointer-events","none").style("fill",
function(a){return K(a)}).attr("x",-200).attr("y",function(){return la/2-9}).attr("width",10).attr("height",10);e.append("text").text(function(a){return u(Ja[a])?Ja[a]:a}).style("pointer-events","none").attr("x",-200).attr("y",function(){return la/2});Aa.selectAll("rect.legend-item-event").data(c).transition().duration(f?250:0).attr("x",function(a,b){return d+Ta*b});Aa.selectAll("rect.legend-item-tile").data(c).transition().duration(f?250:0).attr("x",function(a,b){return d+Ta*b});Aa.selectAll("text").data(c).transition().duration(f?
250:0).attr("x",function(a,b){return d+Ta*b+14})}function Ua(a){return u(a)?".target-"+a:".target"}function dc(a){return xc(a.id)}function ec(a){return"data"in a&&xc(a.data.id)}var h={data:{}},pb={},aa="_expanded_",ha="_selected_",cc="_included_",sa=f(["bindto"],"#chart"),Za=f(["size","width"],null),lc=f(["size","height"],null),$a=f(["padding","left"],null),bb=f(["padding","right"],null),oa=f(["zoom","enabled"],!1),hd=f(["zoom","extent"],null),je=f(["zoom","privileged"],!1),ee=f(["onenter"],function(){}),
fe=f(["onleave"],function(){});if(!("data"in ba))throw Error("data is required in config");var na=f(["data","x"],null),$=f(["data","xs"],null),Pb=f(["data","x_format"],"%Y-%m-%d"),Jd=f(["data","id_converter"],function(a){return a}),Ja=f(["data","names"],{}),s=f(["data","groups"],[]),oc=f(["data","axes"],{}),ed=f(["data","type"],null),H=f(["data","types"],{}),id=f(["data","regions"],{}),we=f(["data","colors"],{}),fa=f(["data","selection","enabled"],!1),pa=f(["data","selection","grouped"],!1),ga=f(["data",
"selection","isselectable"],function(){return!0}),za=f(["subchart","show"],!1),Ab=za?f(["subchart","size","height"],60):0,xe=f(["color","pattern"],null),Ba=f(["legend","show"],!0),Ta=f(["legend","item","width"],80),ve=f(["legend","item","onclick"],function(){}),jd=f(["axis","x","type"],"indexed"),Fa=f(["axis","x","categories"],[]),qd=f(["axis","x","tick","centered"],!1),lb=f(["axis","x","tick","format"],null),vb=f(["axis","x","default"],null),ge=f(["axis","x","label"],null),zd=f(["axis","y","max"],
null),xd=f(["axis","y","min"],null),Bd=f(["axis","y","center"],null),he=f(["axis","y","label"],null),ab=f(["axis","y","inner"],!1),be=f(["axis","y","tick","format"],function(a){return a}),Ga=f(["axis","y","padding"],null),ae=f(["axis","y","ticks"],10),Bb=f(["axis","y2","show"],!1),yd=f(["axis","y2","max"],null),wd=f(["axis","y2","min"],null),Ad=f(["axis","y2","center"],null),cb=f(["axis","y2","inner"],!1),de=f(["axis","y2","tick","format"],function(a){return a}),Ha=f(["axis","y2","padding"],null),
ce=f(["axis","y2","ticks"],10),g=f(["axis","rotated"],!1),Xc=f(["grid","x","show"],!1),qe=f(["grid","x","type"],"tick"),Xb=f(["grid","x","lines"],null),Yc=f(["grid","y","show"],!1),Yb=f(["grid","y","lines"],null),Ub=f(["point","show"],!0)?f(["point","r"],2.5):0,ie=f(["point","focus","line","enabled"],!0),Zb=f(["point","focus","expand","enabled"],!0),$b=f(["point","focus","expand","r"],Zb?4:Ub),Pa=f(["point","focus","select","r"],8),pe=f(["point","onclick"],function(){}),Xd=f(["point","onselected"],
function(){}),Yd=f(["point","onunselected"],function(){}),Q=f(["regions"],[]),Kc=f(["tooltip","contents"],function(a){var b="<table class='-tooltip'><tr><th colspan='2'>"+ic()(a[0].x)+"</th></tr>",c,d,f;for(c=0;c<a.length;c++)a[c]&&(a[c].value||0===a[c].value)&&(d=u(a[c].value)?(Math.round(100*a[c].value)/100).toFixed(2):"-",f=a[c].name,b+="<tr class='-tooltip-name-"+a[c].id+"'><td class='name'><span style='background-color:"+K(a[c].id)+"'></span>"+f+"</td><td class='value'>"+d+"</td></tr>");return b+
"</table>"}),ke=f(["tooltip","init","show"],!1),Ca=f(["tooltip","init","x"],0),$c=f(["tooltip","init","position"],{top:"0px",left:"50px"}),Wb=sa.replace("#","")+"-clip",Qa="url(#"+Wb+")",B="timeseries"===jd,ea="categorized"===jd,Mb=!B&&(na||$),bc=null,Ra=!1,ac=!1,la=Ba?40:0,K=function(a,b){var c=[],d=null!==b?b:"#1f77b4 #ff7f0e #2ca02c #d62728 #9467bd #8c564b #e377c2 #7f7f7f #bcbd22 #17becf".split(" ");return function(b){if(b in a)return a[b];-1===c.indexOf(b)&&c.push(b);return d[c.indexOf(b)%d.length]}}(we,
xe),rd=function(){var a=[[d.time.format("%Y/%-m/%-d"),function(){return!0}],[d.time.format("%-m/%-d"),function(a){return a.getMonth()}],[d.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[d.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[d.time.format("%I %p"),function(a){return a.getHours()}],[d.time.format("%I:%M"),function(a){return a.getMinutes()}],[d.time.format(":%S"),function(a){return a.getSeconds()}],[d.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)}}(),p,Cb,t,db,zb,ra,eb,Db,kb,mc,nc,Kb,Eb,Fb,Gb,Hb,Ib,Jb,m,z,Z,V,hb,ib,J,ua,jb,gb,md=g?"left":"bottom",nd=g?ab?"top":"bottom":ab?"right":"left",od=g?cb?"bottom":"top":cb?"left":"right",pd=g?"left":"bottom",M={main:function(){return"translate("+A+","+r+")"},context:function(){return"translate("+Ea+","+Da+")"},legend:function(){return"translate("+gc+","+fc+")"},y2:function(){return"translate("+(g?0:p)+","+(g?10:0)+")"},
x:function(){return"translate(0,"+t+")"},subx:function(){return"translate(0,"+(g?0:db)+")"},arc:function(){return"translate("+p/2+","+t/2+")"}},kc=40,jc=20;Kb=d.layout.pie().value(function(a){return a.values.reduce(function(a,c){return a+c.value},0)});var re=function(){var a=d.svg.line().x(g?function(a){return w(a.id)(a.value)}:va).y(g?va:function(a){return w(a.id)(a.value)});return function(b){var c=Rb(b.values),d;if(Ob(b))return Nc(b)?a.interpolate("cardinal"):a.interpolate("linear"),id[b.id]?$d(c,
m,w(b.id),id[b.id]):a(c);d=m(c[0].x);b=w(b.id)(c[0].value);return g?"M "+b+" "+d:"M "+d+" "+b}}(),se=function(){var a;a=g?d.svg.area().x0(function(a){return w(a.id)(0)}).x1(function(a){return w(a.id)(a.value)}).y(va):d.svg.area().x(va).y0(function(a){return w(a.id)(0)}).y1(function(a){return w(a.id)(a.value)});return function(b){var c=Rb(b.values),d;if(Ia([b],"area")||Ia([b],"area-spline"))return Nc(b)?a.interpolate("cardinal"):a.interpolate("linear"),a(c);d=m(c[0].x);b=w(b.id)(c[0].value);return g?
"M "+b+" "+d:"M "+d+" "+b}}(),te=function(){var a=d.svg.line().x(g?function(a){return F(a.id)(a.value)}:Ec).y(g?Ec:function(a){return F(a.id)(a.value)});return function(b){var c=Rb(b.values);return Ob(b)?a(c):"M "+V(c[0].x)+" "+F(b.id)(c[0].value)}}(),L=d.svg.brush().on("brush",function(){I({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}),D=d.behavior.zoom().on("zoomstart",function(){D.altDomain=d.event.sourceEvent.altKey?m.orgDomain():null}).on("zoom",oa?ue:null);L.update=function(){E&&
E.select(".x.brush").call(this);return this};L.scale=function(a){return g?this.y(a):this.x(a)};D.scale=function(a){return g?this.y(a):this.x(a)};D.orgScaleExtent=function(){var a=hd?hd:[1,10];return[a[0],Math.max(fb()/a[1],a[1])]};D.updateScaleExtent=function(){var a=ta(m.orgDomain())/ta(U),b=this.orgScaleExtent();this.scaleExtent([b[0]*a,b[1]*a]);return this};var q,ub,l,E,Aa,W,tb,U;h.focus=function(a){var b=q.selectAll(Ua(a)),c=b.filter(dc),b=b.filter(ec);h.defocus();c.classed("focused",!0).transition().duration(100).style("opacity",
1);b.transition().duration(100).style("opacity",1);C(h.data.targets)&&Ya(a,!0)};h.defocus=function(a){var b=q.selectAll(Ua(a)),c=b.filter(dc),b=b.filter(ec);c.classed("focused",!1).transition().duration(100).style("opacity",0.3);b.transition().duration(100).style("opacity",0.3);C(h.data.targets)&&xb(a)};h.revert=function(a){var b=q.selectAll(Ua(a)),c=b.filter(dc),b=b.filter(ec);c.classed("focused",!1).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity",1);C(h.data.targets)&&
xb(a)};h.show=function(a){q.selectAll(Ua(a)).transition().style("opacity",1)};h.hide=function(a){q.selectAll(Ua(a)).transition().style("opacity",0)};h.unzoom=function(){L.clear().update();I({withUpdateXDomain:!0})};h.load=function(a){"function"!==typeof a.done&&(a.done=function(){});a.xs&&Id(a.xs);"categories"in a&&ea&&(Fa=a.categories,J.categories(Fa));if("cacheIds"in a&&Ed(a.cacheIds))Sa(Fd(a.cacheIds),a.done);else if("data"in a)Sa(Ka(a.data),a.done);else if("url"in a)d.csv(a.url,function(b,c){Sa(Ka(c),
a.done)});else if("rows"in a)Sa(Ka(uc(a.rows)),a.done);else if("columns"in a)Sa(Ka(vc(a.columns)),a.done);else throw Error("url or rows or columns is required.");};h.unload=function(a){h.data.targets=h.data.targets.filter(function(b){return b.id!==a});q.selectAll(".target-"+a).transition().style("opacity",0).remove();Ba&&(q.selectAll(".legend-item-"+a).remove(),wb(h.data.targets));0<h.data.targets.length&&I({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})};h.selected=function(a){a=u(a)?"-"+a:"";return d.merge(l.selectAll(".-shapes"+
a).selectAll(".-shape").filter(function(){return d.select(this).classed(ha)}).map(function(a){return a.map(function(a){return a.__data__})}))};h.select=function(a,b,c){fa&&l.selectAll(".-shapes").selectAll(".-shape").each(function(e,f){var g="circle"===this.nodeName?Sc:Zd,h="circle"===this.nodeName?Qb:Uc;0<=b.indexOf(f)?ga(e)&&(pa||x(a)||0<=a.indexOf(e.id))&&g(d.select(this).classed(ha,!0),e,f):u(c)&&c&&h(d.select(this).classed(ha,!1),e,f)})};h.unselect=function(a,b){fa&&l.selectAll(".-shapes").selectAll(".-shape").each(function(c,
e){var f="circle"===this.nodeName?Qb:Uc;(x(b)||0<=b.indexOf(e))&&ga(c)&&(pa||x(a)||0<=a.indexOf(c.id))&&f(d.select(this).classed(ha,!1),c,e)})};h.toLine=function(a){Oa(a,"line");I()};h.toSpline=function(a){Oa(a,"spline");I()};h.toBar=function(a){Oa(a,"bar");I()};h.toScatter=function(a){Oa(a,"scatter");I()};h.groups=function(a){if(x(a))return s;s=a;I();return s};h.regions=function(a){if(x(a))return Q;Q=a;I();return Q};h.regions.add=function(a){if(x(a))return Q;Q=Q.concat(a);I();return Q};h.regions.remove=
function(a,b){var c=[].concat(a);b=u(b)?b:{};c.forEach(function(a){var c=q.selectAll("."+a);u(b.duration)&&(c=c.transition().duration(b.duration).style("fill-opacity",0));c.remove();Q=Q.filter(function(b){return 0>b.classes.indexOf(a)})});return Q};h.data.get=function(a){a=h.data.getAsTarget(a);return u(a)?a.values.map(function(a){return a.value}):void 0};h.data.getAsTarget=function(a){var b=nb(function(b){return b.id===a});return 0<b.length?b[0]:void 0};h.destroy=function(){h.data.targets=void 0;
h.data.x={};tb.html("");P.onresize=null};if("url"in ba.data)d.csv(ba.data.url,function(a,b){Vb(b)});else if("rows"in ba.data)Vb(uc(ba.data.rows));else if("columns"in ba.data)Vb(vc(ba.data.columns));else throw Error("url or rows or columns is required.");return h}})(window);
(function(P){function ld(){function u(d,f){d.attr("transform",function(d){return"translate("+(f(d)+ca)+", 0)"})}function x(d,f){d.attr("transform",function(d){return"translate(0,"+f(d)+")"})}function P(d){var f=d[0];d=d[d.length-1];return f<d?[f,d]:[d,f]}function Ea(d){for(var f=[],r=Math.ceil(d[0]);r<d[1];r++)f.push(r);0<f.length&&0<f[0]&&f.unshift(f[0]-(f[1]-f[0]));return f}function Fa(d){d=d<da.length?da[d]:d;return N?N(d):d}function n(n){n.each(function(){var n=d.select(this),ia=Ea(r.domain()),
R=n.selectAll(".tick.major").data(ia,String),S=R.enter().insert("g","path").attr("class","tick major").style("opacity",1E-6),T=d.transition(R.exit()).style("opacity",1E-6).remove(),w=d.transition(R).style("opacity",1),G,N=r.rangeExtent?r.rangeExtent():P(r.range()),n=n.selectAll(".domain").data([0]);n.enter().append("path").attr("class","domain");var n=d.transition(n),y=r.copy(),da=this.__chart__||y;this.__chart__=y;S.append("line");S.append("text");var ja=S.select("line"),Wa=w.select("line"),ka=R.select("text"),
Xa=S.select("text"),Ya=w.select("text");ca=(y(1)-y(0))/2;R=ra?0:ca;switch(A){case "bottom":G=u;ja.attr("y2",O);Xa.attr("y",Math.max(O,0)+f);Wa.attr("x1",R).attr("x2",R).attr("y2",O);Ya.attr("x",0).attr("y",Math.max(O,0)+f);ka.attr("dy",".71em").style("text-anchor","middle");ka.text(function(d){return ia.length<X||0===d%Math.ceil(ia.length/X)?Fa(d):""});n.attr("d","M"+N[0]+","+Y+"V0H"+N[1]+"V"+Y);break;case "left":G=x,ja.attr("x2",-O),Xa.attr("x",-(Math.max(O,0)+f)),Wa.attr("x2",-O).attr("y2",0),Ya.attr("x",
-(Math.max(O,0)+f)).attr("y",ca),ka.attr("dy",".32em").style("text-anchor","end"),ka.text(function(d){return ia.length<X||0===d%Math.ceil(ia.length/X)?Fa(d):""}),n.attr("d","M"+-Y+","+N[0]+"H0V"+N[1]+"H"+-Y)}if(r.ticks)S.call(G,da),w.call(G,y),T.call(G,y);else{var Za=y.rangeBand()/2,T=function(d){return y(d)+Za};S.call(G,T);w.call(G,T)}})}var r=d.scale.linear(),A="bottom",O=6,Y=6,f=3,ra=!1,X=10,ca=0,N=null,da=[];n.scale=function(d){if(!arguments.length)return r;r=d;return n};n.orient=function(d){if(!arguments.length)return A;
A=d in{top:1,right:1,bottom:1,left:1}?d+"":"bottom";return n};n.categories=function(d){if(!arguments.length)return da;da=d;return n};n.tickCentered=function(d){if(!arguments.length)return ra;ra=d;return n};n.tickTextNum=function(d){if(!arguments.length)return X;X=d;return n};n.tickFormat=function(d){if(!arguments.length)return N;N=d;return n};n.tickOffset=function(){return ca};n.ticks=function(){};return n}function x(d){return"undefined"===typeof d}function u(d){return"undefined"!==typeof d}var yb=
P.c3={},d=P.d3;yb.generate=function(ba){var gc,hc,Ea,Fa,n,r,A,O,Y;function f(a,b){for(var c=ba,e=0;e<a.length;e++){if(!(a[e]in c))return b;c=c[a[e]]}return c}function ra(){zb=null===$a?ca():$a;sa=X();r=0;A=(g?Ab+kc:0)+(ab?ab:bb?1:40);O=20+(g?0:Ab)+la;Y=cb?cb:Bb?db||g?1:40:20;p=zb-A-Y;s=sa-r-O;Ea=g?r:sa-Ab-la;Fa=g?lc:A;n=20+la;Cb=g?A-lc-kc:p;eb=g?s:sa-Ea-n;gc=sa-la;hc=A;Db=s/2;Ga=0.95*Db;Eb=ma(h.data.targets,"dount")?0.6*Ga:0}function X(){var a=null===mc?+d.select(ta).style("height").replace("px",
""):mc;return 0<a?a:320}function ca(){return+d.select(ta).style("width").replace("px","")}function N(){return p+2+A+Y}function da(){return 40}function ia(){return A+20}function yb(){return s-r+2}function md(){var a=g?s:p,b=ua(U)/ua(m.domain()),c=fb();return 1<c?a*b/(c-1):a}function R(){Fb=g?1:0;Gb=g?s:p;Hb=g?0:s;Ib=g?p:1;Jb=g?0:eb;Kb=g?Cb:1;m=S(Fb,Gb,u(m)?m.domain():void 0,function(){return J.tickOffset()});z=T(Hb,Ib,u(z)?z.domain():void 0);Z=T(Hb,Ib,u(Z)?Z.domain():void 0);V=S(Fb,Gb,u(U)?U:void 0,
function(a){return 0===a%1?gb.tickOffset():0});hb=T(Jb,Kb);ib=T(Jb,Kb);J=ic(m,nd);va=d.svg.axis().scale(z).orient(od);jb=d.svg.axis().scale(Z).orient(pd);gb=ic(V,qd);kb=Wa();nc=ka();oc=ka(0.98)}function S(a,b,c,e){var k=(B?d.time.scale():d.scale.linear()).range([a,b]);k.orgDomain=function(){return k.domain()};u(c)&&k.domain(c);x(e)&&(e=function(){return 0});if(ea){var H=k,f,k=function(a){return H(a)+e(a)};for(f in H)k[f]=H[f];k.orgDomain=function(){return H.domain()};k.domain=function(a){if(!arguments.length)return a=
H.domain(),[a[0],a[1]+1];H.domain(a);return k}}return k}function T(a,b){return d.scale.linear().range([a,b])}function w(a){return"y2"===y(a)?Z:z}function G(a){return"y2"===y(a)?ib:hb}function ic(a,b){var c=(ea?ld():d.svg.axis()).scale(a).orient(b);c.tickFormat(jc());ea?c.categories(Ha).tickCentered(rd):c.tickOffset=function(){return 0};return c}function y(a){return a in pc?pc[a]:"y"}function jc(){var a=B?sd:ea?td:function(a){return a};lb&&(a="function"===typeof lb?lb:B?function(a){return d.time.format(lb)(a)}:
a);return a}function ja(a){var b=!1;Lb(h.data.targets).forEach(function(c){b||c.data.id!==a.data.id||(b=!0,a=c)});return b?a:null}function Wa(){var a=d.svg.arc().outerRadius(Ga).innerRadius(Eb),b=function(b,e){var k;return e?a(b):(k=ja(b))?a(k):"M 0 0"};b.centroid=a.centroid;return b}function ka(a){var b=d.svg.arc().outerRadius(Db*(a?a:1)).innerRadius(Eb);return function(a){return(a=ja(a))?b(a):"M 0 0"}}function Xa(a){a=ja(a);var b,c;b="";a&&(b=kb.centroid(a),a=b[0],b=b[1],c=Math.sqrt(a*a+b*b),b=
"translate("+0.8*(a/c)*Ga+","+0.8*(b/c)*Ga+")");return b}function Ya(a){return(100*(a.endAngle-a.startAngle)/(2*Math.PI)).toFixed(1)+"%"}function Za(a,b){var c=q.selectAll(".chart-arc.target"+(a?"-"+a:"")),e=q.selectAll(".-arc").filter(function(b){return b.data.id!==a});c.selectAll("path").transition().duration(50).attr("d",nc).transition().duration(100).attr("d",oc);b||e.style("opacity",0.3)}function xb(a){q.selectAll(".chart-arc.target"+(a?"-"+a:"")).selectAll("path").transition().duration(50).attr("d",
kb);q.selectAll(".-arc").style("opacity",1)}function ud(a){var b=qc(a),c,e,k,H;if(0<t.length)for(H=rc(a),a=0;a<t.length;a++)for(e=t[a][0],H&&b[e]&&b[e].forEach(function(a,c){b[e][c]=0>a?a:0}),c=1;c<t[a].length;c++)k=t[a][c],b[k]&&b[k].forEach(function(a,c){y(k)!==y(e)||!b[e]||H&&0<+a||(b[e][c]+=+a)});return d.min(Object.keys(b).map(function(a){return d.min(b[a])}))}function vd(a){var b=qc(a),c,e,k,H;if(0<t.length)for(H=wd(a),a=0;a<t.length;a++)for(e=t[a][0],H&&b[e]&&b[e].forEach(function(a,c){b[e][c]=
0<a?a:0}),c=1;c<t[a].length;c++)k=t[a][c],b[k]&&b[k].forEach(function(a,c){y(k)!==y(e)||!b[e]||H&&0>+a||(b[e][c]+=+a)});return d.max(Object.keys(b).map(function(a){return d.max(b[a])}))}function mb(a){var b=nb(function(b){return y(b.id)===a}),c="y2"===a?xd:yd,e="y2"===a?zd:Ad,c=c?c:ud(b),e=e?e:vd(b),k=0.1*Math.abs(e-c),d=k,f=k,g="y2"===a?Bd:Cd;g&&(c=Math.max(Math.abs(c),Math.abs(e)),e=c-g,c=g-c);"y"===a&&Ia&&(d=Ia.top?Ia.top:k,f=Ia.bottom?Ia.bottom:k);"y2"===a&&Ja&&(d=Ja.top?Ja.top:k,f=Ja.bottom?
Ja.bottom:k);ma(b,"bar")&&!rc(b)&&(f=c);return[c-f,e+d]}function Dd(a){return d.min(a,function(a){return d.min(a.values,function(a){return a.x})})}function Ed(a){return d.max(a,function(a){return d.max(a.values,function(a){return a.x})})}function ob(a){var b=[Dd(a),Ed(a)];a=b[0];var b=b[1],c=ea?0:0.01*Math.abs(a-b);a=B?new Date(a.getTime()-c):a-c;b=B?new Date(b.getTime()+c):b+c;return[a,b]}function ua(a){return a[1]-a[0]}function Fd(a){for(var b=0;b<a.length;b++)if(!(a[b]in pb))return!1;return!0}
function Gd(a){for(var b=[],c=0;c<a.length;c++)a[c]in pb&&b.push(sc(pb[a[c]]));return b}function Mb(a){return"start"in a?m(B?na(a.start):a.start):0}function tc(a){var b=Mb(a);a=("end"in a?m(B?na(a.end):a.end):p)-b;return 0>a?0:a}function uc(a){return oa&&a===oa||$&&Hd($,a)}function Id(a){return!uc(a)}function Jd(a){Object.keys(a).forEach(function(b){$[b]=a[b]})}function qb(a){var b;a&&(b=Ka[a.id],a.name=b?b:a.id);return a}function vc(a){var b=a[0],c={},e=[],k,d;for(k=1;k<a.length;k++){c={};for(d=
0;d<a[k].length;d++)c[b[d]]=a[k][d];e.push(c)}return e}function wc(a){var b=[],c,e,k;for(c=0;c<a.length;c++)for(k=a[c][0],e=1;e<a[c].length;e++)x(b[e-1])&&(b[e-1]={}),b[e-1][k]=a[c][e];return b}function La(a){var b=d.keys(a[0]).filter(Id),c=d.keys(a[0]).filter(uc);if(B&&0===c.length)return P.alert('data.x or data.xs must be specified when axis.x.type == "timeseries"'),[];Nb&&b.forEach(function(b){var k=oa?oa:$?$[b]:null;0<=c.indexOf(k)?h.data.x[b]=a.map(function(a){return a[k]}):h.data.x[b]=h.data.x[Object.keys(h.data.x)[0]]});
b=b.map(function(b){var c=Kd(b);return{id:c,id_org:b,values:a.map(function(a,d){var f;f=oa?oa:$?$[b]:null;f=B?na(a[f]):Nb?a[f]?a[f]:b in h.data.x&&h.data.x[b]&&h.data.x[b][d]?h.data.x[b][d]:d:d;a.x=f;return{x:f,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){return(a.x||0===a.x?a.x:Infinity)-(b.x||0===b.x?b.x:Infinity)});b=0;a.values.forEach(function(a){a.index=b++})});xc&&Ma(rb(b).filter(function(a){return!(a in C)}),xc);b.forEach(function(a){pb[a.id_org]=
sc(a)});return b}function sc(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 yc(a){return 0<a&&h.data.targets[0].values[a-1]?h.data.targets[0].values[a-1].x:void 0}function fb(){return d.max(h.data.targets,function(a){return a.values.length})}function Ld(){var a=h.data.targets.length,b=0,c;1<a?h.data.targets.forEach(function(a){a.values.length>b&&(c=a,b=a.values.length)}):c=a?h.data.targets[0]:null;return c}function rb(a){a=x(a)?h.data.targets:
a;return a.map(function(a){return a.id})}function zc(a){var b=rb(),c;for(c=0;c<b.length;c++)if(b[c]===a)return!0;return!1}function nb(a){return u(a)?h.data.targets.filter(a):h.data.targets}function qc(a){var b={};a.forEach(function(a){b[a.id]=[];a.values.forEach(function(e){b[a.id].push(e.value)})});return b}function Ac(a,b){var c=Object.keys(a),e,k,d;for(e=0;e<c.length;e++)for(d=a[c[e]].values,k=0;k<d.length;k++)if(b(d[k].value))return!0;return!1}function rc(a){return Ac(a,function(a){return 0>a})}
function wd(a){return Ac(a,function(a){return 0<a})}function td(a){return a<Ha.length?Ha[a]:a}function Na(a){return"-shapes -shapes-"+a.id}function Bc(a){return Na(a)+" -line -line-"+a.id}function Md(a){return Na(a)+" -circles -circles-"+a.id}function Cc(a){return Na(a)+" -bars -bars-"+a.id}function Nd(a){return Na(a.data)+" -arc -arc-"+a.data.id}function Od(a){return Na(a)+" -area -area-"+a.id}function Pd(a,b){return"-shape -shape-"+b+" -circle -circle-"+b}function Dc(a,b){return"-shape -shape-"+
b+" -bar -bar-"+b}function Qd(a,b){return"region region-"+b+" "+("classes"in a?[].concat(a.classes).join(" "):"")}function Ec(a,b){return"event-rect event-rect-"+b}function Rd(a){return a.value?Fc(a)?0.5:1:0}function wa(a){return m(a.x)}function Oa(a){return m(B?na(a.value):a.value)}function Pa(a){return z(a.value)}function Gc(a){return V(a.x)}function Hc(a,b){var c,e=a[b].x,k=[];for(c=b-1;0<=c&&e===a[c].x;c--)k.push(a[c]);for(c=b;c<a.length&&e===a[c].x;c++)k.push(a[c]);return k}function Ic(a,b,c,
e){c=c?c:0;e=e?e:a.length-1;var k=Math.floor((e-c)/2)+c;0<m(a[k].x)-b[0]?e=k:c=k;return 1===e-c?(k=[],a[c].x&&(k=k.concat(Hc(a,c))),a[e].x&&(k=k.concat(Hc(a,e))),Jc(k,b)):Ic(a,b,c,e)}function Kc(a,b){var c;c=a.map(function(a){return Ic(a.values,b)});return Jc(c,b)}function Jc(a,b){var c,e;a.forEach(function(a){var d=Ob(a,b);if(d<c||!c)c=d,e=a});return e}function Lc(a,b){var c,e,k,d,f;0!==a.filter(function(a){return a.value}).length&&(W.html(Mc(a)).style("visibility","hidden").style("display","block"),
c=W.property("offsetWidth"),e=W.property("offsetHeight"),g?d=b[0]:(k=q.property("offsetLeft"),d=k+(ab?ab:bb?1:40)+m(a[0].x)+20,f=d+c,k=k+(null===$a?ca():$a)-(cb?cb:Bb?db||g?1:40:20),f>k&&(d-=c+30)),c=b[1]+15+e<X()?b[1]+15:b[1]-e,W.style("top",c+"px").style("left",d+"px").style("visibility","visible"))}function Nc(a){ma(h.data.targets,"scatter")||D(h.data.targets)||l.selectAll("line.xgrid-focus").style("visibility","visible").data([a]).attr(g?"y1":"x1",wa).attr(g?"y2":"x2",wa)}function Oc(){l.select("line.xgrid-focus").style("visibility",
"hidden")}function xa(a){return a.x||0===a.x?m(a.x):null}function ya(a){return w(a.id)(a.value)}function Sd(){var a={},b=0,c,e;nb(sb).forEach(function(k){for(c=0;c<t.length;c++)if(!(0>t[c].indexOf(k.id)))for(e=0;e<t[c].length;e++)if(t[c][e]in a){a[k.id]=a[t[c][e]];break}x(a[k.id])&&(a[k.id]=b++)});a.__max__=b-1;return a}function Td(a,b,c,e){var k=e?V:m;return b?function(e){var d=e.id in c?c[e.id]:0;return e.x||0===e.x?k(e.x)-a*(b/2-d):0}:function(){return 0}}function Ud(a){return function(b){return(a?
G(b.id):w(b.id))(b.value)}}function Vd(a,b){var c=Object.keys(a);return function(e,k){var d=b?G(e.id):w(e.id),f=d(0),g=f;nb(sb).forEach(function(b){b.id!==e.id&&a[b.id]===a[e.id]&&c.indexOf(b.id)<c.indexOf(e.id)&&0<b.values[k].value*e.value&&(g+=d(b.values[k].value)-f)});return g}}function Ma(a,b){var c=x(a)?rb():a;"string"===typeof c&&(c=[c]);for(var e=0;e<c.length;e++)C[c[e]]=b}function ma(a,b){var c=!1;a.forEach(function(a){C[a.id]===b&&(c=!0);a.id in C||"line"!==b||(c=!0)});return c}function D(a){return ma(a,
"pie")||ma(a,"dount")}function Pb(a){a="string"===typeof a?a:a.id;return!(a in C)||"line"===C[a]||"spline"===C[a]||"area"===C[a]||"area-spline"===C[a]}function Pc(a){a="string"===typeof a?a:a.id;return"spline"===C[a]||"area-spline"===C[a]}function sb(a){return"bar"===C["string"===typeof a?a:a.id]}function Fc(a){return"scatter"===C["string"===typeof a?a:a.id]}function Qc(a){a="string"===typeof a?a:a.id;return"pie"===C[a]||"dount"===C[a]}function Rc(a){return sb(a)?a.values:[]}function Wd(a){return Pb(a)||
Fc(a)?a.values:[]}function na(a){var b;if(!a)throw Error(a+" can not be parsed as d3.time with format "+Qb+". Maybe 'x' of this data is not defined. See data.x or data.xs option.");b=d.time.format(Qb).parse(a);if(!b)throw Error("Failed to parse '"+a+"' with format "+Qb);return b}function Sc(a,b){var c=d.mouse(a),e=d.select(a),k=1*e.attr("cx"),e=1*e.attr("cy");return Math.sqrt(Math.pow(k-c[0],2)+Math.pow(e-c[1],2))<b}function Tc(a){var b=d.mouse(a),c=d.select(a);a=1*c.attr("x");var e=1*c.attr("y"),
c=1*c.attr("width");return a-10<b[0]&&b[0]<a+c+10&&e-10<b[1]}function Xd(a,b){var c;for(c=0;c<b.length;c++)if(b[c].start<a&&a<=b[c].end)return!0;return!1}function Hd(a,b){var c=!1;Object.keys(a).forEach(function(e){a[e]===b&&(c=!0)});return c}function Ob(a,b){return Math.pow(m(a.x)-b[0],2)+Math.pow(z(a.value)-b[1],2)}function Uc(a,b,c){Yd(a,b);l.select(".selected-circles-"+b.id).selectAll(".selected-circle-"+c).data([b]).enter().append("circle").attr("class",function(){return"selected-circle selected-circle-"+
c}).attr("cx",g?ya:xa).attr("cy",g?xa:ya).attr("stroke",function(){return K(b.id)}).attr("r",1.4*Qa).transition().duration(100).attr("r",Qa)}function Rb(a,b,c){Zd(a,b);l.select(".selected-circles-"+b.id).selectAll(".selected-circle-"+c).transition().duration(100).attr("r",0).remove()}function Vc(a,b,c,e){a?Uc(b,c,e):Rb(b,c,e)}function $d(){}function Wc(){}function Xc(a,b,c,e){}function Sb(a){return a.filter(function(a){return null!==a.value})}function Tb(a,b){return(b?l.selectAll(".-circles-"+b):
l).selectAll(".-circle"+(a||0===a?"-"+a:""))}function Ub(a){Tb(a).filter(function(){return d.select(this).classed(aa)}).classed(aa,!1).attr("r",Vb)}function Yc(a){return l.selectAll(".-bar"+(a||0===a?"-"+a:""))}function ae(a,b,c,e){var d,f,h="M",l,m,za,n,r,p=[];if(u(e))for(d=0;d<e.length;d++)p[d]={},x(e[d].start)?p[d].start=a[0].x:p[d].start=B?na(e[d].start):e[d].start,x(e[d].end)?p[d].end=a[a.length-1].x:p[d].end=B?na(e[d].end):e[d].end;n=g?function(a){return c(a.value)}:function(a){return b(a.x)};
r=g?function(a){return b(a.x)}:function(a){return c(a.value)};e=B?function(a,e,d,k){var f=a.x.getTime();a=e.x-a.x;e=new Date(f+a*(d+k));return"M"+b(new Date(f+a*d))+" "+c(m(d))+" "+b(e)+" "+c(m(d+k))}:function(a,e,d,k){return"M"+b(l(d))+" "+c(m(d))+" "+b(l(d+k))+" "+c(m(d+k))};for(d=0;d<a.length;d++)if(x(p)||!Xd(a[d].x,p))h+=" "+n(a[d])+" "+r(a[d]);else{l=S(a[d-1].x,a[d].x);m=T(a[d-1].value,a[d].value);f=b(a[d].x)-b(a[d-1].x);za=c(a[d].value)-c(a[d-1].value);f=Math.sqrt(Math.pow(f,2)+Math.pow(za,
2));za=2/f;var q=2*za;for(f=za;1>=f;f+=q)h+=e(a[d-1],a[d],f,za)}return h}function Wb(a){var b;tb=d.select(ta);if(tb.empty())P.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');else{tb.html("");h.data.x={};h.data.targets=La(a);ra();R();m.domain(d.extent(ob(h.data.targets)));z.domain(mb("y"));Z.domain(mb("y2"));V.domain(m.domain());hb.domain(z.domain());ib.domain(Z.domain());J.ticks(10>a.length?a.length:10);va.ticks(be).outerTickSize(0).tickFormat(ce);
jb.ticks(de).outerTickSize(0).tickFormat(ee);U=m.domain();L.scale(V);pa&&E.scale(m);q=d.select(ta).append("svg").attr("width",p+A+Y).attr("height",s+r+O).on("mouseenter",fe).on("mouseleave",ge);ub=q.append("defs");ub.append("clipPath").attr("id",Xb).append("rect").attr("y",r).attr("width",p).attr("height",s-r);ub.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1-A).attr("y",-20).attr("width",N).attr("height",da);ub.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",
-A+1).attr("y",r-1).attr("width",ia).attr("height",yb);l=q.append("g").attr("transform",M.main);F=Aa?q.append("g").attr("transform",M.context):null;Ba=Ca?q.append("g").attr("transform",M.legend):null;W=d.select(ta).style("position","relative").append("div").style("position","absolute").style("z-index","10").style("display","none");l.append("g").attr("class","x axis").attr("clip-path",g?"":"url(#xaxis-clip)").attr("transform",M.x).call(g?va:J).append("text").attr("class","-axis-x-label").attr("x",
p).attr("dy","-.5em").style("text-anchor","end").text(he);l.append("g").attr("class","y axis").attr("clip-path",g?"url(#yaxis-clip)":"").call(g?J:va).append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(ie);Bb&&l.append("g").attr("class","y2 axis").attr("transform",M.y2).call(jb);a=l.append("g").attr("clip-path",Ra).attr("class","grid");Zc&&a.append("g").attr("class","xgrids");Yb&&(b=a.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(Yb).enter().append("g").attr("class",
"xgrid-line"),b.append("line").attr("class",function(a){return""+a["class"]}),b.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",g?"":"rotate(-90)").attr("dx",g?0:-r).attr("dy",-5).text(function(a){return a.text}));je&&a.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",g?0:-10).attr("x2",g?p:-10).attr("y1",g?-10:r).attr("y2",g?-10:s);$c&&a.append("g").attr("class","ygrids");Zb&&(a=a.append("g").attr("class",
"ygrid-lines").selectAll("ygrid-line").data(Zb).enter().append("g").attr("class","ygrid-line"),a.append("line").attr("class",function(a){return""+a["class"]}),a.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",g?"rotate(-90)":"").attr("dx",g?0:-r).attr("dy",-5).text(function(a){return a.text}));l.append("g").attr("clip-path",Ra).attr("class","regions");l.append("g").attr("clip-path",Ra).attr("class","chart");l.select(".chart").append("g").attr("class",
"event-rects").style("fill-opacity",0).style("cursor",pa?"ew-resize":null);l.select(".chart").append("g").attr("class","chart-bars");l.select(".chart").append("g").attr("class","chart-lines");l.select(".chart").append("g").attr("class","chart-arcs").attr("transform",M.arc);if(pa)l.insert("rect",ke?null:"g.grid").attr("class","zoom-rect").attr("width",p).attr("height",s).style("opacity",0).style("cursor","ew-resize").call(E).on("dblclick.zoom",null);null!==vb&&L.extent("function"!==typeof vb?vb:vb(ob()));
Aa&&(F.append("g").attr("clip-path",Ra).attr("class","chart"),F.select(".chart").append("g").attr("class","chart-bars"),F.select(".chart").append("g").attr("class","chart-lines"),F.append("g").attr("clip-path",Ra).attr("class","x brush").call(L).selectAll("rect").attr(g?"width":"height",g?Cb:eb),F.append("g").attr("class","x axis").attr("transform",M.subx).attr("clip-path",g?"url(#yaxis-clip)":"").call(gb));Ca&&wb(h.data.targets);ad(h.data.targets);I({withTransition:!1,withUpdateXDomain:!0});if(le){if(B&&
"string"===typeof Da){Da=na(Da);for(a=0;a<h.data.targets[0].values.length&&0!==h.data.targets[0].values[a].x-Da;a++);Da=a}W.html(Mc(h.data.targets.map(function(a){return qb(a.values[Da])})));W.style("top",bd.top).style("left",bd.left).style("display","block")}null==P.onresize&&(P.onresize=me());P.onresize.add&&P.onresize.add(ne)}}function oe(a){a.append("rect").attr("class",Ec).style("cursor",fa&&qa?"pointer":null).on("mouseover",function(a,c){if(!Sa&&!D(h.data.targets)){var e=h.data.targets.map(function(a){return qb(a.values[c])}),
d,f;if(0<Object.keys(Ka).length){f=[];for(var g in Ka)for(d=0;d<e.length;d++)if(e[d].id===g){f.push(e[d]);e.shift(d);break}e=f.concat(e)}$b&&Tb(c,void 0).classed(aa,!0).attr("r",ac);Yc(c).classed(aa,!1);Nc(e[0])}}).on("mouseout",function(a,c){D(h.data.targets)||(Oc(),W.style("display","none"),Ub(c),Yc(void 0).classed(aa,!1))}).on("mousemove",function(a,c){var e;Sa||D(h.data.targets)||(e=h.data.targets.map(function(a){return qb(a.values[c])}),Lc(e,d.mouse(this)),fa&&(qa||l.selectAll(".-shape-"+c).filter(function(a){return ga(a)}).each(function(){var a=
d.select(this).classed(aa,!0);"circle"===this.nodeName&&a.attr("r",ac);q.select(".event-rect-"+c).style("cursor",null)}).filter(function(){var a=d.select(this);if("circle"===this.nodeName)return Sc(this,Qa);if("rect"===this.nodeName)return Tc(this,a.attr("x"),a.attr("y"))}).each(function(){var a=d.select(this);a.classed(aa)||(a.classed(aa,!0),"circle"===this.nodeName&&a.attr("r",Qa));q.select(".event-rect-"+c).style("cursor","pointer")})))}).on("click",function(a,c){D(h.data.targets)||(bc?bc=!1:l.selectAll(".-shape-"+
c).each(function(a){cd(this,a,c)}))}).call(d.behavior.drag().origin(Object).on("drag",function(){dd(d.mouse(this))}).on("dragstart",function(){ed(d.mouse(this))}).on("dragend",function(){fd()})).call(E).on("dblclick.zoom",null)}function pe(a){a.append("rect").attr("x",0).attr("y",0).attr("width",p).attr("height",s).attr("class","event-rect").on("mouseout",function(){D(h.data.targets)||(Oc(),W.style("display","none"),Ub())}).on("mousemove",function(){var a,c,e;Sa||D(h.data.targets)||(a=d.mouse(this),
c=Kc(h.data.targets,a),e=[qb(c)],Lc(e,a),$b&&(Ub(),Tb(c.index,c.id).classed(aa,!0).attr("r",ac)),Nc(e[0]),100>Ob(c,a)?q.select(".event-rect").style("cursor","pointer"):q.select(".event-rect").style("cursor",null))}).on("click",function(){var a,c;D(h.data.targets)||(a=d.mouse(this),c=Kc(h.data.targets,a),100>Ob(c,a)&&l.select(".-circles-"+c.id).select(".-circle-"+c.index).each(function(){cd(this,c,c.index)}))}).call(d.behavior.drag().origin(Object).on("drag",function(){dd(d.mouse(this))}).on("dragstart",
function(){ed(d.mouse(this))}).on("dragend",function(){fd()})).call(E).on("dblclick.zoom",null)}function cd(a,b,c){var e=d.select(a),f=e.classed(ha),g=!1,h;"circle"===a.nodeName?(g=Sc(a,1.5*Qa),h=Vc):"rect"===a.nodeName&&(g=Tc(a),h=Xc);if(qa||g)fa&&ga(b)&&(e.classed(ha,!f),h(!f,e,b,c)),qe(b,e)}function dd(a){var b,c,e,f,g,m,p;D(h.data.targets)||!fa||pa&&!E.altDomain||(b=cc[0],c=cc[1],e=a[0],a=a[1],f=Math.min(b,e),g=Math.max(b,e),m=qa?r:Math.min(c,a),p=qa?s:Math.max(c,a),l.select(".dragarea").attr("x",
f).attr("y",m).attr("width",g-f).attr("height",p-m),l.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return ga(a)}).each(function(a,b){var c=d.select(this),e=c.classed(ha),h=c.classed(dc),l,n,r,q;l=!1;"circle"===this.nodeName?(l=1*c.attr("cx"),n=1*c.attr("cy"),q=Vc,l=f<l&&l<g&&m<n&&n<p):"rect"===this.nodeName&&(l=1*c.attr("x"),n=1*c.attr("y"),r=1*c.attr("width"),q=Xc,l=f<l+r&&l<g&&n<p);l^h&&(c.classed(dc,!h),c.classed(ha,!e),q(!e,c,a,b))}))}function ed(a){!D(h.data.targets)&&fa&&(cc=
a,l.select(".chart").append("rect").attr("class","dragarea").style("opacity",0.1),Sa=!0)}function fd(){!D(h.data.targets)&&fa&&(l.select(".dragarea").transition().duration(100).style("opacity",0).remove(),l.selectAll(".-shape").classed(dc,!1),Sa=!1)}function I(a){var b,c,e,f=Sd(),n=f.__max__+1,q,v,t=D(h.data.targets);a=u(a)?a:{};c=u(a.withY)?a.withY:!0;e=u(a.withSubchart)?a.withSubchart:!0;v=u(a.withTransition)?a.withTransition:!0;b=u(a.withUpdateXDomain)?a.withUpdateXDomain:!1;a=u(a.withUpdateOrgXDomain)?
a.withUpdateOrgXDomain:!1;v=v?250:0;a&&(m.domain(d.extent(ob(h.data.targets))),U=m.domain(),E.scale(m).updateScaleExtent(),V.domain(m.domain()),L.scale(V));b&&(m.domain(L.empty()?U:L.extent()),pa&&E.scale(m).updateScaleExtent());z.domain(mb("y"));Z.domain(mb("y2"));l.select(".x.axis").transition().duration(g?v:0).call(g?va:J).style("opacity",t?0:1);l.select(".y.axis").transition().duration(g?0:v).call(g?J:va).style("opacity",t?0:1);l.select(".y2.axis").transition().call(jb).style("opacity",t?0:1);
l.select(".x.axis .-axis-x-label").attr("x",p);hb.domain(z.domain());ib.domain(Z.domain());W.style("display","none");l.select("line.xgrid-focus").style("visibility","hidden").attr("y2",s);if(Zc){if("year"===re)for(b=[],a=ob(),t=a[0].getFullYear(),a=a[1].getFullYear();t<=a;t++)b.push(new Date(t+"-01-01 00:00:00"));else b=m.ticks(10);b=l.select(".xgrids").selectAll(".xgrid").data(b);b.enter().append("line").attr("class","xgrid");b.attr("x1",g?0:function(a){return m(a)-J.tickOffset()}).attr("x2",g?p:
function(a){return m(a)-J.tickOffset()}).attr("y1",g?function(a){return m(a)-J.tickOffset()}:r).attr("y2",g?function(a){return m(a)-J.tickOffset()}:s).style("opacity",function(){return+d.select(this).attr(g?"y1":"x1")===(g?s:0)?0:1});b.exit().remove()}Yb&&(b=l.selectAll(".xgrid-lines"),b.selectAll("line").transition().duration(v).attr("x1",g?0:Oa).attr("x2",g?p:Oa).attr("y1",g?Oa:r).attr("y2",g?Oa:s),b.selectAll("text").attr("x",g?p:0).attr("y",Oa));c&&$c&&(b=l.select(".ygrids").selectAll(".ygrid").data(z.ticks(10)),
b.enter().append("line").attr("class","ygrid"),b.attr("x1",g?z:0).attr("x2",g?z:p).attr("y1",g?0:z).attr("y2",g?s:z),b.exit().remove());c&&Zb&&(c=l.select(".ygrid-lines"),c.selectAll("line").transition().duration(v).attr("x1",g?Pa:0).attr("x2",g?Pa:p).attr("y1",g?0:Pa).attr("y2",g?s:Pa),c.selectAll("text").attr("x",g?0:p).attr("y",Pa));c=function(a){var b=ea?n?1.2*J.tickOffset()/n:0:0.6*((g?s:p)*(a?1:ua(U)/ua(m.domain()))/(fb()-1)),c=Td(b,n,f,!!a),e=Ud(!!a),d=Vd(f,!!a),h=a?G:w;return function(a,f){var k=
h(a.id)(0),l=d(a,f)||k,k=[[c(a),l],[c(a),e(a)-(k-l)],[c(a)+b,e(a)-(k-l)],[c(a)+b,l]],l=g?1:0,m=g?0:1;return"M "+k[0][l]+","+k[0][m]+" L"+k[1][l]+","+k[1][m]+" L"+k[2][l]+","+k[2][m]+" L"+k[3][l]+","+k[3][m]+" z"}};b=l.selectAll(".-bars").selectAll(".-bar").data(Rc);b.enter().append("path").attr("d",c(!1)).style("stroke","none").style("opacity",0).style("fill",function(a){return K(a.id)}).attr("class",Dc);b.transition().duration(v).attr("d",c(!1)).style("opacity",1);b.exit().transition().duration(v).style("opacity",
0).remove();l.selectAll(".chart-line").select(".-line").transition().duration(v).attr("d",se);l.selectAll(".-area").transition().duration(v).attr("d",te);b=l.selectAll(".-circles").selectAll(".-circle").data(Wd);b.enter().append("circle").attr("class",Pd).attr("r",Vb);b.transition().duration(v).style("opacity",Rd).attr("cx",g?ya:xa).attr("cy",g?xa:ya);b.exit().remove();l.selectAll(".chart-arc").select(".-arc").style("opacity",function(a){return a===this._current?0:1}).transition().duration(v).attrTween("d",
function(a){a=ja(a);if(!a)return function(){return"M 0 0"};var b=d.interpolate(this._current,a);this._current=b(0);return function(a){a=b(a);return Qc(a.data)?kb(a,!0):"M 0 0"}}).style("opacity",1);l.selectAll(".chart-arc").select("text").attr("transform",Xa).attr("opacity",0).transition().duration(v).text(Ya).attr("opacity",function(a){return Qc(a.data)?1:0});Aa&&(null!==d.event&&"zoom"===d.event.type&&L.extent(m.orgDomain()).update(),e&&(F.select(".x.axis").transition().duration(g?v:0).call(gb),
L.empty()||L.extent(m.orgDomain()).update(),e=F.selectAll(".-bars").selectAll(".-bar").data(Rc),e.enter().append("path").attr("d",c(!0)).style("stroke","none").style("fill",function(a){return K(a.id)}).attr("class",Dc),e.style("opacity",0).transition().duration(v).attr("d",c(!0)).style("opacity",1),e.exit().transition().duration(v).style("opacity",0).remove(),F.selectAll(".-line").transition().duration(v).attr("d",ue)));l.selectAll(".selected-circles").filter(function(a){return sb(a)}).selectAll("circle").remove();
l.selectAll(".selected-circle").transition().duration(v).attr("cx",g?ya:xa).attr("cy",g?xa:ya);$?(c=l.select(".event-rects").selectAll(".event-rect").data([0]),pe(c.enter()),c.attr("x",0).attr("y",0).attr("width",p).attr("height",s)):(Nb?(q=function(a,b){var c=yc(b),e=b<fb()-1?h.data.targets[0].values[b+1].x:void 0;return(m(e?e:a.x+50)-m(c?c:a.x-50))/2},e=function(a,b){var c=yc(b);return(m(a.x)+m(c?c:a.x-50))/2}):(q=md(),e=function(a){return m(a.x)-q/2}),c=Ld(),l.select(".event-rects").datum(c?c.values:
[]),c=l.select(".event-rects").selectAll(".event-rect").data(function(a){return a}),oe(c.enter()),c.attr("class",Ec).attr("x",g?0:e).attr("y",g?e:0).attr("width",g?p:q).attr("height",g?q:s),c.exit().remove());e=l.select(".regions").selectAll("rect.region").data(Q);e.enter().append("rect");e.attr("class",Qd).attr("x",g?0:Mb).attr("y",g?Mb:r).attr("width",g?p:tc).attr("height",g?tc:s).style("fill-opacity",function(a){return u(a.opacity)?a.opacity:0.1});e.exit().transition().duration(v).style("fill-opacity",
0).remove()}function ve(){"mousemove"===d.event.sourceEvent.type&&E.altDomain?(m.domain(E.altDomain),E.scale(m).updateScaleExtent()):(ea&&m.orgDomain()[0]===U[0]&&m.domain([U[0]-1E-10,m.orgDomain()[1]]),I({withTransition:!1,withY:!1,withSubchart:!1}),"mousemove"===d.event.sourceEvent.type&&(bc=!0))}function me(){function a(){b.forEach(function(a){a()})}var b=[];a.add=function(a){b.push(a)};return a}function ne(){ra();R();L.scale(V);pa&&E.scale(m);q.attr("width",zb).attr("height",sa);q.select("#"+
Xb).select("rect").attr("width",p).attr("height",s);q.select("#xaxis-clip").select("rect").attr("width",N);q.select(".zoom-rect").attr("width",p).attr("height",s);l.select(".x.axis").attr("transform",M.x);l.select(".y2.axis").attr("transform",M.y2);l.select(".chart-arcs").attr("transform",M.arc);Aa&&(F.attr("transform",M.context),F.select(".x.axis").attr("transform",M.subx));Ca&&(Ba.attr("transform",M.legend),wb(h.data.targets,{withTransition:!1}));I({withTransition:!1,withUpdateXDomain:!0})}function ad(a){var b;
l.select(".chart-bars").selectAll(".chart-bar").data(a).enter().append("g").attr("class",function(a){return"chart-bar target target-"+a.id}).style("pointer-events","none").style("opacity",0).append("g").attr("class",Cc).style("fill",function(a){return K(a.id)}).style("stroke",function(a){return K(a.id)}).style("stroke-width",0).style("cursor",function(a){return ga(a)?"pointer":null});b=l.select(".chart-lines").selectAll(".chart-line").data(a).enter().append("g").attr("class",function(a){return"chart-line target target-"+
a.id}).style("pointer-events","none").style("opacity",0);b.append("path").attr("class",Bc).style("stroke",function(a){return K(a.id)});b.append("path").attr("class",Od).style("fill",function(a){return K(a.id)});b.append("g").attr("class",function(a){return"selected-circles selected-circles-"+a.id});b.append("g").attr("class",Md).style("fill",function(a){return K(a.id)}).style("cursor",function(a){return ga(a)?"pointer":null});a.forEach(function(a){l.selectAll(".selected-circles-"+a.id).selectAll(".selected-circle").each(function(b){b.value=
a.values[b.x].value})});b=l.select(".chart-arcs").selectAll(".chart-arc").data(Lb(a)).enter().append("g").attr("class",function(a){return"chart-arc target target-"+a.data.id}).style("opacity",0);b.append("path").attr("class",Nd).style("fill",function(a){return K(a.data.id)}).style("cursor",function(a){return ga(a)?"pointer":null}).each(function(a){this._current=a}).on("mouseover",function(a){Za(a.data.id);gd(a.data.id)}).on("mouseout",function(a){xb(a.data.id);hd()});b.append("text").attr("dy",".35em").style("text-anchor",
"middle").style("pointer-events","none");Aa&&(b=F.select(".chart-bars").selectAll(".chart-bar").data(a),b=b.enter().append("g").attr("class",function(a){return"chart-bar target target-"+a.id}).style("opacity",0),b.append("g").attr("class",Cc).style("fill",function(a){return K(a.id)}),b=F.select(".chart-lines").selectAll(".chart-line").data(a),b=b.enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}).style("opacity",0),b.append("path").attr("class",Bc).style("stroke",
function(a){return K(a.id)}));Ca&&wb(a);q.selectAll(".target").transition().style("opacity",1)}function Ta(a,b){h.data.targets.forEach(function(b){for(var e=0;e<a.length;e++)if(b.id===a[e].id){b.values=a[e].values;a.splice(e,1);break}});h.data.targets=h.data.targets.concat(a);ad(h.data.targets);I({withUpdateOrgXDomain:!0,withUpdateXDomain:!0});b()}function gd(a){q.selectAll(".legend-item").filter(function(b){return b!==a}).transition().duration(100).style("opacity",0.3)}function hd(){q.selectAll(".legend-item").transition().duration(100).style("opacity",
1)}function wb(a,b){var c=rb(a),e,d=p/2-Ua*Object.keys(a).length/2,f;b=x(b)?{}:b;f=u(b.withTransition)?b.withTransition:!0;e=Ba.selectAll(".legend-item").data(c).enter().append("g").attr("class",function(a){return"legend-item legend-item-"+a}).style("cursor","pointer").on("click",function(a){we(a)}).on("mouseover",function(a){gd(a);h.focus(a)}).on("mouseout",function(){hd();h.revert()});e.append("rect").attr("class","legend-item-event").style("fill-opacity",0).attr("x",-200).attr("y",function(){return la/
2-16}).attr("width",Ua).attr("height",24);e.append("rect").attr("class","legend-item-tile").style("pointer-events","none").style("fill",function(a){return K(a)}).attr("x",-200).attr("y",function(){return la/2-9}).attr("width",10).attr("height",10);e.append("text").text(function(a){return u(Ka[a])?Ka[a]:a}).style("pointer-events","none").attr("x",-200).attr("y",function(){return la/2});Ba.selectAll("rect.legend-item-event").data(c).transition().duration(f?250:0).attr("x",function(a,b){return d+Ua*
b});Ba.selectAll("rect.legend-item-tile").data(c).transition().duration(f?250:0).attr("x",function(a,b){return d+Ua*b});Ba.selectAll("text").data(c).transition().duration(f?250:0).attr("x",function(a,b){return d+Ua*b+14})}function Va(a){return u(a)?".target-"+a:".target"}function ec(a){return zc(a.id)}function fc(a){return"data"in a&&zc(a.data.id)}var h={data:{}},pb={},aa="_expanded_",ha="_selected_",dc="_included_",ta=f(["bindto"],"#chart"),$a=f(["size","width"],null),mc=f(["size","height"],null),
ab=f(["padding","left"],null),cb=f(["padding","right"],null),pa=f(["zoom","enabled"],!1),id=f(["zoom","extent"],null),ke=f(["zoom","privileged"],!1),fe=f(["onenter"],function(){}),ge=f(["onleave"],function(){});if(!("data"in ba))throw Error("data is required in config");var oa=f(["data","x"],null),$=f(["data","xs"],null),Qb=f(["data","x_format"],"%Y-%m-%d"),Kd=f(["data","id_converter"],function(a){return a}),Ka=f(["data","names"],{}),t=f(["data","groups"],[]),pc=f(["data","axes"],{}),xc=f(["data",
"type"],null),C=f(["data","types"],{}),jd=f(["data","regions"],{}),xe=f(["data","colors"],{}),fa=f(["data","selection","enabled"],!1),qa=f(["data","selection","grouped"],!1),ga=f(["data","selection","isselectable"],function(){return!0}),Aa=f(["subchart","show"],!1),Ab=Aa?f(["subchart","size","height"],60):0,ye=f(["color","pattern"],null),Ca=f(["legend","show"],!0),Ua=f(["legend","item","width"],80),we=f(["legend","item","onclick"],function(){}),kd=f(["axis","x","type"],"indexed"),Ha=f(["axis","x",
"categories"],[]),rd=f(["axis","x","tick","centered"],!1),lb=f(["axis","x","tick","format"],null),vb=f(["axis","x","default"],null),he=f(["axis","x","label"],null),Ad=f(["axis","y","max"],null),yd=f(["axis","y","min"],null),Cd=f(["axis","y","center"],null),ie=f(["axis","y","label"],null),bb=f(["axis","y","inner"],!1),ce=f(["axis","y","tick","format"],function(a){return a}),Ia=f(["axis","y","padding"],null),be=f(["axis","y","ticks"],10),Bb=f(["axis","y2","show"],!1),zd=f(["axis","y2","max"],null),
xd=f(["axis","y2","min"],null),Bd=f(["axis","y2","center"],null),db=f(["axis","y2","inner"],!1),ee=f(["axis","y2","tick","format"],function(a){return a}),Ja=f(["axis","y2","padding"],null),de=f(["axis","y2","ticks"],10),g=f(["axis","rotated"],!1),Zc=f(["grid","x","show"],!1),re=f(["grid","x","type"],"tick"),Yb=f(["grid","x","lines"],null),$c=f(["grid","y","show"],!1),Zb=f(["grid","y","lines"],null),Vb=f(["point","show"],!0)?f(["point","r"],2.5):0,je=f(["point","focus","line","enabled"],!0),$b=f(["point",
"focus","expand","enabled"],!0),ac=f(["point","focus","expand","r"],$b?4:Vb),Qa=f(["point","focus","select","r"],8),qe=f(["point","onclick"],function(){}),Yd=f(["point","onselected"],function(){}),Zd=f(["point","onunselected"],function(){}),Q=f(["regions"],[]),Mc=f(["tooltip","contents"],function(a){var b="<table class='-tooltip'><tr><th colspan='2'>"+jc()(a[0].x)+"</th></tr>",c,d,f;for(c=0;c<a.length;c++)a[c]&&(a[c].value||0===a[c].value)&&(d=u(a[c].value)?(Math.round(100*a[c].value)/100).toFixed(2):
"-",f=a[c].name,b+="<tr class='-tooltip-name-"+a[c].id+"'><td class='name'><span style='background-color:"+K(a[c].id)+"'></span>"+f+"</td><td class='value'>"+d+"</td></tr>");return b+"</table>"}),le=f(["tooltip","init","show"],!1),Da=f(["tooltip","init","x"],0),bd=f(["tooltip","init","position"],{top:"0px",left:"50px"}),Xb=ta.replace("#","")+"-clip",Ra="url(#"+Xb+")",B="timeseries"===kd,ea="categorized"===kd,Nb=!B&&(oa||$),cc=null,Sa=!1,bc=!1,la=Ca?40:0,K=function(a,b){var c=[],d=null!==b?b:"#1f77b4 #ff7f0e #2ca02c #d62728 #9467bd #8c564b #e377c2 #7f7f7f #bcbd22 #17becf".split(" ");
return function(b){if(b in a)return a[b];-1===c.indexOf(b)&&c.push(b);return d[c.indexOf(b)%d.length]}}(xe,ye),sd=function(){var a=[[d.time.format("%Y/%-m/%-d"),function(){return!0}],[d.time.format("%-m/%-d"),function(a){return a.getMonth()}],[d.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[d.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[d.time.format("%I %p"),function(a){return a.getHours()}],[d.time.format("%I:%M"),function(a){return a.getMinutes()}],[d.time.format(":%S"),
function(a){return a.getSeconds()}],[d.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)}}(),p,Cb,s,eb,zb,sa,Ga,Db,Eb,kb,nc,oc,Lb,Fb,Gb,Hb,Ib,Jb,Kb,m,z,Z,V,hb,ib,J,va,jb,gb,nd=g?"left":"bottom",od=g?bb?"top":"bottom":bb?"right":"left",pd=g?db?"bottom":"top":db?"left":"right",qd=g?"left":"bottom",M={main:function(){return"translate("+A+","+r+")"},context:function(){return"translate("+Fa+","+Ea+")"},legend:function(){return"translate("+
hc+","+gc+")"},y2:function(){return"translate("+(g?0:p)+","+(g?10:0)+")"},x:function(){return"translate(0,"+s+")"},subx:function(){return"translate(0,"+(g?0:eb)+")"},arc:function(){return"translate("+p/2+","+s/2+")"}},lc=40,kc=20;Lb=d.layout.pie().value(function(a){return a.values.reduce(function(a,c){return a+c.value},0)});var se=function(){var a=d.svg.line().x(g?function(a){return w(a.id)(a.value)}:wa).y(g?wa:function(a){return w(a.id)(a.value)});return function(b){var c=Sb(b.values),d;if(Pb(b))return Pc(b)?
a.interpolate("cardinal"):a.interpolate("linear"),jd[b.id]?ae(c,m,w(b.id),jd[b.id]):a(c);d=m(c[0].x);b=w(b.id)(c[0].value);return g?"M "+b+" "+d:"M "+d+" "+b}}(),te=function(){var a;a=g?d.svg.area().x0(function(a){return w(a.id)(0)}).x1(function(a){return w(a.id)(a.value)}).y(wa):d.svg.area().x(wa).y0(function(a){return w(a.id)(0)}).y1(function(a){return w(a.id)(a.value)});return function(b){var c=Sb(b.values),d;if(ma([b],"area")||ma([b],"area-spline"))return Pc(b)?a.interpolate("cardinal"):a.interpolate("linear"),
a(c);d=m(c[0].x);b=w(b.id)(c[0].value);return g?"M "+b+" "+d:"M "+d+" "+b}}(),ue=function(){var a=d.svg.line().x(g?function(a){return G(a.id)(a.value)}:Gc).y(g?Gc:function(a){return G(a.id)(a.value)});return function(b){var c=Sb(b.values);return Pb(b)?a(c):"M "+V(c[0].x)+" "+G(b.id)(c[0].value)}}(),L=d.svg.brush().on("brush",function(){I({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}),E=d.behavior.zoom().on("zoomstart",function(){E.altDomain=d.event.sourceEvent.altKey?m.orgDomain():
null}).on("zoom",pa?ve:null);L.update=function(){F&&F.select(".x.brush").call(this);return this};L.scale=function(a){return g?this.y(a):this.x(a)};E.scale=function(a){return g?this.y(a):this.x(a)};E.orgScaleExtent=function(){var a=id?id:[1,10];return[a[0],Math.max(fb()/a[1],a[1])]};E.updateScaleExtent=function(){var a=ua(m.orgDomain())/ua(U),b=this.orgScaleExtent();this.scaleExtent([b[0]*a,b[1]*a]);return this};var q,ub,l,F,Ba,W,tb,U;h.focus=function(a){var b=q.selectAll(Va(a)),c=b.filter(ec),b=b.filter(fc);
h.defocus();c.classed("focused",!0).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity",1);D(h.data.targets)&&Za(a,!0)};h.defocus=function(a){var b=q.selectAll(Va(a)),c=b.filter(ec),b=b.filter(fc);c.classed("focused",!1).transition().duration(100).style("opacity",0.3);b.transition().duration(100).style("opacity",0.3);D(h.data.targets)&&xb(a)};h.revert=function(a){var b=q.selectAll(Va(a)),c=b.filter(ec),b=b.filter(fc);c.classed("focused",!1).transition().duration(100).style("opacity",
1);b.transition().duration(100).style("opacity",1);D(h.data.targets)&&xb(a)};h.show=function(a){q.selectAll(Va(a)).transition().style("opacity",1)};h.hide=function(a){q.selectAll(Va(a)).transition().style("opacity",0)};h.unzoom=function(){L.clear().update();I({withUpdateXDomain:!0})};h.load=function(a){"function"!==typeof a.done&&(a.done=function(){});a.xs&&Jd(a.xs);"categories"in a&&ea&&(Ha=a.categories,J.categories(Ha));if("cacheIds"in a&&Fd(a.cacheIds))Ta(Gd(a.cacheIds),a.done);else if("data"in
a)Ta(La(a.data),a.done);else if("url"in a)d.csv(a.url,function(b,c){Ta(La(c),a.done)});else if("rows"in a)Ta(La(vc(a.rows)),a.done);else if("columns"in a)Ta(La(wc(a.columns)),a.done);else throw Error("url or rows or columns is required.");};h.unload=function(a){h.data.targets=h.data.targets.filter(function(b){return b.id!==a});q.selectAll(".target-"+a).transition().style("opacity",0).remove();Ca&&(q.selectAll(".legend-item-"+a).remove(),wb(h.data.targets));0<h.data.targets.length&&I({withUpdateOrgXDomain:!0,
withUpdateXDomain:!0})};h.selected=function(a){a=u(a)?"-"+a:"";return d.merge(l.selectAll(".-shapes"+a).selectAll(".-shape").filter(function(){return d.select(this).classed(ha)}).map(function(a){return a.map(function(a){return a.__data__})}))};h.select=function(a,b,c){fa&&l.selectAll(".-shapes").selectAll(".-shape").each(function(e,f){var g="circle"===this.nodeName?Uc:$d,h="circle"===this.nodeName?Rb:Wc;0<=b.indexOf(f)?ga(e)&&(qa||x(a)||0<=a.indexOf(e.id))&&g(d.select(this).classed(ha,!0),e,f):u(c)&&
c&&h(d.select(this).classed(ha,!1),e,f)})};h.unselect=function(a,b){fa&&l.selectAll(".-shapes").selectAll(".-shape").each(function(c,e){var f="circle"===this.nodeName?Rb:Wc;(x(b)||0<=b.indexOf(e))&&ga(c)&&(qa||x(a)||0<=a.indexOf(c.id))&&f(d.select(this).classed(ha,!1),c,e)})};h.toLine=function(a){Ma(a,"line");I()};h.toSpline=function(a){Ma(a,"spline");I()};h.toBar=function(a){Ma(a,"bar");I()};h.toScatter=function(a){Ma(a,"scatter");I()};h.groups=function(a){if(x(a))return t;t=a;I();return t};h.regions=
function(a){if(x(a))return Q;Q=a;I();return Q};h.regions.add=function(a){if(x(a))return Q;Q=Q.concat(a);I();return Q};h.regions.remove=function(a,b){var c=[].concat(a);b=u(b)?b:{};c.forEach(function(a){var c=q.selectAll("."+a);u(b.duration)&&(c=c.transition().duration(b.duration).style("fill-opacity",0));c.remove();Q=Q.filter(function(b){return 0>b.classes.indexOf(a)})});return Q};h.data.get=function(a){a=h.data.getAsTarget(a);return u(a)?a.values.map(function(a){return a.value}):void 0};h.data.getAsTarget=
function(a){var b=nb(function(b){return b.id===a});return 0<b.length?b[0]:void 0};h.destroy=function(){h.data.targets=void 0;h.data.x={};tb.html("");P.onresize=null};if("url"in ba.data)d.csv(ba.data.url,function(a,b){Wb(b)});else if("rows"in ba.data)Wb(vc(ba.data.rows));else if("columns"in ba.data)Wb(wc(ba.data.columns));else throw Error("url or rows or columns is required.");return h}})(window);

Loading…
Cancel
Save