Browse Source

Fix timeseries with region when resize

pull/1/head
Masayuki Tanaka 11 years ago
parent
commit
fea302bdff
  1. 16
      c3.js
  2. 92
      c3.min.js

16
c3.js

@ -734,24 +734,26 @@
//-- Shape --//
function lineWithRegions (d, x, y, regions) {
function lineWithRegions (d, x, y, _regions) {
var prev = -1, i, j;
var s = "M", sWithRegion;
var xp, yp, dx, dy, dd, diff, diff2;
var xValue, yValue;
var regions = [];
// Check start/end of regions
if (isDefined(regions)) {
for (i = 0; i < regions.length; i++){
if (isUndefined(regions[i].start)) {
if (isDefined(_regions)) {
for (i = 0; i < _regions.length; i++){
regions[i] = {};
if (isUndefined(_regions[i].start)) {
regions[i].start = d[0].x;
} else if (isTimeSeries) {
regions[i].start = parseDate(regions[i].start);
regions[i].start = parseDate(_regions[i].start);
}
if (isUndefined(regions[i].end)) {
if (isUndefined(_regions[i].end)) {
regions[i].end = d[d.length-1].x;
} else if (isTimeSeries) {
regions[i].end = parseDate(regions[i].end);
regions[i].end = parseDate(_regions[i].end);
}
}
}

92
c3.min.js vendored

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

Loading…
Cancel
Save