From 217d98381cde17f52bfbf5655d07c0ac5297a2c4 Mon Sep 17 00:00:00 2001 From: Masayuki Tanaka Date: Thu, 6 Mar 2014 22:58:08 +0900 Subject: [PATCH] Fix svgLeft - #52 --- c3.js | 8 +++++--- c3.min.js | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/c3.js b/c3.js index 10e4c41..e76e4f9 100644 --- a/c3.js +++ b/c3.js @@ -296,8 +296,9 @@ innerRadius = hasDonutType(c3.data.targets) ? radius * 0.6 : 0; } function getSvgLeft() { - var svgLeft = svg.property('offsetLeft'); - return svgLeft ? svgLeft : 0; + var svgRect = d3.select('.y.axis').node().getBoundingClientRect(), + chartRect = d3.select(__bindto).node().getBoundingClientRect(); + return svgRect.right - chartRect.left - getCurrentPaddingLeft(); } function getCurrentWidth() { return __size_width ? __size_width : getParentWidth(); @@ -1064,7 +1065,8 @@ tHeight = tooltip.property('offsetHeight'); // Determin tooltip position if (__axis_rotated) { - tooltipLeft = mouse[0] + 100; + svgLeft = getSvgLeft(); + tooltipLeft = svgLeft + mouse[0] + 100; tooltipRight = tooltipLeft + tWidth; chartRight = getCurrentWidth() - getCurrentPaddingRight(); tooltipTop = x(dataToShow[0].x) + 20; diff --git a/c3.min.js b/c3.min.js index 3b76a4c..bebe816 100644 --- a/c3.min.js +++ b/c3.min.js @@ -1,2 +1,2 @@ -!function(a){"use strict";function b(){function a(a,b){a.attr("transform",function(a){return"translate("+(b(a)+q)+", 0)"})}function b(a,b){a.attr("transform",function(a){return"translate(0,"+b(a)+")"})}function c(a){var b=a[0],c=a[a.length-1];return c>b?[b,c]:[c,b]}function d(a){for(var b=[],c=Math.ceil(a[0]);c0&&b[0]>0&&b.unshift(b[0]-(b[1]-b[0])),b}function e(a,b){var c=a.length-1;return p>=c||b%Math.ceil(c/p)===0}function f(a){return a0?a:320}function s(){return yc(Dd.data.targets)?0:Ld?Ld:jf?1:u("y")}function t(){return yc(Dd.data.targets)?0:Md?Md:hg?be*(nf&&!Xe?1.25:1):nf?rf||Xe?1:u("y2"):1}function u(){return 40}function v(){return+g.select(Id).style("width").replace("px","")}function w(){return+g.select(Id).style("height").replace("px","")}function x(){return Wd+2}function y(){return 40}function z(){return Td.left+20}function A(){return Yd+2}function B(){var a=Xe?Yd:Wd,b=_(),c=wb();return c>1?a*b/(c-1):a}function C(){return Ue?hg?150:$d:0}function D(){return Ue?hg?_d:40:0}function E(){var a,b;je=Xe?1:0,ke=Xe?Yd:Wd,le=Xe?0:Yd,me=Xe?Wd:1,ne=je,oe=ke,pe=Xe?0:Zd,qe=Xe?Xd:1,re=G(je,ke,re?re.domain():void 0,function(){return xe.tickOffset()}),se=H(le,me,se?se.domain():void 0),te=H(le,me,te?te.domain():void 0),ue=G(je,ke,wg,function(a){return a%1?0:Ae.tickOffset()}),ve=H(pe,qe),we=H(pe,qe),a=N(),b=O(),xe=K(re,cg,a,b),Ae=K(ue,fg,a,b),ye=L(se,dg,kf,mf),ze=L(te,eg,sf,uf),F()}function F(){fe=Q(),ge=R(),he=R(.98)}function G(a,b,c,f){var h=(Wf?g.time.scale():g.scale.linear()).range([a,b]);if(h.orgDomain=function(){return h.domain()},e(c)&&h.domain(c),d(f)&&(f=function(){return 0}),Xf){var i,j=h;h=function(a){return j(a)+f(a)};for(i in j)h[i]=j[i];h.orgDomain=function(){return j.domain()},h.domain=function(a){return arguments.length?(j.domain(a),h):(a=j.domain(),[a[0],a[1]+1])}}return h}function H(a,b){return g.scale.linear().range([a,b])}function I(a){return"y2"===M(a)?te:se}function J(a){return"y2"===M(a)?we:ve}function K(a,c,d,e){var f=(Xf?b():g.svg.axis()).scale(a).orient(c);return f.tickFormat(d).ticks(e),Xf?f.tickCentered($e):f.tickOffset=function(){var a=Xe?Yd:Wd;return a*_()/wb()/2},Xf&&f.categories(Ze),f}function L(a,b,c,d){return g.svg.axis().scale(a).orient(b).tickFormat(c).ticks(d).outerTickSize(0)}function M(a){return a in He?He[a]:"y"}function N(){var a=Wf?bg:Xf?Fb:null;return _e&&("function"==typeof _e?a=_e:Wf&&(a=function(a){return g.time.format(_e)(a)})),a}function O(){var a=wb();return af&&a>bf?bf:a}function P(a){var b=!1;return ie(Dd.data.targets).forEach(function(c){return b||c.data.id!==a.data.id?void 0:(b=!0,void(a=c))}),b?a:null}function Q(){var a=g.svg.arc().outerRadius(ce).innerRadius(ee),b=function(b,c){var d;return c?a(b):(d=P(b),d?a(d):"M 0 0")};return b.centroid=a.centroid,b}function R(a){var b=g.svg.arc().outerRadius(de*(a?a:1)).innerRadius(ee);return function(a){var c=P(a);return c?b(c):"M 0 0"}}function S(a,b){return Fc(a.data)?fe(a,b):"M 0 0"}function T(a){var b,c,d,e,f=P(a),g="";return f&&(b=fe.centroid(f),c=b[0],d=b[1],e=Math.sqrt(c*c+d*d),g="translate("+c/e*ce*.8+","+d/e*ce*.8+")"),g}function U(a){return(a.endAngle-a.startAngle)/(2*Math.PI)}function V(a){return Kf(a,U(a))}function W(a,b){var c=pg.selectAll(".chart-arc"+Ad(a)),d=pg.selectAll(".-arc").filter(function(b){return b.data.id!==a});c.selectAll("path").transition().duration(50).attr("d",ge).transition().duration(100).attr("d",he).each(function(a){Ec(a.data)}),b||d.style("opacity",.3)}function X(a){var b=pg.selectAll(".chart-arc"+Ad(a));b.selectAll("path").transition().duration(50).attr("d",fe),pg.selectAll(".-arc").style("opacity",1)}function Y(a){var b,c,d,e,f,h=Bb(a);if(Ge.length>0)for(f=Db(a),b=0;ba?a:0}),c=1;c0||(h[d][b]+=+a)});return g.min(Object.keys(h).map(function(a){return g.min(h[a])}))}function Z(a){var b,c,d,e,f,h=Bb(a);if(Ge.length>0)for(f=Eb(a),b=0;b0?a:0}),c=1;c+a||(h[d][b]+=+a)});return g.max(Object.keys(h).map(function(a){return g.max(h[a])}))}function $(a){var b=Ab(function(b){return M(b.id)===a}),d="y2"===a?pf:ff,e="y2"===a?of:ef,f=d?d:Y(b),g=e?e:Z(b),h=.22*Math.abs(g-f),i=h,j=h,k="y2"===a?qf:gf;if(k){var l=Math.max(Math.abs(f),Math.abs(g));g=l-k,f=k-l}return"y"===a&&lf&&(i=c(lf.top)?lf.top:h,j=c(lf.bottom)?lf.bottom:h),"y2"===a&&tf&&(i=c(tf.top)?tf.top:h,j=c(tf.bottom)?tf.bottom:h),uc(b)&&!Db(b)&&(j=f),[f-j,g+i]}function _(a){return a?1:eb(wg)/eb(re.domain())}function ab(a){return g.min(a,function(a){return g.min(a.values,function(a){return a.x})})}function bb(a){return g.max(a,function(a){return g.max(a.values,function(a){return a.x})})}function cb(a,b){var c,d=b[0],e=b[1],f=Math.abs(d-e);return c=Xf?0:uc(a)?f/(wb()-1)/2:.01*f}function db(a){var b=[ab(a),bb(a)],c=b[0],d=b[1],e=cb(a,b),f=Wf?new Date(c.getTime()-e):c-e,g=Wf?new Date(d.getTime()+e):d+e;return[f,g]}function eb(a){return a[1]-a[0]}function fb(a){for(var b=0;bd?0:d}function kb(a){return Be&&a===Be||Ce&&Oc(Ce,a)}function lb(a){return!kb(a)}function mb(a){return Be?Be:Ce?Ce[a]:null}function nb(a,b){return a in Dd.data.x&&Dd.data.x[a]&&Dd.data.x[a][b]?Dd.data.x[a][b]:b}function ob(a){Object.keys(a).forEach(function(b){Ce[b]=a[b]})}function pb(a){var b;return a&&(b=Fe[a.id],a.name=b?b:a.id),a}function qb(a){var b,c,d=a[0],e={},f=[];for(b=1;b=0?b.map(function(a){return a[c]}):Dd.data.x[Object.keys(Dd.data.x)[0]]}),c=d.map(function(a){var c=Ee(a);return{id:c,id_org:a,values:b.map(function(b,d){var e,f=mb(a);return e=Wf?Kc(b[f]):Yf?b[f]?+b[f]:nb(a,d):d,b.x=e,{x:e,value:null===b[a]||isNaN(b[a])?null:+b[a],id:c}})}}),c.forEach(function(a){var b;a.values=a.values.sort(function(a,b){var c=a.x||0===a.x?a.x:1/0,d=b.x||0===b.x?b.x:1/0;return c-d}),b=0,a.values.forEach(function(a){a.index=b++})}),Ie&&sc(yb(c).filter(function(a){return!(a in Je)}),Ie),c.forEach(function(a){gb(a.id_org,a)}),c)}function tb(a){return{id:a.id,id_org:a.id_org,values:a.values.map(function(a){return{x:a.x,value:a.value,id:a.id}})}}function ub(a){return a>0&&Dd.data.targets[0].values[a-1]?Dd.data.targets[0].values[a-1].x:void 0}function vb(a){return a1?Dd.data.targets.forEach(function(b){b.values.length>c&&(a=b,c=b.values.length)}):a=b?Dd.data.targets[0]:null,a}function yb(a){return a=d(a)?Dd.data.targets:a,a.map(function(a){return a.id})}function zb(a){var b,c=yb();for(b=0;ba})}function Eb(a){return Cb(a,function(a){return a>0})}function Fb(a){return a=0&&d===a[c].x;c--)e.push(a[c]);for(c=b;c0?g=h:f=h,g-f===1?(e=[],a[f].x&&(e=e.concat(ac(a,f))),a[g].x&&(e=e.concat(ac(a,g))),dc(e,b)):bc(a,b,f,g)}function cc(a,b){var c;return c=a.map(function(a){return bc(a.values,b)}),dc(c,b)}function dc(a,b){var c,d;return a.forEach(function(a){var e=Pc(a,b);(c>e||!c)&&(c=e,d=a)}),d}function ec(){return Le&&"desc"===Le.toLowerCase()}function fc(){return Le&&"asc"===Le.toLowerCase()}function gc(a){var b=fc(),c=ec();return b||c?a.sort(function(a,c){var d=function(a,b){return a+Math.abs(b.value)},e=a.values.reduce(d,0),f=c.values.reduce(d,0);return b?f-e:e-f}):"function"==typeof Le&&a.sort(Le),a}function hc(a,b){var d,e,f,g,h,i,j,k=a.filter(function(a){return a&&c(a.value)});Nf&&0!==k.length&&(ug.html(Qf(a,N(),_b,ag)).style("visibility","hidden").style("display","block"),d=ug.property("offsetWidth"),e=ug.property("offsetHeight"),Xe?(g=b[0]+100,h=g+d,j=q()-t(),i=re(k[0].x)+20):(f=p(),g=f+s()+re(k[0].x)+20,h=g+d,j=f+q()-t(),i=b[1]+15),h>j&&(g-=d+60),i+e>r()&&(i-=e+30),ug.style("top",i+"px").style("left",g+"px").style("visibility","visible"))}function ic(){ug.style("display","none")}function jc(a){var b=a.filter(function(a){return a&&c(a.value)});Nf&&(vc(Dd.data.targets)||yc(Dd.data.targets)||rg.selectAll("line.xgrid-focus").style("visibility","visible").data([b[0]]).attr(Xe?"y1":"x1",Xb).attr(Xe?"y2":"x2",Xb))}function kc(){rg.select("line.xgrid-focus").style("visibility","hidden")}function lc(a){return a.x||0===a.x?re(a.x):null}function mc(a){return I(a.id)(a.value)}function nc(){var a,b,c={},e=0;return Ab(Bc).forEach(function(f){for(a=0;a0&&(i+=g(b.values[f].value)-h)}),i}}function rc(a,b){return b?2*a.tickOffset()*.6/b:0}function sc(a,b){var c=d(a)?yb():a;"string"==typeof c&&(c=[c]);for(var e=0;e=h;h+=u)s+=i(a[g-1],a[g],h,o)}r=a[g].x}return s}function hd(b){var c,d,e,f,h;if(vg=g.select(Id),vg.empty())return void a.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');if(vg.html(""),Dd.data.x={},Dd.data.targets=sb(b),n(),E(),re.domain(g.extent(db(Dd.data.targets))),se.domain($("y")),te.domain($("y2")),ue.domain(re.domain()),ve.domain(se.domain()),we.domain(te.domain()),wg=re.domain(),kg.scale(ue),Nd&&og.scale(re),pg=g.select(Id).append("svg").attr("width",Wd+Td.left+Td.right).attr("height",Yd+Td.top+Td.bottom).on("mouseenter",Qd).on("mouseleave",Rd),qg=pg.append("defs"),qg.append("clipPath").attr("id",Uf).append("rect").attr("width",Wd).attr("height",Yd),qg.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1).attr("y",-20).attr("width",x).attr("height",y),qg.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-Td.left+1).attr("width",z).attr("height",A),rg=pg.append("g").attr("transform",gg.main),sg=Re?pg.append("g").attr("transform",gg.context):null,tg=Ue?pg.append("g").attr("transform",gg.legend):null,ug=g.select(Id).style("position","relative").append("div").style("position","absolute").style("z-index","10").style("display","none"),rg.append("g").attr("class","x axis").attr("clip-path",Xe?"":"url("+document.URL+"#xaxis-clip)").attr("transform",gg.x).append("text").attr("class","-axis-x-label").attr("x",Wd).attr("dy","-.5em").style("text-anchor","end").text(df),rg.append("g").attr("class","y axis").attr("clip-path",Xe?"url("+document.URL+"#yaxis-clip)":"").append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(hf),nf&&rg.append("g").attr("class","y2 axis").attr("transform",gg.y2),d=rg.append("g").attr("clip-path",Vf).attr("class","grid"),vf&&d.append("g").attr("class","xgrids"),xf&&(e=d.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(xf).enter().append("g").attr("class","xgrid-line"),e.append("line").attr("class",function(a){return""+a["class"]}),e.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",Xe?"":"rotate(-90)").attr("dx",Xe?0:-Td.top).attr("dy",-5).text(function(a){return a.text})),Df&&d.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",Xe?0:-10).attr("x2",Xe?Wd:-10).attr("y1",Xe?-10:Td.top).attr("y2",Xe?-10:Yd),yf&&d.append("g").attr("class","ygrids"),zf&&(f=d.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(zf).enter().append("g").attr("class","ygrid-line"),f.append("line").attr("class",function(a){return""+a["class"]}),f.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",Xe?"rotate(-90)":"").attr("dx",Xe?0:-Td.top).attr("dy",-5).text(function(a){return a.text})),rg.append("g").attr("clip-path",Vf).attr("class","regions"),rg.append("g").attr("clip-path",Vf).attr("class","chart"),c=rg.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",Nd?Xe?"ns-resize":"ew-resize":null),rg.select(".chart").append("g").attr("class","chart-bars"),rg.select(".chart").append("g").attr("class","chart-lines"),rg.select(".chart").append("g").attr("class","chart-arcs").attr("transform",gg.arc).append("text").attr("class","chart-arcs-title").style("text-anchor","middle").text(Lf),rg.select(".chart").append("g").attr("class","chart-texts"),Nd&&rg.insert("rect",Pd?null:"g.grid").attr("class","zoom-rect").attr("width",Wd).attr("height",Yd).style("opacity",0).style("cursor",Xe?"ns-resize":"ew-resize").call(og).on("dblclick.zoom",null),null!==cf&&kg.extent("function"!=typeof cf?cf:cf(db())),Re&&(sg.append("g").attr("clip-path",Vf).attr("class","chart"),sg.select(".chart").append("g").attr("class","chart-bars"),sg.select(".chart").append("g").attr("class","chart-lines"),sg.append("g").attr("clip-path",Vf).attr("class","x brush").call(kg).selectAll("rect").attr(Xe?"width":"height",Xe?Xd:Zd),sg.append("g").attr("class","x axis").attr("transform",gg.subx).attr("clip-path",Xe?"url("+document.URL+"#yaxis-clip)":"")),Ue&&yd(Dd.data.targets),td(Dd.data.targets),od({withTransform:!0,withUpdateXDomain:!0}),Rf){if(Wf&&"string"==typeof Sf){for(Sf=Kc(Sf),h=0;h0){d=[];for(var f in Fe)for(c=0;cf&&h>c&&d>i&&j>d):"rect"===this.nodeName&&(c=1*l.attr("x"),d=1*l.attr("y"),e=1*l.attr("width"),k=Vc,o=c+e>f&&h>c&&j>d),o^n&&(l.classed(Hd,!n),l.classed(Gd,!m),k(!m,l,a,b))}))}function md(a){yc(Dd.data.targets)||Oe&&(Zf=a,rg.select(".chart").append("rect").attr("class","dragarea").style("opacity",.1),$f=!0)}function nd(){yc(Dd.data.targets)||Oe&&(rg.select(".dragarea").transition().duration(100).style("opacity",0).remove(),rg.selectAll(".-shape").classed(Hd,!1),$f=!1)}function od(a){var b,d,f,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,C,D,E,F=nc(),G=yc(Dd.data.targets);if(a=e(a)?a:{},s=e(a.withY)?a.withY:!0,t=e(a.withSubchart)?a.withSubchart:!0,u=e(a.withTransition)?a.withTransition:!0,v=e(a.withTransform)?a.withTransform:!1,w=e(a.withUpdateXDomain)?a.withUpdateXDomain:!1,x=e(a.withUpdateOrgXDomain)?a.withUpdateOrgXDomain:!1,D=u?Sd:0,E=e(a.durationForExit)?a.durationForExit:D,x&&(re.domain(g.extent(db(Dd.data.targets))),wg=re.domain(),Nd&&og.scale(re).updateScaleExtent(),ue.domain(re.domain()),kg.scale(ue)),w&&(re.domain(kg.empty()?wg:kg.extent()),Nd&&og.scale(re).updateScaleExtent()),se.domain($("y")),te.domain($("y2")),rg.select(".x.axis").style("opacity",G?0:1).transition().duration(D).call(Xe?ye:xe),rg.select(".y.axis").style("opacity",G?0:1).transition().duration(D).call(Xe?xe:ye),rg.select(".y2.axis").style("opacity",G?0:1).transition().call(ze),y=bd(F),A=cd(F,!0),C=cd(F,!1),rg.select(".x.axis .-axis-x-label").attr("x",Wd),ve.domain(se.domain()),we.domain(te.domain()),ug.style("display","none"),rg.select("line.xgrid-focus").style("visibility","hidden").attr("y2",Yd),vf){if("year"===wf){d=[];for(var H=db(),I=H[0].getFullYear(),J=H[1].getFullYear(),K=I;J>=K;K++)d.push(new Date(K+"-01-01 00:00:00"))}else d=re.ticks(10);b=rg.select(".xgrids").selectAll(".xgrid").data(d),b.enter().append("line").attr("class","xgrid"),b.attr("x1",Xe?0:function(a){return re(a)-xe.tickOffset()}).attr("x2",Xe?Wd:function(a){return re(a)-xe.tickOffset()}).attr("y1",Xe?function(a){return re(a)-xe.tickOffset()}:Td.top).attr("y2",Xe?function(a){return re(a)-xe.tickOffset()}:Yd).style("opacity",function(){return+g.select(this).attr(Xe?"y1":"x1")===(Xe?Yd:0)?0:1}),b.exit().remove()}xf&&(f=rg.selectAll(".xgrid-lines"),f.selectAll("line").transition().duration(D).attr("x1",Xe?0:Yb).attr("x2",Xe?Wd:Yb).attr("y1",Xe?Yb:Td.top).attr("y2",Xe?Yb:Yd),f.selectAll("text").attr("x",Xe?Wd:0).attr("y",Yb)),s&&yf&&(h=rg.select(".ygrids").selectAll(".ygrid").data(se.ticks(Af)),h.enter().append("line").attr("class","ygrid"),h.attr("x1",Xe?se:0).attr("x2",Xe?se:Wd).attr("y1",Xe?0:se).attr("y2",Xe?Yd:se),h.exit().remove()),s&&zf&&(i=rg.select(".ygrid-lines"),i.selectAll("line").transition().duration(D).attr("x1",Xe?Zb:0).attr("x2",Xe?Zb:Wd).attr("y1",Xe?0:Zb).attr("y2",Xe?Yd:Zb),i.selectAll("text").attr("x",Xe?0:Wd).attr("y",Zb)),k=rg.selectAll(".-bars").selectAll(".-bar").data(Gc),k.enter().append("path").attr("d",y).style("stroke","none").style("opacity",0).style("fill",function(a){return ag(a.id)}).attr("class",Qb),k.style("opacity",Tb).transition().duration(D).attr("d",y).style("opacity",1),k.exit().transition().duration(E).style("opacity",0).remove(),m=rg.selectAll(".-texts").selectAll(".-text").data(Ic),m.enter().append("text").attr("class",Gb).attr("text-anchor",function(a){return Xe?a.value<0?"end":"start":"middle"}).style("stroke","none").style("fill-opacity",0).text(function(a){return _b(a.value)}),m.style("fill-opacity",Ub).transition().duration(D).attr("x",A).attr("y",C).style("fill-opacity",Wb),m.exit().transition().duration(E).style("fill-opacity",0).remove(),rg.selectAll(".-line").style("opacity",Tb).transition().duration(D).attr("d",lg).style("opacity",1),rg.selectAll(".-area").style("opacity",0).transition().duration(D).attr("d",mg).style("opacity",xg),j=rg.selectAll(".-circles").selectAll(".-circle").data(Hc),j.enter().append("circle").attr("class",Pb).style("opacity",0).attr("r",Cf),j.style("opacity",Tb).transition().duration(D).style("opacity",Vb).attr("cx",Xe?mc:lc).attr("cy",Xe?lc:mc),j.exit().remove(),rg.selectAll(".chart-arc").select(".-arc").attr("transform",v?"scale(0)":"").style("opacity",function(a){return a===this._current?0:1}).transition().duration(D).attrTween("d",function(a){var b=P(a);if(!b)return function(){return"M 0 0"};var c=g.interpolate(this._current,b);return this._current=c(0),function(a){return S(c(a),!0)}}).attr("transform",v?"scale(1)":"").style("opacity",1),rg.selectAll(".chart-arc").select("text").attr("transform",T).style("opacity",0).transition().duration(D).text(V).style("opacity",function(a){return Fc(a.data)?1:0}),rg.select(".chart-arcs-title").style("opacity",xc(Dd.data.targets)?1:0),Re&&(null!==g.event&&"zoom"===g.event.type&&kg.extent(re.orgDomain()).update(),t&&(sg.select(".x.axis").style("opacity",G?0:1).transition().duration(D).call(Ae),kg.empty()||kg.extent(re.orgDomain()).update(),z=bd(F,!0),n=sg.selectAll(".-bars").selectAll(".-bar").data(Gc),n.enter().append("path").attr("d",z).style("stroke","none").style("fill",function(a){return ag(a.id) +!function(a){"use strict";function b(){function a(a,b){a.attr("transform",function(a){return"translate("+(b(a)+q)+", 0)"})}function b(a,b){a.attr("transform",function(a){return"translate(0,"+b(a)+")"})}function c(a){var b=a[0],c=a[a.length-1];return c>b?[b,c]:[c,b]}function d(a){for(var b=[],c=Math.ceil(a[0]);c0&&b[0]>0&&b.unshift(b[0]-(b[1]-b[0])),b}function e(a,b){var c=a.length-1;return p>=c||b%Math.ceil(c/p)===0}function f(a){return a0?a:320}function s(){return yc(Dd.data.targets)?0:Ld?Ld:jf?1:u("y")}function t(){return yc(Dd.data.targets)?0:Md?Md:hg?be*(nf&&!Xe?1.25:1):nf?rf||Xe?1:u("y2"):1}function u(){return 40}function v(){return+g.select(Id).style("width").replace("px","")}function w(){return+g.select(Id).style("height").replace("px","")}function x(){return Wd+2}function y(){return 40}function z(){return Td.left+20}function A(){return Yd+2}function B(){var a=Xe?Yd:Wd,b=_(),c=wb();return c>1?a*b/(c-1):a}function C(){return Ue?hg?150:$d:0}function D(){return Ue?hg?_d:40:0}function E(){var a,b;je=Xe?1:0,ke=Xe?Yd:Wd,le=Xe?0:Yd,me=Xe?Wd:1,ne=je,oe=ke,pe=Xe?0:Zd,qe=Xe?Xd:1,re=G(je,ke,re?re.domain():void 0,function(){return xe.tickOffset()}),se=H(le,me,se?se.domain():void 0),te=H(le,me,te?te.domain():void 0),ue=G(je,ke,wg,function(a){return a%1?0:Ae.tickOffset()}),ve=H(pe,qe),we=H(pe,qe),a=N(),b=O(),xe=K(re,cg,a,b),Ae=K(ue,fg,a,b),ye=L(se,dg,kf,mf),ze=L(te,eg,sf,uf),F()}function F(){fe=Q(),ge=R(),he=R(.98)}function G(a,b,c,f){var h=(Wf?g.time.scale():g.scale.linear()).range([a,b]);if(h.orgDomain=function(){return h.domain()},e(c)&&h.domain(c),d(f)&&(f=function(){return 0}),Xf){var i,j=h;h=function(a){return j(a)+f(a)};for(i in j)h[i]=j[i];h.orgDomain=function(){return j.domain()},h.domain=function(a){return arguments.length?(j.domain(a),h):(a=j.domain(),[a[0],a[1]+1])}}return h}function H(a,b){return g.scale.linear().range([a,b])}function I(a){return"y2"===M(a)?te:se}function J(a){return"y2"===M(a)?we:ve}function K(a,c,d,e){var f=(Xf?b():g.svg.axis()).scale(a).orient(c);return f.tickFormat(d).ticks(e),Xf?f.tickCentered($e):f.tickOffset=function(){var a=Xe?Yd:Wd;return a*_()/wb()/2},Xf&&f.categories(Ze),f}function L(a,b,c,d){return g.svg.axis().scale(a).orient(b).tickFormat(c).ticks(d).outerTickSize(0)}function M(a){return a in He?He[a]:"y"}function N(){var a=Wf?bg:Xf?Fb:null;return _e&&("function"==typeof _e?a=_e:Wf&&(a=function(a){return g.time.format(_e)(a)})),a}function O(){var a=wb();return af&&a>bf?bf:a}function P(a){var b=!1;return ie(Dd.data.targets).forEach(function(c){return b||c.data.id!==a.data.id?void 0:(b=!0,void(a=c))}),b?a:null}function Q(){var a=g.svg.arc().outerRadius(ce).innerRadius(ee),b=function(b,c){var d;return c?a(b):(d=P(b),d?a(d):"M 0 0")};return b.centroid=a.centroid,b}function R(a){var b=g.svg.arc().outerRadius(de*(a?a:1)).innerRadius(ee);return function(a){var c=P(a);return c?b(c):"M 0 0"}}function S(a,b){return Fc(a.data)?fe(a,b):"M 0 0"}function T(a){var b,c,d,e,f=P(a),g="";return f&&(b=fe.centroid(f),c=b[0],d=b[1],e=Math.sqrt(c*c+d*d),g="translate("+c/e*ce*.8+","+d/e*ce*.8+")"),g}function U(a){return(a.endAngle-a.startAngle)/(2*Math.PI)}function V(a){return Kf(a,U(a))}function W(a,b){var c=pg.selectAll(".chart-arc"+Ad(a)),d=pg.selectAll(".-arc").filter(function(b){return b.data.id!==a});c.selectAll("path").transition().duration(50).attr("d",ge).transition().duration(100).attr("d",he).each(function(a){Ec(a.data)}),b||d.style("opacity",.3)}function X(a){var b=pg.selectAll(".chart-arc"+Ad(a));b.selectAll("path").transition().duration(50).attr("d",fe),pg.selectAll(".-arc").style("opacity",1)}function Y(a){var b,c,d,e,f,h=Bb(a);if(Ge.length>0)for(f=Db(a),b=0;ba?a:0}),c=1;c0||(h[d][b]+=+a)});return g.min(Object.keys(h).map(function(a){return g.min(h[a])}))}function Z(a){var b,c,d,e,f,h=Bb(a);if(Ge.length>0)for(f=Eb(a),b=0;b0?a:0}),c=1;c+a||(h[d][b]+=+a)});return g.max(Object.keys(h).map(function(a){return g.max(h[a])}))}function $(a){var b=Ab(function(b){return M(b.id)===a}),d="y2"===a?pf:ff,e="y2"===a?of:ef,f=d?d:Y(b),g=e?e:Z(b),h=.22*Math.abs(g-f),i=h,j=h,k="y2"===a?qf:gf;if(k){var l=Math.max(Math.abs(f),Math.abs(g));g=l-k,f=k-l}return"y"===a&&lf&&(i=c(lf.top)?lf.top:h,j=c(lf.bottom)?lf.bottom:h),"y2"===a&&tf&&(i=c(tf.top)?tf.top:h,j=c(tf.bottom)?tf.bottom:h),uc(b)&&!Db(b)&&(j=f),[f-j,g+i]}function _(a){return a?1:eb(wg)/eb(re.domain())}function ab(a){return g.min(a,function(a){return g.min(a.values,function(a){return a.x})})}function bb(a){return g.max(a,function(a){return g.max(a.values,function(a){return a.x})})}function cb(a,b){var c,d=b[0],e=b[1],f=Math.abs(d-e);return c=Xf?0:uc(a)?f/(wb()-1)/2:.01*f}function db(a){var b=[ab(a),bb(a)],c=b[0],d=b[1],e=cb(a,b),f=Wf?new Date(c.getTime()-e):c-e,g=Wf?new Date(d.getTime()+e):d+e;return[f,g]}function eb(a){return a[1]-a[0]}function fb(a){for(var b=0;bd?0:d}function kb(a){return Be&&a===Be||Ce&&Oc(Ce,a)}function lb(a){return!kb(a)}function mb(a){return Be?Be:Ce?Ce[a]:null}function nb(a,b){return a in Dd.data.x&&Dd.data.x[a]&&Dd.data.x[a][b]?Dd.data.x[a][b]:b}function ob(a){Object.keys(a).forEach(function(b){Ce[b]=a[b]})}function pb(a){var b;return a&&(b=Fe[a.id],a.name=b?b:a.id),a}function qb(a){var b,c,d=a[0],e={},f=[];for(b=1;b=0?b.map(function(a){return a[c]}):Dd.data.x[Object.keys(Dd.data.x)[0]]}),c=d.map(function(a){var c=Ee(a);return{id:c,id_org:a,values:b.map(function(b,d){var e,f=mb(a);return e=Wf?Kc(b[f]):Yf?b[f]?+b[f]:nb(a,d):d,b.x=e,{x:e,value:null===b[a]||isNaN(b[a])?null:+b[a],id:c}})}}),c.forEach(function(a){var b;a.values=a.values.sort(function(a,b){var c=a.x||0===a.x?a.x:1/0,d=b.x||0===b.x?b.x:1/0;return c-d}),b=0,a.values.forEach(function(a){a.index=b++})}),Ie&&sc(yb(c).filter(function(a){return!(a in Je)}),Ie),c.forEach(function(a){gb(a.id_org,a)}),c)}function tb(a){return{id:a.id,id_org:a.id_org,values:a.values.map(function(a){return{x:a.x,value:a.value,id:a.id}})}}function ub(a){return a>0&&Dd.data.targets[0].values[a-1]?Dd.data.targets[0].values[a-1].x:void 0}function vb(a){return a1?Dd.data.targets.forEach(function(b){b.values.length>c&&(a=b,c=b.values.length)}):a=b?Dd.data.targets[0]:null,a}function yb(a){return a=d(a)?Dd.data.targets:a,a.map(function(a){return a.id})}function zb(a){var b,c=yb();for(b=0;ba})}function Eb(a){return Cb(a,function(a){return a>0})}function Fb(a){return a=0&&d===a[c].x;c--)e.push(a[c]);for(c=b;c0?g=h:f=h,g-f===1?(e=[],a[f].x&&(e=e.concat(ac(a,f))),a[g].x&&(e=e.concat(ac(a,g))),dc(e,b)):bc(a,b,f,g)}function cc(a,b){var c;return c=a.map(function(a){return bc(a.values,b)}),dc(c,b)}function dc(a,b){var c,d;return a.forEach(function(a){var e=Pc(a,b);(c>e||!c)&&(c=e,d=a)}),d}function ec(){return Le&&"desc"===Le.toLowerCase()}function fc(){return Le&&"asc"===Le.toLowerCase()}function gc(a){var b=fc(),c=ec();return b||c?a.sort(function(a,c){var d=function(a,b){return a+Math.abs(b.value)},e=a.values.reduce(d,0),f=c.values.reduce(d,0);return b?f-e:e-f}):"function"==typeof Le&&a.sort(Le),a}function hc(a,b){var d,e,f,g,h,i,j,k=a.filter(function(a){return a&&c(a.value)});Nf&&0!==k.length&&(ug.html(Qf(a,N(),_b,ag)).style("visibility","hidden").style("display","block"),d=ug.property("offsetWidth"),e=ug.property("offsetHeight"),Xe?(f=p(),g=f+b[0]+100,h=g+d,j=q()-t(),i=re(k[0].x)+20):(f=p(),g=f+s()+re(k[0].x)+20,h=g+d,j=f+q()-t(),i=b[1]+15),h>j&&(g-=d+60),i+e>r()&&(i-=e+30),ug.style("top",i+"px").style("left",g+"px").style("visibility","visible"))}function ic(){ug.style("display","none")}function jc(a){var b=a.filter(function(a){return a&&c(a.value)});Nf&&(vc(Dd.data.targets)||yc(Dd.data.targets)||rg.selectAll("line.xgrid-focus").style("visibility","visible").data([b[0]]).attr(Xe?"y1":"x1",Xb).attr(Xe?"y2":"x2",Xb))}function kc(){rg.select("line.xgrid-focus").style("visibility","hidden")}function lc(a){return a.x||0===a.x?re(a.x):null}function mc(a){return I(a.id)(a.value)}function nc(){var a,b,c={},e=0;return Ab(Bc).forEach(function(f){for(a=0;a0&&(i+=g(b.values[f].value)-h)}),i}}function rc(a,b){return b?2*a.tickOffset()*.6/b:0}function sc(a,b){var c=d(a)?yb():a;"string"==typeof c&&(c=[c]);for(var e=0;e=h;h+=u)s+=i(a[g-1],a[g],h,o)}r=a[g].x}return s}function hd(b){var c,d,e,f,h;if(vg=g.select(Id),vg.empty())return void a.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');if(vg.html(""),Dd.data.x={},Dd.data.targets=sb(b),n(),E(),re.domain(g.extent(db(Dd.data.targets))),se.domain($("y")),te.domain($("y2")),ue.domain(re.domain()),ve.domain(se.domain()),we.domain(te.domain()),wg=re.domain(),kg.scale(ue),Nd&&og.scale(re),pg=g.select(Id).append("svg").attr("width",Wd+Td.left+Td.right).attr("height",Yd+Td.top+Td.bottom).on("mouseenter",Qd).on("mouseleave",Rd),qg=pg.append("defs"),qg.append("clipPath").attr("id",Uf).append("rect").attr("width",Wd).attr("height",Yd),qg.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1).attr("y",-20).attr("width",x).attr("height",y),qg.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-Td.left+1).attr("width",z).attr("height",A),rg=pg.append("g").attr("transform",gg.main),sg=Re?pg.append("g").attr("transform",gg.context):null,tg=Ue?pg.append("g").attr("transform",gg.legend):null,ug=g.select(Id).style("position","relative").append("div").style("position","absolute").style("z-index","10").style("display","none"),rg.append("g").attr("class","x axis").attr("clip-path",Xe?"":"url("+document.URL+"#xaxis-clip)").attr("transform",gg.x).append("text").attr("class","-axis-x-label").attr("x",Wd).attr("dy","-.5em").style("text-anchor","end").text(df),rg.append("g").attr("class","y axis").attr("clip-path",Xe?"url("+document.URL+"#yaxis-clip)":"").append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(hf),nf&&rg.append("g").attr("class","y2 axis").attr("transform",gg.y2),d=rg.append("g").attr("clip-path",Vf).attr("class","grid"),vf&&d.append("g").attr("class","xgrids"),xf&&(e=d.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(xf).enter().append("g").attr("class","xgrid-line"),e.append("line").attr("class",function(a){return""+a["class"]}),e.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",Xe?"":"rotate(-90)").attr("dx",Xe?0:-Td.top).attr("dy",-5).text(function(a){return a.text})),Df&&d.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",Xe?0:-10).attr("x2",Xe?Wd:-10).attr("y1",Xe?-10:Td.top).attr("y2",Xe?-10:Yd),yf&&d.append("g").attr("class","ygrids"),zf&&(f=d.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(zf).enter().append("g").attr("class","ygrid-line"),f.append("line").attr("class",function(a){return""+a["class"]}),f.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",Xe?"rotate(-90)":"").attr("dx",Xe?0:-Td.top).attr("dy",-5).text(function(a){return a.text})),rg.append("g").attr("clip-path",Vf).attr("class","regions"),rg.append("g").attr("clip-path",Vf).attr("class","chart"),c=rg.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",Nd?Xe?"ns-resize":"ew-resize":null),rg.select(".chart").append("g").attr("class","chart-bars"),rg.select(".chart").append("g").attr("class","chart-lines"),rg.select(".chart").append("g").attr("class","chart-arcs").attr("transform",gg.arc).append("text").attr("class","chart-arcs-title").style("text-anchor","middle").text(Lf),rg.select(".chart").append("g").attr("class","chart-texts"),Nd&&rg.insert("rect",Pd?null:"g.grid").attr("class","zoom-rect").attr("width",Wd).attr("height",Yd).style("opacity",0).style("cursor",Xe?"ns-resize":"ew-resize").call(og).on("dblclick.zoom",null),null!==cf&&kg.extent("function"!=typeof cf?cf:cf(db())),Re&&(sg.append("g").attr("clip-path",Vf).attr("class","chart"),sg.select(".chart").append("g").attr("class","chart-bars"),sg.select(".chart").append("g").attr("class","chart-lines"),sg.append("g").attr("clip-path",Vf).attr("class","x brush").call(kg).selectAll("rect").attr(Xe?"width":"height",Xe?Xd:Zd),sg.append("g").attr("class","x axis").attr("transform",gg.subx).attr("clip-path",Xe?"url("+document.URL+"#yaxis-clip)":"")),Ue&&yd(Dd.data.targets),td(Dd.data.targets),od({withTransform:!0,withUpdateXDomain:!0}),Rf){if(Wf&&"string"==typeof Sf){for(Sf=Kc(Sf),h=0;h0){d=[];for(var f in Fe)for(c=0;cf&&h>c&&d>i&&j>d):"rect"===this.nodeName&&(c=1*l.attr("x"),d=1*l.attr("y"),e=1*l.attr("width"),k=Vc,o=c+e>f&&h>c&&j>d),o^n&&(l.classed(Hd,!n),l.classed(Gd,!m),k(!m,l,a,b))}))}function md(a){yc(Dd.data.targets)||Oe&&(Zf=a,rg.select(".chart").append("rect").attr("class","dragarea").style("opacity",.1),$f=!0)}function nd(){yc(Dd.data.targets)||Oe&&(rg.select(".dragarea").transition().duration(100).style("opacity",0).remove(),rg.selectAll(".-shape").classed(Hd,!1),$f=!1)}function od(a){var b,d,f,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,C,D,E,F=nc(),G=yc(Dd.data.targets);if(a=e(a)?a:{},s=e(a.withY)?a.withY:!0,t=e(a.withSubchart)?a.withSubchart:!0,u=e(a.withTransition)?a.withTransition:!0,v=e(a.withTransform)?a.withTransform:!1,w=e(a.withUpdateXDomain)?a.withUpdateXDomain:!1,x=e(a.withUpdateOrgXDomain)?a.withUpdateOrgXDomain:!1,D=u?Sd:0,E=e(a.durationForExit)?a.durationForExit:D,x&&(re.domain(g.extent(db(Dd.data.targets))),wg=re.domain(),Nd&&og.scale(re).updateScaleExtent(),ue.domain(re.domain()),kg.scale(ue)),w&&(re.domain(kg.empty()?wg:kg.extent()),Nd&&og.scale(re).updateScaleExtent()),se.domain($("y")),te.domain($("y2")),rg.select(".x.axis").style("opacity",G?0:1).transition().duration(D).call(Xe?ye:xe),rg.select(".y.axis").style("opacity",G?0:1).transition().duration(D).call(Xe?xe:ye),rg.select(".y2.axis").style("opacity",G?0:1).transition().call(ze),y=bd(F),A=cd(F,!0),C=cd(F,!1),rg.select(".x.axis .-axis-x-label").attr("x",Wd),ve.domain(se.domain()),we.domain(te.domain()),ug.style("display","none"),rg.select("line.xgrid-focus").style("visibility","hidden").attr("y2",Yd),vf){if("year"===wf){d=[];for(var H=db(),I=H[0].getFullYear(),J=H[1].getFullYear(),K=I;J>=K;K++)d.push(new Date(K+"-01-01 00:00:00"))}else d=re.ticks(10);b=rg.select(".xgrids").selectAll(".xgrid").data(d),b.enter().append("line").attr("class","xgrid"),b.attr("x1",Xe?0:function(a){return re(a)-xe.tickOffset()}).attr("x2",Xe?Wd:function(a){return re(a)-xe.tickOffset()}).attr("y1",Xe?function(a){return re(a)-xe.tickOffset()}:Td.top).attr("y2",Xe?function(a){return re(a)-xe.tickOffset()}:Yd).style("opacity",function(){return+g.select(this).attr(Xe?"y1":"x1")===(Xe?Yd:0)?0:1}),b.exit().remove()}xf&&(f=rg.selectAll(".xgrid-lines"),f.selectAll("line").transition().duration(D).attr("x1",Xe?0:Yb).attr("x2",Xe?Wd:Yb).attr("y1",Xe?Yb:Td.top).attr("y2",Xe?Yb:Yd),f.selectAll("text").attr("x",Xe?Wd:0).attr("y",Yb)),s&&yf&&(h=rg.select(".ygrids").selectAll(".ygrid").data(se.ticks(Af)),h.enter().append("line").attr("class","ygrid"),h.attr("x1",Xe?se:0).attr("x2",Xe?se:Wd).attr("y1",Xe?0:se).attr("y2",Xe?Yd:se),h.exit().remove()),s&&zf&&(i=rg.select(".ygrid-lines"),i.selectAll("line").transition().duration(D).attr("x1",Xe?Zb:0).attr("x2",Xe?Zb:Wd).attr("y1",Xe?0:Zb).attr("y2",Xe?Yd:Zb),i.selectAll("text").attr("x",Xe?0:Wd).attr("y",Zb)),k=rg.selectAll(".-bars").selectAll(".-bar").data(Gc),k.enter().append("path").attr("d",y).style("stroke","none").style("opacity",0).style("fill",function(a){return ag(a.id)}).attr("class",Qb),k.style("opacity",Tb).transition().duration(D).attr("d",y).style("opacity",1),k.exit().transition().duration(E).style("opacity",0).remove(),m=rg.selectAll(".-texts").selectAll(".-text").data(Ic),m.enter().append("text").attr("class",Gb).attr("text-anchor",function(a){return Xe?a.value<0?"end":"start":"middle"}).style("stroke","none").style("fill-opacity",0).text(function(a){return _b(a.value)}),m.style("fill-opacity",Ub).transition().duration(D).attr("x",A).attr("y",C).style("fill-opacity",Wb),m.exit().transition().duration(E).style("fill-opacity",0).remove(),rg.selectAll(".-line").style("opacity",Tb).transition().duration(D).attr("d",lg).style("opacity",1),rg.selectAll(".-area").style("opacity",0).transition().duration(D).attr("d",mg).style("opacity",xg),j=rg.selectAll(".-circles").selectAll(".-circle").data(Hc),j.enter().append("circle").attr("class",Pb).style("opacity",0).attr("r",Cf),j.style("opacity",Tb).transition().duration(D).style("opacity",Vb).attr("cx",Xe?mc:lc).attr("cy",Xe?lc:mc),j.exit().remove(),rg.selectAll(".chart-arc").select(".-arc").attr("transform",v?"scale(0)":"").style("opacity",function(a){return a===this._current?0:1}).transition().duration(D).attrTween("d",function(a){var b=P(a);if(!b)return function(){return"M 0 0"};var c=g.interpolate(this._current,b);return this._current=c(0),function(a){return S(c(a),!0)}}).attr("transform",v?"scale(1)":"").style("opacity",1),rg.selectAll(".chart-arc").select("text").attr("transform",T).style("opacity",0).transition().duration(D).text(V).style("opacity",function(a){return Fc(a.data)?1:0}),rg.select(".chart-arcs-title").style("opacity",xc(Dd.data.targets)?1:0),Re&&(null!==g.event&&"zoom"===g.event.type&&kg.extent(re.orgDomain()).update(),t&&(sg.select(".x.axis").style("opacity",G?0:1).transition().duration(D).call(Ae),kg.empty()||kg.extent(re.orgDomain()).update(),z=bd(F,!0),n=sg.selectAll(".-bars").selectAll(".-bar").data(Gc),n.enter().append("path").attr("d",z).style("stroke","none").style("fill",function(a){return ag(a.id) }).attr("class",Qb),n.style("opacity",Tb).transition().duration(D).attr("d",z).style("opacity",1),n.exit().transition().duration(D).style("opacity",0).remove(),sg.selectAll(".-line").style("opacity",Tb).transition().duration(D).attr("d",ng).style("opacity",1))),rg.selectAll(".selected-circles").filter(function(a){return Bc(a)}).selectAll("circle").remove(),rg.selectAll(".selected-circle").transition().duration(D).attr("cx",Xe?mc:lc).attr("cy",Xe?lc:mc),Ce?(o=rg.select(".event-rects").selectAll(".event-rect").data([0]),jd(o.enter()),o.attr("x",0).attr("y",0).attr("width",Wd).attr("height",Yd)):(Yf?(r=function(a,b){var c=ub(b),d=vb(b);return(re(d?d:a.x+50)-re(c?c:a.x-50))/2},q=function(a,b){var c=ub(b);return(re(a.x)+re(c?c:a.x-50))/2}):(r=B(),q=function(a){return re(a.x)-r/2}),p=xb(),rg.select(".event-rects").datum(p?p.values:[]),o=rg.select(".event-rects").selectAll(".event-rect").data(function(a){return a}),id(o.enter()),o.attr("class",Sb).attr("x",Xe?0:q).attr("y",Xe?q:0).attr("width",Xe?Wd:r).attr("height",Xe?r:Yd),o.exit().remove()),l=rg.select(".regions").selectAll("rect.region").data(Mf),l.enter().append("rect").style("fill-opacity",0),l.attr("class",Rb).attr("x",Xe?0:ib).attr("y",Xe?ib:Td.top).attr("width",Xe?Wd:jb).attr("height",Xe?jb:Yd).transition().duration(D).style("fill-opacity",function(a){return c(a.opacity)?a.opacity:.1}),l.exit().transition().duration(D).style("fill-opacity",0).remove(),Ue&&yd(Dd.data.targets,{withTransition:u}),yb().forEach(function(a){yg[a]=!0})}function pd(){od({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}function qd(){return"mousemove"===g.event.sourceEvent.type&&og.altDomain?(re.domain(og.altDomain),void og.scale(re).updateScaleExtent()):(Xf&&re.orgDomain()[0]===wg[0]&&re.domain([wg[0]-1e-10,re.orgDomain()[1]]),od({withTransition:!1,withY:!1,withSubchart:!1}),void("mousemove"===g.event.sourceEvent.type&&(_f=!0)))}function rd(){function a(){b.forEach(function(a){a()})}var b=[];return a.add=function(a){b.push(a)},a}function sd(a){var b,c;a=e(a)?a:{},b=e(a.withTransition)?a.withTransition:!1,c=e(a.withTransform)?a.withTransform:!1,n(),E(),kg.scale(ue),Nd&&og.scale(re),pg.attr("width",$d).attr("height",_d),pg.select("#"+Uf).select("rect").attr("width",Wd).attr("height",Yd),pg.select("#xaxis-clip").select("rect").attr("width",x),pg.select(".zoom-rect").attr("width",Wd).attr("height",Yd),m(b),od({withTransition:b,withUpdateXDomain:!0,withTransform:c,durationForExit:0})}function td(a){var b,c,d,e,f,h,i,j,k,l,m,n;i=rg.select(".chart-texts").selectAll(".chart-text").data(a),j=i.enter().append("g").attr("class",function(a){return"chart-text target target-"+a.id}).style("pointer-events","none"),j.append("g").attr("class",Hb).style("fill",function(a){return ag(a.id)}),e=rg.select(".chart-bars").selectAll(".chart-bar").data(a),d=e.enter().append("g").attr("class",function(a){return"chart-bar target target-"+a.id}).style("pointer-events","none"),d.append("g").attr("class",Lb).style("fill",function(a){return ag(a.id)}).style("stroke","none").style("cursor",function(a){return Qe(a)?"pointer":null}),c=rg.select(".chart-lines").selectAll(".chart-line").data(a),b=c.enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}).style("pointer-events","none"),b.append("path").attr("class",Jb).style("opacity",0).style("stroke",function(a){return ag(a.id)}),b.append("path").attr("class",Nb).style("opacity",function(){return xg=+g.select(this).style("opacity"),0}).style("fill",function(a){return ag(a.id)}),b.append("g").attr("class",function(a){return"selected-circles selected-circles-"+a.id}),b.append("g").attr("class",Kb).style("fill",function(a){return ag(a.id)}).style("cursor",function(a){return Qe(a)?"pointer":null}),a.forEach(function(a){var b=zd(a.id);rg.selectAll(".selected-circles"+b).selectAll(".selected-circle").each(function(b){b.value=a.values[b.x].value})}),h=rg.select(".chart-arcs").selectAll(".chart-arc").data(ie(a)),f=h.enter().append("g").attr("class",function(a){return"chart-arc target target-"+a.data.id}),f.append("path").attr("class",Mb).style("opacity",0).style("fill",function(a){return ag(a.data.id)}).style("cursor",function(a){return Qe(a)?"pointer":null}).each(function(a){this._current=a}).on("mouseover",function(a){W(a.data.id),vd(a.data.id)}).on("mouseout",function(a){X(a.data.id),xd()}),f.append("text").attr("dy",".35em").style("opacity",0).style("text-anchor","middle").style("pointer-events","none"),Re&&(n=sg.select(".chart-bars").selectAll(".chart-bar").data(a),m=n.enter().append("g").attr("class",function(a){return"chart-bar target target-"+a.id}),m.append("g").attr("class",Lb).style("fill",function(a){return ag(a.id)}),l=sg.select(".chart-lines").selectAll(".chart-line").data(a),k=l.enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}),k.append("path").attr("class",Jb).style("opacity",0).style("stroke",function(a){return ag(a.id)})),Ue&&yd(a),pg.selectAll(".target").transition().style("opacity",1)}function ud(a,b){Dd.data.targets.forEach(function(b){for(var c=0;cq&&(q=d,hg||(l=(be-q*Object.keys(a).length)/2)),e>p&&(p=e,hg&&(l=(ae-p*Object.keys(a).length)/2))},c=tg.selectAll(".legend-item").data(o).enter().append("g").attr("class",function(a){return"legend-item legend-item-"+a}).style("cursor","pointer").on("click",function(a){We(a)}).on("mouseover",function(a){vd(a),Dd.focus(a)}).on("mouseout",function(){xd(),Dd.revert()}),c.append("text").text(function(a){return e(Fe[a])?Fe[a]:a}).each(function(){m(this)}).style("pointer-events","none").attr("x",hg?g:-200).attr("y",hg?-200:i),c.append("rect").attr("class","legend-item-event").style("fill-opacity",0).attr("x",hg?h:-200).attr("y",hg?-200:k).attr("width",q+14).attr("height",24),c.append("rect").attr("class","legend-item-tile").style("pointer-events","none").style("fill",function(a){return ag(a)}).attr("x",hg?g:-200).attr("y",hg?-200:j).attr("width",10).attr("height",10),tg.selectAll("text").data(o).each(function(){m(this)}).transition().duration(n?250:0).attr("x",g).attr("y",j),tg.selectAll("rect.legend-item-event").data(o).transition().duration(n?250:0).attr("x",h).attr("y",k),tg.selectAll("rect.legend-item-tile").data(o).transition().duration(n?250:0).attr("x",f).attr("y",i)}function zd(a){return a?"-"+a.replace(/\./g,"\\."):""}function Ad(a){return".target"+zd(a)}function Bd(a){return zb(a.id)}function Cd(a){return"data"in a&&zb(a.data.id)}var Dd={data:{}},Ed={},Fd="_expanded_",Gd="_selected_",Hd="_included_",Id=i(["bindto"],"#chart"),Jd=i(["size","width"],null),Kd=i(["size","height"],null),Ld=i(["padding","left"],null),Md=i(["padding","right"],null),Nd=i(["zoom","enabled"],!1),Od=i(["zoom","extent"],null),Pd=i(["zoom","privileged"],!1),Qd=i(["onenter"],function(){}),Rd=i(["onleave"],function(){}),Sd=i(["transition","duration"],350);h("data","data is required in config");var Td,Ud,Vd,Wd,Xd,Yd,Zd,$d,_d,ae,be,ce,de,ee,fe,ge,he,ie,je,ke,le,me,ne,oe,pe,qe,re,se,te,ue,ve,we,xe,ye,ze,Ae,Be=i(["data","x"],null),Ce=i(["data","xs"],null),De=i(["data","x_format"],"%Y-%m-%d"),Ee=i(["data","id_converter"],function(a){return a}),Fe=i(["data","names"],{}),Ge=i(["data","groups"],[]),He=i(["data","axes"],{}),Ie=i(["data","type"],null),Je=i(["data","types"],{}),Ke=i(["data","labels"],{}),Le=i(["data","order"],null),Me=i(["data","regions"],{}),Ne=i(["data","colors"],{}),Oe=i(["data","selection","enabled"],!1),Pe=i(["data","selection","grouped"],!1),Qe=i(["data","selection","isselectable"],function(){return!0}),Re=i(["subchart","show"],!1),Se=Re?i(["subchart","size","height"],60):0,Te=i(["color","pattern"],null),Ue=i(["legend","show"],!0),Ve=i(["legend","position"],"bottom"),We=i(["legend","item","onclick"],function(){}),Xe=i(["axis","rotated"],!1),Ye=i(["axis","x","type"],"indexed"),Ze=i(["axis","x","categories"],[]),$e=i(["axis","x","tick","centered"],!1),_e=i(["axis","x","tick","format"],null),af=i(["axis","x","tick","culling"],Xe||"categorized"===Ye?!1:!0),bf=i(["axis","x","tick","count"],10),cf=i(["axis","x","default"],null),df=i(["axis","x","label"],null),ef=i(["axis","y","max"],null),ff=i(["axis","y","min"],null),gf=i(["axis","y","center"],null),hf=i(["axis","y","label"],null),jf=i(["axis","y","inner"],!1),kf=i(["axis","y","tick","format"],null),lf=i(["axis","y","padding"],null),mf=i(["axis","y","ticks"],10),nf=i(["axis","y2","show"],!1),of=i(["axis","y2","max"],null),pf=i(["axis","y2","min"],null),qf=i(["axis","y2","center"],null),rf=i(["axis","y2","inner"],!1),sf=i(["axis","y2","tick","format"],null),tf=i(["axis","y2","padding"],null),uf=i(["axis","y2","ticks"],10),vf=i(["grid","x","show"],!1),wf=i(["grid","x","type"],"tick"),xf=i(["grid","x","lines"],null),yf=i(["grid","y","show"],!1),zf=i(["grid","y","lines"],null),Af=i(["grid","y","ticks"],10),Bf=i(["point","show"],!0),Cf=Bf?i(["point","r"],2.5):0,Df=i(["point","focus","line","enabled"],!0),Ef=i(["point","focus","expand","enabled"],!0),Ff=i(["point","focus","expand","r"],Ef?4:Cf),Gf=i(["point","focus","select","r"],8),Hf=i(["point","onclick"],function(){}),If=i(["point","onselected"],function(){}),Jf=i(["point","onunselected"],function(){}),Kf=i(["arc","label","format"],function(a,b){return(100*b).toFixed(1)+"%"}),Lf=i(["arc","title"],""),Mf=i(["regions"],[]),Nf=i(["tooltip","enabled"],!0),Of=i(["tooltip","format","title"],null),Pf=i(["tooltip","format","value"],null),Qf=i(["tooltip","contents"],function(a,b,c,d){var e,f,g,h,i,j=Of?Of:b,k=Pf?Pf:c;for(f=0;f"+g+""),i=a[f].name,h=k(a[f].value),e+=""+i+""+h+"");return e+""}),Rf=i(["tooltip","init","show"],!1),Sf=i(["tooltip","init","x"],0),Tf=i(["tooltip","init","position"],{top:"0px",left:"50px"}),Uf=Id.replace("#","")+"-clip",Vf="url("+document.URL+"#"+Uf+")",Wf="timeseries"===Ye,Xf="categorized"===Ye,Yf=!Wf&&(Be||Ce),Zf=null,$f=!1,_f=!1,ag=Jc(Ne,Te),bg=function(){var a=[[g.time.format("%Y/%-m/%-d"),function(){return!0}],[g.time.format("%-m/%-d"),function(a){return a.getMonth()}],[g.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[g.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[g.time.format("%I %p"),function(a){return a.getHours()}],[g.time.format("%I:%M"),function(a){return a.getMinutes()}],[g.time.format(":%S"),function(a){return a.getSeconds()}],[g.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)}}(),cg=Xe?"left":"bottom",dg=Xe?jf?"top":"bottom":jf?"right":"left",eg=Xe?rf?"bottom":"top":rf?"left":"right",fg=Xe?"left":"bottom",gg={main:function(){return"translate("+Td.left+","+Td.top+")"},context:function(){return"translate("+Ud.left+","+Ud.top+")"},legend:function(){return"translate("+Vd.left+","+Vd.top+")"},y2:function(){return"translate("+(Xe?0:Wd)+","+(Xe?1:0)+")"},x:function(){return"translate(0,"+Yd+")"},subx:function(){return"translate(0,"+(Xe?0:Zd)+")"},arc:function(){return"translate("+Wd/2+","+Yd/2+")"}},hg="right"===Ve,ig=40,jg=20;ie=g.layout.pie().value(function(a){return a.values.reduce(function(a,b){return a+b.value},0)});var kg,lg=function(){var a=g.svg.line().x(Xe?function(a){return I(a.id)(a.value)}:Xb).y(Xe?Xb:function(a){return I(a.id)(a.value)});return function(b){var c,d,e=Wc(b.values);return zc(b)?(a.interpolate(Ac(b)?"cardinal":"linear"),Me[b.id]?gd(e,re,I(b.id),Me[b.id]):a(e)):(c=re(e[0].x),d=I(b.id)(e[0].value),Xe?"M "+d+" "+c:"M "+c+" "+d)}}(),mg=function(){var a;return a=Xe?g.svg.area().x0(function(a){return I(a.id)(0)}).x1(function(a){return I(a.id)(a.value)}).y(Xb):g.svg.area().x(Xb).y0(function(a){return I(a.id)(0)}).y1(function(a){return I(a.id)(a.value)}),function(b){var c,d,e=Wc(b.values);return tc([b],"area")||tc([b],"area-spline")?(a.interpolate(Ac(b)?"cardinal":"linear"),a(e)):(c=re(e[0].x),d=I(b.id)(e[0].value),Xe?"M "+d+" "+c:"M "+c+" "+d)}}(),ng=function(){var a=g.svg.line().x(Xe?function(a){return J(a.id)(a.value)}:$b).y(Xe?$b:function(a){return J(a.id)(a.value)});return function(b){var c=Wc(b.values);return zc(b)?a(c):"M "+ue(c[0].x)+" "+J(b.id)(c[0].value)}}(),og=function(){};kg=g.svg.brush().on("brush",pd),kg.update=function(){return sg&&sg.select(".x.brush").call(this),this},kg.scale=function(a){return Xe?this.y(a):this.x(a)},Nd&&(og=g.behavior.zoom().on("zoomstart",function(){og.altDomain=g.event.sourceEvent.altKey?re.orgDomain():null}).on("zoom",Nd?qd:null),og.scale=function(a){return Xe?this.y(a):this.x(a)},og.orgScaleExtent=function(){var a=Od?Od:[1,10];return[a[0],Math.max(wb()/a[1],a[1])]},og.updateScaleExtent=function(){var a=eb(re.orgDomain())/eb(wg),b=this.orgScaleExtent();return this.scaleExtent([b[0]*a,b[1]*a]),this});var pg,qg,rg,sg,tg,ug,vg,wg,xg,yg={};if(Dd.focus=function(a){function b(a){a.transition().duration(100).style("opacity",1)}var c=pg.selectAll(Ad(a)),d=c.filter(Bd),e=c.filter(Cd);Dd.revert(),Dd.defocus(),b(d.classed("focused",!0)),b(e),yc(Dd.data.targets)&&W(a,!0),vd(a)},Dd.defocus=function(a){function b(a){a.transition().duration(100).style("opacity",.3)}var c=pg.selectAll(Ad(a)),d=c.filter(Bd),e=c.filter(Cd);Dd.revert(),b(d.classed("focused",!1)),b(e),yc(Dd.data.targets)&&X(a),wd(a)},Dd.revert=function(a){function b(a){a.transition().duration(100).style("opacity",1)}var c=pg.selectAll(Ad(a)),d=c.filter(Bd),e=c.filter(Cd);b(d.classed("focused",!1)),b(e),yc(Dd.data.targets)&&X(a),xd()},Dd.show=function(a){pg.selectAll(Ad(a)).transition().style("opacity",1)},Dd.hide=function(a){pg.selectAll(Ad(a)).transition().style("opacity",0)},Dd.unzoom=function(){kg.clear().update(),od({withUpdateXDomain:!0})},Dd.load=function(a){if("function"!=typeof a.done&&(a.done=function(){}),a.xs&&ob(a.xs),"categories"in a&&Xf&&(Ze=a.categories,xe.categories(Ze)),"cacheIds"in a&&fb(a.cacheIds))return void ud(hb(a.cacheIds),a.done);if("data"in a)ud(sb(a.data),a.done);else if("url"in a)g.csv(a.url,function(b,c){ud(sb(c),a.done)});else if("rows"in a)ud(sb(qb(a.rows)),a.done);else{if(!("columns"in a))throw Error("url or rows or columns is required.");ud(sb(rb(a.columns)),a.done)}},Dd.unload=function(a){Dd.data.targets=Dd.data.targets.filter(function(b){return b.id!==a}),pg.selectAll(Ad(a)).transition().style("opacity",0).remove(),Ue&&(pg.selectAll(".legend-item"+zd(a)).remove(),yd(Dd.data.targets)),Dd.data.targets.length>0&&od({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})},Dd.selected=function(a){var b=zd(a);return g.merge(rg.selectAll(".-shapes"+b).selectAll(".-shape").filter(function(){return g.select(this).classed(Gd)}).map(function(a){return a.map(function(a){return a.__data__})}))},Dd.select=function(a,b,c){Oe&&rg.selectAll(".-shapes").selectAll(".-shape").each(function(f,h){var i="circle"===this.nodeName?Qc:Tc,j="circle"===this.nodeName?Rc:Uc;b.indexOf(h)>=0?Qe(f)&&(Pe||d(a)||a.indexOf(f.id)>=0)&&i(g.select(this).classed(Gd,!0),f,h):e(c)&&c&&j(g.select(this).classed(Gd,!1),f,h)})},Dd.unselect=function(a,b){Oe&&rg.selectAll(".-shapes").selectAll(".-shape").each(function(c,e){var f="circle"===this.nodeName?Rc:Uc;(d(b)||b.indexOf(e)>=0)&&Qe(c)&&(Pe||d(a)||a.indexOf(c.id)>=0)&&f(g.select(this).classed(Gd,!1),c,e)})},Dd.toLine=function(a){sc(a,"line"),sd({withTransition:!0})},Dd.toSpline=function(a){sc(a,"spline"),sd({withTransition:!0})},Dd.toBar=function(a){sc(a,"bar"),sd({withTransition:!0})},Dd.toScatter=function(a){sc(a,"scatter"),sd({withTransition:!0})},Dd.toArea=function(a){sc(a,"area"),sd({withTransition:!0})},Dd.toAreaSpline=function(a){sc(a,"area-spline"),sd({withTransition:!0})},Dd.toPie=function(a){sc(a,"pie"),sd({withTransition:!0,withTransform:!0})},Dd.toDonut=function(a){sc(a,"donut"),sd({withTransition:!0,withTransform:!0})},Dd.groups=function(a){return d(a)?Ge:(Ge=a,od(),Ge)},Dd.regions=function(a){return d(a)?Mf:(Mf=a,od(),Mf)},Dd.regions.add=function(a){return d(a)?Mf:(Mf=Mf.concat(a),od(),Mf)},Dd.regions.remove=function(a,b){var d=[].concat(a);return b=e(b)?b:{},d.forEach(function(a){var d=c(b.duration)?b.duration:0;pg.selectAll("."+a).transition().duration(d).style("fill-opacity",0).remove(),Mf=Mf.filter(function(b){return b.classes.indexOf(a)<0})}),Mf},Dd.data.get=function(a){var b=Dd.data.getAsTarget(a);return e(b)?b.values.map(function(a){return a.value}):void 0},Dd.data.getAsTarget=function(a){var b=Ab(function(b){return b.id===a});return b.length>0?b[0]:void 0},Dd.resize=function(a){Jd=a?a.width:null,Kd=a?a.height:null,sd()},Dd.destroy=function(){Dd.data.targets=void 0,Dd.data.x={},vg.html(""),a.onresize=null},"url"in f.data)g.csv(f.data.url,function(a,b){hd(b)});else if("rows"in f.data)hd(qb(f.data.rows));else{if(!("columns"in f.data))throw Error("url or rows or columns is required.");hd(rb(f.data.columns))}return Dd}}(window); \ No newline at end of file