From c91efd94aca5806fbb784c9756735b5c4a909b5d Mon Sep 17 00:00:00 2001 From: Masayuki Tanaka Date: Thu, 20 Feb 2014 11:26:55 +0900 Subject: [PATCH] Fix focus/defocus interface --- c3.js | 18 +++++++-- c3.min.js | 107 +++++++++++++++++++++++++++--------------------------- 2 files changed, 69 insertions(+), 56 deletions(-) diff --git a/c3.js b/c3.js index 43a2d22..ef73945 100644 --- a/c3.js +++ b/c3.js @@ -2468,9 +2468,18 @@ /*-- Draw Legend --*/ function focusLegend(id) { - svg.selectAll('.legend-item').filter(function (d) { return d !== id; }) - .transition().duration(100) - .style('opacity', 0.3); + var legendItem = svg.selectAll('.legend-item'), + isTarget = function (d) { return !id || d === id; }, + notTarget = function (d) { return !isTarget(d); }; + legendItem.filter(notTarget).transition().duration(100).style('opacity', 0.3); + legendItem.filter(isTarget).transition().duration(100).style('opacity', 1); + } + function defocusLegend(id) { + var legendItem = svg.selectAll('.legend-item'), + isTarget = function (d) { return !id || d === id; }, + notTarget = function (d) { return !isTarget(d); }; + legendItem.filter(notTarget).transition().duration(100).style('opacity', 1); + legendItem.filter(isTarget).transition().duration(100).style('opacity', 0.3); } function revertLegend() { svg.selectAll('.legend-item') @@ -2560,6 +2569,7 @@ function focus(targets) { targets.transition().duration(100).style('opacity', 1); } + c3.revert(); c3.defocus(); focus(candidatesForNoneArc.classed('focused', true)); focus(candidatesForArc); @@ -2576,11 +2586,13 @@ function defocus(targets) { targets.transition().duration(100).style('opacity', 0.3); } + c3.revert(); defocus(candidatesForNoneArc.classed('focused', false)); defocus(candidatesForArc); if (hasArcType(c3.data.targets)) { unexpandArc(target); } + defocusLegend(target); }; c3.revert = function (target) { diff --git a/c3.min.js b/c3.min.js index b7979d8..9be010b 100644 --- a/c3.min.js +++ b/c3.min.js @@ -1,18 +1,18 @@ -(function(P){function ld(){function u(d,f){d.attr("transform",function(d){return"translate("+(f(d)+ca)+", 0)"})}function x(d,f){d.attr("transform",function(d){return"translate(0,"+f(d)+")"})}function P(d){var f=d[0];d=d[d.length-1];return fa?a:0}),c=1;ca?a:0}),c=1;c+a||(b[e][c]+=+a)});return d.max(Object.keys(b).map(function(a){return d.max(b[a])}))}function mb(a){var b=nb(function(b){return y(b.id)===a}),c="y2"===a?xd:yd,e="y2"===a?zd:Ad,c=c?c:ud(b),e=e?e:vd(b),k=0.1*Math.abs(e-c),d=k,f=k,g="y2"===a?Bd:Cd;g&&(c=Math.max(Math.abs(c),Math.abs(e)),e=c-g,c=g-c);"y"===a&&Ia&&(d=Ia.top?Ia.top:k,f=Ia.bottom?Ia.bottom:k);"y2"===a&&Ja&&(d=Ja.top?Ja.top:k,f=Ja.bottom? Ja.bottom:k);ma(b,"bar")&&!tc(b)&&(f=c);return[c-f,e+d]}function Dd(a){return d.min(a,function(a){return d.min(a.values,function(a){return a.x})})}function Ed(a){return d.max(a,function(a){return d.max(a.values,function(a){return a.x})})}function ob(a){var b=[Dd(a),Ed(a)];a=b[0];var b=b[1],c=ea?0:0.01*Math.abs(a-b);a=B?new Date(a.getTime()-c):a-c;b=B?new Date(b.getTime()+c):b+c;return[a,b]}function ua(a){return a[1]-a[0]}function Fd(a){for(var b=0;ba?0:a}function wc(a){return oa&&a===oa||$&&Hd($,a)}function Id(a){return!wc(a)}function Jd(a){Object.keys(a).forEach(function(b){$[b]=a[b]})}function qb(a){var b;a&&(b=Ka[a.id],a.name=b?b:a.id);return a}function xc(a){var b=a[0],c={},e=[],k,d;for(k=1;ka?0:a}function wc(a){return oa&&a===oa||$&&Hd($,a)}function Id(a){return!wc(a)}function Jd(a){Object.keys(a).forEach(function(b){$[b]=a[b]})}function qb(a){var b;a&&(b=Ka[a.id],a.name=b?b:a.id);return a}function xc(a){var b=a[0],c={},e=[],k,d;for(k=1;kb&&(c=a,b=a.values.length)}):c=a?h.data.targets[0]:null;return c}function rb(a){a=x(a)?h.data.targets: @@ -20,67 +20,68 @@ a;return a.map(function(a){return a.id})}function Bc(a){var b=rb(),c;for(c=0;ck&&(d-=c+30)),c=b[1]+15+ek&&(d-=c+30)),c=b[1]+15+et[c].indexOf(k.id)))for(e=0;e=f;f+=q)h+=e(a[d-1],a[d],f,za)}return h}function Wb(a){var b;tb=d.select(ta);if(tb.empty())P.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');else{tb.html("");h.data.x={};h.data.targets=La(a);ra();R();m.domain(d.extent(ob(h.data.targets)));z.domain(mb("y"));Z.domain(mb("y2"));V.domain(m.domain());hb.domain(z.domain());ib.domain(Z.domain());J.ticks(10>a.length?a.length:10);va.ticks(be).outerTickSize(0).tickFormat(ce); -jb.ticks(de).outerTickSize(0).tickFormat(ee);U=m.domain();L.scale(V);pa&&E.scale(m);q=d.select(ta).append("svg").attr("width",p+A+Y).attr("height",s+r+O).on("mouseenter",fe).on("mouseleave",ge);ub=q.append("defs");ub.append("clipPath").attr("id",Xb).append("rect").attr("y",r).attr("width",p).attr("height",s-r);ub.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1-A).attr("y",-20).attr("width",N).attr("height",da);ub.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x", --A+1).attr("y",r-1).attr("width",ia).attr("height",yb);l=q.append("g").attr("transform",M.main);F=Aa?q.append("g").attr("transform",M.context):null;Ba=Ca?q.append("g").attr("transform",M.legend):null;W=d.select(ta).style("position","relative").append("div").style("position","absolute").style("z-index","10").style("display","none");l.append("g").attr("class","x axis").attr("clip-path",g?"":"url(#xaxis-clip)").attr("transform",M.x).call(g?va:J).append("text").attr("class","-axis-x-label").attr("x", -p).attr("dy","-.5em").style("text-anchor","end").text(he);l.append("g").attr("class","y axis").attr("clip-path",g?"url(#yaxis-clip)":"").call(g?J:va).append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(ie);Bb&&l.append("g").attr("class","y2 axis").attr("transform",M.y2).call(jb);a=l.append("g").attr("clip-path",Ra).attr("class","grid");ad&&a.append("g").attr("class","xgrids");Yb&&(b=a.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(Yb).enter().append("g").attr("class", -"xgrid-line"),b.append("line").attr("class",function(a){return""+a["class"]}),b.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",g?"":"rotate(-90)").attr("dx",g?0:-r).attr("dy",-5).text(function(a){return a.text}));je&&a.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:r).attr("y2",g?-10:s);bd&&a.append("g").attr("class","ygrids");Zb&&(a=a.append("g").attr("class", -"ygrid-lines").selectAll("ygrid-line").data(Zb).enter().append("g").attr("class","ygrid-line"),a.append("line").attr("class",function(a){return""+a["class"]}),a.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",g?"rotate(-90)":"").attr("dx",g?0:-r).attr("dy",-5).text(function(a){return a.text}));l.append("g").attr("clip-path",Ra).attr("class","regions");l.append("g").attr("clip-path",Ra).attr("class","chart");l.select(".chart").append("g").attr("class", -"event-rects").style("fill-opacity",0).style("cursor",pa?"ew-resize":null);l.select(".chart").append("g").attr("class","chart-bars");l.select(".chart").append("g").attr("class","chart-lines");l.select(".chart").append("g").attr("class","chart-arcs").attr("transform",M.arc);if(pa)l.insert("rect",ke?null:"g.grid").attr("class","zoom-rect").attr("width",p).attr("height",s).style("opacity",0).style("cursor","ew-resize").call(E).on("dblclick.zoom",null);null!==vb&&L.extent("function"!==typeof vb?vb:vb(ob())); +l).selectAll(".-circle"+(a||0===a?"-"+a:""))}function Ub(a){Tb(a).filter(function(){return d.select(this).classed(aa)}).classed(aa,!1).attr("r",Vb)}function $c(a){return l.selectAll(".-bar"+(a||0===a?"-"+a:""))}function ae(a,b,c,e){var d,f,h="M",l,m,za,p,q,n=[];if(u(e))for(d=0;d=f;f+=r)h+=e(a[d-1],a[d],f,za)}return h}function Wb(a){var b;tb=d.select(ta);if(tb.empty())P.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');else{tb.html("");h.data.x={};h.data.targets=La(a);ra();R();m.domain(d.extent(ob(h.data.targets)));z.domain(mb("y"));Z.domain(mb("y2"));V.domain(m.domain());hb.domain(z.domain());ib.domain(Z.domain());J.ticks(10>a.length?a.length:10);va.ticks(be).outerTickSize(0).tickFormat(ce); +jb.ticks(de).outerTickSize(0).tickFormat(ee);U=m.domain();L.scale(V);pa&&E.scale(m);p=d.select(ta).append("svg").attr("width",r+A+Y).attr("height",s+n+O).on("mouseenter",fe).on("mouseleave",ge);ub=p.append("defs");ub.append("clipPath").attr("id",Xb).append("rect").attr("y",n).attr("width",r).attr("height",s-n);ub.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1-A).attr("y",-20).attr("width",N).attr("height",da);ub.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x", +-A+1).attr("y",n-1).attr("width",ia).attr("height",yb);l=p.append("g").attr("transform",M.main);F=Aa?p.append("g").attr("transform",M.context):null;Ba=Ca?p.append("g").attr("transform",M.legend):null;W=d.select(ta).style("position","relative").append("div").style("position","absolute").style("z-index","10").style("display","none");l.append("g").attr("class","x axis").attr("clip-path",g?"":"url(#xaxis-clip)").attr("transform",M.x).call(g?va:J).append("text").attr("class","-axis-x-label").attr("x", +r).attr("dy","-.5em").style("text-anchor","end").text(he);l.append("g").attr("class","y axis").attr("clip-path",g?"url(#yaxis-clip)":"").call(g?J:va).append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(ie);Bb&&l.append("g").attr("class","y2 axis").attr("transform",M.y2).call(jb);a=l.append("g").attr("clip-path",Ra).attr("class","grid");ad&&a.append("g").attr("class","xgrids");Yb&&(b=a.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(Yb).enter().append("g").attr("class", +"xgrid-line"),b.append("line").attr("class",function(a){return""+a["class"]}),b.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",g?"":"rotate(-90)").attr("dx",g?0:-n).attr("dy",-5).text(function(a){return a.text}));je&&a.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",g?0:-10).attr("x2",g?r:-10).attr("y1",g?-10:n).attr("y2",g?-10:s);bd&&a.append("g").attr("class","ygrids");Zb&&(a=a.append("g").attr("class", +"ygrid-lines").selectAll("ygrid-line").data(Zb).enter().append("g").attr("class","ygrid-line"),a.append("line").attr("class",function(a){return""+a["class"]}),a.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",g?"rotate(-90)":"").attr("dx",g?0:-n).attr("dy",-5).text(function(a){return a.text}));l.append("g").attr("clip-path",Ra).attr("class","regions");l.append("g").attr("clip-path",Ra).attr("class","chart");l.select(".chart").append("g").attr("class", +"event-rects").style("fill-opacity",0).style("cursor",pa?"ew-resize":null);l.select(".chart").append("g").attr("class","chart-bars");l.select(".chart").append("g").attr("class","chart-lines");l.select(".chart").append("g").attr("class","chart-arcs").attr("transform",M.arc);if(pa)l.insert("rect",ke?null:"g.grid").attr("class","zoom-rect").attr("width",r).attr("height",s).style("opacity",0).style("cursor","ew-resize").call(E).on("dblclick.zoom",null);null!==vb&&L.extent("function"!==typeof vb?vb:vb(ob())); Aa&&(F.append("g").attr("clip-path",Ra).attr("class","chart"),F.select(".chart").append("g").attr("class","chart-bars"),F.select(".chart").append("g").attr("class","chart-lines"),F.append("g").attr("clip-path",Ra).attr("class","x brush").call(L).selectAll("rect").attr(g?"width":"height",g?Cb:eb),F.append("g").attr("class","x axis").attr("transform",M.subx).attr("clip-path",g?"url(#yaxis-clip)":"").call(gb));Ca&&wb(h.data.targets);cd(h.data.targets);I({withTransition:!1,withUpdateXDomain:!0});if(le){if(B&& "string"===typeof Da){Da=na(Da);for(a=0;aOb(c,a)?q.select(".event-rect").style("cursor","pointer"):q.select(".event-rect").style("cursor",null))}).on("click",function(){var a,c;D(h.data.targets)||(a=d.mouse(this),c=Mc(h.data.targets,a),100>Ob(c,a)&&l.select(".-circles-"+c.id).select(".-circle-"+c.index).each(function(){ed(this,c,c.index)}))}).call(d.behavior.drag().origin(Object).on("drag",function(){fd(d.mouse(this))}).on("dragstart", -function(){gd(d.mouse(this))}).on("dragend",function(){hd()})).call(E).on("dblclick.zoom",null)}function ed(a,b,c){var e=d.select(a),f=e.classed(ha),g=!1,h;"circle"===a.nodeName?(g=Uc(a,1.5*Qa),h=Xc):"rect"===a.nodeName&&(g=Vc(a),h=Zc);if(qa||g)fa&&ga(b)&&(e.classed(ha,!f),h(!f,e,b,c)),qe(b,e)}function fd(a){var b,c,e,f,g,m,p;D(h.data.targets)||!fa||pa&&!E.altDomain||(b=cc[0],c=cc[1],e=a[0],a=a[1],f=Math.min(b,e),g=Math.max(b,e),m=qa?r:Math.min(c,a),p=qa?s:Math.max(c,a),l.select(".dragarea").attr("x", -f).attr("y",m).attr("width",g-f).attr("height",p-m),l.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return ga(a)}).each(function(a,b){var c=d.select(this),e=c.classed(ha),h=c.classed(dc),l,n,r,q;l=!1;"circle"===this.nodeName?(l=1*c.attr("cx"),n=1*c.attr("cy"),q=Xc,l=fOb(c,a)?p.select(".event-rect").style("cursor","pointer"):p.select(".event-rect").style("cursor",null))}).on("click",function(){var a,c;D(h.data.targets)||(a=d.mouse(this),c=Mc(h.data.targets,a),100>Ob(c,a)&&l.select(".-circles-"+c.id).select(".-circle-"+c.index).each(function(){ed(this,c,c.index)}))}).call(d.behavior.drag().origin(Object).on("drag",function(){fd(d.mouse(this))}).on("dragstart", +function(){gd(d.mouse(this))}).on("dragend",function(){hd()})).call(E).on("dblclick.zoom",null)}function ed(a,b,c){var e=d.select(a),f=e.classed(ha),g=!1,h;"circle"===a.nodeName?(g=Uc(a,1.5*Qa),h=Xc):"rect"===a.nodeName&&(g=Vc(a),h=Zc);if(qa||g)fa&&ga(b)&&(e.classed(ha,!f),h(!f,e,b,c)),qe(b,e)}function fd(a){var b,c,e,f,g,m,p;D(h.data.targets)||!fa||pa&&!E.altDomain||(b=cc[0],c=cc[1],e=a[0],a=a[1],f=Math.min(b,e),g=Math.max(b,e),m=qa?n:Math.min(c,a),p=qa?s:Math.max(c,a),l.select(".dragarea").attr("x", +f).attr("y",m).attr("width",g-f).attr("height",p-m),l.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return ga(a)}).each(function(a,b){var c=d.select(this),e=c.classed(ha),h=c.classed(dc),l,n,q,r;l=!1;"circle"===this.nodeName?(l=1*c.attr("cx"),n=1*c.attr("cy"),r=Xc,l=f",c,d,f;for(c=0;c"+f+""+d+"");return b+""}),le=f(["tooltip","init","show"],!1),Da=f(["tooltip","init","x"],0),dd=f(["tooltip","init","position"],{top:"0px",left:"50px"}),Xb=ta.replace("#","")+"-clip",Ra="url(#"+Xb+")",B="timeseries"===kd,ea="categorized"===kd,Nb=!B&&(oa||$),cc=null,Sa=!1,bc=!1,la=Ca?40:0,K=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];-1===c.indexOf(b)&&c.push(b);return d[c.indexOf(b)%d.length]}}(xe,ye),sd=function(){var a=[[d.time.format("%Y/%-m/%-d"),function(){return!0}],[d.time.format("%-m/%-d"),function(a){return a.getMonth()}],[d.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[d.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[d.time.format("%I %p"),function(a){return a.getHours()}],[d.time.format("%I:%M"),function(a){return a.getMinutes()}],[d.time.format(":%S"), -function(a){return a.getSeconds()}],[d.time.format(".%L"),function(a){return a.getMilliseconds()}]];return function(b){for(var c=a.length-1,d=a[c];!d[1](b);)d=a[--c];return d[0](b)}}(),p,Cb,s,eb,zb,sa,Ga,Db,Eb,kb,pc,qc,Lb,Fb,Gb,Hb,Ib,Jb,Kb,m,z,Z,V,hb,ib,J,va,jb,gb,nd=g?"left":"bottom",od=g?bb?"top":"bottom":bb?"right":"left",pd=g?db?"bottom":"top":db?"left":"right",qd=g?"left":"bottom",M={main:function(){return"translate("+A+","+r+")"},context:function(){return"translate("+Fa+","+Ea+")"},legend:function(){return"translate("+ -jc+","+ic+")"},y2:function(){return"translate("+(g?0:p)+","+(g?10:0)+")"},x:function(){return"translate(0,"+s+")"},subx:function(){return"translate(0,"+(g?0:eb)+")"},arc:function(){return"translate("+p/2+","+s/2+")"}},nc=40,mc=20;Lb=d.layout.pie().value(function(a){return a.values.reduce(function(a,c){return a+c.value},0)});var se=function(){var a=d.svg.line().x(g?function(a){return w(a.id)(a.value)}:wa).y(g?wa:function(a){return w(a.id)(a.value)});return function(b){var c=Sb(b.values),d;if(Pb(b))return Rc(b)? -a.interpolate("cardinal"):a.interpolate("linear"),jd[b.id]?ae(c,m,w(b.id),jd[b.id]):a(c);d=m(c[0].x);b=w(b.id)(c[0].value);return g?"M "+b+" "+d:"M "+d+" "+b}}(),te=function(){var a;a=g?d.svg.area().x0(function(a){return w(a.id)(0)}).x1(function(a){return w(a.id)(a.value)}).y(wa):d.svg.area().x(wa).y0(function(a){return w(a.id)(0)}).y1(function(a){return w(a.id)(a.value)});return function(b){var c=Sb(b.values),d;if(ma([b],"area")||ma([b],"area-spline"))return Rc(b)?a.interpolate("cardinal"):a.interpolate("linear"), -a(c);d=m(c[0].x);b=w(b.id)(c[0].value);return g?"M "+b+" "+d:"M "+d+" "+b}}(),ue=function(){var a=d.svg.line().x(g?function(a){return G(a.id)(a.value)}:Ic).y(g?Ic:function(a){return G(a.id)(a.value)});return function(b){var c=Sb(b.values);return Pb(b)?a(c):"M "+V(c[0].x)+" "+G(b.id)(c[0].value)}}(),L=d.svg.brush().on("brush",function(){I({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}),E=d.behavior.zoom().on("zoomstart",function(){E.altDomain=d.event.sourceEvent.altKey?m.orgDomain(): -null}).on("zoom",pa?ve:null);L.update=function(){F&&F.select(".x.brush").call(this);return this};L.scale=function(a){return g?this.y(a):this.x(a)};E.scale=function(a){return g?this.y(a):this.x(a)};E.orgScaleExtent=function(){var a=id?id:[1,10];return[a[0],Math.max(fb()/a[1],a[1])]};E.updateScaleExtent=function(){var a=ua(m.orgDomain())/ua(U),b=this.orgScaleExtent();this.scaleExtent([b[0]*a,b[1]*a]);return this};var q,ub,l,F,Ba,W,tb,U;h.focus=function(a){var b=q.selectAll(Va(a)),c=b.filter(gc),b=b.filter(hc); -h.defocus();c.classed("focused",!0).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity",1);D(h.data.targets)&&Za(a,!0);ec(a)};h.defocus=function(a){var b=q.selectAll(Va(a)),c=b.filter(gc),b=b.filter(hc);c.classed("focused",!1).transition().duration(100).style("opacity",0.3);b.transition().duration(100).style("opacity",0.3);D(h.data.targets)&&xb(a)};h.revert=function(a){var b=q.selectAll(Va(a)),c=b.filter(gc),b=b.filter(hc);c.classed("focused",!1).transition().duration(100).style("opacity", -1);b.transition().duration(100).style("opacity",1);D(h.data.targets)&&xb(a);fc()};h.show=function(a){q.selectAll(Va(a)).transition().style("opacity",1)};h.hide=function(a){q.selectAll(Va(a)).transition().style("opacity",0)};h.unzoom=function(){L.clear().update();I({withUpdateXDomain:!0})};h.load=function(a){"function"!==typeof a.done&&(a.done=function(){});a.xs&&Jd(a.xs);"categories"in a&&ea&&(Ha=a.categories,J.categories(Ha));if("cacheIds"in a&&Fd(a.cacheIds))Ta(Gd(a.cacheIds),a.done);else if("data"in -a)Ta(La(a.data),a.done);else if("url"in a)d.csv(a.url,function(b,c){Ta(La(c),a.done)});else if("rows"in a)Ta(La(xc(a.rows)),a.done);else if("columns"in a)Ta(La(yc(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});q.selectAll(".target-"+a).transition().style("opacity",0).remove();Ca&&(q.selectAll(".legend-item-"+a).remove(),wb(h.data.targets));0",c,d,f;for(c=0;c"+f+""+d+"");return b+""}), +le=f(["tooltip","init","show"],!1),Da=f(["tooltip","init","x"],0),dd=f(["tooltip","init","position"],{top:"0px",left:"50px"}),Xb=ta.replace("#","")+"-clip",Ra="url(#"+Xb+")",B="timeseries"===kd,ea="categorized"===kd,Nb=!B&&(oa||$),cc=null,Sa=!1,bc=!1,la=Ca?40:0,K=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];-1===c.indexOf(b)&&c.push(b);return d[c.indexOf(b)%d.length]}}(ye,ze), +sd=function(){var a=[[d.time.format("%Y/%-m/%-d"),function(){return!0}],[d.time.format("%-m/%-d"),function(a){return a.getMonth()}],[d.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[d.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[d.time.format("%I %p"),function(a){return a.getHours()}],[d.time.format("%I:%M"),function(a){return a.getMinutes()}],[d.time.format(":%S"),function(a){return a.getSeconds()}],[d.time.format(".%L"),function(a){return a.getMilliseconds()}]]; +return function(b){for(var c=a.length-1,d=a[c];!d[1](b);)d=a[--c];return d[0](b)}}(),r,Cb,s,eb,zb,sa,Ga,Db,Eb,kb,pc,qc,Lb,Fb,Gb,Hb,Ib,Jb,Kb,m,z,Z,V,hb,ib,J,va,jb,gb,nd=g?"left":"bottom",od=g?bb?"top":"bottom":bb?"right":"left",pd=g?db?"bottom":"top":db?"left":"right",qd=g?"left":"bottom",M={main:function(){return"translate("+A+","+n+")"},context:function(){return"translate("+Fa+","+Ea+")"},legend:function(){return"translate("+jc+","+ic+")"},y2:function(){return"translate("+(g?0:r)+","+(g?10:0)+")"}, +x:function(){return"translate(0,"+s+")"},subx:function(){return"translate(0,"+(g?0:eb)+")"},arc:function(){return"translate("+r/2+","+s/2+")"}},nc=40,mc=20;Lb=d.layout.pie().value(function(a){return a.values.reduce(function(a,c){return a+c.value},0)});var se=function(){var a=d.svg.line().x(g?function(a){return w(a.id)(a.value)}:wa).y(g?wa:function(a){return w(a.id)(a.value)});return function(b){var c=Sb(b.values),d;if(Pb(b))return Rc(b)?a.interpolate("cardinal"):a.interpolate("linear"),jd[b.id]?ae(c, +m,w(b.id),jd[b.id]):a(c);d=m(c[0].x);b=w(b.id)(c[0].value);return g?"M "+b+" "+d:"M "+d+" "+b}}(),te=function(){var a;a=g?d.svg.area().x0(function(a){return w(a.id)(0)}).x1(function(a){return w(a.id)(a.value)}).y(wa):d.svg.area().x(wa).y0(function(a){return w(a.id)(0)}).y1(function(a){return w(a.id)(a.value)});return function(b){var c=Sb(b.values),d;if(ma([b],"area")||ma([b],"area-spline"))return Rc(b)?a.interpolate("cardinal"):a.interpolate("linear"),a(c);d=m(c[0].x);b=w(b.id)(c[0].value);return g? +"M "+b+" "+d:"M "+d+" "+b}}(),ue=function(){var a=d.svg.line().x(g?function(a){return G(a.id)(a.value)}:Ic).y(g?Ic:function(a){return G(a.id)(a.value)});return function(b){var c=Sb(b.values);return Pb(b)?a(c):"M "+V(c[0].x)+" "+G(b.id)(c[0].value)}}(),L=d.svg.brush().on("brush",function(){I({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}),E=d.behavior.zoom().on("zoomstart",function(){E.altDomain=d.event.sourceEvent.altKey?m.orgDomain():null}).on("zoom",pa?ve:null);L.update=function(){F&& +F.select(".x.brush").call(this);return this};L.scale=function(a){return g?this.y(a):this.x(a)};E.scale=function(a){return g?this.y(a):this.x(a)};E.orgScaleExtent=function(){var a=id?id:[1,10];return[a[0],Math.max(fb()/a[1],a[1])]};E.updateScaleExtent=function(){var a=ua(m.orgDomain())/ua(U),b=this.orgScaleExtent();this.scaleExtent([b[0]*a,b[1]*a]);return this};var p,ub,l,F,Ba,W,tb,U;h.focus=function(a){var b=p.selectAll(Va(a)),c=b.filter(gc),b=b.filter(hc);h.revert();h.defocus();c.classed("focused", +!0).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity",1);D(h.data.targets)&&Za(a,!0);ec(a)};h.defocus=function(a){var b=p.selectAll(Va(a)),c=b.filter(gc),b=b.filter(hc);h.revert();c.classed("focused",!1).transition().duration(100).style("opacity",0.3);b.transition().duration(100).style("opacity",0.3);D(h.data.targets)&&xb(a);we(a)};h.revert=function(a){var b=p.selectAll(Va(a)),c=b.filter(gc),b=b.filter(hc);c.classed("focused",!1).transition().duration(100).style("opacity", +1);b.transition().duration(100).style("opacity",1);D(h.data.targets)&&xb(a);fc()};h.show=function(a){p.selectAll(Va(a)).transition().style("opacity",1)};h.hide=function(a){p.selectAll(Va(a)).transition().style("opacity",0)};h.unzoom=function(){L.clear().update();I({withUpdateXDomain:!0})};h.load=function(a){"function"!==typeof a.done&&(a.done=function(){});a.xs&&Jd(a.xs);"categories"in a&&ea&&(Ha=a.categories,J.categories(Ha));if("cacheIds"in a&&Fd(a.cacheIds))Ta(Gd(a.cacheIds),a.done);else if("data"in +a)Ta(La(a.data),a.done);else if("url"in a)d.csv(a.url,function(b,c){Ta(La(c),a.done)});else if("rows"in a)Ta(La(xc(a.rows)),a.done);else if("columns"in a)Ta(La(yc(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});p.selectAll(".target-"+a).transition().style("opacity",0).remove();Ca&&(p.selectAll(".legend-item-"+a).remove(),wb(h.data.targets));0b.classes.indexOf(a)})});return Q};h.data.get=function(a){a=h.data.getAsTarget(a);return u(a)?a.values.map(function(a){return a.value}):void 0};h.data.getAsTarget= +function(a){if(x(a))return Q;Q=a;I();return Q};h.regions.add=function(a){if(x(a))return Q;Q=Q.concat(a);I();return Q};h.regions.remove=function(a,b){var c=[].concat(a);b=u(b)?b:{};c.forEach(function(a){var c=p.selectAll("."+a);u(b.duration)&&(c=c.transition().duration(b.duration).style("fill-opacity",0));c.remove();Q=Q.filter(function(b){return 0>b.classes.indexOf(a)})});return Q};h.data.get=function(a){a=h.data.getAsTarget(a);return u(a)?a.values.map(function(a){return a.value}):void 0};h.data.getAsTarget= function(a){var b=nb(function(b){return b.id===a});return 0