Browse Source

Enable zoom extent option

pull/1/head
Masayuki Tanaka 11 years ago
parent
commit
1f10d96a18
  1. 27
      c3.js
  2. 129
      c3.min.js

27
c3.js

@ -33,7 +33,8 @@
var __size_width = getConfig(['size','width'], null),
__size_height = getConfig(['size','height'], null);
var __zoom_enabled = getConfig(['zoom','enabled'], false);
var __zoom_enabled = getConfig(['zoom','enabled'], false),
__zoom_extent = getConfig(['zoom','extent'], [1, 10]);
// data - data configuration
checkConfig('data', 'data is required in config');
@ -362,6 +363,9 @@
}
return (domain[1] - domain[0]) / (extent[1] - extent[0]);
}
function diffDomain (d) {
return d[1]-d[0];
}
//-- Cache --//
@ -793,13 +797,19 @@
//-- Define brush/zoom -//
var brush = d3.svg.brush().on("brush", redrawForBrush);
var zoom = d3.behavior.zoom().on("zoomstart", function(){ zoom.startDomain = d3.event.sourceEvent.altKey ? x.orgDomain() : null; }).on("zoom", __zoom_enabled ? redrawForZoom : null);
var zoom = d3.behavior.zoom().on("zoomstart", function(){ zoom.altDomain = d3.event.sourceEvent.altKey ? x.orgDomain() : null; }).on("zoom", __zoom_enabled ? redrawForZoom : null).scaleExtent(__zoom_extent);
// define functions for c3
brush.update = function () {
if (context) context.select('.x.brush').call(this);
return this;
}
zoom.orgScaleExtent = zoom.scaleExtent();
zoom.updateScaleExtent = function () {
var ratio = diffDomain(x.orgDomain())/diffDomain(orgXDomain);
this.scaleExtent([this.orgScaleExtent[0]*ratio, this.orgScaleExtent[1]*ratio]);
return this;
}
/*-- Draw Chart --*/
@ -1104,7 +1114,7 @@
.call(
d3.behavior.drag().origin(Object).on('drag', function(d){
if ( ! __data_selection_enabled) return; // do nothing if not selectable
if (__zoom_enabled && ! zoom.startDomain) return; // skip if zoomable because of conflict drag dehavior
if (__zoom_enabled && ! zoom.altDomain) return; // skip if zoomable because of conflict drag dehavior
var sx = dragStart[0], sy = dragStart[1],
mouse = d3.mouse(this),
@ -1263,7 +1273,7 @@
// ATTENTION: call here to update tickOffset
if (withUpdateXDomain) {
x.domain(brush.empty() ? orgXDomain : brush.extent());
if (__zoom_enabled) zoom.x(x);
if (__zoom_enabled) zoom.x(x).updateScaleExtent();
}
y.domain(getYDomain(c3.data.targets, 'y'));
y2.domain(getYDomain(c3.data.targets, 'y2'));
@ -1461,11 +1471,14 @@
});
}
function redrawForZoom() {
if (d3.event.sourceEvent.type === 'mousemove' && zoom.startDomain) {
x.domain(zoom.startDomain);
zoom.x(x);
if (d3.event.sourceEvent.type === 'mousemove' && zoom.altDomain) {
x.domain(zoom.altDomain);
zoom.x(x).updateScaleExtent();
return;
}
if (isCategorized && x.orgDomain()[0] === orgXDomain[0]) {
x.domain([orgXDomain[0]-1e-10, x.orgDomain()[1]]);
}
redraw({
withTransition: false,
withY: false,

129
c3.min.js vendored

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

Loading…
Cancel
Save