Browse Source

Move axis init location

pull/1/head
Masayuki Tanaka 11 years ago
parent
commit
0eaad0cbb4
  1. 50
      c3.js
  2. 83
      c3.min.js

50
c3.js

@ -833,6 +833,31 @@
/*-- Main Region --*/
// Add Axis
main.append("g")
.attr("class", "x axis")
.attr("clip-path", __axis_rotated ? "" : "url(#xaxis-clip)")
.attr("transform", "translate(0," + height + ")")
.call(__axis_rotated ? yAxis : xAxis);
main.append("g")
.attr("class", "y axis")
.attr("clip-path", __axis_rotated ? "url(#yaxis-clip)" : "")
.call(__axis_rotated ? xAxis : yAxis)
.append("text")
.attr("transform", "rotate(-90)")
.attr("dy", "1.4em")
.attr("dx", "-.8em")
.style("text-anchor", "end")
.text(__axis_y_text);
if (__axis_y2_show) {
main.append("g")
.attr("class", "y2 axis")
.attr("transform", "translate(" + (__axis_rotated ? 0 : width) + "," + (__axis_rotated ? 10 : 0) + ")")
.call(yAxis2);
}
// Grids
grid = main.append('g')
.attr("clip-path", clipPath)
.attr('class', 'grid');
@ -1084,31 +1109,6 @@
main.select(".chart").append("g")
.attr("class", "chart-lines");
// ATTENTION: This must be called AFTER chart added
// Add Axis
main.append("g")
.attr("class", "x axis")
.attr("clip-path", __axis_rotated ? "" : "url(#xaxis-clip)")
.attr("transform", "translate(0," + height + ")")
.call(__axis_rotated ? yAxis : xAxis);
main.append("g")
.attr("class", "y axis")
.attr("clip-path", __axis_rotated ? "url(#yaxis-clip)" : "")
.call(__axis_rotated ? xAxis : yAxis)
.append("text")
.attr("transform", "rotate(-90)")
.attr("dy", "1.4em")
.attr("dx", "-.8em")
.style("text-anchor", "end")
.text(__axis_y_text);
if (__axis_y2_show) {
main.append("g")
.attr("class", "y2 axis")
.attr("transform", "translate(" + (__axis_rotated ? 0 : width) + "," + (__axis_rotated ? 10 : 0) + ")")
.call(yAxis2);
}
/*-- Context Region --*/
if (__subchart_show) {

83
c3.min.js vendored

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

Loading…
Cancel
Save