Browse Source

Fix line with region for timeseries

pull/1/head
Masayuki Tanaka 11 years ago
parent
commit
10db08343a
  1. 50
      c3.js
  2. 114
      c3.min.js

50
c3.js

@ -170,12 +170,12 @@
yMin = __axis_rotated ? 0 : height,
yMax = __axis_rotated ? width : 1;
var x = ((isTimeSeries) ? d3.time.scale() : d3.scale.linear()).range([xMin, xMax]),
y = d3.scale.linear().range([yMin, yMax]),
y2 = d3.scale.linear().range([yMin, yMax]),
subX = ((isTimeSeries) ? d3.time.scale() : d3.scale.linear()).range([0, width]),
subY = d3.scale.linear().range([height2, 10]),
subY2 = d3.scale.linear().range([height2, 10]);
var x = getX(xMin, xMax),
y = getY(yMin, yMax),
y2 = getY(yMin, yMax),
subX = getX(0, width),
subY = getY(height2, 10),
subY2 = getY(height2, 10);
// TODO: Enable set position
var xAxis = isCategorized ? categoryAxis() : d3.svg.axis(),
@ -328,6 +328,15 @@
/*-- Define Functions --*/
//-- Scale --//
function getX (min, max) {
return ((isTimeSeries) ? d3.time.scale() : d3.scale.linear()).range([min, max]);
}
function getY (min, max) {
return d3.scale.linear().range([min, max]);
}
//-- Domain --//
function getYDomainMin (targets) {
@ -698,7 +707,7 @@
function lineWithRegions (d, x, y, regions) {
var prev = -1, i, j;
var s = "M";
var s = "M", sWithRegion;
var xp, yp, dx, dy, dd, diff, diff2;
var xValue, yValue;
@ -707,9 +716,13 @@
for (i = 0; i < regions.length; i++){
if (isUndefined(regions[i].start)) {
regions[i].start = d[0].x;
} else if (isTimeSeries) {
regions[i].start = parseDate(regions[i].start);
}
if (isUndefined(regions[i].end)) {
regions[i].end = d[d.length-1].x;
} else if (isTimeSeries) {
regions[i].end = parseDate(regions[i].end);
}
}
}
@ -718,6 +731,20 @@
xValue = __axis_rotated ? function(d){ return y(d.value); } : function(d){ return x(d.x); };
yValue = __axis_rotated ? function(d){ return x(d.x); } : function(d){ return y(d.value); };
// Define svg generator function for region
if (isTimeSeries) {
sWithRegion = function (d0, d1, j, diff) {
var x0 = d0.x.getTime(), x_diff = d1.x-d0.x,
xv0 = new Date(x0 + x_diff * j),
xv1 = new Date(x0 + x_diff * (j+diff));
return "M"+x(xv0)+" "+y(yp(j))+" "+x(xv1)+" "+y(yp(j+diff));
}
} else {
sWithRegion = function (d0, d1, j, diff) {
return "M"+x(xp(j))+" "+y(yp(j))+" "+x(xp(j+diff))+" "+y(yp(j+diff));
}
}
// Generate
for (i = 0; i < d.length; i++) {
// Draw as normal
@ -726,19 +753,22 @@
}
// Draw with region // TODO: Fix for horizotal charts
else {
xp = d3.scale.linear().range([d[i-1].x, d[i].x]);
yp = d3.scale.linear().range([d[i-1].value, d[i].value]);
xp = getX(d[i-1].x, d[i].x);
yp = getY(d[i-1].value, d[i].value);
dx = x(d[i].x) - x(d[i-1].x);
dy = y(d[i].value) - y(d[i-1].value);
dd = Math.sqrt(Math.pow(dx,2) + Math.pow(dy,2));
diff = 2/dd;
diffx2 = diff*2;
for (j = diff; j <= 1; j += diffx2) {
s += "M"+x(xp(j))+" "+y(yp(j))+" "+x(xp(j+diff))+" "+y(yp(j+diff));
s += sWithRegion(d[i-1], d[i], j, diff);
}
}
prev = d[i].x;
}
return s;
}

114
c3.min.js vendored

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

Loading…
Cancel
Save