Browse Source

Fix cursor when zoom enabled

pull/34/merge
Masayuki Tanaka 11 years ago
parent
commit
10d5fb2723
  1. 4
      c3.js
  2. 48
      c3.min.js

4
c3.js

@ -1583,7 +1583,7 @@
eventRect = main.select('.chart').append("g")
.attr("class", "event-rects")
.style('fill-opacity', 0)
.style('cursor', __zoom_enabled ? 'ew-resize' : null);
.style('cursor', __zoom_enabled ? __axis_rotated ? 'ns-resize' : 'ew-resize' : null);
// Define g for bar chart area
main.select(".chart").append("g")
@ -1609,7 +1609,7 @@
.attr('width', width)
.attr('height', height)
.style('opacity', 0)
.style('cursor', 'ew-resize')
.style('cursor', __axis_rotated ? 'ns-resize' : 'ew-resize')
.call(zoom).on("dblclick.zoom", null);
}

48
c3.min.js vendored

@ -35,30 +35,30 @@ jb.ticks(fe).outerTickSize(0).tickFormat(ge);T=m.domain();K.scale(U);oa&&E.scale
r).attr("dy","-.5em").style("text-anchor","end").text(je);l.append("g").attr("class","y axis").attr("clip-path",g?"url(#yaxis-clip)":"").call(g?I:ua).append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(ke);Bb&&l.append("g").attr("class","y2 axis").attr("transform",L.y2).call(jb);a=l.append("g").attr("clip-path",Ra).attr("class","grid");bd&&a.append("g").attr("class","xgrids");Zb&&(b=a.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(Zb).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}));le&&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);cd&&a.append("g").attr("class","ygrids");$b&&(a=a.append("g").attr("class",
"ygrid-lines").selectAll("ygrid-line").data($b).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",oa?"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",L.arc).append("text").attr("class","chart-arcs-title").style("text-anchor","middle").text(me);if(oa)l.insert("rect",ne?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&&K.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(K).selectAll("rect").attr(g?"width":"height",g?Cb:eb),F.append("g").attr("class","x axis").attr("transform",L.subx).attr("clip-path",g?"url(#yaxis-clip)":"").call(gb));Ca&&wb(h.data.targets);dd(h.data.targets);
H({withTransition:!1,withUpdateXDomain:!0});if(oe){if(B&&"string"===typeof Da){Da=ma(Da);for(a=0;a<h.data.targets[0].values.length&&0!==h.data.targets[0].values[a].x-Da;a++);Da=a}V.html(Pc(h.data.targets.map(function(a){return qb(a.values[Da])})));V.style("top",ed.top).style("left",ed.left).style("display","block")}null==O.onresize&&(O.onresize=pe());O.onresize.add&&O.onresize.add(qe)}}function re(a){a.append("rect").attr("class",Hc).style("cursor",ea&&pa?"pointer":null).on("mouseover",function(a,
c){if(!Sa&&!D(h.data.targets)){var e=h.data.targets.map(function(a){return qb(a.values[c])}),d,f;if(0<Object.keys(Ka).length){f=[];for(var g in Ka)for(d=0;d<e.length;d++)if(e[d].id===g){f.push(e[d]);e.shift(d);break}e=f.concat(e)}ac&&Ub(c,void 0).classed($,!0).attr("r",bc);ad(c).classed($,!1);Qc(e[0])}}).on("mouseout",function(a,c){D(h.data.targets)||(Rc(),V.style("display","none"),Vb(c),ad(void 0).classed($,!1))}).on("mousemove",function(a,c){var e;Sa||D(h.data.targets)||(e=h.data.targets.map(function(a){return qb(a.values[c])}),
Oc(e,d.mouse(this)),ea&&(pa||l.selectAll(".-shape-"+c).filter(function(a){return fa(a)}).each(function(){var a=d.select(this).classed($,!0);"circle"===this.nodeName&&a.attr("r",bc);p.select(".event-rect-"+c).style("cursor",null)}).filter(function(){var a=d.select(this);if("circle"===this.nodeName)return Vc(this,Qa);if("rect"===this.nodeName)return Wc(this,a.attr("x"),a.attr("y"))}).each(function(){var a=d.select(this);a.classed($)||(a.classed($,!0),"circle"===this.nodeName&&a.attr("r",Qa));p.select(".event-rect-"+
c).style("cursor","pointer")})))}).on("click",function(a,c){D(h.data.targets)||(cc?cc=!1:l.selectAll(".-shape-"+c).each(function(a){fd(this,a,c)}))}).call(d.behavior.drag().origin(Object).on("drag",function(){gd(d.mouse(this))}).on("dragstart",function(){hd(d.mouse(this))}).on("dragend",function(){id()})).call(E).on("dblclick.zoom",null)}function se(a){a.append("rect").attr("x",0).attr("y",0).attr("width",r).attr("height",s).attr("class","event-rect").on("mouseout",function(){D(h.data.targets)||(Rc(),
V.style("display","none"),Vb())}).on("mousemove",function(){var a,c,e;Sa||D(h.data.targets)||(a=d.mouse(this),c=Nc(h.data.targets,a),e=[qb(c)],Oc(e,a),ac&&(Vb(),Ub(c.index,c.id).classed($,!0).attr("r",bc)),Qc(e[0]),100>Pb(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=Nc(h.data.targets,a),100>Pb(c,a)&&l.select(".-circles-"+c.id).select(".-circle-"+c.index).each(function(){fd(this,
c,c.index)}))}).call(d.behavior.drag().origin(Object).on("drag",function(){gd(d.mouse(this))}).on("dragstart",function(){hd(d.mouse(this))}).on("dragend",function(){id()})).call(E).on("dblclick.zoom",null)}function fd(a,b,c){var e=d.select(a),f=e.classed(ga),g=!1,h;"circle"===a.nodeName?(g=Vc(a,1.5*Qa),h=Yc):"rect"===a.nodeName&&(g=Wc(a),h=$c);if(pa||g)ea&&fa(b)&&(e.classed(ga,!f),h(!f,e,b,c)),te(b,e)}function gd(a){var b,c,e,f,g,m,p;D(h.data.targets)||!ea||oa&&!E.altDomain||(b=dc[0],c=dc[1],e=a[0],
a=a[1],f=Math.min(b,e),g=Math.max(b,e),m=pa?n:Math.min(c,a),p=pa?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 fa(a)}).each(function(a,b){var c=d.select(this),e=c.classed(ga),h=c.classed(ec),l,n,q,r;l=!1;"circle"===this.nodeName?(l=1*c.attr("cx"),n=1*c.attr("cy"),r=Yc,l=f<l&&l<g&&m<n&&n<p):"rect"===this.nodeName&&(l=1*c.attr("x"),n=1*c.attr("y"),q=1*c.attr("width"),r=$c,l=f<
l+q&&l<g&&n<p);l^h&&(c.classed(ec,!h),c.classed(ga,!e),r(!e,c,a,b))}))}function hd(a){!D(h.data.targets)&&ea&&(dc=a,l.select(".chart").append("rect").attr("class","dragarea").style("opacity",0.1),Sa=!0)}function id(){!D(h.data.targets)&&ea&&(l.select(".dragarea").transition().duration(100).style("opacity",0).remove(),l.selectAll(".-shape").classed(ec,!1),Sa=!1)}function H(a){var b,c,e,f=Ud(),p=f.__max__+1,q,v,t=D(h.data.targets);a=u(a)?a:{};c=u(a.withY)?a.withY:!0;e=u(a.withSubchart)?a.withSubchart:
!0;v=u(a.withTransition)?a.withTransition:!0;b=u(a.withUpdateXDomain)?a.withUpdateXDomain:!1;a=u(a.withUpdateOrgXDomain)?a.withUpdateOrgXDomain:!1;v=v?250:0;a&&(m.domain(d.extent(ob(h.data.targets))),T=m.domain(),E.scale(m).updateScaleExtent(),U.domain(m.domain()),K.scale(U));b&&(m.domain(K.empty()?T:K.extent()),oa&&E.scale(m).updateScaleExtent());z.domain(mb("y"));Y.domain(mb("y2"));l.select(".x.axis").transition().duration(g?v:0).call(g?ua:I).style("opacity",t?0:1);l.select(".y.axis").transition().duration(g?
0:v).call(g?I:ua).style("opacity",t?0:1);l.select(".y2.axis").transition().call(jb).style("opacity",t?0:1);l.select(".x.axis .-axis-x-label").attr("x",r);hb.domain(z.domain());ib.domain(Y.domain());V.style("display","none");l.select("line.xgrid-focus").style("visibility","hidden").attr("y2",s);if(bd){if("year"===ue)for(b=[],a=ob(),t=a[0].getFullYear(),a=a[1].getFullYear();t<=a;t++)b.push(new Date(t+"-01-01 00:00:00"));else b=m.ticks(10);b=l.select(".xgrids").selectAll(".xgrid").data(b);b.enter().append("line").attr("class",
"xgrid");b.attr("x1",g?0:function(a){return m(a)-I.tickOffset()}).attr("x2",g?r:function(a){return m(a)-I.tickOffset()}).attr("y1",g?function(a){return m(a)-I.tickOffset()}:n).attr("y2",g?function(a){return m(a)-I.tickOffset()}:s).style("opacity",function(){return+d.select(this).attr(g?"y1":"x1")===(g?s:0)?0:1});b.exit().remove()}Zb&&(b=l.selectAll(".xgrid-lines"),b.selectAll("line").transition().duration(v).attr("x1",g?0:Oa).attr("x2",g?r:Oa).attr("y1",g?Oa:n).attr("y2",g?Oa:s),b.selectAll("text").attr("x",
g?r:0).attr("y",Oa));c&&cd&&(b=l.select(".ygrids").selectAll(".ygrid").data(z.ticks(10)),b.enter().append("line").attr("class","ygrid"),b.attr("x1",g?z:0).attr("x2",g?z:r).attr("y1",g?0:z).attr("y2",g?s:z),b.exit().remove());c&&$b&&(c=l.select(".ygrid-lines"),c.selectAll("line").transition().duration(v).attr("x1",g?Pa:0).attr("x2",g?Pa:r).attr("y1",g?0:Pa).attr("y2",g?s:Pa),c.selectAll("text").attr("x",g?0:r).attr("y",Pa));c=function(a){var b=da?p?1.2*I.tickOffset()/p:0:0.6*((g?s:r)*(a?1:ta(T)/ta(m.domain()))/
(fb()-1)),c=Vd(b,p,f,!!a),e=Wd(!!a),d=Xd(f,!!a),h=a?G:w;return function(a,f){var k=h(a.id)(0),l=d(a,f)||k,k=[[c(a),l],[c(a),e(a)-(k-l)],[c(a)+b,e(a)-(k-l)],[c(a)+b,l]],l=g?1:0,m=g?0:1;return"M "+k[0][l]+","+k[0][m]+" L"+k[1][l]+","+k[1][m]+" L"+k[2][l]+","+k[2][m]+" L"+k[3][l]+","+k[3][m]+" z"}};b=l.selectAll(".-bars").selectAll(".-bar").data(Uc);b.enter().append("path").attr("d",c(!1)).style("stroke","none").style("opacity",0).style("fill",function(a){return J(a.id)}).attr("class",Gc);b.transition().duration(v).attr("d",
c(!1)).style("opacity",1);b.exit().transition().duration(v).style("opacity",0).remove();l.selectAll(".chart-line").select(".-line").transition().duration(v).attr("d",ve);l.selectAll(".-area").transition().duration(v).attr("d",we);b=l.selectAll(".-circles").selectAll(".-circle").data(Yd);b.enter().append("circle").attr("class",Rd).attr("r",Wb);b.transition().duration(v).style("opacity",Td).attr("cx",g?ya:xa).attr("cy",g?xa:ya);b.exit().remove();l.selectAll(".chart-arc").select(".-arc").style("opacity",
function(a){return a===this._current?0:1}).transition().duration(v).attrTween("d",function(a){a=ia(a);if(!a)return function(){return"M 0 0"};var b=d.interpolate(this._current,a);this._current=b(0);return function(a){a=b(a);return Tc(a.data)||Mb(a.data)?kb(a,!0):"M 0 0"}}).style("opacity",1);l.selectAll(".chart-arc").select("text").attr("transform",Xa).attr("opacity",0).transition().duration(v).text(Ya).attr("opacity",function(a){return Tc(a.data)||Mb(a.data)?1:0});Aa&&(null!==d.event&&"zoom"===d.event.type&&
K.extent(m.orgDomain()).update(),e&&(F.select(".x.axis").transition().duration(g?v:0).call(gb),K.empty()||K.extent(m.orgDomain()).update(),e=F.selectAll(".-bars").selectAll(".-bar").data(Uc),e.enter().append("path").attr("d",c(!0)).style("stroke","none").style("fill",function(a){return J(a.id)}).attr("class",Gc),e.style("opacity",0).transition().duration(v).attr("d",c(!0)).style("opacity",1),e.exit().transition().duration(v).style("opacity",0).remove(),F.selectAll(".-line").transition().duration(v).attr("d",
xe)));l.selectAll(".selected-circles").filter(function(a){return sb(a)}).selectAll("circle").remove();l.selectAll(".selected-circle").transition().duration(v).attr("cx",g?ya:xa).attr("cy",g?xa:ya);Z?(c=l.select(".event-rects").selectAll(".event-rect").data([0]),se(c.enter()),c.attr("x",0).attr("y",0).attr("width",r).attr("height",s)):(Ob?(q=function(a,b){var c=Bc(b),e=b<fb()-1?h.data.targets[0].values[b+1].x:void 0;return(m(e?e:a.x+50)-m(c?c:a.x-50))/2},e=function(a,b){var c=Bc(b);return(m(a.x)+m(c?
c:a.x-50))/2}):(q=nd(),e=function(a){return m(a.x)-q/2}),c=Nd(),l.select(".event-rects").datum(c?c.values:[]),c=l.select(".event-rects").selectAll(".event-rect").data(function(a){return a}),re(c.enter()),c.attr("class",Hc).attr("x",g?0:e).attr("y",g?e:0).attr("width",g?r:q).attr("height",g?q:s),c.exit().remove());e=l.select(".regions").selectAll("rect.region").data(P);e.enter().append("rect");e.attr("class",Sd).attr("x",g?0:Nb).attr("y",g?Nb:n).attr("width",g?r:wc).attr("height",g?wc:s).style("fill-opacity",
function(a){return u(a.opacity)?a.opacity:0.1});e.exit().transition().duration(v).style("fill-opacity",0).remove()}function ye(){"mousemove"===d.event.sourceEvent.type&&E.altDomain?(m.domain(E.altDomain),E.scale(m).updateScaleExtent()):(da&&m.orgDomain()[0]===T[0]&&m.domain([T[0]-1E-10,m.orgDomain()[1]]),H({withTransition:!1,withY:!1,withSubchart:!1}),"mousemove"===d.event.sourceEvent.type&&(cc=!0))}function pe(){function a(){b.forEach(function(a){a()})}var b=[];a.add=function(a){b.push(a)};return a}
function qe(){qa();Q();K.scale(U);oa&&E.scale(m);p.attr("width",zb).attr("height",ra);p.select("#"+Yb).select("rect").attr("width",r).attr("height",s);p.select("#xaxis-clip").select("rect").attr("width",M);p.select(".zoom-rect").attr("width",r).attr("height",s);l.select(".x.axis").attr("transform",L.x);l.select(".y2.axis").attr("transform",L.y2);l.select(".chart-arcs").attr("transform",L.arc);Aa&&(F.attr("transform",L.context),F.select(".x.axis").attr("transform",L.subx));Ca&&(Ba.attr("transform",
L.legend),wb(h.data.targets,{withTransition:!1}));H({withTransition:!1,withUpdateXDomain:!0})}function dd(a){var b;l.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",Fc).style("fill",function(a){return J(a.id)}).style("stroke",function(a){return J(a.id)}).style("stroke-width",0).style("cursor",function(a){return fa(a)?"pointer":null});
b=l.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",Ec).style("stroke",function(a){return J(a.id)});b.append("path").attr("class",Qd).style("fill",function(a){return J(a.id)});b.append("g").attr("class",function(a){return"selected-circles selected-circles-"+a.id});b.append("g").attr("class",Od).style("fill",function(a){return J(a.id)}).style("cursor",
"event-rects").style("fill-opacity",0).style("cursor",oa?g?"ns-resize":"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",L.arc).append("text").attr("class","chart-arcs-title").style("text-anchor","middle").text(me);if(oa)l.insert("rect",ne?null:"g.grid").attr("class","zoom-rect").attr("width",r).attr("height",s).style("opacity",0).style("cursor",
g?"ns-resize":"ew-resize").call(E).on("dblclick.zoom",null);null!==vb&&K.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(K).selectAll("rect").attr(g?"width":"height",g?Cb:eb),F.append("g").attr("class","x axis").attr("transform",L.subx).attr("clip-path",g?"url(#yaxis-clip)":
"").call(gb));Ca&&wb(h.data.targets);dd(h.data.targets);H({withTransition:!1,withUpdateXDomain:!0});if(oe){if(B&&"string"===typeof Da){Da=ma(Da);for(a=0;a<h.data.targets[0].values.length&&0!==h.data.targets[0].values[a].x-Da;a++);Da=a}V.html(Pc(h.data.targets.map(function(a){return qb(a.values[Da])})));V.style("top",ed.top).style("left",ed.left).style("display","block")}null==O.onresize&&(O.onresize=pe());O.onresize.add&&O.onresize.add(qe)}}function re(a){a.append("rect").attr("class",Hc).style("cursor",
ea&&pa?"pointer":null).on("mouseover",function(a,c){if(!Sa&&!D(h.data.targets)){var e=h.data.targets.map(function(a){return qb(a.values[c])}),d,f;if(0<Object.keys(Ka).length){f=[];for(var g in Ka)for(d=0;d<e.length;d++)if(e[d].id===g){f.push(e[d]);e.shift(d);break}e=f.concat(e)}ac&&Ub(c,void 0).classed($,!0).attr("r",bc);ad(c).classed($,!1);Qc(e[0])}}).on("mouseout",function(a,c){D(h.data.targets)||(Rc(),V.style("display","none"),Vb(c),ad(void 0).classed($,!1))}).on("mousemove",function(a,c){var e;
Sa||D(h.data.targets)||(e=h.data.targets.map(function(a){return qb(a.values[c])}),Oc(e,d.mouse(this)),ea&&(pa||l.selectAll(".-shape-"+c).filter(function(a){return fa(a)}).each(function(){var a=d.select(this).classed($,!0);"circle"===this.nodeName&&a.attr("r",bc);p.select(".event-rect-"+c).style("cursor",null)}).filter(function(){var a=d.select(this);if("circle"===this.nodeName)return Vc(this,Qa);if("rect"===this.nodeName)return Wc(this,a.attr("x"),a.attr("y"))}).each(function(){var a=d.select(this);
a.classed($)||(a.classed($,!0),"circle"===this.nodeName&&a.attr("r",Qa));p.select(".event-rect-"+c).style("cursor","pointer")})))}).on("click",function(a,c){D(h.data.targets)||(cc?cc=!1:l.selectAll(".-shape-"+c).each(function(a){fd(this,a,c)}))}).call(d.behavior.drag().origin(Object).on("drag",function(){gd(d.mouse(this))}).on("dragstart",function(){hd(d.mouse(this))}).on("dragend",function(){id()})).call(E).on("dblclick.zoom",null)}function se(a){a.append("rect").attr("x",0).attr("y",0).attr("width",
r).attr("height",s).attr("class","event-rect").on("mouseout",function(){D(h.data.targets)||(Rc(),V.style("display","none"),Vb())}).on("mousemove",function(){var a,c,e;Sa||D(h.data.targets)||(a=d.mouse(this),c=Nc(h.data.targets,a),e=[qb(c)],Oc(e,a),ac&&(Vb(),Ub(c.index,c.id).classed($,!0).attr("r",bc)),Qc(e[0]),100>Pb(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=Nc(h.data.targets,
a),100>Pb(c,a)&&l.select(".-circles-"+c.id).select(".-circle-"+c.index).each(function(){fd(this,c,c.index)}))}).call(d.behavior.drag().origin(Object).on("drag",function(){gd(d.mouse(this))}).on("dragstart",function(){hd(d.mouse(this))}).on("dragend",function(){id()})).call(E).on("dblclick.zoom",null)}function fd(a,b,c){var e=d.select(a),f=e.classed(ga),g=!1,h;"circle"===a.nodeName?(g=Vc(a,1.5*Qa),h=Yc):"rect"===a.nodeName&&(g=Wc(a),h=$c);if(pa||g)ea&&fa(b)&&(e.classed(ga,!f),h(!f,e,b,c)),te(b,e)}
function gd(a){var b,c,e,f,g,m,p;D(h.data.targets)||!ea||oa&&!E.altDomain||(b=dc[0],c=dc[1],e=a[0],a=a[1],f=Math.min(b,e),g=Math.max(b,e),m=pa?n:Math.min(c,a),p=pa?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 fa(a)}).each(function(a,b){var c=d.select(this),e=c.classed(ga),h=c.classed(ec),l,n,q,r;l=!1;"circle"===this.nodeName?(l=1*c.attr("cx"),n=1*c.attr("cy"),r=Yc,l=f<l&&l<
g&&m<n&&n<p):"rect"===this.nodeName&&(l=1*c.attr("x"),n=1*c.attr("y"),q=1*c.attr("width"),r=$c,l=f<l+q&&l<g&&n<p);l^h&&(c.classed(ec,!h),c.classed(ga,!e),r(!e,c,a,b))}))}function hd(a){!D(h.data.targets)&&ea&&(dc=a,l.select(".chart").append("rect").attr("class","dragarea").style("opacity",0.1),Sa=!0)}function id(){!D(h.data.targets)&&ea&&(l.select(".dragarea").transition().duration(100).style("opacity",0).remove(),l.selectAll(".-shape").classed(ec,!1),Sa=!1)}function H(a){var b,c,e,f=Ud(),p=f.__max__+
1,q,v,t=D(h.data.targets);a=u(a)?a:{};c=u(a.withY)?a.withY:!0;e=u(a.withSubchart)?a.withSubchart:!0;v=u(a.withTransition)?a.withTransition:!0;b=u(a.withUpdateXDomain)?a.withUpdateXDomain:!1;a=u(a.withUpdateOrgXDomain)?a.withUpdateOrgXDomain:!1;v=v?250:0;a&&(m.domain(d.extent(ob(h.data.targets))),T=m.domain(),E.scale(m).updateScaleExtent(),U.domain(m.domain()),K.scale(U));b&&(m.domain(K.empty()?T:K.extent()),oa&&E.scale(m).updateScaleExtent());z.domain(mb("y"));Y.domain(mb("y2"));l.select(".x.axis").transition().duration(g?
v:0).call(g?ua:I).style("opacity",t?0:1);l.select(".y.axis").transition().duration(g?0:v).call(g?I:ua).style("opacity",t?0:1);l.select(".y2.axis").transition().call(jb).style("opacity",t?0:1);l.select(".x.axis .-axis-x-label").attr("x",r);hb.domain(z.domain());ib.domain(Y.domain());V.style("display","none");l.select("line.xgrid-focus").style("visibility","hidden").attr("y2",s);if(bd){if("year"===ue)for(b=[],a=ob(),t=a[0].getFullYear(),a=a[1].getFullYear();t<=a;t++)b.push(new Date(t+"-01-01 00:00:00"));
else b=m.ticks(10);b=l.select(".xgrids").selectAll(".xgrid").data(b);b.enter().append("line").attr("class","xgrid");b.attr("x1",g?0:function(a){return m(a)-I.tickOffset()}).attr("x2",g?r:function(a){return m(a)-I.tickOffset()}).attr("y1",g?function(a){return m(a)-I.tickOffset()}:n).attr("y2",g?function(a){return m(a)-I.tickOffset()}:s).style("opacity",function(){return+d.select(this).attr(g?"y1":"x1")===(g?s:0)?0:1});b.exit().remove()}Zb&&(b=l.selectAll(".xgrid-lines"),b.selectAll("line").transition().duration(v).attr("x1",
g?0:Oa).attr("x2",g?r:Oa).attr("y1",g?Oa:n).attr("y2",g?Oa:s),b.selectAll("text").attr("x",g?r:0).attr("y",Oa));c&&cd&&(b=l.select(".ygrids").selectAll(".ygrid").data(z.ticks(10)),b.enter().append("line").attr("class","ygrid"),b.attr("x1",g?z:0).attr("x2",g?z:r).attr("y1",g?0:z).attr("y2",g?s:z),b.exit().remove());c&&$b&&(c=l.select(".ygrid-lines"),c.selectAll("line").transition().duration(v).attr("x1",g?Pa:0).attr("x2",g?Pa:r).attr("y1",g?0:Pa).attr("y2",g?s:Pa),c.selectAll("text").attr("x",g?0:
r).attr("y",Pa));c=function(a){var b=da?p?1.2*I.tickOffset()/p:0:0.6*((g?s:r)*(a?1:ta(T)/ta(m.domain()))/(fb()-1)),c=Vd(b,p,f,!!a),e=Wd(!!a),d=Xd(f,!!a),h=a?G:w;return function(a,f){var k=h(a.id)(0),l=d(a,f)||k,k=[[c(a),l],[c(a),e(a)-(k-l)],[c(a)+b,e(a)-(k-l)],[c(a)+b,l]],l=g?1:0,m=g?0:1;return"M "+k[0][l]+","+k[0][m]+" L"+k[1][l]+","+k[1][m]+" L"+k[2][l]+","+k[2][m]+" L"+k[3][l]+","+k[3][m]+" z"}};b=l.selectAll(".-bars").selectAll(".-bar").data(Uc);b.enter().append("path").attr("d",c(!1)).style("stroke",
"none").style("opacity",0).style("fill",function(a){return J(a.id)}).attr("class",Gc);b.transition().duration(v).attr("d",c(!1)).style("opacity",1);b.exit().transition().duration(v).style("opacity",0).remove();l.selectAll(".chart-line").select(".-line").transition().duration(v).attr("d",ve);l.selectAll(".-area").transition().duration(v).attr("d",we);b=l.selectAll(".-circles").selectAll(".-circle").data(Yd);b.enter().append("circle").attr("class",Rd).attr("r",Wb);b.transition().duration(v).style("opacity",
Td).attr("cx",g?ya:xa).attr("cy",g?xa:ya);b.exit().remove();l.selectAll(".chart-arc").select(".-arc").style("opacity",function(a){return a===this._current?0:1}).transition().duration(v).attrTween("d",function(a){a=ia(a);if(!a)return function(){return"M 0 0"};var b=d.interpolate(this._current,a);this._current=b(0);return function(a){a=b(a);return Tc(a.data)||Mb(a.data)?kb(a,!0):"M 0 0"}}).style("opacity",1);l.selectAll(".chart-arc").select("text").attr("transform",Xa).attr("opacity",0).transition().duration(v).text(Ya).attr("opacity",
function(a){return Tc(a.data)||Mb(a.data)?1:0});Aa&&(null!==d.event&&"zoom"===d.event.type&&K.extent(m.orgDomain()).update(),e&&(F.select(".x.axis").transition().duration(g?v:0).call(gb),K.empty()||K.extent(m.orgDomain()).update(),e=F.selectAll(".-bars").selectAll(".-bar").data(Uc),e.enter().append("path").attr("d",c(!0)).style("stroke","none").style("fill",function(a){return J(a.id)}).attr("class",Gc),e.style("opacity",0).transition().duration(v).attr("d",c(!0)).style("opacity",1),e.exit().transition().duration(v).style("opacity",
0).remove(),F.selectAll(".-line").transition().duration(v).attr("d",xe)));l.selectAll(".selected-circles").filter(function(a){return sb(a)}).selectAll("circle").remove();l.selectAll(".selected-circle").transition().duration(v).attr("cx",g?ya:xa).attr("cy",g?xa:ya);Z?(c=l.select(".event-rects").selectAll(".event-rect").data([0]),se(c.enter()),c.attr("x",0).attr("y",0).attr("width",r).attr("height",s)):(Ob?(q=function(a,b){var c=Bc(b),e=b<fb()-1?h.data.targets[0].values[b+1].x:void 0;return(m(e?e:a.x+
50)-m(c?c:a.x-50))/2},e=function(a,b){var c=Bc(b);return(m(a.x)+m(c?c:a.x-50))/2}):(q=nd(),e=function(a){return m(a.x)-q/2}),c=Nd(),l.select(".event-rects").datum(c?c.values:[]),c=l.select(".event-rects").selectAll(".event-rect").data(function(a){return a}),re(c.enter()),c.attr("class",Hc).attr("x",g?0:e).attr("y",g?e:0).attr("width",g?r:q).attr("height",g?q:s),c.exit().remove());e=l.select(".regions").selectAll("rect.region").data(P);e.enter().append("rect");e.attr("class",Sd).attr("x",g?0:Nb).attr("y",
g?Nb:n).attr("width",g?r:wc).attr("height",g?wc:s).style("fill-opacity",function(a){return u(a.opacity)?a.opacity:0.1});e.exit().transition().duration(v).style("fill-opacity",0).remove()}function ye(){"mousemove"===d.event.sourceEvent.type&&E.altDomain?(m.domain(E.altDomain),E.scale(m).updateScaleExtent()):(da&&m.orgDomain()[0]===T[0]&&m.domain([T[0]-1E-10,m.orgDomain()[1]]),H({withTransition:!1,withY:!1,withSubchart:!1}),"mousemove"===d.event.sourceEvent.type&&(cc=!0))}function pe(){function a(){b.forEach(function(a){a()})}
var b=[];a.add=function(a){b.push(a)};return a}function qe(){qa();Q();K.scale(U);oa&&E.scale(m);p.attr("width",zb).attr("height",ra);p.select("#"+Yb).select("rect").attr("width",r).attr("height",s);p.select("#xaxis-clip").select("rect").attr("width",M);p.select(".zoom-rect").attr("width",r).attr("height",s);l.select(".x.axis").attr("transform",L.x);l.select(".y2.axis").attr("transform",L.y2);l.select(".chart-arcs").attr("transform",L.arc);Aa&&(F.attr("transform",L.context),F.select(".x.axis").attr("transform",
L.subx));Ca&&(Ba.attr("transform",L.legend),wb(h.data.targets,{withTransition:!1}));H({withTransition:!1,withUpdateXDomain:!0})}function dd(a){var b;l.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",Fc).style("fill",function(a){return J(a.id)}).style("stroke",function(a){return J(a.id)}).style("stroke-width",0).style("cursor",function(a){return fa(a)?
"pointer":null});b=l.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",Ec).style("stroke",function(a){return J(a.id)});b.append("path").attr("class",Qd).style("fill",function(a){return J(a.id)});b.append("g").attr("class",function(a){return"selected-circles selected-circles-"+a.id});b.append("g").attr("class",Od).style("fill",function(a){return J(a.id)}).style("cursor",
function(a){return fa(a)?"pointer":null});a.forEach(function(a){l.selectAll(".selected-circles-"+a.id).selectAll(".selected-circle").each(function(b){b.value=a.values[b.x].value})});b=l.select(".chart-arcs").selectAll(".chart-arc").data(Lb(a)).enter().append("g").attr("class",function(a){return"chart-arc target target-"+a.data.id}).style("opacity",0);b.append("path").attr("class",Pd).style("fill",function(a){return J(a.data.id)}).style("cursor",function(a){return fa(a)?"pointer":null}).each(function(a){this._current=
a}).on("mouseover",function(a){Za(a.data.id);fc(a.data.id)}).on("mouseout",function(a){xb(a.data.id);gc()});b.append("text").attr("dy",".35em").style("text-anchor","middle").style("pointer-events","none");Aa&&(b=F.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",Fc).style("fill",function(a){return J(a.id)}),b=F.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",Ec).style("stroke",function(a){return J(a.id)}));Ca&&wb(a);p.selectAll(".target").transition().style("opacity",1)}function Ta(a,b){h.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}});h.data.targets=h.data.targets.concat(a);dd(h.data.targets);H({withUpdateOrgXDomain:!0,withUpdateXDomain:!0});

Loading…
Cancel
Save