Browse Source

Enable to specify padding of axis as top and bottom

pull/1/head
Masayuki Tanaka 11 years ago
parent
commit
c5bb0515ce
  1. 13
      c3.js
  2. 116
      c3.min.js
  3. 116
      htdocs/js/c3.min.js

13
c3.js

@ -403,15 +403,22 @@
yDomainMin = (yMin !== null) ? yMin : getYDomainMin(yTargets),
yDomainMax = (yMax !== null) ? yMax : getYDomainMax(yTargets),
padding = Math.abs(yDomainMax - yDomainMin) * 0.1,
padding_top = padding, padding_bottom = padding,
center = axisId === 'y2' ? __axis_y2_center : __axis_y_center;
if (center !== null) {
yDomainAbs = Math.max(Math.abs(yDomainMin), Math.abs(yDomainMax));
yDomainMax = yDomainAbs - center;
yDomainMin = center - yDomainAbs;
}
if (axisId === 'y' && __axis_y_padding !== null) padding = __axis_y_padding;
if (axisId === 'y2' && __axis_y2_padding !== null) padding = __axis_y2_padding;
return [hasBarType(yTargets) ? 0 : yDomainMin-padding, yDomainMax+padding];
if (axisId === 'y' && __axis_y_padding !== null) {
padding_top = isDefined(__axis_y_padding.top) ? __axis_y_padding.top : padding;
padding_bottom = isDefined(__axis_y_padding.bottom) ? __axis_y_padding.bottom : padding;
}
if (axisId === 'y2' && __axis_y2_padding !== null) {
padding_top = isDefined(__axis_y2_padding.top) ? __axis_y2_padding.top : padding;
padding_bottom = isDefined(__axis_y2_padding.bottom) ? __axis_y2_padding.bottom : padding;
}
return [hasBarType(yTargets) ? 0 : yDomainMin-padding_bottom, yDomainMax+padding_top];
}
function getXDomainRatio () {
if (brush.empty()) return 1;

116
c3.min.js vendored

@ -1,61 +1,61 @@
(function(mb){function nb(){function l(c,k){c.attr("transform",function(c){return"translate("+(k(c)+R)+",0)"})}function u(c,k){c.attr("transform",function(c){return"translate(0,"+k(c)+")"})}function Ca(c){var k=c[0];c=c[c.length-1];return k<c?[k,c]:[c,k]}function ma(c){for(var k=[],l=Math.ceil(c[0]);l<c[1];l++)k.push(l);0<k.length&&0<k[0]&&k.unshift(k[0]-(k[1]-k[0]));return k}function r(A){A.each(function(){var k=d3.select(this),A=ma(I.domain()),r=k.selectAll(".tick.major").data(A,String),S=r.enter().insert("g",
"path").attr("class","tick major").style("opacity",1E-6),da=d3.transition(r.exit()).style("opacity",1E-6).remove(),ea=d3.transition(r).style("opacity",1),B,F=I.rangeExtent?I.rangeExtent():Ca(I.range()),k=k.selectAll(".domain").data([0]),k=(k.enter().append("path").attr("class","domain"),d3.transition(k)),C=I.copy(),Ea=this.__chart__||C;this.__chart__=C;S.append("line");S.append("text");var na=S.select("line"),oa=ea.select("line"),L=r.select("text"),pa=S.select("text"),qa=ea.select("text");R=(C(1)-
C(0))/2;r=c?0:R;switch(t){case "bottom":B=l;na.attr("y2",D);pa.attr("y",Math.max(D,0)+G);oa.attr("x1",r).attr("x2",r).attr("y2",D);qa.attr("x",0).attr("y",Math.max(D,0)+G);L.attr("dy",".71em").style("text-anchor","middle");L.text(function(c){return A.length<O||0==c%Math.ceil(A.length/O)?c<M.length?M[c]:c:""});k.attr("d","M"+F[0]+","+T+"V0H"+F[1]+"V"+T);break;case "left":B=u,na.attr("x2",-D),pa.attr("x",-(Math.max(D,0)+G)),oa.attr("x2",-D).attr("y2",0),qa.attr("x",-(Math.max(D,0)+G)).attr("y",R),L.attr("dy",
".32em").style("text-anchor","end"),L.text(function(c){return A.length<O||0==c%Math.ceil(A.length/O)?c<M.length?M[c]:c:""}),k.attr("d","M"+-T+","+F[0]+"H0V"+F[1]+"H"+-T)}if(I.ticks)S.call(B,Ea),ea.call(B,C),da.call(B,C);else{var ra=C.rangeBand()/2,da=function(c){return C(c)+ra};S.call(B,da);ea.call(B,da)}})}var I=d3.scale.linear(),t="bottom",D=6,T=6,G=3,c=!1,O=10,R=0,M=[];r.scale=function(c){if(!arguments.length)return I;I=c;return r};r.orient=function(c){if(!arguments.length)return t;t=c in{top:1,
right:1,bottom:1,left:1}?c+"":"bottom";return r};r.categories=function(c){if(!arguments.length)return M;M=c;return r};r.tickCentered=function(l){if(!arguments.length)return c;c=l;return r};r.tickTextNum=function(c){if(!arguments.length)return O;O=c;return r};r.tickOffset=function(){return R};r.ticks=function(){};return r}function u(l){return"undefined"===typeof l}function l(l){return"undefined"!==typeof l}mb.c3={};c3.generate=function(z){var ob,Ca,ma,r,I,t,D,T,G;function c(a,b){for(var d=z,e=0;e<
a.length;e++){if(!(a[e]in d))return b;d=d[a[e]]}return d}function O(){pb=20+qb+$;rb=!sb||f||Ua?1:50;left=Va?0:40;tb=Fa-qb-$;ub=20+$;vb=Fa-$;t=0;D=rb;T=pb;G=left;ma=tb;r=ub;I=left;ob=vb;Ca=left;q=(null==wb?+d3.select(z.bindto).style("width").replace("px",""):wb)-G-D;w=Fa-t-T;fa=Fa-ma-r}function R(){var a,b,d,e;xb=f?10:0;yb=f?w:q;Wa=f?0:w;Xa=f?q:1;a=M(xb,yb);b=A(Wa,Xa);d=A(Wa,Xa);e=M(0,q);p=l(p)?a.domain(p.domain()):a;x=l(x)?b.domain(x.domain()):b;P=l(P)?d.domain(P.domain()):d;y=l(y)?e.domain(y.domain()):
e;Ga=A(fa,10);Ha=A(fa,10);E.scale(p).orient(f?"left":"bottom");ga.scale(x).orient(f?Va?"top":"bottom":Va?"right":"left");Ia.scale(P).orient(f?Ua?"bottom":"top":Ua?"left":"right");ha.scale(y).orient("bottom")}function M(a,b){return(H?d3.time.scale():d3.scale.linear()).range([a,b])}function A(a,b){return d3.scale.linear().range([a,b])}function k(a){return d3.min(a,function(a){return d3.min(a.values,function(a){return a.value})})}function ac(a){var b={},d,e;a.forEach(function(a){b[a.id]=[];a.values.forEach(function(d){b[a.id].push(d.value)})});
for(d=0;d<v.length;d++)for(e=1;e<v[d].length;e++)sa(v[d][e])&&(u(b[v[d][e]])||b[v[d][e]].forEach(function(a,c){B(v[d][e])===B(v[d][0])&&(b[v[d][0]][c]+=1*a)}));return d3.max(Object.keys(b).map(function(a){return d3.max(b[a])}))}function Da(a,b){var d=Ja(function(a){return B(a.id)===b}),e="y2"===b?bc:cc,n="y2"===b?dc:ec,e=null!==e?e:k(d),n=null!==n?n:ac(d),c=0.1*Math.abs(n-e),m="y2"===b?fc:gc;null!==m&&(yDomainAbs=Math.max(Math.abs(e),Math.abs(n)),n=yDomainAbs-m,e=m-yDomainAbs);"y"===b&&null!==zb&&
(c=zb);"y2"===b&&null!==Ab&&(c=Ab);return[hc(d,"bar")?0:e-c,n+c]}function S(){if(ia.empty())return 1;var a=y.domain(),b=ia.extent();return(a[1]-a[0])/(b[1]-b[0])}function da(a){for(var b=0;b<a.length;b++)if(!(a[b]in Ka))return!1;return!0}function ea(a){for(var b=[],d=0;d<a.length;d++)a[d]in Ka&&b.push(pa(Ka[a[d]]));return b}function B(a){return a in Bb?Bb[a]:"y"}function F(a){return"y2"===B(a)?P:x}function C(a){return"y2"===B(a)?Ha:Ga}function Ea(a){var b=ta[a.id];a.name=l(b)?b:a.id;return a}function na(a){var b=
a[0],d={},e=[],n,c;for(n=1;n<a.length;n++){d={};for(c=0;c<a[n].length;c++)d[b[c]]=a[n][c];e.push(d)}return e}function oa(a){var b=[],d,e,n;for(d=0;d<a.length;d++)for(n=a[d][0],e=1;e<a[d].length;e++)u(b[e-1])&&(b[e-1]={}),b[e-1][n]=a[d][e];return b}function L(a){var b=d3.keys(a[0]).filter(function(a){return a!==La}),d=0,e;a.forEach(function(a){if(H){if(!(La in a))throw Error("'"+La+"' must be included in data");e=aa(a[La]);if(null===e)throw Error("Failed to parse timeseries date in data");a.x=e}else a.x=
d++;null===Ma&&(Ma=new Date(a.x));Ya=new Date(a.x)});b=b.map(function(b,d){var e=ic(b);return{id:e,id_org:b,values:a.map(function(a){return{x:a.x,value:+a[b],id:e}})}});b.forEach(function(a){Ka[a.id_org]=pa(a)});return b}function pa(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 qa(){return d3.max(h.data.targets,function(a){return a.values.length})}function ra(a){a=u(a)?h.data.targets:a;return a.map(function(a){return a.id})}function Ta(a){var b=
ra(),d;for(d=0;d<b.length;d++)if(b[d]===a)return!0;return!1}function Ja(a){return l(a)?h.data.targets.filter(a):h.data.targets}function Za(a){return"-shapes -shapes-"+a.id}function Cb(a){return Za(a)+" -line -line-"+a.id}function jc(a){return Za(a)+" -circles -circles-"+a.id}function Db(a){return Za(a)+" -bars -bars-"+a.id}function kc(a,b){return"-shape -shape-"+b+" -circle -circle-"+b}function Eb(a,b){return"-shape -shape-"+b+" -bar -bar-"+b}function lc(a,b){return"region region-"+b+" "+("classes"in
a?[].concat(a.classes).join(" "):"")}function Na(a){return p(a.x)}function ua(a){return p(H?aa(a.value):a.value)}function Fb(a){return x(a.value)}function U(a){return p(a.x)}function V(a){return F(a.id)(a.value)}function mc(){var a={},b=0,d,e;Ja(sa).forEach(function(c){for(d=0;d<v.length;d++)if(!(0>v[d].indexOf(c.id)))for(e=0;e<v[d].length;e++)if(v[d][e]in a){a[c.id]=a[v[d][e]];break}u(a[c.id])&&(a[c.id]=b++)});a.__max__=b-1;return a}function Gb(a,b,d,e){var c=e?y:p;return function(e){var m=e.id in
d?d[e.id]:0;return c(e.x)-a*(b/2-m)}}function Hb(a,b,d,e){var c=Object.keys(b);return function(f,m){var g=0,h=e?C(f.id):F(f.id);Ja(sa).forEach(function(d){d.id!==f.id&&b[d.id]===b[f.id]&&c.indexOf(d.id)<c.indexOf(f.id)&&(g+=a(d.values[m]))});return d?g:h(f.value)-g}}function Ib(a,b){var d=null===a?function(a){return a}:function(b){return a-b};return function(a){var c=b?C(a.id):F(a.id);return d(c(a.value))}}function $a(a,b){var d=u(a)?ra():a;"string"===typeof d&&(d=[d]);for(var e=0;e<d.length;e++)W[d[e]]=
b}function hc(a,b){var d=!1;a.forEach(function(a){W[a.id]===b&&(d=!0);a.id in W||"line"!==b||(d=!0)});return d}function ab(a){a="string"===typeof a?a:a.id;return!(a in W)||"line"===W[a]||"spline"===W[a]}function sa(a){return"bar"===W["string"===typeof a?a:a.id]}function nc(a){return ab(a)?a.values:[]}function Jb(a){return sa(a)?a.values:[]}function Kb(a,b){var d=d3.mouse(a),e=d3.select(a),c=1*e.attr("cx"),e=1*e.attr("cy");return Math.sqrt(Math.pow(c-d[0],2)+Math.pow(e-d[1],2))<b}function Lb(a){var b=
d3.mouse(a),d=d3.select(a);a=1*d.attr("x");var e=1*d.attr("y"),d=1*d.attr("width");return a-10<b[0]&&b[0]<a+d+10&&e-10<b[1]}function oc(a,b){var d;for(d=0;d<b.length;d++)if(b[d].start<a&&a<=b[d].end)return!0;return!1}function Mb(a,b,d){pc(a,b);g.select(".selected-circles-"+b.id).selectAll(".selected-circle-"+d).data([b]).enter().append("circle").attr("class",function(a){return"selected-circle selected-circle-"+d}).attr("cx",f?V:U).attr("cy",f?U:V).attr("stroke",function(){return Q(b.id)}).attr("r",
1.4*va).transition().duration(100).attr("r",va)}function bb(a,b,d){qc(a,b);g.select(".selected-circles-"+b.id).selectAll(".selected-circle-"+d).transition().duration(100).attr("r",0).remove()}function Nb(a,b,d,e){a?Mb(b,d,e):bb(b,d,e)}function rc(a,b,d){}function Ob(a,b,d){}function Pb(a,b,d,e){}function sc(a,b,d,e){var c,s,m="M",g,h,k,p,r,q=[];if(l(e))for(c=0;c<e.length;c++)q[c]={},u(e[c].start)?q[c].start=a[0].x:H&&(q[c].start=aa(e[c].start)),u(e[c].end)?q[c].end=a[a.length-1].x:H&&(q[c].end=aa(e[c].end));
p=f?function(a){return d(a.value)}:function(a){return b(a.x)};r=f?function(a){return b(a.x)}:function(a){return d(a.value)};e=H?function(a,c,e,m){var n=a.x.getTime();a=c.x-a.x;c=new Date(n+a*(e+m));return"M"+b(new Date(n+a*e))+" "+d(h(e))+" "+b(c)+" "+d(h(e+m))}:function(a,c,e,m){return"M"+b(g(e))+" "+d(h(e))+" "+b(g(e+m))+" "+d(h(e+m))};for(c=0;c<a.length;c++)if(u(q)||!oc(a[c].x,q))m+=" "+p(a[c])+" "+r(a[c]);else for(g=M(a[c-1].x,a[c].x),h=A(a[c-1].value,a[c].value),s=b(a[c].x)-b(a[c-1].x),k=d(a[c].value)-
d(a[c-1].value),s=Math.sqrt(Math.pow(s,2)+Math.pow(k,2)),k=2/s,diffx2=2*k,s=k;1>=s;s+=diffx2)m+=e(a[c-1],a[c],s,k);return m}function cb(a){var b=h.data.targets=L(a),d,c;p.domain(d3.extent(a.map(function(a){return a.x})));x.domain(Da(b,"y"));P.domain(Da(b,"y2"));y.domain(p.domain());Ga.domain(x.domain());Ha.domain(P.domain());E.ticks(10>a.length?a.length:10);ga.ticks(3).outerTickSize(0).tickFormat(tc);Ia.ticks(3).outerTickSize(0).tickFormat(uc);g.append("g").attr("class","x axis").attr("clip-path",
f?"":"url(#xaxis-clip)").attr("transform","translate(0,"+w+")").call(f?ga:E);g.append("g").attr("class","y axis").attr("clip-path",f?"url(#yaxis-clip)":"").call(f?E:ga).append("text").attr("transform","rotate(-90)").attr("dy","1.4em").attr("dx","-.8em").style("text-anchor","end").text(vc);sb&&g.append("g").attr("class","y2 axis").attr("transform","translate("+(f?0:q)+","+(f?10:0)+")").call(Ia);d=g.append("g").attr("clip-path",Oa).attr("class","grid");Qb&&d.append("g").attr("class","xgrids");db&&(c=
d.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(db).enter().append("g").attr("class","xgrid-line"),c.append("line").attr("class",function(a){return""+a["class"]}),c.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",f?"":"rotate(-90)").attr("dx",f?0:-t).attr("dy",-6).text(function(a){return a.text}));wc&&d.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",f?0:-10).attr("x2",f?q:
-10).attr("y1",f?-10:t).attr("y2",f?-10:w);Rb&&d.append("g").attr("class","ygrids");eb&&d.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(eb).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]});g.append("g").attr("clip-path",Oa).attr("class","regions");g.append("g").attr("clip-path",Oa).attr("class","chart");g.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).selectAll(".event-rects").data(a).enter().append("rect").attr("class",
function(a,b){return"event-rect event-rect-"+b}).style("cursor",function(a){return X&&ba?"pointer":null}).on("mouseover",function(a,b){if(!Pa){var d=h.data.targets.map(function(a){return Ea(a.values[b])}),c,e;if(0<Object.keys(ta).length){e=[];for(var k in ta)for(c=0;c<d.length;c++)if(d[c].id===k){e.push(d[c]);d.shift(c);break}d=e.concat(d)}Sb&&g.selectAll(".-circle-"+b).classed(Y,!0).attr("r",Tb);g.selectAll(".-bar-"+b).classed(Y,!0);g.selectAll("line.xgrid-focus").style("visibility","visible").data([d[0]]).attr(f?
"y1":"x1",Na).attr(f?"y2":"x2",Na);ja.style("top",d3.mouse(this)[1]+30+"px").style("left",(f?d3.mouse(this)[0]:p(d[0].x))+60+"px");ja.html(Ub(d));ja.style("visibility","visible")}}).on("mouseout",function(a,b){g.select("line.xgrid-focus").style("visibility","hidden");ja.style("visibility","hidden");g.selectAll(".-circle-"+b).filter(function(){return d3.select(this).classed(Y)}).classed(Y,!1).attr("r",fb);g.selectAll(".-bar-"+b).classed(Y,!1)}).on("mousemove",function(a,b){X&&!Pa&&(ba||g.selectAll(".-shape-"+
b).filter(function(a){return ca(a)}).each(function(a){a=d3.select(this).classed(Y,!0);"circle"===this.nodeName&&a.attr("r",Tb);d3.select(".event-rect-"+b).style("cursor",null)}).filter(function(a){a=d3.select(this);if("circle"===this.nodeName)return Kb(this,va);if("rect"===this.nodeName)return Lb(this,a.attr("x"),a.attr("y"))}).each(function(a){a=d3.select(this);a.classed(Y)||(a.classed(Y,!0),"circle"===this.nodeName&&a.attr("r",va));d3.select(".event-rect-"+b).style("cursor","pointer")}))}).on("click",
function(a,b){g.selectAll(".-shape-"+b).each(function(a){var d=d3.select(this),c=d.classed(Z),e=!1,f;"circle"===this.nodeName?(e=Kb(this,1.5*va),f=Nb):"rect"===this.nodeName&&(e=Lb(this),f=Pb);if(ba||e)X&&ca(a)&&(d.classed(Z,!c),f(!c,d,a,b)),xc(a,d)})}).call(d3.behavior.drag().origin(Object).on("drag",function(a){if(X){a=gb[0];var b=gb[1],d=d3.mouse(this),c=d[0],d=d[1],e=Math.min(a,c),f=Math.max(a,c),h=ba?t:Math.min(b,d),k=ba?w:Math.max(b,d);g.select(".dragarea").attr("x",e).attr("y",h).attr("width",
f-e).attr("height",k-h);g.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return ca(a)}).each(function(a,b){var d=d3.select(this),c=d.classed(Z),n=d.classed(hb),g,m,s,l;g=!1;"circle"===this.nodeName?(g=1*d.attr("cx"),m=1*d.attr("cy"),l=Nb,g=e<g&&g<f&&h<m&&m<k):"rect"===this.nodeName&&(g=1*d.attr("x"),m=1*d.attr("y"),s=1*d.attr("width"),l=Pb,g=e<g+s&&g<f&&m<k);g^n&&(d.classed(hb,!n),d.classed(Z,!c),l(!c,d,a,b))})}}).on("dragstart",function(){X&&(gb=d3.mouse(this),g.select(".chart").append("rect").attr("class",
"dragarea").style("opacity",0.1),Pa=!0)}).on("dragend",function(){X&&(g.select(".dragarea").transition().duration(100).style("opacity",0).remove(),g.selectAll(".-shape").classed(hb,!1),Pa=!1)}));g.select(".chart").append("g").attr("class","chart-bars");g.select(".chart").append("g").attr("class","chart-lines");wa&&(N.append("g").attr("clip-path",Oa).attr("class","chart"),N.select(".chart").append("g").attr("class","chart-bars"),N.select(".chart").append("g").attr("class","chart-lines"),null!==ib&&
ia.extent(H?ib(Ma,Ya):ib(0,qa()-1)),N.append("g").attr("class","x brush").call(ia).selectAll("rect").attr("height",fa),N.append("g").attr("class","x axis").attr("transform","translate(0,"+fa+")").call(ha));ka&&Qa(b);Vb(b);J({withTransition:!1});if(yc){if(H&&"string"==typeof la){la=aa(la);for(a=0;a<b[0].values.length&&0!=b[0].values[a].x-la;a++);la=a}ja.html(Ub(b.map(function(a){return Ea(a.values[la])})));ja.style("top",Wb.top).style("left",Wb.left).style("visibility","visible")}}function J(a){var b=
mc(),d=b.__max__+1,c,n,s,m,k;a=l(a)?a:{};withY=l(a.withY)?a.withY:!0;withSubchart=l(a.withSubchart)?a.withSubchart:!0;withTransition=l(a.withTransition)?a.withTransition:!0;p.domain(ia.empty()?y.domain():ia.extent());x.domain(Da(h.data.targets,"y"));P.domain(Da(h.data.targets,"y2"));g.selectAll(".x.axis").transition().duration(f?250:0).call(f?ga:E);g.selectAll(".y.axis").transition().duration(f?0:250).call(f?E:ga);g.selectAll(".y2.axis").transition().call(Ia);Ga.domain(x.domain());Ha.domain(P.domain());
if(Qb){if("year"===zc)for(a=[],firstYear=Ma.getFullYear(),lastYear=Ya.getFullYear(),c=firstYear;c<=lastYear;c++)a.push(new Date(c+"-01-01 00:00:00"));else a=p.ticks(10);a=g.select(".xgrids").selectAll(".xgrid").data(a);a.enter().append("line").attr("class","xgrid");a.exit().remove();g.selectAll(".xgrid").attr("x1",function(a){return p(a)-E.tickOffset()}).attr("x2",function(a){return p(a)-E.tickOffset()}).attr("y1",t).attr("y2",w)}db&&(a=g.selectAll(".xgrid-lines"),a.selectAll("line").attr("x1",f?
0:ua).attr("x2",f?q:ua).attr("y1",f?ua:t).attr("y2",f?ua:w),a.selectAll("text").attr("x",f?q:0).attr("y",ua));withY&&Rb&&(ygrid=g.select(".ygrids").selectAll(".ygrid").data(x.ticks(10)),ygrid.enter().append("line").attr("class","ygrid"),ygrid.attr("x1",f?x:0).attr("x2",f?x:q).attr("y1",f?0:x).attr("y2",f?w:x).attr("opacity",0).transition().attr("opacity",1),ygrid.exit().remove());withY&&eb&&g.select(".ygrid-lines").selectAll(".ygrid-line").attr("y1",Fb).attr("y2",Fb);s=1.2*E.tickOffset()/d;m=Ib(f?
null:w);c=Gb(s,d,b);n=Hb(m,b,f);a=g.selectAll(".-bars").selectAll(".-bar").data(Jb);a.transition().duration(withTransition?250:0).attr("x",f?n:c).attr("y",f?c:n).attr("width",f?m:s).attr("height",f?s:m);a.enter().append("rect").attr("class",Eb).attr("x",f?n:c).attr("y",f?c:n).attr("width",f?m:s).attr("height",f?s:m).style("opacity",0).transition().duration(withTransition?250:0).style("opacity",1);a.exit().transition().duration(withTransition?250:0).style("opacity",0).remove();g.selectAll(".-line").transition().duration(withTransition?
250:0).attr("d",Ac);a=g.selectAll(".-circles").selectAll(".-circle").data(nc);a.transition().duration(withTransition?250:0).attr("cx",f?V:U).attr("cy",f?U:V);a.enter().append("circle").attr("class",kc).attr("cx",f?V:U).attr("cy",f?U:V).attr("r",fb);a.exit().remove();withSubchart&&wa&&(s=1.2*ha.tickOffset()/d,m=Ib(fa,!0),c=Gb(s,d,b,!0),n=Hb(m,b,!1,!0),contextBar=N.selectAll(".-bars").selectAll(".-bar").data(Jb),contextBar.transition().duration(withTransition?250:0).attr("x",c).attr("y",n).attr("width",
s).attr("height",m),contextBar.enter().append("rect").attr("class",Eb).attr("x",c).attr("y",n).attr("width",s).attr("height",m).style("opacity",0).transition().style("opacity",1),contextBar.exit().transition().style("opacity",0).remove(),N.selectAll(".-line").transition().duration(withTransition?250:0).attr("d",Bc));g.selectAll(".selected-circles").filter(function(a){return sa(a)}).selectAll("circle").remove();g.selectAll(".selected-circle").transition().duration(withTransition?250:0).attr("cx",f?
V:U).attr("cy",f?U:V);k=(f?w:q)*S()/(qa()-1);b=function(a){return p(a.x)-k/2};g.selectAll(".event-rect").attr("x",f?0:b).attr("y",f?b:0).attr("width",f?q:k).attr("height",f?k:w);mainRegion=g.select(".regions").selectAll("rect.region").data(K);mainRegion.enter().append("rect");mainRegion.attr("class",lc).attr("x",f?0:jb).attr("y",f?jb:t).attr("width",f?q:Xb).attr("height",f?Xb:w).style("fill-opacity",function(a){return l(a.opacity)?a.opacity:0.1});mainRegion.exit().transition().duration(withTransition?
(function(ob){function pb(){function h(c,Ua){c.attr("transform",function(c){return"translate("+(Ua(c)+R)+",0)"})}function t(c,h){c.attr("transform",function(c){return"translate(0,"+h(c)+")"})}function Ea(c){var h=c[0];c=c[c.length-1];return h<c?[h,c]:[c,h]}function ma(c){for(var h=[],r=Math.ceil(c[0]);r<c[1];r++)h.push(r);0<h.length&&0<h[0]&&h.unshift(h[0]-(h[1]-h[0]));return h}function n(v){v.each(function(){var v=d3.select(this),n=ma(I.domain()),E=v.selectAll(".tick.major").data(n,String),S=E.enter().insert("g",
"path").attr("class","tick major").style("opacity",1E-6),da=d3.transition(E.exit()).style("opacity",1E-6).remove(),ea=d3.transition(E).style("opacity",1),A,F=I.rangeExtent?I.rangeExtent():Ea(I.range()),v=v.selectAll(".domain").data([0]),v=(v.enter().append("path").attr("class","domain"),d3.transition(v)),B=I.copy(),Fa=this.__chart__||B;this.__chart__=B;S.append("line");S.append("text");var na=S.select("line"),oa=ea.select("line"),L=E.select("text"),pa=S.select("text"),qa=ea.select("text");R=(B(1)-
B(0))/2;E=c?0:R;switch(r){case "bottom":A=h;na.attr("y2",C);pa.attr("y",Math.max(C,0)+G);oa.attr("x1",E).attr("x2",E).attr("y2",C);qa.attr("x",0).attr("y",Math.max(C,0)+G);L.attr("dy",".71em").style("text-anchor","middle");L.text(function(c){return n.length<O||0==c%Math.ceil(n.length/O)?c<M.length?M[c]:c:""});v.attr("d","M"+F[0]+","+T+"V0H"+F[1]+"V"+T);break;case "left":A=t,na.attr("x2",-C),pa.attr("x",-(Math.max(C,0)+G)),oa.attr("x2",-C).attr("y2",0),qa.attr("x",-(Math.max(C,0)+G)).attr("y",R),L.attr("dy",
".32em").style("text-anchor","end"),L.text(function(c){return n.length<O||0==c%Math.ceil(n.length/O)?c<M.length?M[c]:c:""}),v.attr("d","M"+-T+","+F[0]+"H0V"+F[1]+"H"+-T)}if(I.ticks)S.call(A,Fa),ea.call(A,B),da.call(A,B);else{var ra=B.rangeBand()/2,da=function(c){return B(c)+ra};S.call(A,da);ea.call(A,da)}})}var I=d3.scale.linear(),r="bottom",C=6,T=6,G=3,c=!1,O=10,R=0,M=[];n.scale=function(c){if(!arguments.length)return I;I=c;return n};n.orient=function(c){if(!arguments.length)return r;r=c in{top:1,
right:1,bottom:1,left:1}?c+"":"bottom";return n};n.categories=function(c){if(!arguments.length)return M;M=c;return n};n.tickCentered=function(h){if(!arguments.length)return c;c=h;return n};n.tickTextNum=function(c){if(!arguments.length)return O;O=c;return n};n.tickOffset=function(){return R};n.ticks=function(){};return n}function t(h){return"undefined"===typeof h}function h(h){return"undefined"!==typeof h}ob.c3={};c3.generate=function(z){var qb,Ea,ma,n,I,r,C,T,G;function c(a,b){for(var d=z,e=0;e<
a.length;e++){if(!(a[e]in d))return b;d=d[a[e]]}return d}function O(){rb=20+sb+$;tb=!ub||f||Wa?1:50;left=Xa?0:40;vb=Ga-sb-$;wb=20+$;xb=Ga-$;r=0;C=tb;T=rb;G=left;ma=vb;n=wb;I=left;qb=xb;Ea=left;p=(null==yb?+d3.select(z.bindto).style("width").replace("px",""):yb)-G-C;w=Ga-r-T;fa=Ga-ma-n}function R(){var a,b,d,e;zb=f?10:0;Ab=f?w:p;Ya=f?0:w;Za=f?p:1;a=M(zb,Ab);b=v(Ya,Za);d=v(Ya,Za);e=M(0,p);l=h(l)?a.domain(l.domain()):a;x=h(x)?b.domain(x.domain()):b;P=h(P)?d.domain(P.domain()):d;y=h(y)?e.domain(y.domain()):
e;Ha=v(fa,10);Ia=v(fa,10);D.scale(l).orient(f?"left":"bottom");ga.scale(x).orient(f?Xa?"top":"bottom":Xa?"right":"left");Ja.scale(P).orient(f?Wa?"bottom":"top":Wa?"left":"right");ha.scale(y).orient("bottom")}function M(a,b){return(H?d3.time.scale():d3.scale.linear()).range([a,b])}function v(a,b){return d3.scale.linear().range([a,b])}function Ua(a){return d3.min(a,function(a){return d3.min(a.values,function(a){return a.value})})}function ac(a){var b={},d,e;a.forEach(function(a){b[a.id]=[];a.values.forEach(function(d){b[a.id].push(d.value)})});
for(d=0;d<u.length;d++)for(e=1;e<u[d].length;e++)sa(u[d][e])&&(t(b[u[d][e]])||b[u[d][e]].forEach(function(a,c){A(u[d][e])===A(u[d][0])&&(b[u[d][0]][c]+=1*a)}));return d3.max(Object.keys(b).map(function(a){return d3.max(b[a])}))}function E(a,b){var d=Ka(function(a){return A(a.id)===b}),e="y2"===b?bc:cc,q="y2"===b?dc:ec,e=null!==e?e:Ua(d),q=null!==q?q:ac(d),c=0.1*Math.abs(q-e),m=c,f=c,g="y2"===b?fc:gc;null!==g&&(yDomainAbs=Math.max(Math.abs(e),Math.abs(q)),q=yDomainAbs-g,e=g-yDomainAbs);"y"===b&&null!==
ta&&(m=h(ta.top)?ta.top:c,f=h(ta.bottom)?ta.bottom:c);"y2"===b&&null!==ua&&(m=h(ua.top)?ua.top:c,f=h(ua.bottom)?ua.bottom:c);return[hc(d,"bar")?0:e-f,q+m]}function S(){if(ia.empty())return 1;var a=y.domain(),b=ia.extent();return(a[1]-a[0])/(b[1]-b[0])}function da(a){for(var b=0;b<a.length;b++)if(!(a[b]in La))return!1;return!0}function ea(a){for(var b=[],d=0;d<a.length;d++)a[d]in La&&b.push(pa(La[a[d]]));return b}function A(a){return a in Bb?Bb[a]:"y"}function F(a){return"y2"===A(a)?P:x}function B(a){return"y2"===
A(a)?Ia:Ha}function Fa(a){var b=va[a.id];a.name=h(b)?b:a.id;return a}function na(a){var b=a[0],d={},e=[],q,c;for(q=1;q<a.length;q++){d={};for(c=0;c<a[q].length;c++)d[b[c]]=a[q][c];e.push(d)}return e}function oa(a){var b=[],d,e,q;for(d=0;d<a.length;d++)for(q=a[d][0],e=1;e<a[d].length;e++)t(b[e-1])&&(b[e-1]={}),b[e-1][q]=a[d][e];return b}function L(a){var b=d3.keys(a[0]).filter(function(a){return a!==Ma}),d=0,e;a.forEach(function(a){if(H){if(!(Ma in a))throw Error("'"+Ma+"' must be included in data");
e=aa(a[Ma]);if(null===e)throw Error("Failed to parse timeseries date in data");a.x=e}else a.x=d++;null===Na&&(Na=new Date(a.x));$a=new Date(a.x)});b=b.map(function(b,d){var e=ic(b);return{id:e,id_org:b,values:a.map(function(a){return{x:a.x,value:+a[b],id:e}})}});b.forEach(function(a){La[a.id_org]=pa(a)});return b}function pa(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 qa(){return d3.max(k.data.targets,function(a){return a.values.length})}
function ra(a){a=t(a)?k.data.targets:a;return a.map(function(a){return a.id})}function Va(a){var b=ra(),d;for(d=0;d<b.length;d++)if(b[d]===a)return!0;return!1}function Ka(a){return h(a)?k.data.targets.filter(a):k.data.targets}function ab(a){return"-shapes -shapes-"+a.id}function Cb(a){return ab(a)+" -line -line-"+a.id}function jc(a){return ab(a)+" -circles -circles-"+a.id}function Db(a){return ab(a)+" -bars -bars-"+a.id}function kc(a,b){return"-shape -shape-"+b+" -circle -circle-"+b}function Eb(a,
b){return"-shape -shape-"+b+" -bar -bar-"+b}function lc(a,b){return"region region-"+b+" "+("classes"in a?[].concat(a.classes).join(" "):"")}function Oa(a){return l(a.x)}function wa(a){return l(H?aa(a.value):a.value)}function Fb(a){return x(a.value)}function U(a){return l(a.x)}function V(a){return F(a.id)(a.value)}function mc(){var a={},b=0,d,e;Ka(sa).forEach(function(c){for(d=0;d<u.length;d++)if(!(0>u[d].indexOf(c.id)))for(e=0;e<u[d].length;e++)if(u[d][e]in a){a[c.id]=a[u[d][e]];break}t(a[c.id])&&
(a[c.id]=b++)});a.__max__=b-1;return a}function Gb(a,b,d,e){var c=e?y:l;return function(e){var m=e.id in d?d[e.id]:0;return c(e.x)-a*(b/2-m)}}function Hb(a,b,d,e){var c=Object.keys(b);return function(f,m){var h=0,g=e?B(f.id):F(f.id);Ka(sa).forEach(function(d){d.id!==f.id&&b[d.id]===b[f.id]&&c.indexOf(d.id)<c.indexOf(f.id)&&(h+=a(d.values[m]))});return d?h:g(f.value)-h}}function Ib(a,b){var d=null===a?function(a){return a}:function(b){return a-b};return function(a){var c=b?B(a.id):F(a.id);return d(c(a.value))}}
function bb(a,b){var d=t(a)?ra():a;"string"===typeof d&&(d=[d]);for(var e=0;e<d.length;e++)W[d[e]]=b}function hc(a,b){var d=!1;a.forEach(function(a){W[a.id]===b&&(d=!0);a.id in W||"line"!==b||(d=!0)});return d}function cb(a){a="string"===typeof a?a:a.id;return!(a in W)||"line"===W[a]||"spline"===W[a]}function sa(a){return"bar"===W["string"===typeof a?a:a.id]}function nc(a){return cb(a)?a.values:[]}function Jb(a){return sa(a)?a.values:[]}function Kb(a,b){var d=d3.mouse(a),e=d3.select(a),c=1*e.attr("cx"),
e=1*e.attr("cy");return Math.sqrt(Math.pow(c-d[0],2)+Math.pow(e-d[1],2))<b}function Lb(a){var b=d3.mouse(a),d=d3.select(a);a=1*d.attr("x");var e=1*d.attr("y"),d=1*d.attr("width");return a-10<b[0]&&b[0]<a+d+10&&e-10<b[1]}function oc(a,b){var d;for(d=0;d<b.length;d++)if(b[d].start<a&&a<=b[d].end)return!0;return!1}function Mb(a,b,d){pc(a,b);g.select(".selected-circles-"+b.id).selectAll(".selected-circle-"+d).data([b]).enter().append("circle").attr("class",function(a){return"selected-circle selected-circle-"+
d}).attr("cx",f?V:U).attr("cy",f?U:V).attr("stroke",function(){return Q(b.id)}).attr("r",1.4*xa).transition().duration(100).attr("r",xa)}function db(a,b,d){qc(a,b);g.select(".selected-circles-"+b.id).selectAll(".selected-circle-"+d).transition().duration(100).attr("r",0).remove()}function Nb(a,b,d,e){a?Mb(b,d,e):db(b,d,e)}function rc(a,b,d){}function Ob(a,b,d){}function Pb(a,b,d,e){}function sc(a,b,d,e){var c,s,m="M",g,k,l,n,r,p=[];if(h(e))for(c=0;c<e.length;c++)p[c]={},t(e[c].start)?p[c].start=a[0].x:
H&&(p[c].start=aa(e[c].start)),t(e[c].end)?p[c].end=a[a.length-1].x:H&&(p[c].end=aa(e[c].end));n=f?function(a){return d(a.value)}:function(a){return b(a.x)};r=f?function(a){return b(a.x)}:function(a){return d(a.value)};e=H?function(a,c,e,f){var m=a.x.getTime();a=c.x-a.x;c=new Date(m+a*(e+f));return"M"+b(new Date(m+a*e))+" "+d(k(e))+" "+b(c)+" "+d(k(e+f))}:function(a,c,e,f){return"M"+b(g(e))+" "+d(k(e))+" "+b(g(e+f))+" "+d(k(e+f))};for(c=0;c<a.length;c++)if(t(p)||!oc(a[c].x,p))m+=" "+n(a[c])+" "+r(a[c]);
else for(g=M(a[c-1].x,a[c].x),k=v(a[c-1].value,a[c].value),s=b(a[c].x)-b(a[c-1].x),l=d(a[c].value)-d(a[c-1].value),s=Math.sqrt(Math.pow(s,2)+Math.pow(l,2)),l=2/s,diffx2=2*l,s=l;1>=s;s+=diffx2)m+=e(a[c-1],a[c],s,l);return m}function eb(a){var b=k.data.targets=L(a),d,c;l.domain(d3.extent(a.map(function(a){return a.x})));x.domain(E(b,"y"));P.domain(E(b,"y2"));y.domain(l.domain());Ha.domain(x.domain());Ia.domain(P.domain());D.ticks(10>a.length?a.length:10);ga.ticks(3).outerTickSize(0).tickFormat(tc);
Ja.ticks(3).outerTickSize(0).tickFormat(uc);g.append("g").attr("class","x axis").attr("clip-path",f?"":"url(#xaxis-clip)").attr("transform","translate(0,"+w+")").call(f?ga:D);g.append("g").attr("class","y axis").attr("clip-path",f?"url(#yaxis-clip)":"").call(f?D:ga).append("text").attr("transform","rotate(-90)").attr("dy","1.4em").attr("dx","-.8em").style("text-anchor","end").text(vc);ub&&g.append("g").attr("class","y2 axis").attr("transform","translate("+(f?0:p)+","+(f?10:0)+")").call(Ja);d=g.append("g").attr("clip-path",
Pa).attr("class","grid");Qb&&d.append("g").attr("class","xgrids");fb&&(c=d.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(fb).enter().append("g").attr("class","xgrid-line"),c.append("line").attr("class",function(a){return""+a["class"]}),c.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",f?"":"rotate(-90)").attr("dx",f?0:-r).attr("dy",-6).text(function(a){return a.text}));wc&&d.append("g").attr("class","xgrid-focus").append("line").attr("class",
"xgrid-focus").attr("x1",f?0:-10).attr("x2",f?p:-10).attr("y1",f?-10:r).attr("y2",f?-10:w);Rb&&d.append("g").attr("class","ygrids");gb&&d.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(gb).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]});g.append("g").attr("clip-path",Pa).attr("class","regions");g.append("g").attr("clip-path",Pa).attr("class","chart");g.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).selectAll(".event-rects").data(a).enter().append("rect").attr("class",
function(a,b){return"event-rect event-rect-"+b}).style("cursor",function(a){return X&&ba?"pointer":null}).on("mouseover",function(a,b){if(!Qa){var d=k.data.targets.map(function(a){return Fa(a.values[b])}),c,e;if(0<Object.keys(va).length){e=[];for(var h in va)for(c=0;c<d.length;c++)if(d[c].id===h){e.push(d[c]);d.shift(c);break}d=e.concat(d)}Sb&&g.selectAll(".-circle-"+b).classed(Y,!0).attr("r",Tb);g.selectAll(".-bar-"+b).classed(Y,!0);g.selectAll("line.xgrid-focus").style("visibility","visible").data([d[0]]).attr(f?
"y1":"x1",Oa).attr(f?"y2":"x2",Oa);ja.style("top",d3.mouse(this)[1]+30+"px").style("left",(f?d3.mouse(this)[0]:l(d[0].x))+60+"px");ja.html(Ub(d));ja.style("visibility","visible")}}).on("mouseout",function(a,b){g.select("line.xgrid-focus").style("visibility","hidden");ja.style("visibility","hidden");g.selectAll(".-circle-"+b).filter(function(){return d3.select(this).classed(Y)}).classed(Y,!1).attr("r",hb);g.selectAll(".-bar-"+b).classed(Y,!1)}).on("mousemove",function(a,b){X&&!Qa&&(ba||g.selectAll(".-shape-"+
b).filter(function(a){return ca(a)}).each(function(a){a=d3.select(this).classed(Y,!0);"circle"===this.nodeName&&a.attr("r",Tb);d3.select(".event-rect-"+b).style("cursor",null)}).filter(function(a){a=d3.select(this);if("circle"===this.nodeName)return Kb(this,xa);if("rect"===this.nodeName)return Lb(this,a.attr("x"),a.attr("y"))}).each(function(a){a=d3.select(this);a.classed(Y)||(a.classed(Y,!0),"circle"===this.nodeName&&a.attr("r",xa));d3.select(".event-rect-"+b).style("cursor","pointer")}))}).on("click",
function(a,b){g.selectAll(".-shape-"+b).each(function(a){var d=d3.select(this),c=d.classed(Z),e=!1,f;"circle"===this.nodeName?(e=Kb(this,1.5*xa),f=Nb):"rect"===this.nodeName&&(e=Lb(this),f=Pb);if(ba||e)X&&ca(a)&&(d.classed(Z,!c),f(!c,d,a,b)),xc(a,d)})}).call(d3.behavior.drag().origin(Object).on("drag",function(a){if(X){a=ib[0];var b=ib[1],d=d3.mouse(this),c=d[0],d=d[1],e=Math.min(a,c),f=Math.max(a,c),h=ba?r:Math.min(b,d),k=ba?w:Math.max(b,d);g.select(".dragarea").attr("x",e).attr("y",h).attr("width",
f-e).attr("height",k-h);g.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return ca(a)}).each(function(a,b){var d=d3.select(this),c=d.classed(Z),q=d.classed(jb),g,m,s,l;g=!1;"circle"===this.nodeName?(g=1*d.attr("cx"),m=1*d.attr("cy"),l=Nb,g=e<g&&g<f&&h<m&&m<k):"rect"===this.nodeName&&(g=1*d.attr("x"),m=1*d.attr("y"),s=1*d.attr("width"),l=Pb,g=e<g+s&&g<f&&m<k);g^q&&(d.classed(jb,!q),d.classed(Z,!c),l(!c,d,a,b))})}}).on("dragstart",function(){X&&(ib=d3.mouse(this),g.select(".chart").append("rect").attr("class",
"dragarea").style("opacity",0.1),Qa=!0)}).on("dragend",function(){X&&(g.select(".dragarea").transition().duration(100).style("opacity",0).remove(),g.selectAll(".-shape").classed(jb,!1),Qa=!1)}));g.select(".chart").append("g").attr("class","chart-bars");g.select(".chart").append("g").attr("class","chart-lines");ya&&(N.append("g").attr("clip-path",Pa).attr("class","chart"),N.select(".chart").append("g").attr("class","chart-bars"),N.select(".chart").append("g").attr("class","chart-lines"),null!==kb&&
ia.extent(H?kb(Na,$a):kb(0,qa()-1)),N.append("g").attr("class","x brush").call(ia).selectAll("rect").attr("height",fa),N.append("g").attr("class","x axis").attr("transform","translate(0,"+fa+")").call(ha));ka&&Ra(b);Vb(b);J({withTransition:!1});if(yc){if(H&&"string"==typeof la){la=aa(la);for(a=0;a<b[0].values.length&&0!=b[0].values[a].x-la;a++);la=a}ja.html(Ub(b.map(function(a){return Fa(a.values[la])})));ja.style("top",Wb.top).style("left",Wb.left).style("visibility","visible")}}function J(a){var b=
mc(),d=b.__max__+1,c,q,s,m,n;a=h(a)?a:{};withY=h(a.withY)?a.withY:!0;withSubchart=h(a.withSubchart)?a.withSubchart:!0;withTransition=h(a.withTransition)?a.withTransition:!0;l.domain(ia.empty()?y.domain():ia.extent());x.domain(E(k.data.targets,"y"));P.domain(E(k.data.targets,"y2"));g.selectAll(".x.axis").transition().duration(f?250:0).call(f?ga:D);g.selectAll(".y.axis").transition().duration(f?0:250).call(f?D:ga);g.selectAll(".y2.axis").transition().call(Ja);Ha.domain(x.domain());Ia.domain(P.domain());
if(Qb){if("year"===zc)for(a=[],firstYear=Na.getFullYear(),lastYear=$a.getFullYear(),c=firstYear;c<=lastYear;c++)a.push(new Date(c+"-01-01 00:00:00"));else a=l.ticks(10);a=g.select(".xgrids").selectAll(".xgrid").data(a);a.enter().append("line").attr("class","xgrid");a.exit().remove();g.selectAll(".xgrid").attr("x1",function(a){return l(a)-D.tickOffset()}).attr("x2",function(a){return l(a)-D.tickOffset()}).attr("y1",r).attr("y2",w)}fb&&(a=g.selectAll(".xgrid-lines"),a.selectAll("line").attr("x1",f?
0:wa).attr("x2",f?p:wa).attr("y1",f?wa:r).attr("y2",f?wa:w),a.selectAll("text").attr("x",f?p:0).attr("y",wa));withY&&Rb&&(ygrid=g.select(".ygrids").selectAll(".ygrid").data(x.ticks(10)),ygrid.enter().append("line").attr("class","ygrid"),ygrid.attr("x1",f?x:0).attr("x2",f?x:p).attr("y1",f?0:x).attr("y2",f?w:x).attr("opacity",0).transition().attr("opacity",1),ygrid.exit().remove());withY&&gb&&g.select(".ygrid-lines").selectAll(".ygrid-line").attr("y1",Fb).attr("y2",Fb);s=1.2*D.tickOffset()/d;m=Ib(f?
null:w);c=Gb(s,d,b);q=Hb(m,b,f);a=g.selectAll(".-bars").selectAll(".-bar").data(Jb);a.transition().duration(withTransition?250:0).attr("x",f?q:c).attr("y",f?c:q).attr("width",f?m:s).attr("height",f?s:m);a.enter().append("rect").attr("class",Eb).attr("x",f?q:c).attr("y",f?c:q).attr("width",f?m:s).attr("height",f?s:m).style("opacity",0).transition().duration(withTransition?250:0).style("opacity",1);a.exit().transition().duration(withTransition?250:0).style("opacity",0).remove();g.selectAll(".-line").transition().duration(withTransition?
250:0).attr("d",Ac);a=g.selectAll(".-circles").selectAll(".-circle").data(nc);a.transition().duration(withTransition?250:0).attr("cx",f?V:U).attr("cy",f?U:V);a.enter().append("circle").attr("class",kc).attr("cx",f?V:U).attr("cy",f?U:V).attr("r",hb);a.exit().remove();withSubchart&&ya&&(s=1.2*ha.tickOffset()/d,m=Ib(fa,!0),c=Gb(s,d,b,!0),q=Hb(m,b,!1,!0),contextBar=N.selectAll(".-bars").selectAll(".-bar").data(Jb),contextBar.transition().duration(withTransition?250:0).attr("x",c).attr("y",q).attr("width",
s).attr("height",m),contextBar.enter().append("rect").attr("class",Eb).attr("x",c).attr("y",q).attr("width",s).attr("height",m).style("opacity",0).transition().style("opacity",1),contextBar.exit().transition().style("opacity",0).remove(),N.selectAll(".-line").transition().duration(withTransition?250:0).attr("d",Bc));g.selectAll(".selected-circles").filter(function(a){return sa(a)}).selectAll("circle").remove();g.selectAll(".selected-circle").transition().duration(withTransition?250:0).attr("cx",f?
V:U).attr("cy",f?U:V);n=(f?w:p)*S()/(qa()-1);b=function(a){return l(a.x)-n/2};g.selectAll(".event-rect").attr("x",f?0:b).attr("y",f?b:0).attr("width",f?p:n).attr("height",f?n:w);mainRegion=g.select(".regions").selectAll("rect.region").data(K);mainRegion.enter().append("rect");mainRegion.attr("class",lc).attr("x",f?0:lb).attr("y",f?lb:r).attr("width",f?p:Xb).attr("height",f?Xb:w).style("fill-opacity",function(a){return h(a.opacity)?a.opacity:0.1});mainRegion.exit().transition().duration(withTransition?
250:0).style("fill-opacity",0).remove()}function Vb(a){var b;g.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",Db).style("fill",function(a){return Q(a.id)}).style("stroke",function(a){return Q(a.id)}).style("stroke-width",0).style("cursor",function(a){return ca(a)?"pointer":null});b=g.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",Cb).style("stroke",function(a){return Q(a.id)});b.append("g").attr("class",function(a){return"selected-circles selected-circles-"+a.id});b.append("g").attr("class",jc).style("fill",function(a){return Q(a.id)}).style("cursor",function(a){return ca(a)?"pointer":null});a.forEach(function(a){g.selectAll(".selected-circles-"+a.id).selectAll(".selected-circle").each(function(b){b.value=
a.values[b.x].value})});wa&&(b=N.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",Db).style("fill",function(a){return Q(a.id)}),b=N.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",Cb).style("stroke",function(a){return Q(a.id)}));
ka&&Qa(a);d3.selectAll(".target").transition().style("opacity",1)}function xa(a,b){h.data.targets.forEach(function(b){for(var c=0;c<a.length;c++)if(b.id===a[c].id){b.values=a[c].values;a.splice(c,1);break}});h.data.targets=h.data.targets.concat(a);Vb(h.data.targets);J();b()}function Qa(a,b){var c=ra(a),e,f=q/2-ya*Object.keys(a).length/2,g;b=u(b)?{}:b;g=l(b.withTransition)?b.withTransition:!0;e=za.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){Cc(a)}).on("mouseover",function(a){d3.selectAll(".legend-item").filter(function(b){return b!==a}).transition().duration(100).style("opacity",0.3);h.focus(a)}).on("mouseout",function(a){d3.selectAll(".legend-item").transition().duration(100).style("opacity",1);h.revert()});e.append("rect").attr("class","legend-item-event").style("fill-opacity",0).attr("x",-200).attr("y",function(){return $/2-16}).attr("width",ya).attr("height",24);e.append("rect").attr("class",
"legend-item-tile").style("fill",function(a){return Q(a)}).attr("x",-200).attr("y",function(){return $/2-9}).attr("width",10).attr("height",10);e.append("text").text(function(a){return l(ta[a])?ta[a]:a}).attr("x",-200).attr("y",function(a,b){return $/2});za.selectAll("rect.legend-item-event").data(c).transition().duration(g?250:0).attr("x",function(a,b){return f+ya*b});za.selectAll("rect.legend-item-tile").data(c).transition().duration(g?250:0).attr("x",function(a,b){return f+ya*b});za.selectAll("text").data(c).transition().duration(g?
250:0).attr("x",function(a,b){return f+ya*b+14})}function Aa(a){return l(a)?".target-"+a:".target"}var h={data:{}},Ka={},Y="_expanded_",Z="_selected_",hb="_included_";if(!("bindto"in z))throw Error("bindto is required in config");var wb=c(["size","width"],null),Fa=c(["size","height"],280);if(!("data"in z))throw Error("data is required in config");var La=c(["data","x"],"x"),Dc=c(["data","x_format"],"%Y-%m-%d"),ic=c(["data","id_converter"],function(a){return a}),ta=c(["data","names"],{}),v=c(["data",
"groups"],[]),Bb=c(["data","axes"],{}),W=c(["data","types"],{}),Yb=c(["data","regions"],{}),Ec=c(["data","colors"],{}),X=c(["data","selection","enabled"],!1),ba=c(["data","selection","grouped"],!1),ca=c(["data","selection","isselectable"],function(a){return!0}),wa=c(["subchart","show"],!1),qb=wa?c(["subchart","size","height"],60):0,ib=c(["subchart","default"],null),Fc=c(["color","pattern"],null),ka=c(["legend","show"],!0),ya=c(["legend","item","width"],80),Cc=c(["legend","item","onclick"],function(){}),
Zb=c(["axis","x","type"],"indexed"),Ra=c(["axis","x","categories"],[]),$b=c(["axis","x","tick","centered"],!1),ec=c(["axis","y","max"],null),cc=c(["axis","y","min"],null),gc=c(["axis","y","center"],null),vc=c(["axis","y","text"],null);c(["axis","y","rescale"],!0);var Va=c(["axis","y","inner"],!1),tc=c(["axis","y","format"],function(a){return a}),zb=c(["axis","y","padding"],null),sb=c(["axis","y2","show"],!1),dc=c(["axis","y2","max"],null),bc=c(["axis","y2","min"],null),fc=c(["axis","y2","center"],
null);c(["axis","y2","text"],null);c(["axis","y2","rescale"],!0);var Ua=c(["axis","y2","inner"],!1),uc=c(["axis","y2","format"],function(a){return a}),Ab=c(["axis","y2","padding"],null),f=c(["axis","rotated"],!1),Qb=c(["grid","x","show"],!1),zc=c(["grid","x","type"],"tick"),db=c(["grid","x","lines"],null),Rb=c(["grid","y","show"],!1);c(["grid","y","type"],"tick");var eb=c(["grid","y","lines"],null),fb=c(["point","show"],!0)?c(["point","r"],2.5):0,wc=c(["point","focus","line","enabled"],!0),Sb=c(["point",
"focus","expand","enabled"],!0),Tb=c(["point","focus","expand","r"],Sb?4:fb),va=c(["point","focus","select","r"],8),xc=c(["point","onclick"],function(){}),pc=c(["point","onselected"],function(){}),qc=c(["point","onunselected"],function(){}),K=c(["regions"],[]),Ub=c(["tooltip","contents"],function(a){var b="<table class='-tooltip'><tr><th colspan='2'>"+(H?a[0].x.getFullYear()+"."+(a[0].x.getMonth()+1)+"."+a[0].x.getDate():Ba?a[0].x<Ra.length?Ra[a[0].x]:a[0].x:a[0].x)+"</th></tr>",c,e,f;for(c=0;c<a.length;c++)l(a[c])?
(e=l(a[c].value)?(Math.round(100*a[c].value)/100).toFixed(2):"-",f=a[c].name):f=e="-",b+="<tr><td><span style='background-color:"+Q(a[c].id)+"'></span>"+f+"</td><td class='value'>"+e+"</td></tr>";return b+"</table>"}),yc=c(["tooltip","init","show"],!1),la=c(["tooltip","init","x"],0),Wb=c(["tooltip","init","position"],{top:"0px",left:"50px"}),kb=z.bindto.replace("#","")+"-clip",Oa="url(#"+kb+")",H="timeseries"===Zb,Ba="categorized"===Zb,gb=null,Pa=!1,$=ka?40:0,Gc=function(a){return function(b){for(var c=
a.values[b.x].value})});ya&&(b=N.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",Db).style("fill",function(a){return Q(a.id)}),b=N.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",Cb).style("stroke",function(a){return Q(a.id)}));
ka&&Ra(a);d3.selectAll(".target").transition().style("opacity",1)}function za(a,b){k.data.targets.forEach(function(b){for(var c=0;c<a.length;c++)if(b.id===a[c].id){b.values=a[c].values;a.splice(c,1);break}});k.data.targets=k.data.targets.concat(a);Vb(k.data.targets);J();b()}function Ra(a,b){var c=ra(a),e,f=p/2-Aa*Object.keys(a).length/2,g;b=t(b)?{}:b;g=h(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){Cc(a)}).on("mouseover",function(a){d3.selectAll(".legend-item").filter(function(b){return b!==a}).transition().duration(100).style("opacity",0.3);k.focus(a)}).on("mouseout",function(a){d3.selectAll(".legend-item").transition().duration(100).style("opacity",1);k.revert()});e.append("rect").attr("class","legend-item-event").style("fill-opacity",0).attr("x",-200).attr("y",function(){return $/2-16}).attr("width",Aa).attr("height",24);e.append("rect").attr("class",
"legend-item-tile").style("fill",function(a){return Q(a)}).attr("x",-200).attr("y",function(){return $/2-9}).attr("width",10).attr("height",10);e.append("text").text(function(a){return h(va[a])?va[a]:a}).attr("x",-200).attr("y",function(a,b){return $/2});Ba.selectAll("rect.legend-item-event").data(c).transition().duration(g?250:0).attr("x",function(a,b){return f+Aa*b});Ba.selectAll("rect.legend-item-tile").data(c).transition().duration(g?250:0).attr("x",function(a,b){return f+Aa*b});Ba.selectAll("text").data(c).transition().duration(g?
250:0).attr("x",function(a,b){return f+Aa*b+14})}function Ca(a){return h(a)?".target-"+a:".target"}var k={data:{}},La={},Y="_expanded_",Z="_selected_",jb="_included_";if(!("bindto"in z))throw Error("bindto is required in config");var yb=c(["size","width"],null),Ga=c(["size","height"],280);if(!("data"in z))throw Error("data is required in config");var Ma=c(["data","x"],"x"),Dc=c(["data","x_format"],"%Y-%m-%d"),ic=c(["data","id_converter"],function(a){return a}),va=c(["data","names"],{}),u=c(["data",
"groups"],[]),Bb=c(["data","axes"],{}),W=c(["data","types"],{}),Yb=c(["data","regions"],{}),Ec=c(["data","colors"],{}),X=c(["data","selection","enabled"],!1),ba=c(["data","selection","grouped"],!1),ca=c(["data","selection","isselectable"],function(a){return!0}),ya=c(["subchart","show"],!1),sb=ya?c(["subchart","size","height"],60):0,kb=c(["subchart","default"],null),Fc=c(["color","pattern"],null),ka=c(["legend","show"],!0),Aa=c(["legend","item","width"],80),Cc=c(["legend","item","onclick"],function(){}),
Zb=c(["axis","x","type"],"indexed"),Sa=c(["axis","x","categories"],[]),$b=c(["axis","x","tick","centered"],!1),ec=c(["axis","y","max"],null),cc=c(["axis","y","min"],null),gc=c(["axis","y","center"],null),vc=c(["axis","y","text"],null);c(["axis","y","rescale"],!0);var Xa=c(["axis","y","inner"],!1),tc=c(["axis","y","format"],function(a){return a}),ta=c(["axis","y","padding"],null),ub=c(["axis","y2","show"],!1),dc=c(["axis","y2","max"],null),bc=c(["axis","y2","min"],null),fc=c(["axis","y2","center"],
null);c(["axis","y2","text"],null);c(["axis","y2","rescale"],!0);var Wa=c(["axis","y2","inner"],!1),uc=c(["axis","y2","format"],function(a){return a}),ua=c(["axis","y2","padding"],null),f=c(["axis","rotated"],!1),Qb=c(["grid","x","show"],!1),zc=c(["grid","x","type"],"tick"),fb=c(["grid","x","lines"],null),Rb=c(["grid","y","show"],!1);c(["grid","y","type"],"tick");var gb=c(["grid","y","lines"],null),hb=c(["point","show"],!0)?c(["point","r"],2.5):0,wc=c(["point","focus","line","enabled"],!0),Sb=c(["point",
"focus","expand","enabled"],!0),Tb=c(["point","focus","expand","r"],Sb?4:hb),xa=c(["point","focus","select","r"],8),xc=c(["point","onclick"],function(){}),pc=c(["point","onselected"],function(){}),qc=c(["point","onunselected"],function(){}),K=c(["regions"],[]),Ub=c(["tooltip","contents"],function(a){var b="<table class='-tooltip'><tr><th colspan='2'>"+(H?a[0].x.getFullYear()+"."+(a[0].x.getMonth()+1)+"."+a[0].x.getDate():Da?a[0].x<Sa.length?Sa[a[0].x]:a[0].x:a[0].x)+"</th></tr>",c,e,f;for(c=0;c<a.length;c++)h(a[c])?
(e=h(a[c].value)?(Math.round(100*a[c].value)/100).toFixed(2):"-",f=a[c].name):f=e="-",b+="<tr><td><span style='background-color:"+Q(a[c].id)+"'></span>"+f+"</td><td class='value'>"+e+"</td></tr>";return b+"</table>"}),yc=c(["tooltip","init","show"],!1),la=c(["tooltip","init","x"],0),Wb=c(["tooltip","init","position"],{top:"0px",left:"50px"}),mb=z.bindto.replace("#","")+"-clip",Pa="url(#"+mb+")",H="timeseries"===Zb,Da="categorized"===Zb,ib=null,Qa=!1,$=ka?40:0,Gc=function(a){return function(b){for(var c=
a.length-1,e=a[c];!e[1](b);)e=a[--c];return e[0](b)}}([[d3.time.format("%Y/%-m/%-d"),function(){return!0}],[d3.time.format("%-m/%-d"),function(a){return a.getMonth()}],[d3.time.format("%-m/%-d"),function(a){return 1!=a.getDate()}],[d3.time.format("%-m/%-d"),function(a){return a.getDay()&&1!=a.getDate()}],[d3.time.format("%I %p"),function(a){return a.getHours()}],[d3.time.format("%I:%M"),function(a){return a.getMinutes()}],[d3.time.format(":%S"),function(a){return a.getSeconds()}],[d3.time.format(".%L"),
function(a){return a.getMilliseconds()}]]),aa=d3.time.format(Dc).parse,pb,ub,rb,tb,vb,q,w,fa,xb,yb,Wa,Xa,p,x,P,y,Ga,Ha,E=Ba?nb():d3.svg.axis(),ga=d3.svg.axis(),Ia=d3.svg.axis(),ha=Ba?nb():d3.svg.axis();O();R();H&&E.tickFormat(Gc);Ba?(E.categories(Ra).tickCentered($b),ha.categories(Ra).tickCentered($b)):(E.tickOffset=function(){return 0},ha.tickOffset=function(){return 0});Ba&&function(){var a=p,b=y,c=Object.keys(p),e,f;p=function(b){return a(b)+E.tickOffset()};y=function(a){return b(a)+ha.tickOffset()};
for(f=0;f<c.length;f++)e=c[f],p[e]=a[e],y[e]=b[e];p.domain=function(b){if(!arguments.length)return b=a.domain(),b[1]++,b;a.domain(b);return p}}();var Ac=function(){var a=d3.svg.line().x(f?function(a){return F(a.id)(a.value)}:Na).y(f?Na:function(a){return F(a.id)(a.value)});return function(b){var c;if(ab(b))return"spline"===W["string"===typeof b?b:b.id]?a.interpolate("cardinal"):a.interpolate("linear"),0<Object.keys(Yb).length?sc(b.values,p,F(b.id),Yb[b.id]):a(b.values);c=p(b.values[0].x);b=F(b.id)(b.values[0].value);
return f?"M "+b+" "+c:"M "+c+" "+b}}(),Bc=function(){var a=d3.svg.line().x(function(a){return y(a.x)}).y(function(a){return C(a.id)(a.value)});return function(b){return ab(b)?a(b.values):"M "+y(b.values[0].x)+" "+C(b.id)(b.values[0].value)}}(),jb=function(a){return"start"in a?p(H?aa(a.start):a.start):0},Xb=function(a){var b=jb(a);a=("end"in a?p(H?aa(a.end):a.end):q)-b;return 0>a?0:a},Q=function(a,b){var c=[],e=null!==b?b:"#1f77b4 #ff7f0e #2ca02c #d62728 #9467bd #8c564b #e377c2 #7f7f7f #bcbd22 #17becf".split(" ");
return function(b){if(b in a)return a[b];0<=c.indexOf(b)||c.push(b);return e[c.indexOf(b)%e.length]}}(Ec,Fc),Sa=d3.select(z.bindto).append("svg").attr("width",q+G+D).attr("height",w+t+T),lb=Sa.append("defs");lb.append("clipPath").attr("id",kb).append("rect").attr("y",t).attr("width",q).attr("height",w-t);lb.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1).attr("y",-1).attr("width",q+2).attr("height",40);lb.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-G+
1).attr("y",t-1).attr("width",G).attr("height",w-t+2);var g=Sa.append("g").attr("transform","translate("+G+","+t+")"),N=null;wa&&(N=Sa.append("g").attr("transform","translate("+I+","+ma+")"));var za=null;ka&&(za=Sa.append("g").attr("transform","translate("+Ca+","+ob+")"));var ja=d3.select(z.bindto).style("position","relative").append("div").style("position","absolute").style("width","30%").style("z-index","10").style("visibility","hidden"),ia=d3.svg.brush().x(y).on("brush",function(){J({withTransition:!1,
withY:!1,withSubchart:!1})}),Ma=null,Ya=null;h.focus=function(a){h.defocus();d3.selectAll(Aa(a)).filter(function(a){return Ta(a.id)}).classed("focused",!0).transition().duration(100).style("opacity",1)};h.defocus=function(a){d3.selectAll(Aa(a)).filter(function(a){return Ta(a.id)}).classed("focused",!1).transition().duration(100).style("opacity",0.3)};h.revert=function(a){d3.selectAll(Aa(a)).filter(function(a){return Ta(a.id)}).classed("focused",!1).transition().duration(100).style("opacity",1)};h.show=
function(a){d3.selectAll(Aa(a)).transition().style("opacity",1)};h.hide=function(a){d3.selectAll(Aa(a)).transition().style("opacity",0)};h.load=function(a){u(a.done)&&(a.done=function(){});if("cacheIds"in a&&da(a.cacheIds))xa(ea(a.cacheIds),a.done);else if("data"in a)xa(L(data),a.done);else if("url"in a)d3.csv(a.url,function(b,c){xa(L(c),a.done)});else if("rows"in a)xa(L(na(a.rows)),a.done);else if("columns"in a)xa(L(oa(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});d3.selectAll(".target-"+a).transition().style("opacity",0).remove();ka&&(d3.selectAll(".legend-item-"+a).remove(),Qa(h.data.targets));0<h.data.targets.length&&J()};h.selected=function(a){a=l(a)?"-"+a:"";return d3.merge(g.selectAll(".-shapes"+a).selectAll(".-shape").filter(function(){return d3.select(this).classed(Z)}).map(function(a){return a.map(function(a){return a.__data__})}))};h.select=function(a,b,c){X&&g.selectAll(".-shapes").selectAll(".-shape").each(function(e,
f){var g="circle"===this.nodeName?Mb:rc,h="circle"===this.nodeName?bb:Ob;0<=b.indexOf(f)?ca(e)&&(ba||u(a)||0<=a.indexOf(e.id))&&g(d3.select(this).classed(Z,!0),e,f):l(c)&&c&&h(d3.select(this).classed(Z,!1),e,f)})};h.unselect=function(a,b){X&&g.selectAll(".-shapes").selectAll(".-shape").each(function(c,e){var f="circle"===this.nodeName?bb:Ob;(u(b)||0<=b.indexOf(e))&&ca(c)&&(ba||u(a)||0<=a.indexOf(c.id))&&f(d3.select(this).classed(Z,!1),c,e)})};h.toLine=function(a){$a(a,"line");J()};h.toSpline=function(a){$a(a,
"spline");J()};h.toBar=function(a){$a(a,"bar");J()};h.groups=function(a){if(u(a))return v;v=a;J();return v};h.regions=function(a){if(u(a))return K;K=a;J();return K};h.regions.add=function(a){if(u(a))return K;K=K.concat(a);J();return K};h.regions.remove=function(a,b){var c=[].concat(a);b=l(b)?b:{};c.forEach(function(a){var c=d3.selectAll("."+a);l(b.duration)&&(c=c.transition().duration(b.duration).style("fill-opacity",0));c.remove();K=K.filter(function(b){return 0>b.classes.indexOf(a)})});return K};
h.data.get=function(a){a=h.data.getAsTarget(a);return l(a)?a.values.map(function(a){return a.value}):void 0};h.data.getAsTarget=function(a){var b=Ja(function(b){return b.id==a});return 0<b.length?b[0]:void 0};if("url"in z.data)d3.csv(z.data.url,function(a,b){cb(b)});else if("rows"in z.data)cb(na(z.data.rows));else if("columns"in z.data)cb(oa(z.data.columns));else throw Error("url or rows or columns is required.");mb.onresize=function(){O();R();d3.select("svg").attr("width",q+G+D);d3.select("#"+kb).select("rect").attr("width",
q);d3.select("#xaxis-clip").select("rect").attr("width",q+2);ka&&Qa(h.data.targets,{withTransition:!1});J({withTransition:!1})};return h}})(window);
function(a){return a.getMilliseconds()}]]),aa=d3.time.format(Dc).parse,rb,wb,tb,vb,xb,p,w,fa,zb,Ab,Ya,Za,l,x,P,y,Ha,Ia,D=Da?pb():d3.svg.axis(),ga=d3.svg.axis(),Ja=d3.svg.axis(),ha=Da?pb():d3.svg.axis();O();R();H&&D.tickFormat(Gc);Da?(D.categories(Sa).tickCentered($b),ha.categories(Sa).tickCentered($b)):(D.tickOffset=function(){return 0},ha.tickOffset=function(){return 0});Da&&function(){var a=l,b=y,c=Object.keys(l),e,f;l=function(b){return a(b)+D.tickOffset()};y=function(a){return b(a)+ha.tickOffset()};
for(f=0;f<c.length;f++)e=c[f],l[e]=a[e],y[e]=b[e];l.domain=function(b){if(!arguments.length)return b=a.domain(),b[1]++,b;a.domain(b);return l}}();var Ac=function(){var a=d3.svg.line().x(f?function(a){return F(a.id)(a.value)}:Oa).y(f?Oa:function(a){return F(a.id)(a.value)});return function(b){var c;if(cb(b))return"spline"===W["string"===typeof b?b:b.id]?a.interpolate("cardinal"):a.interpolate("linear"),0<Object.keys(Yb).length?sc(b.values,l,F(b.id),Yb[b.id]):a(b.values);c=l(b.values[0].x);b=F(b.id)(b.values[0].value);
return f?"M "+b+" "+c:"M "+c+" "+b}}(),Bc=function(){var a=d3.svg.line().x(function(a){return y(a.x)}).y(function(a){return B(a.id)(a.value)});return function(b){return cb(b)?a(b.values):"M "+y(b.values[0].x)+" "+B(b.id)(b.values[0].value)}}(),lb=function(a){return"start"in a?l(H?aa(a.start):a.start):0},Xb=function(a){var b=lb(a);a=("end"in a?l(H?aa(a.end):a.end):p)-b;return 0>a?0:a},Q=function(a,b){var c=[],e=null!==b?b:"#1f77b4 #ff7f0e #2ca02c #d62728 #9467bd #8c564b #e377c2 #7f7f7f #bcbd22 #17becf".split(" ");
return function(b){if(b in a)return a[b];0<=c.indexOf(b)||c.push(b);return e[c.indexOf(b)%e.length]}}(Ec,Fc),Ta=d3.select(z.bindto).append("svg").attr("width",p+G+C).attr("height",w+r+T),nb=Ta.append("defs");nb.append("clipPath").attr("id",mb).append("rect").attr("y",r).attr("width",p).attr("height",w-r);nb.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1).attr("y",-1).attr("width",p+2).attr("height",40);nb.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-G+
1).attr("y",r-1).attr("width",G).attr("height",w-r+2);var g=Ta.append("g").attr("transform","translate("+G+","+r+")"),N=null;ya&&(N=Ta.append("g").attr("transform","translate("+I+","+ma+")"));var Ba=null;ka&&(Ba=Ta.append("g").attr("transform","translate("+Ea+","+qb+")"));var ja=d3.select(z.bindto).style("position","relative").append("div").style("position","absolute").style("width","30%").style("z-index","10").style("visibility","hidden"),ia=d3.svg.brush().x(y).on("brush",function(){J({withTransition:!1,
withY:!1,withSubchart:!1})}),Na=null,$a=null;k.focus=function(a){k.defocus();d3.selectAll(Ca(a)).filter(function(a){return Va(a.id)}).classed("focused",!0).transition().duration(100).style("opacity",1)};k.defocus=function(a){d3.selectAll(Ca(a)).filter(function(a){return Va(a.id)}).classed("focused",!1).transition().duration(100).style("opacity",0.3)};k.revert=function(a){d3.selectAll(Ca(a)).filter(function(a){return Va(a.id)}).classed("focused",!1).transition().duration(100).style("opacity",1)};k.show=
function(a){d3.selectAll(Ca(a)).transition().style("opacity",1)};k.hide=function(a){d3.selectAll(Ca(a)).transition().style("opacity",0)};k.load=function(a){t(a.done)&&(a.done=function(){});if("cacheIds"in a&&da(a.cacheIds))za(ea(a.cacheIds),a.done);else if("data"in a)za(L(data),a.done);else if("url"in a)d3.csv(a.url,function(b,c){za(L(c),a.done)});else if("rows"in a)za(L(na(a.rows)),a.done);else if("columns"in a)za(L(oa(a.columns)),a.done);else throw Error("url or rows or columns is required.");};
k.unload=function(a){k.data.targets=k.data.targets.filter(function(b){return b.id!=a});d3.selectAll(".target-"+a).transition().style("opacity",0).remove();ka&&(d3.selectAll(".legend-item-"+a).remove(),Ra(k.data.targets));0<k.data.targets.length&&J()};k.selected=function(a){a=h(a)?"-"+a:"";return d3.merge(g.selectAll(".-shapes"+a).selectAll(".-shape").filter(function(){return d3.select(this).classed(Z)}).map(function(a){return a.map(function(a){return a.__data__})}))};k.select=function(a,b,c){X&&g.selectAll(".-shapes").selectAll(".-shape").each(function(e,
f){var g="circle"===this.nodeName?Mb:rc,k="circle"===this.nodeName?db:Ob;0<=b.indexOf(f)?ca(e)&&(ba||t(a)||0<=a.indexOf(e.id))&&g(d3.select(this).classed(Z,!0),e,f):h(c)&&c&&k(d3.select(this).classed(Z,!1),e,f)})};k.unselect=function(a,b){X&&g.selectAll(".-shapes").selectAll(".-shape").each(function(c,e){var f="circle"===this.nodeName?db:Ob;(t(b)||0<=b.indexOf(e))&&ca(c)&&(ba||t(a)||0<=a.indexOf(c.id))&&f(d3.select(this).classed(Z,!1),c,e)})};k.toLine=function(a){bb(a,"line");J()};k.toSpline=function(a){bb(a,
"spline");J()};k.toBar=function(a){bb(a,"bar");J()};k.groups=function(a){if(t(a))return u;u=a;J();return u};k.regions=function(a){if(t(a))return K;K=a;J();return K};k.regions.add=function(a){if(t(a))return K;K=K.concat(a);J();return K};k.regions.remove=function(a,b){var c=[].concat(a);b=h(b)?b:{};c.forEach(function(a){var c=d3.selectAll("."+a);h(b.duration)&&(c=c.transition().duration(b.duration).style("fill-opacity",0));c.remove();K=K.filter(function(b){return 0>b.classes.indexOf(a)})});return K};
k.data.get=function(a){a=k.data.getAsTarget(a);return h(a)?a.values.map(function(a){return a.value}):void 0};k.data.getAsTarget=function(a){var b=Ka(function(b){return b.id==a});return 0<b.length?b[0]:void 0};if("url"in z.data)d3.csv(z.data.url,function(a,b){eb(b)});else if("rows"in z.data)eb(na(z.data.rows));else if("columns"in z.data)eb(oa(z.data.columns));else throw Error("url or rows or columns is required.");ob.onresize=function(){O();R();d3.select("svg").attr("width",p+G+C);d3.select("#"+mb).select("rect").attr("width",
p);d3.select("#xaxis-clip").select("rect").attr("width",p+2);ka&&Ra(k.data.targets,{withTransition:!1});J({withTransition:!1})};return k}})(window);

