Browse Source

Enable zoom

pull/1/head
Masayuki Tanaka 11 years ago
parent
commit
ab3c382657
  1. 39
      c3.js
  2. 123
      c3.min.js
  3. 123
      htdocs/js/c3.min.js

39
c3.js

@ -421,8 +421,15 @@
return [hasBarType(yTargets) ? 0 : yDomainMin-padding_bottom, yDomainMax+padding_top];
}
function getXDomainRatio () {
if (brush.empty()) return 1;
var domain = subX.domain(), extent = brush.extent();
var domain, extent;
if (__subchart_show) {
if (brush.empty()) return 1;
domain = subX.domain();
extent = brush.extent();
} else {
domain = orgXDomain;
extent = x.domain();
}
return (domain[1] - domain[0]) / (extent[1] - extent[0]);
}
@ -828,6 +835,7 @@
/*-- Define brush --*/
var brush = d3.svg.brush().x(subX).on("brush", redrawForBrush);
var zoom = d3.behavior.zoom().on("zoom", redrawForZoom);
/*-- Draw Chart --*/
@ -835,6 +843,8 @@
var firstDate = null,
lastDate = null;
var orgXDomain;
function init (data) {
var targets = c3.data.targets = convertDataToTargets(data);
var rectX, rectW;
@ -855,6 +865,12 @@
yAxis.ticks(3).outerTickSize(0).tickFormat(__axis_y_format);
yAxis2.ticks(3).outerTickSize(0).tickFormat(__axis_y2_format);
// Save original x domain for zoom update
orgXDomain = x.domain();
// MEMO: must set x here for timeseries data
zoom.x(x);
/*-- Main Region --*/
// Add Axis
@ -1123,7 +1139,8 @@
dragging = false;
// TODO: add callback here
})
);
)
.call(zoom);
// Define g for bar chart area
main.select(".chart").append("g")
@ -1204,14 +1221,20 @@
var barIndices = getBarIndices(), barTargetsNum = barIndices.__max__ + 1;
var barX, barY, barW, barH;
var rectX, rectW;
var withY, withSubchart, withTransition, withUpdateXDomain;
// Hide tooltip and grid
main.select('line.xgrid-focus').style("visibility", "hidden");
tooltip.style("visibility", "hidden");
options = isDefined(options) ? options : {};
withY = isDefined(options.withY) ? options.withY : true;
withSubchart = isDefined(options.withSubchart) ? options.withSubchart : true;
withTransition = isDefined(options.withTransition) ? options.withTransition : true;
withUpdateXDomain = isDefined(options.withUpdateXDomain) ? options.withUpdateXDomain : true;
// ATTENTION: call here to update tickOffset
x.domain(brush.empty() ? subX.domain() : brush.extent());
if (withUpdateXDomain) x.domain(brush.empty() ? subX.domain() : brush.extent());
y.domain(getYDomain(c3.data.targets, 'y'));
y2.domain(getYDomain(c3.data.targets, 'y2'));
@ -1387,6 +1410,14 @@
withSubchart: false
});
}
function redrawForZoom() {
redraw({
withTransition: false,
withY: false,
withSubchart: false,
withUpdateXDomain: false
});
}
function resize () {
// Update sizes and scales

123
c3.min.js vendored

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

123
htdocs/js/c3.min.js vendored

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

Loading…
Cancel
Save