116
htdocs/js/c3.min.js vendored

@ -1,61 +1,61 @@
(function(mb){function nb(){function l(c,k){c.attr("transform",function(c){return"translate("+(k(c)+R)+",0)"})}function u(c,k){c.attr("transform",function(c){return"translate(0,"+k(c)+")"})}function Ca(c){var k=c[0];c=c[c.length-1];return k<c?[k,c]:[c,k]}function ma(c){for(var k=[],l=Math.ceil(c[0]);l<c[1];l++)k.push(l);0<k.length&&0<k[0]&&k.unshift(k[0]-(k[1]-k[0]));return k}function r(A){A.each(function(){var k=d3.select(this),A=ma(I.domain()),r=k.selectAll(".tick.major").data(A,String),S=r.enter().insert("g",
"path").attr("class","tick major").style("opacity",1E-6),da=d3.transition(r.exit()).style("opacity",1E-6).remove(),ea=d3.transition(r).style("opacity",1),B,F=I.rangeExtent?I.rangeExtent():Ca(I.range()),k=k.selectAll(".domain").data([0]),k=(k.enter().append("path").attr("class","domain"),d3.transition(k)),C=I.copy(),Ea=this.__chart__||C;this.__chart__=C;S.append("line");S.append("text");var na=S.select("line"),oa=ea.select("line"),L=r.select("text"),pa=S.select("text"),qa=ea.select("text");R=(C(1)-
C(0))/2;r=c?0:R;switch(t){case "bottom":B=l;na.attr("y2",D);pa.attr("y",Math.max(D,0)+G);oa.attr("x1",r).attr("x2",r).attr("y2",D);qa.attr("x",0).attr("y",Math.max(D,0)+G);L.attr("dy",".71em").style("text-anchor","middle");L.text(function(c){return A.length<O||0==c%Math.ceil(A.length/O)?c<M.length?M[c]:c:""});k.attr("d","M"+F[0]+","+T+"V0H"+F[1]+"V"+T);break;case "left":B=u,na.attr("x2",-D),pa.attr("x",-(Math.max(D,0)+G)),oa.attr("x2",-D).attr("y2",0),qa.attr("x",-(Math.max(D,0)+G)).attr("y",R),L.attr("dy",
".32em").style("text-anchor","end"),L.text(function(c){return A.length<O||0==c%Math.ceil(A.length/O)?c<M.length?M[c]:c:""}),k.attr("d","M"+-T+","+F[0]+"H0V"+F[1]+"H"+-T)}if(I.ticks)S.call(B,Ea),ea.call(B,C),da.call(B,C);else{var ra=C.rangeBand()/2,da=function(c){return C(c)+ra};S.call(B,da);ea.call(B,da)}})}var I=d3.scale.linear(),t="bottom",D=6,T=6,G=3,c=!1,O=10,R=0,M=[];r.scale=function(c){if(!arguments.length)return I;I=c;return r};r.orient=function(c){if(!arguments.length)return t;t=c in{top:1,
right:1,bottom:1,left:1}?c+"":"bottom";return r};r.categories=function(c){if(!arguments.length)return M;M=c;return r};r.tickCentered=function(l){if(!arguments.length)return c;c=l;return r};r.tickTextNum=function(c){if(!arguments.length)return O;O=c;return r};r.tickOffset=function(){return R};r.ticks=function(){};return r}function u(l){return"undefined"===typeof l}function l(l){return"undefined"!==typeof l}mb.c3={};c3.generate=function(z){var ob,Ca,ma,r,I,t,D,T,G;function c(a,b){for(var d=z,e=0;e<
a.length;e++){if(!(a[e]in d))return b;d=d[a[e]]}return d}function O(){pb=20+qb+$;rb=!sb||f||Ua?1:50;left=Va?0:40;tb=Fa-qb-$;ub=20+$;vb=Fa-$;t=0;D=rb;T=pb;G=left;ma=tb;r=ub;I=left;ob=vb;Ca=left;q=(null==wb?+d3.select(z.bindto).style("width").replace("px",""):wb)-G-D;w=Fa-t-T;fa=Fa-ma-r}function R(){var a,b,d,e;xb=f?10:0;yb=f?w:q;Wa=f?0:w;Xa=f?q:1;a=M(xb,yb);b=A(Wa,Xa);d=A(Wa,Xa);e=M(0,q);p=l(p)?a.domain(p.domain()):a;x=l(x)?b.domain(x.domain()):b;P=l(P)?d.domain(P.domain()):d;y=l(y)?e.domain(y.domain()):
e;Ga=A(fa,10);Ha=A(fa,10);E.scale(p).orient(f?"left":"bottom");ga.scale(x).orient(f?Va?"top":"bottom":Va?"right":"left");Ia.scale(P).orient(f?Ua?"bottom":"top":Ua?"left":"right");ha.scale(y).orient("bottom")}function M(a,b){return(H?d3.time.scale():d3.scale.linear()).range([a,b])}function A(a,b){return d3.scale.linear().range([a,b])}function k(a){return d3.min(a,function(a){return d3.min(a.values,function(a){return a.value})})}function ac(a){var b={},d,e;a.forEach(function(a){b[a.id]=[];a.values.forEach(function(d){b[a.id].push(d.value)})});
for(d=0;d<v.length;d++)for(e=1;e<v[d].length;e++)sa(v[d][e])&&(u(b[v[d][e]])||b[v[d][e]].forEach(function(a,c){B(v[d][e])===B(v[d][0])&&(b[v[d][0]][c]+=1*a)}));return d3.max(Object.keys(b).map(function(a){return d3.max(b[a])}))}function Da(a,b){var d=Ja(function(a){return B(a.id)===b}),e="y2"===b?bc:cc,n="y2"===b?dc:ec,e=null!==e?e:k(d),n=null!==n?n:ac(d),c=0.1*Math.abs(n-e),m="y2"===b?fc:gc;null!==m&&(yDomainAbs=Math.max(Math.abs(e),Math.abs(n)),n=yDomainAbs-m,e=m-yDomainAbs);"y"===b&&null!==zb&&
(c=zb);"y2"===b&&null!==Ab&&(c=Ab);return[hc(d,"bar")?0:e-c,n+c]}function S(){if(ia.empty())return 1;var a=y.domain(),b=ia.extent();return(a[1]-a[0])/(b[1]-b[0])}function da(a){for(var b=0;b<a.length;b++)if(!(a[b]in Ka))return!1;return!0}function ea(a){for(var b=[],d=0;d<a.length;d++)a[d]in Ka&&b.push(pa(Ka[a[d]]));return b}function B(a){return a in Bb?Bb[a]:"y"}function F(a){return"y2"===B(a)?P:x}function C(a){return"y2"===B(a)?Ha:Ga}function Ea(a){var b=ta[a.id];a.name=l(b)?b:a.id;return a}function na(a){var b=
a[0],d={},e=[],n,c;for(n=1;n<a.length;n++){d={};for(c=0;c<a[n].length;c++)d[b[c]]=a[n][c];e.push(d)}return e}function oa(a){var b=[],d,e,n;for(d=0;d<a.length;d++)for(n=a[d][0],e=1;e<a[d].length;e++)u(b[e-1])&&(b[e-1]={}),b[e-1][n]=a[d][e];return b}function L(a){var b=d3.keys(a[0]).filter(function(a){return a!==La}),d=0,e;a.forEach(function(a){if(H){if(!(La in a))throw Error("'"+La+"' must be included in data");e=aa(a[La]);if(null===e)throw Error("Failed to parse timeseries date in data");a.x=e}else a.x=
d++;null===Ma&&(Ma=new Date(a.x));Ya=new Date(a.x)});b=b.map(function(b,d){var e=ic(b);return{id:e,id_org:b,values:a.map(function(a){return{x:a.x,value:+a[b],id:e}})}});b.forEach(function(a){Ka[a.id_org]=pa(a)});return b}function pa(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 qa(){return d3.max(h.data.targets,function(a){return a.values.length})}function ra(a){a=u(a)?h.data.targets:a;return a.map(function(a){return a.id})}function Ta(a){var b=
ra(),d;for(d=0;d<b.length;d++)if(b[d]===a)return!0;return!1}function Ja(a){return l(a)?h.data.targets.filter(a):h.data.targets}function Za(a){return"-shapes -shapes-"+a.id}function Cb(a){return Za(a)+" -line -line-"+a.id}function jc(a){return Za(a)+" -circles -circles-"+a.id}function Db(a){return Za(a)+" -bars -bars-"+a.id}function kc(a,b){return"-shape -shape-"+b+" -circle -circle-"+b}function Eb(a,b){return"-shape -shape-"+b+" -bar -bar-"+b}function lc(a,b){return"region region-"+b+" "+("classes"in
a?[].concat(a.classes).join(" "):"")}function Na(a){return p(a.x)}function ua(a){return p(H?aa(a.value):a.value)}function Fb(a){return x(a.value)}function U(a){return p(a.x)}function V(a){return F(a.id)(a.value)}function mc(){var a={},b=0,d,e;Ja(sa).forEach(function(c){for(d=0;d<v.length;d++)if(!(0>v[d].indexOf(c.id)))for(e=0;e<v[d].length;e++)if(v[d][e]in a){a[c.id]=a[v[d][e]];break}u(a[c.id])&&(a[c.id]=b++)});a.__max__=b-1;return a}function Gb(a,b,d,e){var c=e?y:p;return function(e){var m=e.id in
d?d[e.id]:0;return c(e.x)-a*(b/2-m)}}function Hb(a,b,d,e){var c=Object.keys(b);return function(f,m){var g=0,h=e?C(f.id):F(f.id);Ja(sa).forEach(function(d){d.id!==f.id&&b[d.id]===b[f.id]&&c.indexOf(d.id)<c.indexOf(f.id)&&(g+=a(d.values[m]))});return d?g:h(f.value)-g}}function Ib(a,b){var d=null===a?function(a){return a}:function(b){return a-b};return function(a){var c=b?C(a.id):F(a.id);return d(c(a.value))}}function $a(a,b){var d=u(a)?ra():a;"string"===typeof d&&(d=[d]);for(var e=0;e<d.length;e++)W[d[e]]=
b}function hc(a,b){var d=!1;a.forEach(function(a){W[a.id]===b&&(d=!0);a.id in W||"line"!==b||(d=!0)});return d}function ab(a){a="string"===typeof a?a:a.id;return!(a in W)||"line"===W[a]||"spline"===W[a]}function sa(a){return"bar"===W["string"===typeof a?a:a.id]}function nc(a){return ab(a)?a.values:[]}function Jb(a){return sa(a)?a.values:[]}function Kb(a,b){var d=d3.mouse(a),e=d3.select(a),c=1*e.attr("cx"),e=1*e.attr("cy");return Math.sqrt(Math.pow(c-d[0],2)+Math.pow(e-d[1],2))<b}function Lb(a){var b=
d3.mouse(a),d=d3.select(a);a=1*d.attr("x");var e=1*d.attr("y"),d=1*d.attr("width");return a-10<b[0]&&b[0]<a+d+10&&e-10<b[1]}function oc(a,b){var d;for(d=0;d<b.length;d++)if(b[d].start<a&&a<=b[d].end)return!0;return!1}function Mb(a,b,d){pc(a,b);g.select(".selected-circles-"+b.id).selectAll(".selected-circle-"+d).data([b]).enter().append("circle").attr("class",function(a){return"selected-circle selected-circle-"+d}).attr("cx",f?V:U).attr("cy",f?U:V).attr("stroke",function(){return Q(b.id)}).attr("r",
1.4*va).transition().duration(100).attr("r",va)}function bb(a,b,d){qc(a,b);g.select(".selected-circles-"+b.id).selectAll(".selected-circle-"+d).transition().duration(100).attr("r",0).remove()}function Nb(a,b,d,e){a?Mb(b,d,e):bb(b,d,e)}function rc(a,b,d){}function Ob(a,b,d){}function Pb(a,b,d,e){}function sc(a,b,d,e){var c,s,m="M",g,h,k,p,r,q=[];if(l(e))for(c=0;c<e.length;c++)q[c]={},u(e[c].start)?q[c].start=a[0].x:H&&(q[c].start=aa(e[c].start)),u(e[c].end)?q[c].end=a[a.length-1].x:H&&(q[c].end=aa(e[c].end));
p=f?function(a){return d(a.value)}:function(a){return b(a.x)};r=f?function(a){return b(a.x)}:function(a){return d(a.value)};e=H?function(a,c,e,m){var n=a.x.getTime();a=c.x-a.x;c=new Date(n+a*(e+m));return"M"+b(new Date(n+a*e))+" "+d(h(e))+" "+b(c)+" "+d(h(e+m))}:function(a,c,e,m){return"M"+b(g(e))+" "+d(h(e))+" "+b(g(e+m))+" "+d(h(e+m))};for(c=0;c<a.length;c++)if(u(q)||!oc(a[c].x,q))m+=" "+p(a[c])+" "+r(a[c]);else for(g=M(a[c-1].x,a[c].x),h=A(a[c-1].value,a[c].value),s=b(a[c].x)-b(a[c-1].x),k=d(a[c].value)-
d(a[c-1].value),s=Math.sqrt(Math.pow(s,2)+Math.pow(k,2)),k=2/s,diffx2=2*k,s=k;1>=s;s+=diffx2)m+=e(a[c-1],a[c],s,k);return m}function cb(a){var b=h.data.targets=L(a),d,c;p.domain(d3.extent(a.map(function(a){return a.x})));x.domain(Da(b,"y"));P.domain(Da(b,"y2"));y.domain(p.domain());Ga.domain(x.domain());Ha.domain(P.domain());E.ticks(10>a.length?a.length:10);ga.ticks(3).outerTickSize(0).tickFormat(tc);Ia.ticks(3).outerTickSize(0).tickFormat(uc);g.append("g").attr("class","x axis").attr("clip-path",
f?"":"url(#xaxis-clip)").attr("transform","translate(0,"+w+")").call(f?ga:E);g.append("g").attr("class","y axis").attr("clip-path",f?"url(#yaxis-clip)":"").call(f?E:ga).append("text").attr("transform","rotate(-90)").attr("dy","1.4em").attr("dx","-.8em").style("text-anchor","end").text(vc);sb&&g.append("g").attr("class","y2 axis").attr("transform","translate("+(f?0:q)+","+(f?10:0)+")").call(Ia);d=g.append("g").attr("clip-path",Oa).attr("class","grid");Qb&&d.append("g").attr("class","xgrids");db&&(c=
d.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(db).enter().append("g").attr("class","xgrid-line"),c.append("line").attr("class",function(a){return""+a["class"]}),c.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",f?"":"rotate(-90)").attr("dx",f?0:-t).attr("dy",-6).text(function(a){return a.text}));wc&&d.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",f?0:-10).attr("x2",f?q:
-10).attr("y1",f?-10:t).attr("y2",f?-10:w);Rb&&d.append("g").attr("class","ygrids");eb&&d.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(eb).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]});g.append("g").attr("clip-path",Oa).attr("class","regions");g.append("g").attr("clip-path",Oa).attr("class","chart");g.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).selectAll(".event-rects").data(a).enter().append("rect").attr("class",
function(a,b){return"event-rect event-rect-"+b}).style("cursor",function(a){return X&&ba?"pointer":null}).on("mouseover",function(a,b){if(!Pa){var d=h.data.targets.map(function(a){return Ea(a.values[b])}),c,e;if(0<Object.keys(ta).length){e=[];for(var k in ta)for(c=0;c<d.length;c++)if(d[c].id===k){e.push(d[c]);d.shift(c);break}d=e.concat(d)}Sb&&g.selectAll(".-circle-"+b).classed(Y,!0).attr("r",Tb);g.selectAll(".-bar-"+b).classed(Y,!0);g.selectAll("line.xgrid-focus").style("visibility","visible").data([d[0]]).attr(f?
"y1":"x1",Na).attr(f?"y2":"x2",Na);ja.style("top",d3.mouse(this)[1]+30+"px").style("left",(f?d3.mouse(this)[0]:p(d[0].x))+60+"px");ja.html(Ub(d));ja.style("visibility","visible")}}).on("mouseout",function(a,b){g.select("line.xgrid-focus").style("visibility","hidden");ja.style("visibility","hidden");g.selectAll(".-circle-"+b).filter(function(){return d3.select(this).classed(Y)}).classed(Y,!1).attr("r",fb);g.selectAll(".-bar-"+b).classed(Y,!1)}).on("mousemove",function(a,b){X&&!Pa&&(ba||g.selectAll(".-shape-"+
b).filter(function(a){return ca(a)}).each(function(a){a=d3.select(this).classed(Y,!0);"circle"===this.nodeName&&a.attr("r",Tb);d3.select(".event-rect-"+b).style("cursor",null)}).filter(function(a){a=d3.select(this);if("circle"===this.nodeName)return Kb(this,va);if("rect"===this.nodeName)return Lb(this,a.attr("x"),a.attr("y"))}).each(function(a){a=d3.select(this);a.classed(Y)||(a.classed(Y,!0),"circle"===this.nodeName&&a.attr("r",va));d3.select(".event-rect-"+b).style("cursor","pointer")}))}).on("click",
function(a,b){g.selectAll(".-shape-"+b).each(function(a){var d=d3.select(this),c=d.classed(Z),e=!1,f;"circle"===this.nodeName?(e=Kb(this,1.5*va),f=Nb):"rect"===this.nodeName&&(e=Lb(this),f=Pb);if(ba||e)X&&ca(a)&&(d.classed(Z,!c),f(!c,d,a,b)),xc(a,d)})}).call(d3.behavior.drag().origin(Object).on("drag",function(a){if(X){a=gb[0];var b=gb[1],d=d3.mouse(this),c=d[0],d=d[1],e=Math.min(a,c),f=Math.max(a,c),h=ba?t:Math.min(b,d),k=ba?w:Math.max(b,d);g.select(".dragarea").attr("x",e).attr("y",h).attr("width",
f-e).attr("height",k-h);g.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return ca(a)}).each(function(a,b){var d=d3.select(this),c=d.classed(Z),n=d.classed(hb),g,m,s,l;g=!1;"circle"===this.nodeName?(g=1*d.attr("cx"),m=1*d.attr("cy"),l=Nb,g=e<g&&g<f&&h<m&&m<k):"rect"===this.nodeName&&(g=1*d.attr("x"),m=1*d.attr("y"),s=1*d.attr("width"),l=Pb,g=e<g+s&&g<f&&m<k);g^n&&(d.classed(hb,!n),d.classed(Z,!c),l(!c,d,a,b))})}}).on("dragstart",function(){X&&(gb=d3.mouse(this),g.select(".chart").append("rect").attr("class",
"dragarea").style("opacity",0.1),Pa=!0)}).on("dragend",function(){X&&(g.select(".dragarea").transition().duration(100).style("opacity",0).remove(),g.selectAll(".-shape").classed(hb,!1),Pa=!1)}));g.select(".chart").append("g").attr("class","chart-bars");g.select(".chart").append("g").attr("class","chart-lines");wa&&(N.append("g").attr("clip-path",Oa).attr("class","chart"),N.select(".chart").append("g").attr("class","chart-bars"),N.select(".chart").append("g").attr("class","chart-lines"),null!==ib&&
ia.extent(H?ib(Ma,Ya):ib(0,qa()-1)),N.append("g").attr("class","x brush").call(ia).selectAll("rect").attr("height",fa),N.append("g").attr("class","x axis").attr("transform","translate(0,"+fa+")").call(ha));ka&&Qa(b);Vb(b);J({withTransition:!1});if(yc){if(H&&"string"==typeof la){la=aa(la);for(a=0;a<b[0].values.length&&0!=b[0].values[a].x-la;a++);la=a}ja.html(Ub(b.map(function(a){return Ea(a.values[la])})));ja.style("top",Wb.top).style("left",Wb.left).style("visibility","visible")}}function J(a){var b=
mc(),d=b.__max__+1,c,n,s,m,k;a=l(a)?a:{};withY=l(a.withY)?a.withY:!0;withSubchart=l(a.withSubchart)?a.withSubchart:!0;withTransition=l(a.withTransition)?a.withTransition:!0;p.domain(ia.empty()?y.domain():ia.extent());x.domain(Da(h.data.targets,"y"));P.domain(Da(h.data.targets,"y2"));g.selectAll(".x.axis").transition().duration(f?250:0).call(f?ga:E);g.selectAll(".y.axis").transition().duration(f?0:250).call(f?E:ga);g.selectAll(".y2.axis").transition().call(Ia);Ga.domain(x.domain());Ha.domain(P.domain());
if(Qb){if("year"===zc)for(a=[],firstYear=Ma.getFullYear(),lastYear=Ya.getFullYear(),c=firstYear;c<=lastYear;c++)a.push(new Date(c+"-01-01 00:00:00"));else a=p.ticks(10);a=g.select(".xgrids").selectAll(".xgrid").data(a);a.enter().append("line").attr("class","xgrid");a.exit().remove();g.selectAll(".xgrid").attr("x1",function(a){return p(a)-E.tickOffset()}).attr("x2",function(a){return p(a)-E.tickOffset()}).attr("y1",t).attr("y2",w)}db&&(a=g.selectAll(".xgrid-lines"),a.selectAll("line").attr("x1",f?
0:ua).attr("x2",f?q:ua).attr("y1",f?ua:t).attr("y2",f?ua:w),a.selectAll("text").attr("x",f?q:0).attr("y",ua));withY&&Rb&&(ygrid=g.select(".ygrids").selectAll(".ygrid").data(x.ticks(10)),ygrid.enter().append("line").attr("class","ygrid"),ygrid.attr("x1",f?x:0).attr("x2",f?x:q).attr("y1",f?0:x).attr("y2",f?w:x).attr("opacity",0).transition().attr("opacity",1),ygrid.exit().remove());withY&&eb&&g.select(".ygrid-lines").selectAll(".ygrid-line").attr("y1",Fb).attr("y2",Fb);s=1.2*E.tickOffset()/d;m=Ib(f?
null:w);c=Gb(s,d,b);n=Hb(m,b,f);a=g.selectAll(".-bars").selectAll(".-bar").data(Jb);a.transition().duration(withTransition?250:0).attr("x",f?n:c).attr("y",f?c:n).attr("width",f?m:s).attr("height",f?s:m);a.enter().append("rect").attr("class",Eb).attr("x",f?n:c).attr("y",f?c:n).attr("width",f?m:s).attr("height",f?s:m).style("opacity",0).transition().duration(withTransition?250:0).style("opacity",1);a.exit().transition().duration(withTransition?250:0).style("opacity",0).remove();g.selectAll(".-line").transition().duration(withTransition?
250:0).attr("d",Ac);a=g.selectAll(".-circles").selectAll(".-circle").data(nc);a.transition().duration(withTransition?250:0).attr("cx",f?V:U).attr("cy",f?U:V);a.enter().append("circle").attr("class",kc).attr("cx",f?V:U).attr("cy",f?U:V).attr("r",fb);a.exit().remove();withSubchart&&wa&&(s=1.2*ha.tickOffset()/d,m=Ib(fa,!0),c=Gb(s,d,b,!0),n=Hb(m,b,!1,!0),contextBar=N.selectAll(".-bars").selectAll(".-bar").data(Jb),contextBar.transition().duration(withTransition?250:0).attr("x",c).attr("y",n).attr("width",
s).attr("height",m),contextBar.enter().append("rect").attr("class",Eb).attr("x",c).attr("y",n).attr("width",s).attr("height",m).style("opacity",0).transition().style("opacity",1),contextBar.exit().transition().style("opacity",0).remove(),N.selectAll(".-line").transition().duration(withTransition?250:0).attr("d",Bc));g.selectAll(".selected-circles").filter(function(a){return sa(a)}).selectAll("circle").remove();g.selectAll(".selected-circle").transition().duration(withTransition?250:0).attr("cx",f?
V:U).attr("cy",f?U:V);k=(f?w:q)*S()/(qa()-1);b=function(a){return p(a.x)-k/2};g.selectAll(".event-rect").attr("x",f?0:b).attr("y",f?b:0).attr("width",f?q:k).attr("height",f?k:w);mainRegion=g.select(".regions").selectAll("rect.region").data(K);mainRegion.enter().append("rect");mainRegion.attr("class",lc).attr("x",f?0:jb).attr("y",f?jb:t).attr("width",f?q:Xb).attr("height",f?Xb:w).style("fill-opacity",function(a){return l(a.opacity)?a.opacity:0.1});mainRegion.exit().transition().duration(withTransition?
(function(ob){function pb(){function h(c,Ua){c.attr("transform",function(c){return"translate("+(Ua(c)+R)+",0)"})}function t(c,h){c.attr("transform",function(c){return"translate(0,"+h(c)+")"})}function Ea(c){var h=c[0];c=c[c.length-1];return h<c?[h,c]:[c,h]}function ma(c){for(var h=[],r=Math.ceil(c[0]);r<c[1];r++)h.push(r);0<h.length&&0<h[0]&&h.unshift(h[0]-(h[1]-h[0]));return h}function n(v){v.each(function(){var v=d3.select(this),n=ma(I.domain()),E=v.selectAll(".tick.major").data(n,String),S=E.enter().insert("g",
"path").attr("class","tick major").style("opacity",1E-6),da=d3.transition(E.exit()).style("opacity",1E-6).remove(),ea=d3.transition(E).style("opacity",1),A,F=I.rangeExtent?I.rangeExtent():Ea(I.range()),v=v.selectAll(".domain").data([0]),v=(v.enter().append("path").attr("class","domain"),d3.transition(v)),B=I.copy(),Fa=this.__chart__||B;this.__chart__=B;S.append("line");S.append("text");var na=S.select("line"),oa=ea.select("line"),L=E.select("text"),pa=S.select("text"),qa=ea.select("text");R=(B(1)-
B(0))/2;E=c?0:R;switch(r){case "bottom":A=h;na.attr("y2",C);pa.attr("y",Math.max(C,0)+G);oa.attr("x1",E).attr("x2",E).attr("y2",C);qa.attr("x",0).attr("y",Math.max(C,0)+G);L.attr("dy",".71em").style("text-anchor","middle");L.text(function(c){return n.length<O||0==c%Math.ceil(n.length/O)?c<M.length?M[c]:c:""});v.attr("d","M"+F[0]+","+T+"V0H"+F[1]+"V"+T);break;case "left":A=t,na.attr("x2",-C),pa.attr("x",-(Math.max(C,0)+G)),oa.attr("x2",-C).attr("y2",0),qa.attr("x",-(Math.max(C,0)+G)).attr("y",R),L.attr("dy",
".32em").style("text-anchor","end"),L.text(function(c){return n.length<O||0==c%Math.ceil(n.length/O)?c<M.length?M[c]:c:""}),v.attr("d","M"+-T+","+F[0]+"H0V"+F[1]+"H"+-T)}if(I.ticks)S.call(A,Fa),ea.call(A,B),da.call(A,B);else{var ra=B.rangeBand()/2,da=function(c){return B(c)+ra};S.call(A,da);ea.call(A,da)}})}var I=d3.scale.linear(),r="bottom",C=6,T=6,G=3,c=!1,O=10,R=0,M=[];n.scale=function(c){if(!arguments.length)return I;I=c;return n};n.orient=function(c){if(!arguments.length)return r;r=c in{top:1,
right:1,bottom:1,left:1}?c+"":"bottom";return n};n.categories=function(c){if(!arguments.length)return M;M=c;return n};n.tickCentered=function(h){if(!arguments.length)return c;c=h;return n};n.tickTextNum=function(c){if(!arguments.length)return O;O=c;return n};n.tickOffset=function(){return R};n.ticks=function(){};return n}function t(h){return"undefined"===typeof h}function h(h){return"undefined"!==typeof h}ob.c3={};c3.generate=function(z){var qb,Ea,ma,n,I,r,C,T,G;function c(a,b){for(var d=z,e=0;e<
a.length;e++){if(!(a[e]in d))return b;d=d[a[e]]}return d}function O(){rb=20+sb+$;tb=!ub||f||Wa?1:50;left=Xa?0:40;vb=Ga-sb-$;wb=20+$;xb=Ga-$;r=0;C=tb;T=rb;G=left;ma=vb;n=wb;I=left;qb=xb;Ea=left;p=(null==yb?+d3.select(z.bindto).style("width").replace("px",""):yb)-G-C;w=Ga-r-T;fa=Ga-ma-n}function R(){var a,b,d,e;zb=f?10:0;Ab=f?w:p;Ya=f?0:w;Za=f?p:1;a=M(zb,Ab);b=v(Ya,Za);d=v(Ya,Za);e=M(0,p);l=h(l)?a.domain(l.domain()):a;x=h(x)?b.domain(x.domain()):b;P=h(P)?d.domain(P.domain()):d;y=h(y)?e.domain(y.domain()):
e;Ha=v(fa,10);Ia=v(fa,10);D.scale(l).orient(f?"left":"bottom");ga.scale(x).orient(f?Xa?"top":"bottom":Xa?"right":"left");Ja.scale(P).orient(f?Wa?"bottom":"top":Wa?"left":"right");ha.scale(y).orient("bottom")}function M(a,b){return(H?d3.time.scale():d3.scale.linear()).range([a,b])}function v(a,b){return d3.scale.linear().range([a,b])}function Ua(a){return d3.min(a,function(a){return d3.min(a.values,function(a){return a.value})})}function ac(a){var b={},d,e;a.forEach(function(a){b[a.id]=[];a.values.forEach(function(d){b[a.id].push(d.value)})});
for(d=0;d<u.length;d++)for(e=1;e<u[d].length;e++)sa(u[d][e])&&(t(b[u[d][e]])||b[u[d][e]].forEach(function(a,c){A(u[d][e])===A(u[d][0])&&(b[u[d][0]][c]+=1*a)}));return d3.max(Object.keys(b).map(function(a){return d3.max(b[a])}))}function E(a,b){var d=Ka(function(a){return A(a.id)===b}),e="y2"===b?bc:cc,q="y2"===b?dc:ec,e=null!==e?e:Ua(d),q=null!==q?q:ac(d),c=0.1*Math.abs(q-e),m=c,f=c,g="y2"===b?fc:gc;null!==g&&(yDomainAbs=Math.max(Math.abs(e),Math.abs(q)),q=yDomainAbs-g,e=g-yDomainAbs);"y"===b&&null!==
ta&&(m=h(ta.top)?ta.top:c,f=h(ta.bottom)?ta.bottom:c);"y2"===b&&null!==ua&&(m=h(ua.top)?ua.top:c,f=h(ua.bottom)?ua.bottom:c);return[hc(d,"bar")?0:e-f,q+m]}function S(){if(ia.empty())return 1;var a=y.domain(),b=ia.extent();return(a[1]-a[0])/(b[1]-b[0])}function da(a){for(var b=0;b<a.length;b++)if(!(a[b]in La))return!1;return!0}function ea(a){for(var b=[],d=0;d<a.length;d++)a[d]in La&&b.push(pa(La[a[d]]));return b}function A(a){return a in Bb?Bb[a]:"y"}function F(a){return"y2"===A(a)?P:x}function B(a){return"y2"===
A(a)?Ia:Ha}function Fa(a){var b=va[a.id];a.name=h(b)?b:a.id;return a}function na(a){var b=a[0],d={},e=[],q,c;for(q=1;q<a.length;q++){d={};for(c=0;c<a[q].length;c++)d[b[c]]=a[q][c];e.push(d)}return e}function oa(a){var b=[],d,e,q;for(d=0;d<a.length;d++)for(q=a[d][0],e=1;e<a[d].length;e++)t(b[e-1])&&(b[e-1]={}),b[e-1][q]=a[d][e];return b}function L(a){var b=d3.keys(a[0]).filter(function(a){return a!==Ma}),d=0,e;a.forEach(function(a){if(H){if(!(Ma in a))throw Error("'"+Ma+"' must be included in data");
e=aa(a[Ma]);if(null===e)throw Error("Failed to parse timeseries date in data");a.x=e}else a.x=d++;null===Na&&(Na=new Date(a.x));$a=new Date(a.x)});b=b.map(function(b,d){var e=ic(b);return{id:e,id_org:b,values:a.map(function(a){return{x:a.x,value:+a[b],id:e}})}});b.forEach(function(a){La[a.id_org]=pa(a)});return b}function pa(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 qa(){return d3.max(k.data.targets,function(a){return a.values.length})}
function ra(a){a=t(a)?k.data.targets:a;return a.map(function(a){return a.id})}function Va(a){var b=ra(),d;for(d=0;d<b.length;d++)if(b[d]===a)return!0;return!1}function Ka(a){return h(a)?k.data.targets.filter(a):k.data.targets}function ab(a){return"-shapes -shapes-"+a.id}function Cb(a){return ab(a)+" -line -line-"+a.id}function jc(a){return ab(a)+" -circles -circles-"+a.id}function Db(a){return ab(a)+" -bars -bars-"+a.id}function kc(a,b){return"-shape -shape-"+b+" -circle -circle-"+b}function Eb(a,
b){return"-shape -shape-"+b+" -bar -bar-"+b}function lc(a,b){return"region region-"+b+" "+("classes"in a?[].concat(a.classes).join(" "):"")}function Oa(a){return l(a.x)}function wa(a){return l(H?aa(a.value):a.value)}function Fb(a){return x(a.value)}function U(a){return l(a.x)}function V(a){return F(a.id)(a.value)}function mc(){var a={},b=0,d,e;Ka(sa).forEach(function(c){for(d=0;d<u.length;d++)if(!(0>u[d].indexOf(c.id)))for(e=0;e<u[d].length;e++)if(u[d][e]in a){a[c.id]=a[u[d][e]];break}t(a[c.id])&&
(a[c.id]=b++)});a.__max__=b-1;return a}function Gb(a,b,d,e){var c=e?y:l;return function(e){var m=e.id in d?d[e.id]:0;return c(e.x)-a*(b/2-m)}}function Hb(a,b,d,e){var c=Object.keys(b);return function(f,m){var h=0,g=e?B(f.id):F(f.id);Ka(sa).forEach(function(d){d.id!==f.id&&b[d.id]===b[f.id]&&c.indexOf(d.id)<c.indexOf(f.id)&&(h+=a(d.values[m]))});return d?h:g(f.value)-h}}function Ib(a,b){var d=null===a?function(a){return a}:function(b){return a-b};return function(a){var c=b?B(a.id):F(a.id);return d(c(a.value))}}
function bb(a,b){var d=t(a)?ra():a;"string"===typeof d&&(d=[d]);for(var e=0;e<d.length;e++)W[d[e]]=b}function hc(a,b){var d=!1;a.forEach(function(a){W[a.id]===b&&(d=!0);a.id in W||"line"!==b||(d=!0)});return d}function cb(a){a="string"===typeof a?a:a.id;return!(a in W)||"line"===W[a]||"spline"===W[a]}function sa(a){return"bar"===W["string"===typeof a?a:a.id]}function nc(a){return cb(a)?a.values:[]}function Jb(a){return sa(a)?a.values:[]}function Kb(a,b){var d=d3.mouse(a),e=d3.select(a),c=1*e.attr("cx"),
e=1*e.attr("cy");return Math.sqrt(Math.pow(c-d[0],2)+Math.pow(e-d[1],2))<b}function Lb(a){var b=d3.mouse(a),d=d3.select(a);a=1*d.attr("x");var e=1*d.attr("y"),d=1*d.attr("width");return a-10<b[0]&&b[0]<a+d+10&&e-10<b[1]}function oc(a,b){var d;for(d=0;d<b.length;d++)if(b[d].start<a&&a<=b[d].end)return!0;return!1}function Mb(a,b,d){pc(a,b);g.select(".selected-circles-"+b.id).selectAll(".selected-circle-"+d).data([b]).enter().append("circle").attr("class",function(a){return"selected-circle selected-circle-"+
d}).attr("cx",f?V:U).attr("cy",f?U:V).attr("stroke",function(){return Q(b.id)}).attr("r",1.4*xa).transition().duration(100).attr("r",xa)}function db(a,b,d){qc(a,b);g.select(".selected-circles-"+b.id).selectAll(".selected-circle-"+d).transition().duration(100).attr("r",0).remove()}function Nb(a,b,d,e){a?Mb(b,d,e):db(b,d,e)}function rc(a,b,d){}function Ob(a,b,d){}function Pb(a,b,d,e){}function sc(a,b,d,e){var c,s,m="M",g,k,l,n,r,p=[];if(h(e))for(c=0;c<e.length;c++)p[c]={},t(e[c].start)?p[c].start=a[0].x:
H&&(p[c].start=aa(e[c].start)),t(e[c].end)?p[c].end=a[a.length-1].x:H&&(p[c].end=aa(e[c].end));n=f?function(a){return d(a.value)}:function(a){return b(a.x)};r=f?function(a){return b(a.x)}:function(a){return d(a.value)};e=H?function(a,c,e,f){var m=a.x.getTime();a=c.x-a.x;c=new Date(m+a*(e+f));return"M"+b(new Date(m+a*e))+" "+d(k(e))+" "+b(c)+" "+d(k(e+f))}:function(a,c,e,f){return"M"+b(g(e))+" "+d(k(e))+" "+b(g(e+f))+" "+d(k(e+f))};for(c=0;c<a.length;c++)if(t(p)||!oc(a[c].x,p))m+=" "+n(a[c])+" "+r(a[c]);
else for(g=M(a[c-1].x,a[c].x),k=v(a[c-1].value,a[c].value),s=b(a[c].x)-b(a[c-1].x),l=d(a[c].value)-d(a[c-1].value),s=Math.sqrt(Math.pow(s,2)+Math.pow(l,2)),l=2/s,diffx2=2*l,s=l;1>=s;s+=diffx2)m+=e(a[c-1],a[c],s,l);return m}function eb(a){var b=k.data.targets=L(a),d,c;l.domain(d3.extent(a.map(function(a){return a.x})));x.domain(E(b,"y"));P.domain(E(b,"y2"));y.domain(l.domain());Ha.domain(x.domain());Ia.domain(P.domain());D.ticks(10>a.length?a.length:10);ga.ticks(3).outerTickSize(0).tickFormat(tc);
Ja.ticks(3).outerTickSize(0).tickFormat(uc);g.append("g").attr("class","x axis").attr("clip-path",f?"":"url(#xaxis-clip)").attr("transform","translate(0,"+w+")").call(f?ga:D);g.append("g").attr("class","y axis").attr("clip-path",f?"url(#yaxis-clip)":"").call(f?D:ga).append("text").attr("transform","rotate(-90)").attr("dy","1.4em").attr("dx","-.8em").style("text-anchor","end").text(vc);ub&&g.append("g").attr("class","y2 axis").attr("transform","translate("+(f?0:p)+","+(f?10:0)+")").call(Ja);d=g.append("g").attr("clip-path",
Pa).attr("class","grid");Qb&&d.append("g").attr("class","xgrids");fb&&(c=d.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(fb).enter().append("g").attr("class","xgrid-line"),c.append("line").attr("class",function(a){return""+a["class"]}),c.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",f?"":"rotate(-90)").attr("dx",f?0:-r).attr("dy",-6).text(function(a){return a.text}));wc&&d.append("g").attr("class","xgrid-focus").append("line").attr("class",
"xgrid-focus").attr("x1",f?0:-10).attr("x2",f?p:-10).attr("y1",f?-10:r).attr("y2",f?-10:w);Rb&&d.append("g").attr("class","ygrids");gb&&d.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(gb).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]});g.append("g").attr("clip-path",Pa).attr("class","regions");g.append("g").attr("clip-path",Pa).attr("class","chart");g.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).selectAll(".event-rects").data(a).enter().append("rect").attr("class",
function(a,b){return"event-rect event-rect-"+b}).style("cursor",function(a){return X&&ba?"pointer":null}).on("mouseover",function(a,b){if(!Qa){var d=k.data.targets.map(function(a){return Fa(a.values[b])}),c,e;if(0<Object.keys(va).length){e=[];for(var h in va)for(c=0;c<d.length;c++)if(d[c].id===h){e.push(d[c]);d.shift(c);break}d=e.concat(d)}Sb&&g.selectAll(".-circle-"+b).classed(Y,!0).attr("r",Tb);g.selectAll(".-bar-"+b).classed(Y,!0);g.selectAll("line.xgrid-focus").style("visibility","visible").data([d[0]]).attr(f?
"y1":"x1",Oa).attr(f?"y2":"x2",Oa);ja.style("top",d3.mouse(this)[1]+30+"px").style("left",(f?d3.mouse(this)[0]:l(d[0].x))+60+"px");ja.html(Ub(d));ja.style("visibility","visible")}}).on("mouseout",function(a,b){g.select("line.xgrid-focus").style("visibility","hidden");ja.style("visibility","hidden");g.selectAll(".-circle-"+b).filter(function(){return d3.select(this).classed(Y)}).classed(Y,!1).attr("r",hb);g.selectAll(".-bar-"+b).classed(Y,!1)}).on("mousemove",function(a,b){X&&!Qa&&(ba||g.selectAll(".-shape-"+
b).filter(function(a){return ca(a)}).each(function(a){a=d3.select(this).classed(Y,!0);"circle"===this.nodeName&&a.attr("r",Tb);d3.select(".event-rect-"+b).style("cursor",null)}).filter(function(a){a=d3.select(this);if("circle"===this.nodeName)return Kb(this,xa);if("rect"===this.nodeName)return Lb(this,a.attr("x"),a.attr("y"))}).each(function(a){a=d3.select(this);a.classed(Y)||(a.classed(Y,!0),"circle"===this.nodeName&&a.attr("r",xa));d3.select(".event-rect-"+b).style("cursor","pointer")}))}).on("click",
function(a,b){g.selectAll(".-shape-"+b).each(function(a){var d=d3.select(this),c=d.classed(Z),e=!1,f;"circle"===this.nodeName?(e=Kb(this,1.5*xa),f=Nb):"rect"===this.nodeName&&(e=Lb(this),f=Pb);if(ba||e)X&&ca(a)&&(d.classed(Z,!c),f(!c,d,a,b)),xc(a,d)})}).call(d3.behavior.drag().origin(Object).on("drag",function(a){if(X){a=ib[0];var b=ib[1],d=d3.mouse(this),c=d[0],d=d[1],e=Math.min(a,c),f=Math.max(a,c),h=ba?r:Math.min(b,d),k=ba?w:Math.max(b,d);g.select(".dragarea").attr("x",e).attr("y",h).attr("width",
f-e).attr("height",k-h);g.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return ca(a)}).each(function(a,b){var d=d3.select(this),c=d.classed(Z),q=d.classed(jb),g,m,s,l;g=!1;"circle"===this.nodeName?(g=1*d.attr("cx"),m=1*d.attr("cy"),l=Nb,g=e<g&&g<f&&h<m&&m<k):"rect"===this.nodeName&&(g=1*d.attr("x"),m=1*d.attr("y"),s=1*d.attr("width"),l=Pb,g=e<g+s&&g<f&&m<k);g^q&&(d.classed(jb,!q),d.classed(Z,!c),l(!c,d,a,b))})}}).on("dragstart",function(){X&&(ib=d3.mouse(this),g.select(".chart").append("rect").attr("class",
"dragarea").style("opacity",0.1),Qa=!0)}).on("dragend",function(){X&&(g.select(".dragarea").transition().duration(100).style("opacity",0).remove(),g.selectAll(".-shape").classed(jb,!1),Qa=!1)}));g.select(".chart").append("g").attr("class","chart-bars");g.select(".chart").append("g").attr("class","chart-lines");ya&&(N.append("g").attr("clip-path",Pa).attr("class","chart"),N.select(".chart").append("g").attr("class","chart-bars"),N.select(".chart").append("g").attr("class","chart-lines"),null!==kb&&
ia.extent(H?kb(Na,$a):kb(0,qa()-1)),N.append("g").attr("class","x brush").call(ia).selectAll("rect").attr("height",fa),N.append("g").attr("class","x axis").attr("transform","translate(0,"+fa+")").call(ha));ka&&Ra(b);Vb(b);J({withTransition:!1});if(yc){if(H&&"string"==typeof la){la=aa(la);for(a=0;a<b[0].values.length&&0!=b[0].values[a].x-la;a++);la=a}ja.html(Ub(b.map(function(a){return Fa(a.values[la])})));ja.style("top",Wb.top).style("left",Wb.left).style("visibility","visible")}}function J(a){var b=
mc(),d=b.__max__+1,c,q,s,m,n;a=h(a)?a:{};withY=h(a.withY)?a.withY:!0;withSubchart=h(a.withSubchart)?a.withSubchart:!0;withTransition=h(a.withTransition)?a.withTransition:!0;l.domain(ia.empty()?y.domain():ia.extent());x.domain(E(k.data.targets,"y"));P.domain(E(k.data.targets,"y2"));g.selectAll(".x.axis").transition().duration(f?250:0).call(f?ga:D);g.selectAll(".y.axis").transition().duration(f?0:250).call(f?D:ga);g.selectAll(".y2.axis").transition().call(Ja);Ha.domain(x.domain());Ia.domain(P.domain());
if(Qb){if("year"===zc)for(a=[],firstYear=Na.getFullYear(),lastYear=$a.getFullYear(),c=firstYear;c<=lastYear;c++)a.push(new Date(c+"-01-01 00:00:00"));else a=l.ticks(10);a=g.select(".xgrids").selectAll(".xgrid").data(a);a.enter().append("line").attr("class","xgrid");a.exit().remove();g.selectAll(".xgrid").attr("x1",function(a){return l(a)-D.tickOffset()}).attr("x2",function(a){return l(a)-D.tickOffset()}).attr("y1",r).attr("y2",w)}fb&&(a=g.selectAll(".xgrid-lines"),a.selectAll("line").attr("x1",f?
0:wa).attr("x2",f?p:wa).attr("y1",f?wa:r).attr("y2",f?wa:w),a.selectAll("text").attr("x",f?p:0).attr("y",wa));withY&&Rb&&(ygrid=g.select(".ygrids").selectAll(".ygrid").data(x.ticks(10)),ygrid.enter().append("line").attr("class","ygrid"),ygrid.attr("x1",f?x:0).attr("x2",f?x:p).attr("y1",f?0:x).attr("y2",f?w:x).attr("opacity",0).transition().attr("opacity",1),ygrid.exit().remove());withY&&gb&&g.select(".ygrid-lines").selectAll(".ygrid-line").attr("y1",Fb).attr("y2",Fb);s=1.2*D.tickOffset()/d;m=Ib(f?
null:w);c=Gb(s,d,b);q=Hb(m,b,f);a=g.selectAll(".-bars").selectAll(".-bar").data(Jb);a.transition().duration(withTransition?250:0).attr("x",f?q:c).attr("y",f?c:q).attr("width",f?m:s).attr("height",f?s:m);a.enter().append("rect").attr("class",Eb).attr("x",f?q:c).attr("y",f?c:q).attr("width",f?m:s).attr("height",f?s:m).style("opacity",0).transition().duration(withTransition?250:0).style("opacity",1);a.exit().transition().duration(withTransition?250:0).style("opacity",0).remove();g.selectAll(".-line").transition().duration(withTransition?
250:0).attr("d",Ac);a=g.selectAll(".-circles").selectAll(".-circle").data(nc);a.transition().duration(withTransition?250:0).attr("cx",f?V:U).attr("cy",f?U:V);a.enter().append("circle").attr("class",kc).attr("cx",f?V:U).attr("cy",f?U:V).attr("r",hb);a.exit().remove();withSubchart&&ya&&(s=1.2*ha.tickOffset()/d,m=Ib(fa,!0),c=Gb(s,d,b,!0),q=Hb(m,b,!1,!0),contextBar=N.selectAll(".-bars").selectAll(".-bar").data(Jb),contextBar.transition().duration(withTransition?250:0).attr("x",c).attr("y",q).attr("width",
s).attr("height",m),contextBar.enter().append("rect").attr("class",Eb).attr("x",c).attr("y",q).attr("width",s).attr("height",m).style("opacity",0).transition().style("opacity",1),contextBar.exit().transition().style("opacity",0).remove(),N.selectAll(".-line").transition().duration(withTransition?250:0).attr("d",Bc));g.selectAll(".selected-circles").filter(function(a){return sa(a)}).selectAll("circle").remove();g.selectAll(".selected-circle").transition().duration(withTransition?250:0).attr("cx",f?
V:U).attr("cy",f?U:V);n=(f?w:p)*S()/(qa()-1);b=function(a){return l(a.x)-n/2};g.selectAll(".event-rect").attr("x",f?0:b).attr("y",f?b:0).attr("width",f?p:n).attr("height",f?n:w);mainRegion=g.select(".regions").selectAll("rect.region").data(K);mainRegion.enter().append("rect");mainRegion.attr("class",lc).attr("x",f?0:lb).attr("y",f?lb:r).attr("width",f?p:Xb).attr("height",f?Xb:w).style("fill-opacity",function(a){return h(a.opacity)?a.opacity:0.1});mainRegion.exit().transition().duration(withTransition?
250:0).style("fill-opacity",0).remove()}function Vb(a){var b;g.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",Db).style("fill",function(a){return Q(a.id)}).style("stroke",function(a){return Q(a.id)}).style("stroke-width",0).style("cursor",function(a){return ca(a)?"pointer":null});b=g.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",Cb).style("stroke",function(a){return Q(a.id)});b.append("g").attr("class",function(a){return"selected-circles selected-circles-"+a.id});b.append("g").attr("class",jc).style("fill",function(a){return Q(a.id)}).style("cursor",function(a){return ca(a)?"pointer":null});a.forEach(function(a){g.selectAll(".selected-circles-"+a.id).selectAll(".selected-circle").each(function(b){b.value=
a.values[b.x].value})});wa&&(b=N.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",Db).style("fill",function(a){return Q(a.id)}),b=N.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",Cb).style("stroke",function(a){return Q(a.id)}));
ka&&Qa(a);d3.selectAll(".target").transition().style("opacity",1)}function xa(a,b){h.data.targets.forEach(function(b){for(var c=0;c<a.length;c++)if(b.id===a[c].id){b.values=a[c].values;a.splice(c,1);break}});h.data.targets=h.data.targets.concat(a);Vb(h.data.targets);J();b()}function Qa(a,b){var c=ra(a),e,f=q/2-ya*Object.keys(a).length/2,g;b=u(b)?{}:b;g=l(b.withTransition)?b.withTransition:!0;e=za.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){Cc(a)}).on("mouseover",function(a){d3.selectAll(".legend-item").filter(function(b){return b!==a}).transition().duration(100).style("opacity",0.3);h.focus(a)}).on("mouseout",function(a){d3.selectAll(".legend-item").transition().duration(100).style("opacity",1);h.revert()});e.append("rect").attr("class","legend-item-event").style("fill-opacity",0).attr("x",-200).attr("y",function(){return $/2-16}).attr("width",ya).attr("height",24);e.append("rect").attr("class",
"legend-item-tile").style("fill",function(a){return Q(a)}).attr("x",-200).attr("y",function(){return $/2-9}).attr("width",10).attr("height",10);e.append("text").text(function(a){return l(ta[a])?ta[a]:a}).attr("x",-200).attr("y",function(a,b){return $/2});za.selectAll("rect.legend-item-event").data(c).transition().duration(g?250:0).attr("x",function(a,b){return f+ya*b});za.selectAll("rect.legend-item-tile").data(c).transition().duration(g?250:0).attr("x",function(a,b){return f+ya*b});za.selectAll("text").data(c).transition().duration(g?
250:0).attr("x",function(a,b){return f+ya*b+14})}function Aa(a){return l(a)?".target-"+a:".target"}var h={data:{}},Ka={},Y="_expanded_",Z="_selected_",hb="_included_";if(!("bindto"in z))throw Error("bindto is required in config");var wb=c(["size","width"],null),Fa=c(["size","height"],280);if(!("data"in z))throw Error("data is required in config");var La=c(["data","x"],"x"),Dc=c(["data","x_format"],"%Y-%m-%d"),ic=c(["data","id_converter"],function(a){return a}),ta=c(["data","names"],{}),v=c(["data",
"groups"],[]),Bb=c(["data","axes"],{}),W=c(["data","types"],{}),Yb=c(["data","regions"],{}),Ec=c(["data","colors"],{}),X=c(["data","selection","enabled"],!1),ba=c(["data","selection","grouped"],!1),ca=c(["data","selection","isselectable"],function(a){return!0}),wa=c(["subchart","show"],!1),qb=wa?c(["subchart","size","height"],60):0,ib=c(["subchart","default"],null),Fc=c(["color","pattern"],null),ka=c(["legend","show"],!0),ya=c(["legend","item","width"],80),Cc=c(["legend","item","onclick"],function(){}),
Zb=c(["axis","x","type"],"indexed"),Ra=c(["axis","x","categories"],[]),$b=c(["axis","x","tick","centered"],!1),ec=c(["axis","y","max"],null),cc=c(["axis","y","min"],null),gc=c(["axis","y","center"],null),vc=c(["axis","y","text"],null);c(["axis","y","rescale"],!0);var Va=c(["axis","y","inner"],!1),tc=c(["axis","y","format"],function(a){return a}),zb=c(["axis","y","padding"],null),sb=c(["axis","y2","show"],!1),dc=c(["axis","y2","max"],null),bc=c(["axis","y2","min"],null),fc=c(["axis","y2","center"],
null);c(["axis","y2","text"],null);c(["axis","y2","rescale"],!0);var Ua=c(["axis","y2","inner"],!1),uc=c(["axis","y2","format"],function(a){return a}),Ab=c(["axis","y2","padding"],null),f=c(["axis","rotated"],!1),Qb=c(["grid","x","show"],!1),zc=c(["grid","x","type"],"tick"),db=c(["grid","x","lines"],null),Rb=c(["grid","y","show"],!1);c(["grid","y","type"],"tick");var eb=c(["grid","y","lines"],null),fb=c(["point","show"],!0)?c(["point","r"],2.5):0,wc=c(["point","focus","line","enabled"],!0),Sb=c(["point",
"focus","expand","enabled"],!0),Tb=c(["point","focus","expand","r"],Sb?4:fb),va=c(["point","focus","select","r"],8),xc=c(["point","onclick"],function(){}),pc=c(["point","onselected"],function(){}),qc=c(["point","onunselected"],function(){}),K=c(["regions"],[]),Ub=c(["tooltip","contents"],function(a){var b="<table class='-tooltip'><tr><th colspan='2'>"+(H?a[0].x.getFullYear()+"."+(a[0].x.getMonth()+1)+"."+a[0].x.getDate():Ba?a[0].x<Ra.length?Ra[a[0].x]:a[0].x:a[0].x)+"</th></tr>",c,e,f;for(c=0;c<a.length;c++)l(a[c])?
(e=l(a[c].value)?(Math.round(100*a[c].value)/100).toFixed(2):"-",f=a[c].name):f=e="-",b+="<tr><td><span style='background-color:"+Q(a[c].id)+"'></span>"+f+"</td><td class='value'>"+e+"</td></tr>";return b+"</table>"}),yc=c(["tooltip","init","show"],!1),la=c(["tooltip","init","x"],0),Wb=c(["tooltip","init","position"],{top:"0px",left:"50px"}),kb=z.bindto.replace("#","")+"-clip",Oa="url(#"+kb+")",H="timeseries"===Zb,Ba="categorized"===Zb,gb=null,Pa=!1,$=ka?40:0,Gc=function(a){return function(b){for(var c=
a.values[b.x].value})});ya&&(b=N.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",Db).style("fill",function(a){return Q(a.id)}),b=N.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",Cb).style("stroke",function(a){return Q(a.id)}));
ka&&Ra(a);d3.selectAll(".target").transition().style("opacity",1)}function za(a,b){k.data.targets.forEach(function(b){for(var c=0;c<a.length;c++)if(b.id===a[c].id){b.values=a[c].values;a.splice(c,1);break}});k.data.targets=k.data.targets.concat(a);Vb(k.data.targets);J();b()}function Ra(a,b){var c=ra(a),e,f=p/2-Aa*Object.keys(a).length/2,g;b=t(b)?{}:b;g=h(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){Cc(a)}).on("mouseover",function(a){d3.selectAll(".legend-item").filter(function(b){return b!==a}).transition().duration(100).style("opacity",0.3);k.focus(a)}).on("mouseout",function(a){d3.selectAll(".legend-item").transition().duration(100).style("opacity",1);k.revert()});e.append("rect").attr("class","legend-item-event").style("fill-opacity",0).attr("x",-200).attr("y",function(){return $/2-16}).attr("width",Aa).attr("height",24);e.append("rect").attr("class",
"legend-item-tile").style("fill",function(a){return Q(a)}).attr("x",-200).attr("y",function(){return $/2-9}).attr("width",10).attr("height",10);e.append("text").text(function(a){return h(va[a])?va[a]:a}).attr("x",-200).attr("y",function(a,b){return $/2});Ba.selectAll("rect.legend-item-event").data(c).transition().duration(g?250:0).attr("x",function(a,b){return f+Aa*b});Ba.selectAll("rect.legend-item-tile").data(c).transition().duration(g?250:0).attr("x",function(a,b){return f+Aa*b});Ba.selectAll("text").data(c).transition().duration(g?
250:0).attr("x",function(a,b){return f+Aa*b+14})}function Ca(a){return h(a)?".target-"+a:".target"}var k={data:{}},La={},Y="_expanded_",Z="_selected_",jb="_included_";if(!("bindto"in z))throw Error("bindto is required in config");var yb=c(["size","width"],null),Ga=c(["size","height"],280);if(!("data"in z))throw Error("data is required in config");var Ma=c(["data","x"],"x"),Dc=c(["data","x_format"],"%Y-%m-%d"),ic=c(["data","id_converter"],function(a){return a}),va=c(["data","names"],{}),u=c(["data",
"groups"],[]),Bb=c(["data","axes"],{}),W=c(["data","types"],{}),Yb=c(["data","regions"],{}),Ec=c(["data","colors"],{}),X=c(["data","selection","enabled"],!1),ba=c(["data","selection","grouped"],!1),ca=c(["data","selection","isselectable"],function(a){return!0}),ya=c(["subchart","show"],!1),sb=ya?c(["subchart","size","height"],60):0,kb=c(["subchart","default"],null),Fc=c(["color","pattern"],null),ka=c(["legend","show"],!0),Aa=c(["legend","item","width"],80),Cc=c(["legend","item","onclick"],function(){}),
Zb=c(["axis","x","type"],"indexed"),Sa=c(["axis","x","categories"],[]),$b=c(["axis","x","tick","centered"],!1),ec=c(["axis","y","max"],null),cc=c(["axis","y","min"],null),gc=c(["axis","y","center"],null),vc=c(["axis","y","text"],null);c(["axis","y","rescale"],!0);var Xa=c(["axis","y","inner"],!1),tc=c(["axis","y","format"],function(a){return a}),ta=c(["axis","y","padding"],null),ub=c(["axis","y2","show"],!1),dc=c(["axis","y2","max"],null),bc=c(["axis","y2","min"],null),fc=c(["axis","y2","center"],
null);c(["axis","y2","text"],null);c(["axis","y2","rescale"],!0);var Wa=c(["axis","y2","inner"],!1),uc=c(["axis","y2","format"],function(a){return a}),ua=c(["axis","y2","padding"],null),f=c(["axis","rotated"],!1),Qb=c(["grid","x","show"],!1),zc=c(["grid","x","type"],"tick"),fb=c(["grid","x","lines"],null),Rb=c(["grid","y","show"],!1);c(["grid","y","type"],"tick");var gb=c(["grid","y","lines"],null),hb=c(["point","show"],!0)?c(["point","r"],2.5):0,wc=c(["point","focus","line","enabled"],!0),Sb=c(["point",
"focus","expand","enabled"],!0),Tb=c(["point","focus","expand","r"],Sb?4:hb),xa=c(["point","focus","select","r"],8),xc=c(["point","onclick"],function(){}),pc=c(["point","onselected"],function(){}),qc=c(["point","onunselected"],function(){}),K=c(["regions"],[]),Ub=c(["tooltip","contents"],function(a){var b="<table class='-tooltip'><tr><th colspan='2'>"+(H?a[0].x.getFullYear()+"."+(a[0].x.getMonth()+1)+"."+a[0].x.getDate():Da?a[0].x<Sa.length?Sa[a[0].x]:a[0].x:a[0].x)+"</th></tr>",c,e,f;for(c=0;c<a.length;c++)h(a[c])?
(e=h(a[c].value)?(Math.round(100*a[c].value)/100).toFixed(2):"-",f=a[c].name):f=e="-",b+="<tr><td><span style='background-color:"+Q(a[c].id)+"'></span>"+f+"</td><td class='value'>"+e+"</td></tr>";return b+"</table>"}),yc=c(["tooltip","init","show"],!1),la=c(["tooltip","init","x"],0),Wb=c(["tooltip","init","position"],{top:"0px",left:"50px"}),mb=z.bindto.replace("#","")+"-clip",Pa="url(#"+mb+")",H="timeseries"===Zb,Da="categorized"===Zb,ib=null,Qa=!1,$=ka?40:0,Gc=function(a){return function(b){for(var c=
a.length-1,e=a[c];!e[1](b);)e=a[--c];return e[0](b)}}([[d3.time.format("%Y/%-m/%-d"),function(){return!0}],[d3.time.format("%-m/%-d"),function(a){return a.getMonth()}],[d3.time.format("%-m/%-d"),function(a){return 1!=a.getDate()}],[d3.time.format("%-m/%-d"),function(a){return a.getDay()&&1!=a.getDate()}],[d3.time.format("%I %p"),function(a){return a.getHours()}],[d3.time.format("%I:%M"),function(a){return a.getMinutes()}],[d3.time.format(":%S"),function(a){return a.getSeconds()}],[d3.time.format(".%L"),
function(a){return a.getMilliseconds()}]]),aa=d3.time.format(Dc).parse,pb,ub,rb,tb,vb,q,w,fa,xb,yb,Wa,Xa,p,x,P,y,Ga,Ha,E=Ba?nb():d3.svg.axis(),ga=d3.svg.axis(),Ia=d3.svg.axis(),ha=Ba?nb():d3.svg.axis();O();R();H&&E.tickFormat(Gc);Ba?(E.categories(Ra).tickCentered($b),ha.categories(Ra).tickCentered($b)):(E.tickOffset=function(){return 0},ha.tickOffset=function(){return 0});Ba&&function(){var a=p,b=y,c=Object.keys(p),e,f;p=function(b){return a(b)+E.tickOffset()};y=function(a){return b(a)+ha.tickOffset()};
for(f=0;f<c.length;f++)e=c[f],p[e]=a[e],y[e]=b[e];p.domain=function(b){if(!arguments.length)return b=a.domain(),b[1]++,b;a.domain(b);return p}}();var Ac=function(){var a=d3.svg.line().x(f?function(a){return F(a.id)(a.value)}:Na).y(f?Na:function(a){return F(a.id)(a.value)});return function(b){var c;if(ab(b))return"spline"===W["string"===typeof b?b:b.id]?a.interpolate("cardinal"):a.interpolate("linear"),0<Object.keys(Yb).length?sc(b.values,p,F(b.id),Yb[b.id]):a(b.values);c=p(b.values[0].x);b=F(b.id)(b.values[0].value);
return f?"M "+b+" "+c:"M "+c+" "+b}}(),Bc=function(){var a=d3.svg.line().x(function(a){return y(a.x)}).y(function(a){return C(a.id)(a.value)});return function(b){return ab(b)?a(b.values):"M "+y(b.values[0].x)+" "+C(b.id)(b.values[0].value)}}(),jb=function(a){return"start"in a?p(H?aa(a.start):a.start):0},Xb=function(a){var b=jb(a);a=("end"in a?p(H?aa(a.end):a.end):q)-b;return 0>a?0:a},Q=function(a,b){var c=[],e=null!==b?b:"#1f77b4 #ff7f0e #2ca02c #d62728 #9467bd #8c564b #e377c2 #7f7f7f #bcbd22 #17becf".split(" ");
return function(b){if(b in a)return a[b];0<=c.indexOf(b)||c.push(b);return e[c.indexOf(b)%e.length]}}(Ec,Fc),Sa=d3.select(z.bindto).append("svg").attr("width",q+G+D).attr("height",w+t+T),lb=Sa.append("defs");lb.append("clipPath").attr("id",kb).append("rect").attr("y",t).attr("width",q).attr("height",w-t);lb.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1).attr("y",-1).attr("width",q+2).attr("height",40);lb.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-G+
1).attr("y",t-1).attr("width",G).attr("height",w-t+2);var g=Sa.append("g").attr("transform","translate("+G+","+t+")"),N=null;wa&&(N=Sa.append("g").attr("transform","translate("+I+","+ma+")"));var za=null;ka&&(za=Sa.append("g").attr("transform","translate("+Ca+","+ob+")"));var ja=d3.select(z.bindto).style("position","relative").append("div").style("position","absolute").style("width","30%").style("z-index","10").style("visibility","hidden"),ia=d3.svg.brush().x(y).on("brush",function(){J({withTransition:!1,
withY:!1,withSubchart:!1})}),Ma=null,Ya=null;h.focus=function(a){h.defocus();d3.selectAll(Aa(a)).filter(function(a){return Ta(a.id)}).classed("focused",!0).transition().duration(100).style("opacity",1)};h.defocus=function(a){d3.selectAll(Aa(a)).filter(function(a){return Ta(a.id)}).classed("focused",!1).transition().duration(100).style("opacity",0.3)};h.revert=function(a){d3.selectAll(Aa(a)).filter(function(a){return Ta(a.id)}).classed("focused",!1).transition().duration(100).style("opacity",1)};h.show=
function(a){d3.selectAll(Aa(a)).transition().style("opacity",1)};h.hide=function(a){d3.selectAll(Aa(a)).transition().style("opacity",0)};h.load=function(a){u(a.done)&&(a.done=function(){});if("cacheIds"in a&&da(a.cacheIds))xa(ea(a.cacheIds),a.done);else if("data"in a)xa(L(data),a.done);else if("url"in a)d3.csv(a.url,function(b,c){xa(L(c),a.done)});else if("rows"in a)xa(L(na(a.rows)),a.done);else if("columns"in a)xa(L(oa(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});d3.selectAll(".target-"+a).transition().style("opacity",0).remove();ka&&(d3.selectAll(".legend-item-"+a).remove(),Qa(h.data.targets));0<h.data.targets.length&&J()};h.selected=function(a){a=l(a)?"-"+a:"";return d3.merge(g.selectAll(".-shapes"+a).selectAll(".-shape").filter(function(){return d3.select(this).classed(Z)}).map(function(a){return a.map(function(a){return a.__data__})}))};h.select=function(a,b,c){X&&g.selectAll(".-shapes").selectAll(".-shape").each(function(e,
f){var g="circle"===this.nodeName?Mb:rc,h="circle"===this.nodeName?bb:Ob;0<=b.indexOf(f)?ca(e)&&(ba||u(a)||0<=a.indexOf(e.id))&&g(d3.select(this).classed(Z,!0),e,f):l(c)&&c&&h(d3.select(this).classed(Z,!1),e,f)})};h.unselect=function(a,b){X&&g.selectAll(".-shapes").selectAll(".-shape").each(function(c,e){var f="circle"===this.nodeName?bb:Ob;(u(b)||0<=b.indexOf(e))&&ca(c)&&(ba||u(a)||0<=a.indexOf(c.id))&&f(d3.select(this).classed(Z,!1),c,e)})};h.toLine=function(a){$a(a,"line");J()};h.toSpline=function(a){$a(a,
"spline");J()};h.toBar=function(a){$a(a,"bar");J()};h.groups=function(a){if(u(a))return v;v=a;J();return v};h.regions=function(a){if(u(a))return K;K=a;J();return K};h.regions.add=function(a){if(u(a))return K;K=K.concat(a);J();return K};h.regions.remove=function(a,b){var c=[].concat(a);b=l(b)?b:{};c.forEach(function(a){var c=d3.selectAll("."+a);l(b.duration)&&(c=c.transition().duration(b.duration).style("fill-opacity",0));c.remove();K=K.filter(function(b){return 0>b.classes.indexOf(a)})});return K};
h.data.get=function(a){a=h.data.getAsTarget(a);return l(a)?a.values.map(function(a){return a.value}):void 0};h.data.getAsTarget=function(a){var b=Ja(function(b){return b.id==a});return 0<b.length?b[0]:void 0};if("url"in z.data)d3.csv(z.data.url,function(a,b){cb(b)});else if("rows"in z.data)cb(na(z.data.rows));else if("columns"in z.data)cb(oa(z.data.columns));else throw Error("url or rows or columns is required.");mb.onresize=function(){O();R();d3.select("svg").attr("width",q+G+D);d3.select("#"+kb).select("rect").attr("width",
q);d3.select("#xaxis-clip").select("rect").attr("width",q+2);ka&&Qa(h.data.targets,{withTransition:!1});J({withTransition:!1})};return h}})(window);
function(a){return a.getMilliseconds()}]]),aa=d3.time.format(Dc).parse,rb,wb,tb,vb,xb,p,w,fa,zb,Ab,Ya,Za,l,x,P,y,Ha,Ia,D=Da?pb():d3.svg.axis(),ga=d3.svg.axis(),Ja=d3.svg.axis(),ha=Da?pb():d3.svg.axis();O();R();H&&D.tickFormat(Gc);Da?(D.categories(Sa).tickCentered($b),ha.categories(Sa).tickCentered($b)):(D.tickOffset=function(){return 0},ha.tickOffset=function(){return 0});Da&&function(){var a=l,b=y,c=Object.keys(l),e,f;l=function(b){return a(b)+D.tickOffset()};y=function(a){return b(a)+ha.tickOffset()};
for(f=0;f<c.length;f++)e=c[f],l[e]=a[e],y[e]=b[e];l.domain=function(b){if(!arguments.length)return b=a.domain(),b[1]++,b;a.domain(b);return l}}();var Ac=function(){var a=d3.svg.line().x(f?function(a){return F(a.id)(a.value)}:Oa).y(f?Oa:function(a){return F(a.id)(a.value)});return function(b){var c;if(cb(b))return"spline"===W["string"===typeof b?b:b.id]?a.interpolate("cardinal"):a.interpolate("linear"),0<Object.keys(Yb).length?sc(b.values,l,F(b.id),Yb[b.id]):a(b.values);c=l(b.values[0].x);b=F(b.id)(b.values[0].value);
return f?"M "+b+" "+c:"M "+c+" "+b}}(),Bc=function(){var a=d3.svg.line().x(function(a){return y(a.x)}).y(function(a){return B(a.id)(a.value)});return function(b){return cb(b)?a(b.values):"M "+y(b.values[0].x)+" "+B(b.id)(b.values[0].value)}}(),lb=function(a){return"start"in a?l(H?aa(a.start):a.start):0},Xb=function(a){var b=lb(a);a=("end"in a?l(H?aa(a.end):a.end):p)-b;return 0>a?0:a},Q=function(a,b){var c=[],e=null!==b?b:"#1f77b4 #ff7f0e #2ca02c #d62728 #9467bd #8c564b #e377c2 #7f7f7f #bcbd22 #17becf".split(" ");
return function(b){if(b in a)return a[b];0<=c.indexOf(b)||c.push(b);return e[c.indexOf(b)%e.length]}}(Ec,Fc),Ta=d3.select(z.bindto).append("svg").attr("width",p+G+C).attr("height",w+r+T),nb=Ta.append("defs");nb.append("clipPath").attr("id",mb).append("rect").attr("y",r).attr("width",p).attr("height",w-r);nb.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1).attr("y",-1).attr("width",p+2).attr("height",40);nb.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-G+
1).attr("y",r-1).attr("width",G).attr("height",w-r+2);var g=Ta.append("g").attr("transform","translate("+G+","+r+")"),N=null;ya&&(N=Ta.append("g").attr("transform","translate("+I+","+ma+")"));var Ba=null;ka&&(Ba=Ta.append("g").attr("transform","translate("+Ea+","+qb+")"));var ja=d3.select(z.bindto).style("position","relative").append("div").style("position","absolute").style("width","30%").style("z-index","10").style("visibility","hidden"),ia=d3.svg.brush().x(y).on("brush",function(){J({withTransition:!1,
withY:!1,withSubchart:!1})}),Na=null,$a=null;k.focus=function(a){k.defocus();d3.selectAll(Ca(a)).filter(function(a){return Va(a.id)}).classed("focused",!0).transition().duration(100).style("opacity",1)};k.defocus=function(a){d3.selectAll(Ca(a)).filter(function(a){return Va(a.id)}).classed("focused",!1).transition().duration(100).style("opacity",0.3)};k.revert=function(a){d3.selectAll(Ca(a)).filter(function(a){return Va(a.id)}).classed("focused",!1).transition().duration(100).style("opacity",1)};k.show=
function(a){d3.selectAll(Ca(a)).transition().style("opacity",1)};k.hide=function(a){d3.selectAll(Ca(a)).transition().style("opacity",0)};k.load=function(a){t(a.done)&&(a.done=function(){});if("cacheIds"in a&&da(a.cacheIds))za(ea(a.cacheIds),a.done);else if("data"in a)za(L(data),a.done);else if("url"in a)d3.csv(a.url,function(b,c){za(L(c),a.done)});else if("rows"in a)za(L(na(a.rows)),a.done);else if("columns"in a)za(L(oa(a.columns)),a.done);else throw Error("url or rows or columns is required.");};
k.unload=function(a){k.data.targets=k.data.targets.filter(function(b){return b.id!=a});d3.selectAll(".target-"+a).transition().style("opacity",0).remove();ka&&(d3.selectAll(".legend-item-"+a).remove(),Ra(k.data.targets));0<k.data.targets.length&&J()};k.selected=function(a){a=h(a)?"-"+a:"";return d3.merge(g.selectAll(".-shapes"+a).selectAll(".-shape").filter(function(){return d3.select(this).classed(Z)}).map(function(a){return a.map(function(a){return a.__data__})}))};k.select=function(a,b,c){X&&g.selectAll(".-shapes").selectAll(".-shape").each(function(e,
f){var g="circle"===this.nodeName?Mb:rc,k="circle"===this.nodeName?db:Ob;0<=b.indexOf(f)?ca(e)&&(ba||t(a)||0<=a.indexOf(e.id))&&g(d3.select(this).classed(Z,!0),e,f):h(c)&&c&&k(d3.select(this).classed(Z,!1),e,f)})};k.unselect=function(a,b){X&&g.selectAll(".-shapes").selectAll(".-shape").each(function(c,e){var f="circle"===this.nodeName?db:Ob;(t(b)||0<=b.indexOf(e))&&ca(c)&&(ba||t(a)||0<=a.indexOf(c.id))&&f(d3.select(this).classed(Z,!1),c,e)})};k.toLine=function(a){bb(a,"line");J()};k.toSpline=function(a){bb(a,
"spline");J()};k.toBar=function(a){bb(a,"bar");J()};k.groups=function(a){if(t(a))return u;u=a;J();return u};k.regions=function(a){if(t(a))return K;K=a;J();return K};k.regions.add=function(a){if(t(a))return K;K=K.concat(a);J();return K};k.regions.remove=function(a,b){var c=[].concat(a);b=h(b)?b:{};c.forEach(function(a){var c=d3.selectAll("."+a);h(b.duration)&&(c=c.transition().duration(b.duration).style("fill-opacity",0));c.remove();K=K.filter(function(b){return 0>b.classes.indexOf(a)})});return K};
k.data.get=function(a){a=k.data.getAsTarget(a);return h(a)?a.values.map(function(a){return a.value}):void 0};k.data.getAsTarget=function(a){var b=Ka(function(b){return b.id==a});return 0<b.length?b[0]:void 0};if("url"in z.data)d3.csv(z.data.url,function(a,b){eb(b)});else if("rows"in z.data)eb(na(z.data.rows));else if("columns"in z.data)eb(oa(z.data.columns));else throw Error("url or rows or columns is required.");ob.onresize=function(){O();R();d3.select("svg").attr("width",p+G+C);d3.select("#"+mb).select("rect").attr("width",
p);d3.select("#xaxis-clip").select("rect").attr("width",p+2);ka&&Ra(k.data.targets,{withTransition:!1});J({withTransition:!1})};return k}})(window);

Loading…
Cancel
Save