diff --git a/bower.json b/bower.json index 3875dcf..156da9c 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "c3", "main": "c3.min.js", - "version": "0.1.27", + "version": "0.1.28", "homepage": "https://github.com/masayuki0812/c3", "authors": [ "Masayuki Tanaka " diff --git a/c3.js b/c3.js index 346a3cc..67ea8c0 100644 --- a/c3.js +++ b/c3.js @@ -2,7 +2,7 @@ 'use strict'; var c3 = { - version: "0.1.27" + version: "0.1.28" }; var CLASS = { diff --git a/c3.min.js b/c3.min.js index e0421c1..dbfe7fb 100644 --- a/c3.min.js +++ b/c3.min.js @@ -1,2 +1,2 @@ -!function(a){"use strict";function b(a){return a||0===a}function c(a){return"undefined"==typeof a}function d(a){return"undefined"!=typeof a}var e={version:"0.1.27"},f={target:"c3-target",chart:"c3-chart",chartLine:"c3-chart-line",chartLines:"c3-chart-lines",chartBar:"c3-chart-bar",chartBars:"c3-chart-bars",chartText:"c3-chart-text",chartTexts:"c3-chart-texts",chartArc:"c3-chart-arc",chartArcs:"c3-chart-arcs",chartArcsTitle:"c3-chart-arcs-title",selectedCircle:"c3-selected-circle",selectedCircles:"c3-selected-circles",eventRect:"c3-event-rect",eventRects:"c3-event-rects",zoomRect:"c3-zoom-rect",brush:"c3-brush",focused:"c3-focused",region:"c3-region",regions:"c3-regions",tooltip:"c3-tooltip",tooltipName:"c3-tooltip-name",shape:"c3-shape",shapes:"c3-shapes",line:"c3-line",bar:"c3-bar",bars:"c3-bars",circle:"c3-circle",circles:"c3-circles",arc:"c3-arc",area:"c3-area",text:"c3-text",texts:"c3-texts",grid:"c3-grid",xgrid:"c3-xgrid",xgrids:"c3-xgrids",xgridLine:"c3-xgrid-line",xgridLines:"c3-xgrid-lines",xgridFocus:"c3-xgrid-focus",ygrid:"c3-ygrid",ygrids:"c3-ygrids",ygridLine:"c3-ygrid-line",ygridLines:"c3-ygrid-lines",axisX:"c3-axis-x",axisXLabel:"c3-axis-x-label",axisY:"c3-axis-y",axisYLabel:"c3-axis-y-label",axisY2:"c3-axis-y2",axisY2Label:"c3-axis-y2-label",legendItem:"c3-legend-item",legendItemEvent:"c3-legend-item-event",legendItemTile:"c3-legend-item-tile",dragarea:"c3-dragarea",EXPANDED:"_expanded_",SELECTED:"_selected_",INCLUDED:"_included_"};e.generate=function(e){function g(a,b){if(!(a in e))throw Error(b)}function h(a,b){var c,d,f,g=e;for(c=0;clf&&(lf=0),0>nf&&(nf=0),jf={top:vg?hf.top:qf-pg-($h?0:rf),right:0/0,bottom:20+($h?0:rf),left:vg?ci:hf.left},mf=vg?hf.left-ci-di:lf,of=vg?nf:qf-jf.top-jf.bottom,0>mf&&(mf=0),0>of&&(of=0),kf={top:$h?0:qf-rf,right:0/0,bottom:0,left:$h?pf-sf:0},p(),$h&&Kd(We.data.targets)&&(kf.left=lf/2+uf)}function o(){mi.select("line."+f.xgridFocus).attr("x1",vg?0:-10).attr("x2",vg?lf:-10).attr("y1",vg?-10:hf.top).attr("y2",vg?-10:nf)}function p(){uf=nf/2,tf=.95*uf,vf=Jd(We.data.targets)?.6*tf:0}function q(){var a=vg?f.axisX:f.axisY,b=Ve.select("."+a).node(),c=b?b.getBoundingClientRect():{right:0},d=Ve.select(Ye).node().getBoundingClientRect(),e=c.right-d.left-t();return e>0?e:0}function r(){return Ze?Ze:x()}function s(){var a=$e?$e:y();return a>0?a:320}function t(){return Kd(We.data.targets)?0:_e?_e:vg||!Ig||Ng?1:v("y")}function u(){var a=1;return Kd(We.data.targets)?0:af?af:$h?sf+(Rg&&!vg?v("y2"):a):Rg?Wg||vg?a:v("y2"):a}function v(a){var b=gb(a);return b.isInner?20+zb(a):40+zb(a)}function w(a){return"y"!==a||Ig?"y2"!==a||Rg?(gb(a).isInner?30:40)+("y2"===a?-10:0):ei:rg&&!$h?10:1}function x(){return+Ve.select(Ye).style("width").replace("px","")}function y(){return+Ve.select(Ye).style("height").replace("px","")}function z(a){return a?-5:-(hf.left-1)}function A(a){return a?-20:-1}function B(){return z(!vg)}function C(){return A(!vg)}function D(){return z(vg)}function E(){return A(vg)}function F(a){return a?lf+2+4:hf.left+20}function G(a){return a?80:nf+2}function H(){return F(!vg)}function I(){return G(!vg)}function J(){return F(vg)}function K(){return G(vg)}function L(){var a=vg?nf:lf,b=tc(),c=Vb()*(Gd(We.data.targets)?(b-(Mh?.25:1))/b:.98);return b>1?a*c/(b-1):a}function M(a){_h=a}function N(a){ai=a}function O(a){bi=a}function P(){return rg?$h?ai*(_h+1):pf:0}function Q(){return rg?$h?qf:bi*(_h+1):0}function R(){var a,b=!If;Af=vg?1:0,Bf=vg?nf:lf,Cf=vg?0:nf,Df=vg?lf:1,Ef=Af,Ff=Bf,Gf=vg?0:of,Hf=vg?mf:1,If=T(Af,Bf,b?void 0:If.domain(),function(){return Of.tickOffset()}),Jf=U(Cf,Df),Kf=U(Cf,Df),Lf=T(Af,Bf,ri,function(a){return a%1?0:Rf.tickOffset()}),Mf=U(Gf,Hf),Nf=U(Gf,Hf),a=$(),Of=X(If,Vh,a),Rf=X(Lf,Yh,a),Pf=Y(Jf,Wh,Og,Qg),Qf=Y(Kf,Xh,Xg,Zg),b||(fi.scale(Lf),bf&&ji.scale(If)),S()}function S(){wf=Db(),xf=Eb(),yf=Eb(.98)}function T(a,b,e,f){var g=(Lh?Ve.time.scale():Ve.scale.linear()).range([a,b]);if(g.orgDomain=function(){return g.domain()},d(e)&&g.domain(e),c(f)&&(f=function(){return 0}),Mh){var h,i=g;g=function(a){return i(a)+f(a)};for(h in i)g[h]=i[h];g.orgDomain=function(){return i.domain()},g.domain=function(a){return arguments.length?(i.domain(a),g):(a=i.domain(),[a[0],a[1]+1])}}return g}function U(a,b){return Ve.scale.linear().range([a,b])}function V(a){return"y2"===Z(a)?Kf:Jf}function W(a){return"y2"===Z(a)?Nf:Mf}function X(a,b,c){var d=(Mh?Bb():Ve.svg.axis()).scale(a).orient(b);return d.tickFormat(c),Mh?d.tickCentered(yg):d.tickOffset=function(){var a=vg?nf:lf;return a*Vb()/tc()/2},Mh&&d.categories(xg),d}function Y(a,b,c,d){return Ve.svg.axis().scale(a).orient(b).tickFormat(c).ticks(d).outerTickSize(0)}function Z(a){return a in Yf?Yf[a]:"y"}function $(){var a=Lh?Th:Mh?Ic:function(a){return 0>a?a.toFixed(0):a};return zg&&("function"==typeof zg?a=zg:Lh&&(a=function(a){return Ve.time.format(zg)(a)})),a}function _(a){var b;return"y"===a?b=Mg:"y2"===a?b=Vg:"x"===a&&(b=Hg),b}function ab(a){var b=_(a);return"string"==typeof b?b:b?b.text:null}function bb(a,b){var c=_(a);"string"==typeof c?"y"===a?Mg=b:"y2"===a?Vg=b:"x"===a&&(Hg=b):c&&(c.text=b)}function cb(a,b){var c=_(a),d=c&&"object"==typeof c&&c.position?c.position:b;return{isInner:d.indexOf("inner")>=0,isOuter:d.indexOf("outer")>=0,isLeft:d.indexOf("left")>=0,isCenter:d.indexOf("center")>=0,isRight:d.indexOf("right")>=0,isTop:d.indexOf("top")>=0,isMiddle:d.indexOf("middle")>=0,isBottom:d.indexOf("bottom")>=0}}function db(){return cb("x",vg?"inner-top":"inner-right")}function eb(){return cb("y",vg?"inner-right":"inner-top")}function fb(){return cb("y2",vg?"inner-right":"inner-top")}function gb(a){return"y2"===a?fb():"y"===a?eb():db()}function hb(){return ab("x")}function ib(){return ab("y")}function jb(){return ab("y2")}function kb(a,b){return a?b.isLeft?0:b.isCenter?lf/2:lf:b.isBottom?-nf:b.isMiddle?-nf/2:0}function lb(a,b){return a?b.isLeft?"0.5em":b.isRight?"-0.5em":"0":b.isTop?"-0.5em":b.isBottom?"0.5em":"0"}function mb(a,b){return a?b.isLeft?"start":b.isCenter?"middle":"end":b.isBottom?"start":b.isMiddle?"middle":"end"}function nb(){return kb(!vg,db())}function ob(){return kb(vg,eb())}function pb(){return kb(vg,fb())}function qb(){return lb(!vg,db())}function rb(){return lb(vg,eb())}function sb(){return lb(vg,fb())}function tb(){var a=db();return vg?a.isInner?"1.2em":-30-zb("x"):a.isInner?"-0.5em":"3em"}function ub(){var a=eb();return vg?a.isInner?"-0.5em":"3em":a.isInner?"1.2em":-20-zb("y")}function vb(){var a=fb();return vg?a.isInner?"1.2em":"-2.2em":a.isInner?"-0.5em":30+zb("y2")}function wb(){return mb(!vg,db())}function xb(){return mb(vg,eb())}function yb(){return mb(vg,fb())}function zb(a){var b=0,c="x"===a?f.axisX:"y"===a?f.axisY:f.axisY2;return Ve.selectAll("."+c+" .tick text").each(function(){var a=this.getBBox();bb?20:b}function Ab(){mi.select("."+f.axisX+" ."+f.axisXLabel).attr("x",nb).text(hb),mi.select("."+f.axisY+" ."+f.axisYLabel).attr("x",ob).attr("dy",ub).text(ib),mi.select("."+f.axisY2+" ."+f.axisY2Label).attr("x",pb).attr("dy",vb).text(jb)}function Bb(){function a(a,b){a.attr("transform",function(a){return"translate("+(b(a)+p)+", 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 o>=c||b%Math.ceil(c/o)===0}function f(a){return a0)for(g=Gc(a),b=0;b=0}),0!==e.length)for(d=e[0],g&&i[d]&&i[d].forEach(function(a,b){i[d][b]=0>a?a:0}),c=1;c0||(i[d][b]+=+a)});return Ve.min(Object.keys(i).map(function(a){return Ve.min(i[a])}))}function Tb(a){var b,c,d,e,f,g,h=vc(a),i=Ec(a);if(Xf.length>0)for(g=Hc(a),b=0;b=0}),0!==e.length)for(d=e[0],g&&i[d]&&i[d].forEach(function(a,b){i[d][b]=a>0?a:0}),c=1;c+a||(i[d][b]+=+a)});return Ve.max(Object.keys(i).map(function(a){return Ve.max(i[a])}))}function Ub(a,c){var d,e,f,g,h,i,j,k,l=a.filter(function(a){return Z(a.id)===c}),m="y2"===c?Tg:Kg,n="y2"===c?Sg:Jg,o=b(m)?m:Sb(l),p=b(n)?n:Tb(l),q="y2"===c?Ug:Lg,r=bd()&&vg;return 0===l.length?"y2"===c?Kf.domain():Jf.domain():(o===p&&(0>o?p=0:o=0),d=Math.abs(p-o),e=f=g=r?0:.1*d,q&&(h=Math.max(Math.abs(o),Math.abs(p)),p=h-q,o=q-h),r&&(i=cd(o,p),j=$b(Jf.range()),k=[i[0]/j,i[1]/j],f+=d*(k[1]/(1-k[0]-k[1])),g+=d*(k[0]/(1-k[0]-k[1]))),"y"===c&&Pg&&(f=b(Pg.top)?Pg.top:e,g=b(Pg.bottom)?Pg.bottom:e),"y2"===c&&Yg&&(f=b(Yg.top)?Yg.top:e,g=b(Yg.bottom)?Yg.bottom:e),Gd(l)&&!Gc(l)&&(g=o),[o-g,p+f])}function Vb(a){var b=$b(ri),c=$b(If.domain());return a||0===c?1:b/c}function Wb(a){return Fg?Fg:Ve.min(a,function(a){return Ve.min(a.values,function(a){return a.x})})}function Xb(a){return Eg?Eg:Ve.max(a,function(a){return Ve.max(a.values,function(a){return a.x})})}function Yb(a,b){var c,d,e=b[0],f=b[1],g=Math.abs(e-f);return Mh?d=0:Gd(a)?(c=tc(),d=c>1?g/(c-1)/2:.5):d=.01*g,d}function Zb(a){var b=[Wb(a),Xb(a)],c=b[0],d=b[1],e=Yb(a,b),f=Lh?new Date(c.getTime()-e):c-e,g=Lh?new Date(d.getTime()+e):d+e;return[f,g]}function $b(a){return a[1]-a[0]}function _b(a){for(var b=0;bd?0:d}function ec(a){return Sf&&a===Sf||$d(Tf)&&_d(Tf,a)}function fc(a){return!ec(a)}function gc(a){return Sf?Sf:$d(Tf)?Tf[a]:null}function hc(a,b){return a in We.data.x&&We.data.x[a]&&We.data.x[a][b]?We.data.x[a][b]:b}function ic(a){Object.keys(a).forEach(function(b){Tf[b]=a[b]})}function jc(a){var b;return a&&(b=Wf[a.id],a.name=b?b:a.id),a}function kc(a,b){a.forEach(function(a){a.values.forEach(function(c,d){c.x=mc(b[d],a.id,d)}),We.data.x[a.id]=b})}function lc(a,b){a.forEach(function(a){b[a.id]&&kc([a],b[a.id])})}function mc(a,b,c){var d;return d=Lh?a?a instanceof Date?a:Wd(a):Wd(hc(b,c)):Nh&&!Mh?a?+a:hc(b,c):c}function nc(a){var b,c,d=a[0],e={},f=[];for(b=1;b=0&&(We.data.x[b]=a.map(function(a){return a[c]})):We.data.x[b]=a.map(function(a,b){return b})}),c.forEach(function(a){if(!We.data.x[a])throw new Error('x is not defined for id = "'+a+'".')}),b=c.map(function(b,c){var d=Vf(b);return{id:d,id_org:b,values:a.map(function(a,e){var f=gc(b),g=a[f],h=mc(g,b,e);return Nh&&Mh&&0===c&&g&&(0===e&&(xg=[]),xg.push(g)),"undefined"==typeof a[b]&&(h=void 0),{x:h,value:null===a[b]||isNaN(a[b])?null:+a[b],id:d}}).filter(function(a){return"undefined"!=typeof a.x})}}),b.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++})}),Zf&&Ed(vc(b).filter(function(a){return!(a in $f)}),Zf),b.forEach(function(a){ac(a.id_org,a)}),b}function qc(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 rc(a){return a>0&&We.data.targets[0].values[a-1]?We.data.targets[0].values[a-1].x:void 0}function sc(a){return a1?We.data.targets.forEach(function(b){b.values.length>c&&(a=b,c=b.values.length)}):a=b?We.data.targets[0]:null,a}function vc(a){return a=c(a)?We.data.targets:a,a.map(function(a){return a.id})}function wc(a){var b,c=vc();for(b=0;b2){for(e=b-2,c=a[0],d=a[a.length-1],f=(d-c)/(e+1),i=[c],g=0;e>g;g++)h=+c+f*(g+1),i.push(Lh?new Date(h):h);i.push(d)}return i}function Cc(a){Uh=Uh.concat(a)}function Dc(a){Uh=Uh.filter(function(b){return a.indexOf(b)<0})}function Ec(a){var b={};return a.forEach(function(a){b[a.id]=[],a.values.forEach(function(c){b[a.id].push(c.value)})}),b}function Fc(a,b){var c,d,e,f=Object.keys(a);for(c=0;ca})}function Hc(a){return Fc(a,function(a){return a>0})}function Ic(a){return a=0&&d===a[c].x;c--)e.push(a[c]);for(c=b;c0?g=h:f=h,g-f===1||0===f&&0===g?(e=[],a[f].x&&(e=e.concat(kd(a,f))),a[g].x&&(e=e.concat(kd(a,g))),nd(e,b)):ld(a,b,f,g)}function md(a,b){var c;return c=a.map(function(a){return ld(a.values,b)}),nd(c,b)}function nd(a,b){var c,d;return a.forEach(function(a){var e=ae(a,b);(c>e||!c)&&(c=e,d=a)}),d}function od(a,b){return Ve.merge(a.map(function(a){return a.values})).filter(function(a){return a.x===b})}function pd(a){var b=a.getBoundingClientRect(),c=[a.pathSegList.getItem(0),a.pathSegList.getItem(1)],d=c[0].x,e=Math.min(c[0].y,c[1].y);return{x:d,y:e,width:b.width,height:b.height}}function qd(){return ag&&"desc"===ag.toLowerCase()}function rd(){return ag&&"asc"===ag.toLowerCase()}function sd(a){var b=rd(),c=qd();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 ag&&a.sort(ag),a}function td(a,c){var d,e,f,g,h,i,j,k=Kd(We.data.targets),l=k?ed:dd,m=a.filter(function(a){return a&&b(a.value)});yh&&0!==m.length&&(pi.html(Bh(a,$(),l,Sh)).style("display","block"),d=pi.property("offsetWidth"),e=pi.property("offsetHeight"),k?(g=lf/2+c[0],i=nf/2+c[1]+20):(vg?(f=q(),g=f+c[0]+100,h=g+d,j=r()-u(),i=If(m[0].x)+20):(f=q(),g=f+t()+If(m[0].x)+20,h=g+d,j=f+r()-u(),i=c[1]+15),h>j&&(g-=d+60),i+e>s()&&(i-=e+30)),pi.style("top",i+"px").style("left",g+"px"))}function ud(){pi.style("display","none")}function vd(a){var c=a.filter(function(a){return a&&b(a.value)});yh&&(Hd(We.data.targets)||Kd(We.data.targets)||mi.selectAll("line."+f.xgridFocus).style("visibility","visible").data([c[0]]).attr(vg?"y1":"x1",gd).attr(vg?"y2":"x2",gd))}function wd(){mi.select("line."+f.xgridFocus).style("visibility","hidden")}function xd(a){return a.x||0===a.x?If(a.x):null}function yd(a){return V(a.id)(a.value)}function zd(){var a,b,d={},e=0;return zc(xc(Nd)).forEach(function(f){for(a=0;a0&&(i+=g(b.values[f].value)-h)}),i}}function Dd(a,b){return kh?kh:b?2*a.tickOffset()*lh/b:0}function Ed(a,b){var c,d=a?"string"==typeof a?[a]:a:vc();for(c=0;c0}function _d(a,b){var c=!1;return Object.keys(a).forEach(function(d){a[d]===b&&(c=!0)}),c}function ae(a,b){var c="y"===Z(a.id)?Jf:Kf;return Math.pow(If(a.x)-b[0],2)+Math.pow(c(a.value)-b[1],2)}function be(a,b){var c=0;a.each(function(){++c}).each("end",function(){--c||b.apply(this,arguments)})}function ce(a,b,c){kg(b,a.node()),mi.select("."+f.selectedCircles+Xc(b.id)).selectAll("."+f.selectedCircle+"-"+c).data([b]).enter().append("circle").attr("class",function(){return Jc(f.selectedCircle,c)}).attr("cx",vg?yd:xd).attr("cy",vg?xd:yd).attr("stroke",function(){return Sh(b.id)}).attr("r",1.4*jh).transition().duration(100).attr("r",jh)}function de(a,b,c){lg(b,a.node()),mi.select("."+f.selectedCircles+Xc(b.id)).selectAll("."+f.selectedCircle+"-"+c).transition().duration(100).attr("r",0).remove()}function ee(a,b,c,d){a?ce(b,c,d):de(b,c,d)}function fe(a,b){kg(b,a.node()),a.transition().duration(100).style("fill",function(){return Ve.rgb(Sh(b.id)).darker(1)})}function ge(a,b){lg(b,a.node()),a.transition().duration(100).style("fill",function(){return Sh(b.id)})}function he(a,b,c,d){a?fe(b,c,d):ge(b,c,d)}function ie(a){return a.filter(function(a){return b(a.value)})}function je(a,c){return(c?mi.selectAll("."+f.circles+Xc(c)):mi).selectAll("."+f.circle+(b(a)?"-"+a:""))}function ke(a,b){je(a,b).classed(f.EXPANDED,!0).attr("r",ih)}function le(a){je(a).filter(function(){return Ve.select(this).classed(f.EXPANDED)}).classed(f.EXPANDED,!1).attr("r",fh)}function me(a){return mi.selectAll("."+f.bar+(b(a)?"-"+a:""))}function ne(a){me(a).classed(f.EXPANDED,!0)}function oe(a){me(a).classed(f.EXPANDED,!1)}function pe(a,b){var c=te(a,b);return function(a,b){var d=c(a,b),e=vg?1:0,f=vg?0:1,g="M "+d[0][e]+","+d[0][f]+" L"+d[1][e]+","+d[1][f]+" L"+d[2][e]+","+d[2][f]+" L"+d[3][e]+","+d[3][f]+" z";return g}}function qe(a,b){var c=te(a,!1),d=b?re:se;return function(a,b){return d(c(a,b),a,this)}}function re(a,b){var c;return vg?(c=Nd(b)?4:6,a[2][1]+c*(b.value<0?-1:1)):a[0][0]+(a[2][0]-a[0][0])/2}function se(a,b,c){var d=c.getBBox();return vg?(a[0][0]+a[2][0]+.6*d.height)/2:a[2][1]+(b.value<0?d.height:Nd(b)?-3:-6)}function te(a,b){var c=a.__max__+1,d=Dd(Of,c),e=Ad(d,c,a,!!b),f=Bd(!!b),g=Cd(a,!!b),h=b?W:V;return function(a,b){var c=h(a.id)(0),i=g(a,b)||c,j=e(a),k=f(a);return vg&&(a.value>0&&i>k||a.value<0&&k>i)&&(k=i),[[j,i],[j,k-(c-i)],[j+d,k-(c-i)],[j+d,i]]}}function ue(a,b,e,f){var g,h,i,j,k,l,m,n,o,p,q,r=-1,s="M",t=[];if(d(f))for(g=0;g=h;h+=u)s+=i(a[g-1],a[g],h,o)}r=a[g].x}return s}function ve(b){var c,d,e;if(qi=Ve.select(Ye),qi.empty())throw new Error('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');if(qi.html(""),qi.classed("c3",!0),We.data.x={},We.data.targets=pc(b),n(),R(),If.domain(Ve.extent(Zb(We.data.targets))),Jf.domain(Ub(We.data.targets,"y")),Kf.domain(Ub(We.data.targets,"y2")),Lf.domain(If.domain()),Mf.domain(Jf.domain()),Nf.domain(Kf.domain()),ri=If.domain(),fi.scale(Lf),bf&&ji.scale(If),ki=qi.append("svg").attr("width",lf+hf.left+hf.right).attr("height",nf+hf.top+hf.bottom).on("mouseenter",ef).on("mouseleave",ff),li=ki.append("defs"),li.append("clipPath").attr("id",Fh).append("rect").attr("width",lf).attr("height",nf),li.append("clipPath").attr("id",Gh).append("rect").attr("x",B).attr("y",C).attr("width",H).attr("height",I),li.append("clipPath").attr("id",Hh).append("rect").attr("x",D).attr("y",E).attr("width",J).attr("height",K),mi=ki.append("g").attr("transform",Zh.main),ni=og?ki.append("g").attr("transform",Zh.context):null,oi=rg?ki.append("g").attr("transform",Zh.legend):null,pi=Ve.select(Ye).style("position","relative").append("div").style("position","absolute").style("pointer-events","none").style("z-index","10").style("display","none"),mi.append("g").attr("class",f.axisX).attr("clip-path",vg?"":Jh).attr("transform",Zh.x).append("text").attr("class",f.axisXLabel).attr("transform",vg?"rotate(-90)":"").attr("dx",qb).attr("dy",tb).style("text-anchor",wb),Ig&&mi.append("g").attr("class",f.axisY).attr("clip-path",vg?Kh:"").append("text").attr("class",f.axisYLabel).attr("transform",vg?"":"rotate(-90)").attr("dx",rb).attr("dy",ub).style("text-anchor",xb),Rg&&mi.append("g").attr("class",f.axisY2).attr("transform",Zh.y2).append("text").attr("class",f.axisY2Label).attr("transform",vg?"":"rotate(-90)").attr("dx",sb).style("text-anchor",yb),d=mi.append("g").attr("clip-path",Ih).attr("class",f.grid),$g&&d.append("g").attr("class",f.xgrids),$d(ah)&&d.append("g").attr("class",f.xgridLines),gh&&d.append("g").attr("class",f.xgridFocus).append("line").attr("class",f.xgridFocus),bh&&d.append("g").attr("class",f.ygrids),$d(ch)&&d.append("g").attr("class",f.ygridLines),mi.append("g").attr("clip-path",Ih).attr("class",f.regions),mi.append("g").attr("clip-path",Ih).attr("class",f.chart),c=mi.select("."+f.chart).append("g").attr("class",f.eventRects).style("fill-opacity",0).style("cursor",bf?vg?"ns-resize":"ew-resize":null),mi.select("."+f.chart).append("g").attr("class",f.chartBars),mi.select("."+f.chart).append("g").attr("class",f.chartLines),mi.select("."+f.chart).append("g").attr("class",f.chartArcs).attr("transform",Zh.arc).append("text").attr("class",f.chartArcsTitle).style("text-anchor","middle").text(Ob()),mi.select("."+f.chart).append("g").attr("class",f.chartTexts),bf&&mi.insert("rect",df?null:"g."+f.grid).attr("class",f.zoomRect).attr("width",lf).attr("height",nf).style("opacity",0).style("cursor",vg?"ns-resize":"ew-resize").call(ji).on("dblclick.zoom",null),Gg&&fi.extent("function"!=typeof Gg?Gg:Gg(Zb())),og&&(ni.append("g").attr("clip-path",Ih).attr("class",f.chart),ni.select("."+f.chart).append("g").attr("class",f.chartBars),ni.select("."+f.chart).append("g").attr("class",f.chartLines),ni.append("g").attr("clip-path",Ih).attr("class",f.brush).call(fi).selectAll("rect").attr(vg?"width":"height",vg?mf:of),ni.append("g").attr("class",f.axisX).attr("transform",Zh.subx).attr("clip-path",vg?"":Jh)),Ie(We.data.targets),vg?mi.select("."+f.axisX).style("opacity",0).call(Of):(mi.select("."+f.axisY).style("opacity",0).call(Pf),mi.select("."+f.axisY2).style("opacity",0).call(Qf)),He({withTransform:!0,withLegend:!0,withTransitionForAxis:!1}),Ch){if(Lh&&"string"==typeof Dh){for(Dh=Wd(Dh),e=0;elf&&(lf=0),0>nf&&(nf=0),jf={top:vg?hf.top:qf-pg-($h?0:rf),right:0/0,bottom:20+($h?0:rf),left:vg?ci:hf.left},mf=vg?hf.left-ci-di:lf,of=vg?nf:qf-jf.top-jf.bottom,0>mf&&(mf=0),0>of&&(of=0),kf={top:$h?0:qf-rf,right:0/0,bottom:0,left:$h?pf-sf:0},p(),$h&&Kd(We.data.targets)&&(kf.left=lf/2+uf)}function o(){mi.select("line."+f.xgridFocus).attr("x1",vg?0:-10).attr("x2",vg?lf:-10).attr("y1",vg?-10:hf.top).attr("y2",vg?-10:nf)}function p(){uf=nf/2,tf=.95*uf,vf=Jd(We.data.targets)?.6*tf:0}function q(){var a=vg?f.axisX:f.axisY,b=Ve.select("."+a).node(),c=b?b.getBoundingClientRect():{right:0},d=Ve.select(Ye).node().getBoundingClientRect(),e=c.right-d.left-t();return e>0?e:0}function r(){return Ze?Ze:x()}function s(){var a=$e?$e:y();return a>0?a:320}function t(){return Kd(We.data.targets)?0:_e?_e:vg||!Ig||Ng?1:v("y")}function u(){var a=1;return Kd(We.data.targets)?0:af?af:$h?sf+(Rg&&!vg?v("y2"):a):Rg?Wg||vg?a:v("y2"):a}function v(a){var b=gb(a);return b.isInner?20+zb(a):40+zb(a)}function w(a){return"y"!==a||Ig?"y2"!==a||Rg?(gb(a).isInner?30:40)+("y2"===a?-10:0):ei:rg&&!$h?10:1}function x(){return+Ve.select(Ye).style("width").replace("px","")}function y(){return+Ve.select(Ye).style("height").replace("px","")}function z(a){return a?-5:-(hf.left-1)}function A(a){return a?-20:-1}function B(){return z(!vg)}function C(){return A(!vg)}function D(){return z(vg)}function E(){return A(vg)}function F(a){return a?lf+2+4:hf.left+20}function G(a){return a?80:nf+2}function H(){return F(!vg)}function I(){return G(!vg)}function J(){return F(vg)}function K(){return G(vg)}function L(){var a=vg?nf:lf,b=tc(),c=Vb()*(Gd(We.data.targets)?(b-(Mh?.25:1))/b:.98);return b>1?a*c/(b-1):a}function M(a){_h=a}function N(a){ai=a}function O(a){bi=a}function P(){return rg?$h?ai*(_h+1):pf:0}function Q(){return rg?$h?qf:bi*(_h+1):0}function R(){var a,b=!If;Af=vg?1:0,Bf=vg?nf:lf,Cf=vg?0:nf,Df=vg?lf:1,Ef=Af,Ff=Bf,Gf=vg?0:of,Hf=vg?mf:1,If=T(Af,Bf,b?void 0:If.domain(),function(){return Of.tickOffset()}),Jf=U(Cf,Df),Kf=U(Cf,Df),Lf=T(Af,Bf,ri,function(a){return a%1?0:Rf.tickOffset()}),Mf=U(Gf,Hf),Nf=U(Gf,Hf),a=$(),Of=X(If,Vh,a),Rf=X(Lf,Yh,a),Pf=Y(Jf,Wh,Og,Qg),Qf=Y(Kf,Xh,Xg,Zg),b||(fi.scale(Lf),bf&&ji.scale(If)),S()}function S(){wf=Db(),xf=Eb(),yf=Eb(.98)}function T(a,b,e,f){var g=(Lh?Ve.time.scale():Ve.scale.linear()).range([a,b]);if(g.orgDomain=function(){return g.domain()},d(e)&&g.domain(e),c(f)&&(f=function(){return 0}),Mh){var h,i=g;g=function(a){return i(a)+f(a)};for(h in i)g[h]=i[h];g.orgDomain=function(){return i.domain()},g.domain=function(a){return arguments.length?(i.domain(a),g):(a=i.domain(),[a[0],a[1]+1])}}return g}function U(a,b){return Ve.scale.linear().range([a,b])}function V(a){return"y2"===Z(a)?Kf:Jf}function W(a){return"y2"===Z(a)?Nf:Mf}function X(a,b,c){var d=(Mh?Bb():Ve.svg.axis()).scale(a).orient(b);return d.tickFormat(c),Mh?d.tickCentered(yg):d.tickOffset=function(){var a=vg?nf:lf;return a*Vb()/tc()/2},Mh&&d.categories(xg),d}function Y(a,b,c,d){return Ve.svg.axis().scale(a).orient(b).tickFormat(c).ticks(d).outerTickSize(0)}function Z(a){return a in Yf?Yf[a]:"y"}function $(){var a=Lh?Th:Mh?Ic:function(a){return 0>a?a.toFixed(0):a};return zg&&("function"==typeof zg?a=zg:Lh&&(a=function(a){return Ve.time.format(zg)(a)})),a}function _(a){var b;return"y"===a?b=Mg:"y2"===a?b=Vg:"x"===a&&(b=Hg),b}function ab(a){var b=_(a);return"string"==typeof b?b:b?b.text:null}function bb(a,b){var c=_(a);"string"==typeof c?"y"===a?Mg=b:"y2"===a?Vg=b:"x"===a&&(Hg=b):c&&(c.text=b)}function cb(a,b){var c=_(a),d=c&&"object"==typeof c&&c.position?c.position:b;return{isInner:d.indexOf("inner")>=0,isOuter:d.indexOf("outer")>=0,isLeft:d.indexOf("left")>=0,isCenter:d.indexOf("center")>=0,isRight:d.indexOf("right")>=0,isTop:d.indexOf("top")>=0,isMiddle:d.indexOf("middle")>=0,isBottom:d.indexOf("bottom")>=0}}function db(){return cb("x",vg?"inner-top":"inner-right")}function eb(){return cb("y",vg?"inner-right":"inner-top")}function fb(){return cb("y2",vg?"inner-right":"inner-top")}function gb(a){return"y2"===a?fb():"y"===a?eb():db()}function hb(){return ab("x")}function ib(){return ab("y")}function jb(){return ab("y2")}function kb(a,b){return a?b.isLeft?0:b.isCenter?lf/2:lf:b.isBottom?-nf:b.isMiddle?-nf/2:0}function lb(a,b){return a?b.isLeft?"0.5em":b.isRight?"-0.5em":"0":b.isTop?"-0.5em":b.isBottom?"0.5em":"0"}function mb(a,b){return a?b.isLeft?"start":b.isCenter?"middle":"end":b.isBottom?"start":b.isMiddle?"middle":"end"}function nb(){return kb(!vg,db())}function ob(){return kb(vg,eb())}function pb(){return kb(vg,fb())}function qb(){return lb(!vg,db())}function rb(){return lb(vg,eb())}function sb(){return lb(vg,fb())}function tb(){var a=db();return vg?a.isInner?"1.2em":-30-zb("x"):a.isInner?"-0.5em":"3em"}function ub(){var a=eb();return vg?a.isInner?"-0.5em":"3em":a.isInner?"1.2em":-20-zb("y")}function vb(){var a=fb();return vg?a.isInner?"1.2em":"-2.2em":a.isInner?"-0.5em":30+zb("y2")}function wb(){return mb(!vg,db())}function xb(){return mb(vg,eb())}function yb(){return mb(vg,fb())}function zb(a){var b=0,c="x"===a?f.axisX:"y"===a?f.axisY:f.axisY2;return Ve.selectAll("."+c+" .tick text").each(function(){var a=this.getBBox();bb?20:b}function Ab(){mi.select("."+f.axisX+" ."+f.axisXLabel).attr("x",nb).text(hb),mi.select("."+f.axisY+" ."+f.axisYLabel).attr("x",ob).attr("dy",ub).text(ib),mi.select("."+f.axisY2+" ."+f.axisY2Label).attr("x",pb).attr("dy",vb).text(jb)}function Bb(){function a(a,b){a.attr("transform",function(a){return"translate("+(b(a)+p)+", 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 o>=c||b%Math.ceil(c/o)===0}function f(a){return a0)for(g=Gc(a),b=0;b=0}),0!==e.length)for(d=e[0],g&&i[d]&&i[d].forEach(function(a,b){i[d][b]=0>a?a:0}),c=1;c0||(i[d][b]+=+a)});return Ve.min(Object.keys(i).map(function(a){return Ve.min(i[a])}))}function Tb(a){var b,c,d,e,f,g,h=vc(a),i=Ec(a);if(Xf.length>0)for(g=Hc(a),b=0;b=0}),0!==e.length)for(d=e[0],g&&i[d]&&i[d].forEach(function(a,b){i[d][b]=a>0?a:0}),c=1;c+a||(i[d][b]+=+a)});return Ve.max(Object.keys(i).map(function(a){return Ve.max(i[a])}))}function Ub(a,c){var d,e,f,g,h,i,j,k,l=a.filter(function(a){return Z(a.id)===c}),m="y2"===c?Tg:Kg,n="y2"===c?Sg:Jg,o=b(m)?m:Sb(l),p=b(n)?n:Tb(l),q="y2"===c?Ug:Lg,r=bd()&&vg;return 0===l.length?"y2"===c?Kf.domain():Jf.domain():(o===p&&(0>o?p=0:o=0),d=Math.abs(p-o),e=f=g=r?0:.1*d,q&&(h=Math.max(Math.abs(o),Math.abs(p)),p=h-q,o=q-h),r&&(i=cd(o,p),j=$b(Jf.range()),k=[i[0]/j,i[1]/j],f+=d*(k[1]/(1-k[0]-k[1])),g+=d*(k[0]/(1-k[0]-k[1]))),"y"===c&&Pg&&(f=b(Pg.top)?Pg.top:e,g=b(Pg.bottom)?Pg.bottom:e),"y2"===c&&Yg&&(f=b(Yg.top)?Yg.top:e,g=b(Yg.bottom)?Yg.bottom:e),Gd(l)&&!Gc(l)&&(g=o),[o-g,p+f])}function Vb(a){var b=$b(ri),c=$b(If.domain());return a||0===c?1:b/c}function Wb(a){return Fg?Fg:Ve.min(a,function(a){return Ve.min(a.values,function(a){return a.x})})}function Xb(a){return Eg?Eg:Ve.max(a,function(a){return Ve.max(a.values,function(a){return a.x})})}function Yb(a,b){var c,d,e=b[0],f=b[1],g=Math.abs(e-f);return Mh?d=0:Gd(a)?(c=tc(),d=c>1?g/(c-1)/2:.5):d=.01*g,d}function Zb(a){var b=[Wb(a),Xb(a)],c=b[0],d=b[1],e=Yb(a,b),f=Lh?new Date(c.getTime()-e):c-e,g=Lh?new Date(d.getTime()+e):d+e;return[f,g]}function $b(a){return a[1]-a[0]}function _b(a){for(var b=0;bd?0:d}function ec(a){return Sf&&a===Sf||$d(Tf)&&_d(Tf,a)}function fc(a){return!ec(a)}function gc(a){return Sf?Sf:$d(Tf)?Tf[a]:null}function hc(a,b){return a in We.data.x&&We.data.x[a]&&We.data.x[a][b]?We.data.x[a][b]:b}function ic(a){Object.keys(a).forEach(function(b){Tf[b]=a[b]})}function jc(a){var b;return a&&(b=Wf[a.id],a.name=b?b:a.id),a}function kc(a,b){a.forEach(function(a){a.values.forEach(function(c,d){c.x=mc(b[d],a.id,d)}),We.data.x[a.id]=b})}function lc(a,b){a.forEach(function(a){b[a.id]&&kc([a],b[a.id])})}function mc(a,b,c){var d;return d=Lh?a?a instanceof Date?a:Wd(a):Wd(hc(b,c)):Nh&&!Mh?a?+a:hc(b,c):c}function nc(a){var b,c,d=a[0],e={},f=[];for(b=1;b=0&&(We.data.x[b]=a.map(function(a){return a[c]})):We.data.x[b]=a.map(function(a,b){return b})}),c.forEach(function(a){if(!We.data.x[a])throw new Error('x is not defined for id = "'+a+'".')}),b=c.map(function(b,c){var d=Vf(b);return{id:d,id_org:b,values:a.map(function(a,e){var f=gc(b),g=a[f],h=mc(g,b,e);return Nh&&Mh&&0===c&&g&&(0===e&&(xg=[]),xg.push(g)),"undefined"==typeof a[b]&&(h=void 0),{x:h,value:null===a[b]||isNaN(a[b])?null:+a[b],id:d}}).filter(function(a){return"undefined"!=typeof a.x})}}),b.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++})}),Zf&&Ed(vc(b).filter(function(a){return!(a in $f)}),Zf),b.forEach(function(a){ac(a.id_org,a)}),b}function qc(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 rc(a){return a>0&&We.data.targets[0].values[a-1]?We.data.targets[0].values[a-1].x:void 0}function sc(a){return a1?We.data.targets.forEach(function(b){b.values.length>c&&(a=b,c=b.values.length)}):a=b?We.data.targets[0]:null,a}function vc(a){return a=c(a)?We.data.targets:a,a.map(function(a){return a.id})}function wc(a){var b,c=vc();for(b=0;b2){for(e=b-2,c=a[0],d=a[a.length-1],f=(d-c)/(e+1),i=[c],g=0;e>g;g++)h=+c+f*(g+1),i.push(Lh?new Date(h):h);i.push(d)}return i}function Cc(a){Uh=Uh.concat(a)}function Dc(a){Uh=Uh.filter(function(b){return a.indexOf(b)<0})}function Ec(a){var b={};return a.forEach(function(a){b[a.id]=[],a.values.forEach(function(c){b[a.id].push(c.value)})}),b}function Fc(a,b){var c,d,e,f=Object.keys(a);for(c=0;ca})}function Hc(a){return Fc(a,function(a){return a>0})}function Ic(a){return a=0&&d===a[c].x;c--)e.push(a[c]);for(c=b;c0?g=h:f=h,g-f===1||0===f&&0===g?(e=[],a[f].x&&(e=e.concat(kd(a,f))),a[g].x&&(e=e.concat(kd(a,g))),nd(e,b)):ld(a,b,f,g)}function md(a,b){var c;return c=a.map(function(a){return ld(a.values,b)}),nd(c,b)}function nd(a,b){var c,d;return a.forEach(function(a){var e=ae(a,b);(c>e||!c)&&(c=e,d=a)}),d}function od(a,b){return Ve.merge(a.map(function(a){return a.values})).filter(function(a){return a.x===b})}function pd(a){var b=a.getBoundingClientRect(),c=[a.pathSegList.getItem(0),a.pathSegList.getItem(1)],d=c[0].x,e=Math.min(c[0].y,c[1].y);return{x:d,y:e,width:b.width,height:b.height}}function qd(){return ag&&"desc"===ag.toLowerCase()}function rd(){return ag&&"asc"===ag.toLowerCase()}function sd(a){var b=rd(),c=qd();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 ag&&a.sort(ag),a}function td(a,c){var d,e,f,g,h,i,j,k=Kd(We.data.targets),l=k?ed:dd,m=a.filter(function(a){return a&&b(a.value)});yh&&0!==m.length&&(pi.html(Bh(a,$(),l,Sh)).style("display","block"),d=pi.property("offsetWidth"),e=pi.property("offsetHeight"),k?(g=lf/2+c[0],i=nf/2+c[1]+20):(vg?(f=q(),g=f+c[0]+100,h=g+d,j=r()-u(),i=If(m[0].x)+20):(f=q(),g=f+t()+If(m[0].x)+20,h=g+d,j=f+r()-u(),i=c[1]+15),h>j&&(g-=d+60),i+e>s()&&(i-=e+30)),pi.style("top",i+"px").style("left",g+"px"))}function ud(){pi.style("display","none")}function vd(a){var c=a.filter(function(a){return a&&b(a.value)});yh&&(Hd(We.data.targets)||Kd(We.data.targets)||mi.selectAll("line."+f.xgridFocus).style("visibility","visible").data([c[0]]).attr(vg?"y1":"x1",gd).attr(vg?"y2":"x2",gd))}function wd(){mi.select("line."+f.xgridFocus).style("visibility","hidden")}function xd(a){return a.x||0===a.x?If(a.x):null}function yd(a){return V(a.id)(a.value)}function zd(){var a,b,d={},e=0;return zc(xc(Nd)).forEach(function(f){for(a=0;a0&&(i+=g(b.values[f].value)-h)}),i}}function Dd(a,b){return kh?kh:b?2*a.tickOffset()*lh/b:0}function Ed(a,b){var c,d=a?"string"==typeof a?[a]:a:vc();for(c=0;c0}function _d(a,b){var c=!1;return Object.keys(a).forEach(function(d){a[d]===b&&(c=!0)}),c}function ae(a,b){var c="y"===Z(a.id)?Jf:Kf;return Math.pow(If(a.x)-b[0],2)+Math.pow(c(a.value)-b[1],2)}function be(a,b){var c=0;a.each(function(){++c}).each("end",function(){--c||b.apply(this,arguments)})}function ce(a,b,c){kg(b,a.node()),mi.select("."+f.selectedCircles+Xc(b.id)).selectAll("."+f.selectedCircle+"-"+c).data([b]).enter().append("circle").attr("class",function(){return Jc(f.selectedCircle,c)}).attr("cx",vg?yd:xd).attr("cy",vg?xd:yd).attr("stroke",function(){return Sh(b.id)}).attr("r",1.4*jh).transition().duration(100).attr("r",jh)}function de(a,b,c){lg(b,a.node()),mi.select("."+f.selectedCircles+Xc(b.id)).selectAll("."+f.selectedCircle+"-"+c).transition().duration(100).attr("r",0).remove()}function ee(a,b,c,d){a?ce(b,c,d):de(b,c,d)}function fe(a,b){kg(b,a.node()),a.transition().duration(100).style("fill",function(){return Ve.rgb(Sh(b.id)).darker(1)})}function ge(a,b){lg(b,a.node()),a.transition().duration(100).style("fill",function(){return Sh(b.id)})}function he(a,b,c,d){a?fe(b,c,d):ge(b,c,d)}function ie(a){return a.filter(function(a){return b(a.value)})}function je(a,c){return(c?mi.selectAll("."+f.circles+Xc(c)):mi).selectAll("."+f.circle+(b(a)?"-"+a:""))}function ke(a,b){je(a,b).classed(f.EXPANDED,!0).attr("r",ih)}function le(a){je(a).filter(function(){return Ve.select(this).classed(f.EXPANDED)}).classed(f.EXPANDED,!1).attr("r",fh)}function me(a){return mi.selectAll("."+f.bar+(b(a)?"-"+a:""))}function ne(a){me(a).classed(f.EXPANDED,!0)}function oe(a){me(a).classed(f.EXPANDED,!1)}function pe(a,b){var c=te(a,b);return function(a,b){var d=c(a,b),e=vg?1:0,f=vg?0:1,g="M "+d[0][e]+","+d[0][f]+" L"+d[1][e]+","+d[1][f]+" L"+d[2][e]+","+d[2][f]+" L"+d[3][e]+","+d[3][f]+" z";return g}}function qe(a,b){var c=te(a,!1),d=b?re:se;return function(a,b){return d(c(a,b),a,this)}}function re(a,b){var c;return vg?(c=Nd(b)?4:6,a[2][1]+c*(b.value<0?-1:1)):a[0][0]+(a[2][0]-a[0][0])/2}function se(a,b,c){var d=c.getBBox();return vg?(a[0][0]+a[2][0]+.6*d.height)/2:a[2][1]+(b.value<0?d.height:Nd(b)?-3:-6)}function te(a,b){var c=a.__max__+1,d=Dd(Of,c),e=Ad(d,c,a,!!b),f=Bd(!!b),g=Cd(a,!!b),h=b?W:V;return function(a,b){var c=h(a.id)(0),i=g(a,b)||c,j=e(a),k=f(a);return vg&&(a.value>0&&i>k||a.value<0&&k>i)&&(k=i),[[j,i],[j,k-(c-i)],[j+d,k-(c-i)],[j+d,i]]}}function ue(a,b,e,f){var g,h,i,j,k,l,m,n,o,p,q,r=-1,s="M",t=[];if(d(f))for(g=0;g=h;h+=u)s+=i(a[g-1],a[g],h,o)}r=a[g].x}return s}function ve(b){var c,d,e;if(qi=Ve.select(Ye),qi.empty())throw new Error('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');if(qi.html(""),qi.classed("c3",!0),We.data.x={},We.data.targets=pc(b),n(),R(),If.domain(Ve.extent(Zb(We.data.targets))),Jf.domain(Ub(We.data.targets,"y")),Kf.domain(Ub(We.data.targets,"y2")),Lf.domain(If.domain()),Mf.domain(Jf.domain()),Nf.domain(Kf.domain()),ri=If.domain(),fi.scale(Lf),bf&&ji.scale(If),ki=qi.append("svg").attr("width",lf+hf.left+hf.right).attr("height",nf+hf.top+hf.bottom).on("mouseenter",ef).on("mouseleave",ff),li=ki.append("defs"),li.append("clipPath").attr("id",Fh).append("rect").attr("width",lf).attr("height",nf),li.append("clipPath").attr("id",Gh).append("rect").attr("x",B).attr("y",C).attr("width",H).attr("height",I),li.append("clipPath").attr("id",Hh).append("rect").attr("x",D).attr("y",E).attr("width",J).attr("height",K),mi=ki.append("g").attr("transform",Zh.main),ni=og?ki.append("g").attr("transform",Zh.context):null,oi=rg?ki.append("g").attr("transform",Zh.legend):null,pi=Ve.select(Ye).style("position","relative").append("div").style("position","absolute").style("pointer-events","none").style("z-index","10").style("display","none"),mi.append("g").attr("class",f.axisX).attr("clip-path",vg?"":Jh).attr("transform",Zh.x).append("text").attr("class",f.axisXLabel).attr("transform",vg?"rotate(-90)":"").attr("dx",qb).attr("dy",tb).style("text-anchor",wb),Ig&&mi.append("g").attr("class",f.axisY).attr("clip-path",vg?Kh:"").append("text").attr("class",f.axisYLabel).attr("transform",vg?"":"rotate(-90)").attr("dx",rb).attr("dy",ub).style("text-anchor",xb),Rg&&mi.append("g").attr("class",f.axisY2).attr("transform",Zh.y2).append("text").attr("class",f.axisY2Label).attr("transform",vg?"":"rotate(-90)").attr("dx",sb).style("text-anchor",yb),d=mi.append("g").attr("clip-path",Ih).attr("class",f.grid),$g&&d.append("g").attr("class",f.xgrids),$d(ah)&&d.append("g").attr("class",f.xgridLines),gh&&d.append("g").attr("class",f.xgridFocus).append("line").attr("class",f.xgridFocus),bh&&d.append("g").attr("class",f.ygrids),$d(ch)&&d.append("g").attr("class",f.ygridLines),mi.append("g").attr("clip-path",Ih).attr("class",f.regions),mi.append("g").attr("clip-path",Ih).attr("class",f.chart),c=mi.select("."+f.chart).append("g").attr("class",f.eventRects).style("fill-opacity",0).style("cursor",bf?vg?"ns-resize":"ew-resize":null),mi.select("."+f.chart).append("g").attr("class",f.chartBars),mi.select("."+f.chart).append("g").attr("class",f.chartLines),mi.select("."+f.chart).append("g").attr("class",f.chartArcs).attr("transform",Zh.arc).append("text").attr("class",f.chartArcsTitle).style("text-anchor","middle").text(Ob()),mi.select("."+f.chart).append("g").attr("class",f.chartTexts),bf&&mi.insert("rect",df?null:"g."+f.grid).attr("class",f.zoomRect).attr("width",lf).attr("height",nf).style("opacity",0).style("cursor",vg?"ns-resize":"ew-resize").call(ji).on("dblclick.zoom",null),Gg&&fi.extent("function"!=typeof Gg?Gg:Gg(Zb())),og&&(ni.append("g").attr("clip-path",Ih).attr("class",f.chart),ni.select("."+f.chart).append("g").attr("class",f.chartBars),ni.select("."+f.chart).append("g").attr("class",f.chartLines),ni.append("g").attr("clip-path",Ih).attr("class",f.brush).call(fi).selectAll("rect").attr(vg?"width":"height",vg?mf:of),ni.append("g").attr("class",f.axisX).attr("transform",Zh.subx).attr("clip-path",vg?"":Jh)),Ie(We.data.targets),vg?mi.select("."+f.axisX).style("opacity",0).call(Of):(mi.select("."+f.axisY).style("opacity",0).call(Pf),mi.select("."+f.axisY2).style("opacity",0).call(Qf)),He({withTransform:!0,withLegend:!0,withTransitionForAxis:!1}),Ch){if(Lh&&"string"==typeof Dh){for(Dh=Wd(Dh),e=0;e0){d=[];for(var g in Wf)for(c=0;cg&&h>c&&d>i&&j>d):"path"===this.nodeName&&(m=pd(this),c=m.x,d=m.y,e=m.width,k=m.height,l=he,q=!(c>h||g>c+e||d>j||i>d+k)),q^p&&(n.classed(f.INCLUDED,!p),n.classed(f.SELECTED,!o),l(!o,n,a,b))}))}function Ae(a){Kd(We.data.targets)||dg&&(Oh=a,mi.select("."+f.chart).append("rect").attr("class",f.dragarea).style("opacity",.1),Ph=!0,mg())}function Be(){Kd(We.data.targets)||dg&&(mi.select("."+f.dragarea).transition().duration(100).style("opacity",0).remove(),mi.selectAll("."+f.shape).classed(f.INCLUDED,!1),Ph=!1,ng())}function Ce(a){var c,e,g,h,i,j,k,l,m,n,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,M,N,O,P=zd(),Q=Kd(We.data.targets),R=zc(We.data.targets);if(0!==R.length){if(a=d(a)?a:{},v=d(a.withY)?a.withY:!0,w=d(a.withSubchart)?a.withSubchart:!0,x=d(a.withTransition)?a.withTransition:!0,A=d(a.withTransform)?a.withTransform:!1,B=d(a.withUpdateXDomain)?a.withUpdateXDomain:!1,C=d(a.withUpdateOrgXDomain)?a.withUpdateOrgXDomain:!1,D=d(a.withLegend)?a.withLegend:!1,y=d(a.withTransitionForExit)?a.withTransitionForExit:x,z=d(a.withTransitionForAxis)?a.withTransitionForAxis:x,I=x?gf:0,J=y?I:0,K=z?I:0,D&&rg&&Qe(We.data.targets,a),C&&(If.domain(Ve.extent(Zb(R))),ri=If.domain(),bf&&ji.scale(If).updateScaleExtent(),Lf.domain(If.domain()),fi.scale(Lf)),B&&(If.domain(fi.empty()?ri:fi.extent()),bf&&ji.scale(If).updateScaleExtent(),Hd(R)||(M=Bc(Ac(R)),Of.tickValues(M),Rf.tickValues(M))),Jf.domain(Ub(R,"y")),Kf.domain(Ub(R,"y2")),mi.select("."+f.axisX).style("opacity",Q?0:1).transition().duration(K).call(Of),mi.select("."+f.axisY).style("opacity",Q?0:1).transition().duration(K).call(Pf),mi.select("."+f.axisY2).style("opacity",Q?0:1).transition().duration(K).call(Qf),B&&Ag&&M){for(N=1;N=V;V++)e.push(new Date(V+"-01-01 00:00:00"))}else e=If.ticks(10);c=mi.select("."+f.xgrids).selectAll("."+f.xgrid).data(e),c.enter().append("line").attr("class",f.xgrid),c.attr("x1",vg?0:function(a){return If(a)-Of.tickOffset()}).attr("x2",vg?lf:function(a){return If(a)-Of.tickOffset()}).attr("y1",vg?function(a){return If(a)-Of.tickOffset()}:hf.top).attr("y2",vg?function(a){return If(a)-Of.tickOffset()}:nf).style("opacity",function(){return+Ve.select(this).attr(vg?"y1":"x1")===(vg?nf:0)?0:1}),c.exit().remove()}$d(ah)&&(g=mi.select("."+f.xgridLines).selectAll("."+f.xgridLine).data(ah),h=g.enter().append("g").attr("class",function(a){return f.xgridLine+(a.class?a.class:"")}),h.append("line").style("opacity",0),h.append("text").attr("text-anchor","end").attr("transform",vg?"":"rotate(-90)").attr("dx",vg?0:-hf.top).attr("dy",-5).style("opacity",0),g.select("line").transition().duration(I).attr("x1",vg?0:hd).attr("x2",vg?lf:hd).attr("y1",vg?hd:hf.top).attr("y2",vg?hd:nf).style("opacity",1),g.select("text").transition().duration(I).attr("x",vg?lf:0).attr("y",hd).text(function(a){return a.text}).style("opacity",1),g.exit().transition().duration(I).style("opacity",0).remove()),v&&bh&&(i=mi.select("."+f.ygrids).selectAll("."+f.ygrid).data(Jf.ticks(dh)),i.enter().append("line").attr("class",f.ygrid),i.attr("x1",vg?Jf:0).attr("x2",vg?Jf:lf).attr("y1",vg?0:Jf).attr("y2",vg?nf:Jf),i.exit().remove()),v&&$d(ch)&&(j=mi.select("."+f.ygridLines).selectAll("."+f.ygridLine).data(ch),k=j.enter().append("g").attr("class",function(a){return f.ygridLine+(a.class?a.class:"")}),k.append("line").style("opacity",0),k.append("text").attr("text-anchor","end").attr("transform",vg?"rotate(-90)":"").attr("dx",vg?0:-hf.top).attr("dy",-5).style("opacity",0),j.select("line").transition().duration(I).attr("x1",vg?id:0).attr("x2",vg?id:lf).attr("y1",vg?0:id).attr("y2",vg?nf:id).style("opacity",1),j.select("text").transition().duration(I).attr("x",vg?0:lf).attr("y",id).text(function(a){return a.text}).style("opacity",1),j.exit().transition().duration(I).style("opacity",0).remove()),m=mi.selectAll("."+f.bars).selectAll("."+f.bar).data(Sd),m.enter().append("path").attr("d",E).style("stroke","none").style("opacity",0).style("fill",function(a){return Sh(a.id)}).attr("class",Rc),m.style("opacity",Zc).transition().duration(I).attr("d",E).style("opacity",1),m.exit().transition().duration(J).style("opacity",0).remove(),p=mi.selectAll("."+f.texts).selectAll("."+f.text).data(Ud),p.enter().append("text").attr("class",Kc).attr("text-anchor",function(a){return vg?a.value<0?"end":"start":"middle"}).style("stroke","none").style("fill-opacity",0),p.text(function(a){return fd(a.id)(a.value)}).style("fill-opacity",$c).transition().duration(I).attr("x",G).attr("y",H).style("fill-opacity",ad),p.exit().transition().duration(J).style("fill-opacity",0).remove(),mi.selectAll("."+f.line).style("opacity",Zc).transition().duration(I).attr("d",gi).style("opacity",1),mi.selectAll("."+f.area).style("opacity",0).transition().duration(I).attr("d",hi).style("opacity",si),l=mi.selectAll("."+f.circles).selectAll("."+f.circle).data(Td),l.enter().append("circle").attr("class",Pc).style("opacity",0).attr("r",fh),l.style("opacity",Zc).transition().duration(I).style("opacity",_c).attr("cx",vg?yd:xd).attr("cy",vg?xd:yd),l.exit().remove(),mi.selectAll("."+f.chartArc).select("."+f.arc).attr("transform",A?"scale(0)":"").style("opacity",function(a){return a===this._current?0:1}).transition().duration(I).attrTween("d",function(a){var b,c=Cb(a);return c?(b=Ve.interpolate(this._current,c),this._current=b(0),function(a){return Fb(b(a),!0)}):function(){return"M 0 0"}}).attr("transform",A?"scale(1)":"").style("opacity",1),mi.selectAll("."+f.chartArc).select("text").attr("transform",Gb).style("opacity",0).transition().duration(I).text(Jb).style("opacity",function(a){return yc(a.data.id)&&Rd(a.data)?1:0}),mi.select("."+f.chartArcsTitle).style("opacity",Jd(We.data.targets)?1:0),og&&(null!==Ve.event&&"zoom"===Ve.event.type&&fi.extent(If.orgDomain()).update(),w&&(ni.select("."+f.axisX).style("opacity",Q?0:1).transition().duration(I).call(Rf),fi.empty()||fi.extent(If.orgDomain()).update(),F=pe(P,!0),q=ni.selectAll("."+f.bars).selectAll("."+f.bar).data(Sd),q.enter().append("path").attr("d",F).style("stroke","none").style("fill",function(a){return Sh(a.id)}).attr("class",Rc),q.style("opacity",Zc).transition().duration(I).attr("d",F).style("opacity",1),q.exit().transition().duration(I).style("opacity",0).remove(),ni.selectAll("."+f.line).style("opacity",Zc).transition().duration(I).attr("d",ii).style("opacity",1))),mi.selectAll("."+f.selectedCircles).filter(function(a){return Nd(a)}).selectAll("circle").remove(),mi.selectAll("."+f.selectedCircle).transition().duration(I).attr("cx",vg?yd:xd).attr("cy",vg?xd:yd),$d(Tf)?(r=mi.select("."+f.eventRects).selectAll("."+f.eventRect).data([0]),xe(r.enter()),r.attr("x",0).attr("y",0).attr("width",lf).attr("height",nf)):(Nh&&!Mh?(u=function(a,b){var c=rc(b),d=sc(b),e=We.data.x[a.id][b];return(If(d?d:e+50)-If(c?c:e-50))/2},t=function(a,b){var c=rc(b),d=We.data.x[a.id][b];return(If(d)+If(c?c:d-50))/2}):(u=L(),t=function(a){return If(a.x)-u/2}),s=uc(),mi.select("."+f.eventRects).datum(s?s.values:[]),r=mi.select("."+f.eventRects).selectAll("."+f.eventRect).data(function(a){return a}),we(r.enter()),r.attr("class",Wc).attr("x",vg?0:t).attr("y",vg?t:0).attr("width",vg?lf:u).attr("height",vg?u:nf),r.exit().remove()),n=mi.select("."+f.regions).selectAll("rect."+f.region).data(xh),n.enter().append("rect").style("fill-opacity",0),n.attr("class",Vc).attr("x",vg?0:cc).attr("y",vg?cc:hf.top).attr("width",vg?lf:dc).attr("height",vg?dc:nf).transition().duration(I).style("fill-opacity",function(a){return b(a.opacity)?a.opacity:.1}),n.exit().transition().duration(I).style("fill-opacity",0).remove(),vc().forEach(function(a){ti[a]=!0})}}function De(){Ce({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}function Ee(){return"mousemove"===Ve.event.sourceEvent.type&&ji.altDomain?(If.domain(ji.altDomain),void ji.scale(If).updateScaleExtent()):(Mh&&If.orgDomain()[0]===ri[0]&&If.domain([ri[0]-1e-10,If.orgDomain()[1]]),Ce({withTransition:!1,withY:!1,withSubchart:!1}),void("mousemove"===Ve.event.sourceEvent.type&&(Qh=!0)))}function Fe(){function a(){b.forEach(function(a){a()})}var b=[];return a.add=function(a){b.push(a)},a}function Ge(){ki.attr("width",pf).attr("height",qf),ki.select("#"+Fh).select("rect").attr("width",lf).attr("height",nf),ki.select("#"+Gh).select("rect").attr("width",H),ki.select("#"+Hh).select("rect").attr("width",J),ki.select("."+f.zoomRect).attr("width",lf).attr("height",nf)}function He(a){a=d(a)?a:{},a.withTransition=d(a.withTransition)?a.withTransition:!0,a.withTransform=d(a.withTransform)?a.withTransform:!1,a.withLegend=d(a.withLegend)?a.withLegend:!1,a.withUpdateXDomain=!0,a.withUpdateOrgXDomain=!0,a.withTransitionForExit=!1,n(),R(),Ge(),m(a.withTransition),Ce(a)}function Ie(a){var b,c,d,e,g,h,i,j,k,l,m,n;i=mi.select("."+f.chartTexts).selectAll("."+f.chartText).data(a),j=i.enter().append("g").attr("class",function(a){return f.chartText+Jc(f.target,a.id)}).style("pointer-events","none"),j.append("g").attr("class",Lc).style("fill",function(a){return Sh(a.id)}),e=mi.select("."+f.chartBars).selectAll("."+f.chartBar).data(a),d=e.enter().append("g").attr("class",function(a){return f.chartBar+Jc(f.target,a.id)}).style("pointer-events","none"),d.append("g").attr("class",Sc).style("fill",function(a){return Sh(a.id)}).style("stroke","none").style("cursor",function(a){return fg(a)?"pointer":null}),c=mi.select("."+f.chartLines).selectAll("."+f.chartLine).data(a),b=c.enter().append("g").attr("class",function(a){return f.chartLine+Jc(f.target,a.id)}).style("pointer-events","none"),b.append("path").attr("class",Oc).style("opacity",0).style("stroke",function(a){return Sh(a.id)}),b.append("path").attr("class",Uc).style("opacity",function(){return si=+Ve.select(this).style("opacity"),0}).style("fill",function(a){return Sh(a.id)}),b.append("g").attr("class",function(a){return Jc(f.selectedCircles,a.id)}),b.append("g").attr("class",Qc).style("fill",function(a){return Sh(a.id)}).style("cursor",function(a){return fg(a)?"pointer":null}),a.forEach(function(a){mi.selectAll("."+f.selectedCircles+Xc(a.id)).selectAll("."+f.selectedCircle).each(function(b,c){b.value=a.values[c].value})}),h=mi.select("."+f.chartArcs).selectAll("."+f.chartArc).data(zf(a)),g=h.enter().append("g").attr("class",function(a){return f.chartArc+Jc(f.target,a.data.id)}),g.append("path").attr("class",Tc).style("opacity",0).style("fill",function(a){return Sh(a.data.id)}).style("cursor",function(a){return fg(a)?"pointer":null}).each(function(a){this._current=a}).on("mouseover",function(a,b){var c=Cb(a),d=Ib(c),e=Qb();Kb(c.data.id),Ne(c.data.id),e(d,b)}).on("mousemove",function(a){var b=Cb(a),c=[Ib(b)];td(c,Ve.mouse(this))}).on("mouseout",function(a,b){var c=Cb(a),d=Ib(c),e=Rb();Lb(c.data.id),Pe(),ud(),e(d,b)}).on("click",function(a,b){var c=Cb(a),d=Ib(c),e=Pb();e(d,b)}),g.append("text").attr("dy",".35em").style("opacity",0).style("text-anchor","middle").style("pointer-events","none"),og&&(n=ni.select("."+f.chartBars).selectAll("."+f.chartBar).data(a),m=n.enter().append("g").attr("class",function(a){return f.chartBar+Jc(f.target,a.id)}),m.append("g").attr("class",Sc).style("fill",function(a){return Sh(a.id)}),l=ni.select("."+f.chartLines).selectAll("."+f.chartLine).data(a),k=l.enter().append("g").attr("class",function(a){return f.chartLine+Jc(f.target,a.id)}),k.append("path").attr("class",Oc).style("opacity",0).style("stroke",function(a){return Sh(a.id)})),ki.selectAll("."+f.target).filter(function(a){return yc(a.id)}).transition().style("opacity",1)}function Je(a,b){We.data.targets.forEach(function(b){for(var c=0;ce&&(e=(k-j)/2,w=0,C++)),B[a]=C,A[C]=e,x[a]=w,w+=j}var e,f,g=a.getBBox(),h=10*Math.ceil((g.width+s)/10),i=10*Math.ceil((g.height+r)/10),j=$h?i:h,k=$h?rf:sf;c&&(w=0,C=0,t=0,u=0),y[b]=h,z[b]=i,(!t||h>=t)&&(t=h),(!u||i>=u)&&(u=i),f=$h?u:t,ug?(Object.keys(y).forEach(function(a){y[a]=t}),Object.keys(z).forEach(function(a){z[a]=u}),e=(k-f*q.length)/2,v>e?(w=0,C=0,q.forEach(function(a){d(a)})):d(b,!0)):d(b)}var g,h,i,j,k,l,o,p,q=vc(a),r=4,s=26,t=0,u=0,v=10,w=0,x={},y={},z={},A={},B={},C=0;b=c(b)?{}:b,p=d(b.withTransition)?b.withTransition:!0,$h?(h=function(a){return t*(.2+B[a])},k=function(a){return A[B[a]]+x[a]}):(h=function(a){return A[B[a]]+x[a]},k=function(a){return u*(.2+B[a])}),i=function(a,b){return h(a,b)+14},l=function(a,b){return k(a,b)+9},j=function(a,b){return h(a,b)-4},o=function(a,b){return k(a,b)-7},g=oi.selectAll("."+f.legendItem).data(q).enter().append("g").attr("class",function(a){return Jc(f.legendItem,a)}).style("cursor","pointer").on("click",function(a){"function"==typeof tg?tg(a):We.toggle(a)}).on("mouseover",function(a){We.focus(a)}).on("mouseout",function(){We.revert()}),g.append("text").text(function(a){return d(Wf[a])?Wf[a]:a}).each(function(a,b){e(this,a,0===b)}).style("pointer-events","none").attr("x",$h?i:-200).attr("y",$h?-200:l),g.append("rect").attr("class",f.legendItemEvent).style("fill-opacity",0).attr("x",$h?j:-200).attr("y",$h?-200:o).attr("width",function(a){return y[a]}).attr("height",function(a){return z[a]}),g.append("rect").attr("class",f.legendItemTile).style("pointer-events","none").style("fill",function(a){return Sh(a)}).attr("x",$h?i:-200).attr("y",$h?-200:k).attr("width",10).attr("height",10),oi.selectAll("text").data(q).text(function(a){return d(Wf[a])?Wf[a]:a}).each(function(a,b){e(this,a,0===b)}).transition().duration(p?250:0).attr("x",i).attr("y",l),oi.selectAll("rect."+f.legendItemEvent).data(q).transition().duration(p?250:0).attr("x",j).attr("y",o),oi.selectAll("rect."+f.legendItemTile).data(q).transition().duration(p?250:0).attr("x",h).attr("y",k),N(t),O(u),M(C),n(),R(),Ge(),m(!1)}function Re(a){return wc(a.id)}function Se(a){return"data"in a&&wc(a.data.id)}function Te(a){var b=a&&a.value?a.value:null,c=a&&a["class"]?a["class"]:null;return b?function(a){return a.value!==b}:c?function(a){return a["class"]!==c}:function(){return!0}}function Ue(a,b,c){var d=!Kd(We.data.targets);Ed(a,b),He(c?c:{withTransitionForAxis:d})}var Ve=a.d3?a.d3:a.require?a.require("d3"):void 0,We={data:{},axis:{}},Xe={},Ye=h(["bindto"],"#chart"),Ze=h(["size","width"]),$e=h(["size","height"]),_e=h(["padding","left"]),af=h(["padding","right"]),bf=h(["zoom","enabled"],!1),cf=h(["zoom","extent"]),df=h(["zoom","privileged"],!1),ef=h(["onenter"],function(){}),ff=h(["onleave"],function(){}),gf=h(["transition","duration"],350);g("data","data is required in config");var hf,jf,kf,lf,mf,nf,of,pf,qf,rf,sf,tf,uf,vf,wf,xf,yf,zf,Af,Bf,Cf,Df,Ef,Ff,Gf,Hf,If,Jf,Kf,Lf,Mf,Nf,Of,Pf,Qf,Rf,Sf=h(["data","x"]),Tf=h(["data","xs"],{}),Uf=h(["data","x_format"]),Vf=h(["data","id_converter"],function(a){return a}),Wf=h(["data","names"],{}),Xf=h(["data","groups"],[]),Yf=h(["data","axes"],{}),Zf=h(["data","type"]),$f=h(["data","types"],{}),_f=h(["data","labels"],{}),ag=h(["data","order"]),bg=h(["data","regions"],{}),cg=h(["data","colors"],{}),dg=h(["data","selection","enabled"],!1),eg=h(["data","selection","grouped"],!1),fg=h(["data","selection","isselectable"],function(){return!0}),gg=h(["data","selection","multiple"],!0),hg=h(["data","onclick"],function(){}),ig=h(["data","onenter"],function(){}),jg=h(["data","onleave"],function(){}),kg=h(["data","onselected"],function(){}),lg=h(["data","onunselected"],function(){}),mg=h(["data","ondragstart"],function(){}),ng=h(["data","ondragend"],function(){}),og=h(["subchart","show"],!1),pg=og?h(["subchart","size","height"],60):0,qg=h(["color","pattern"],[]),rg=h(["legend","show"],!0),sg=h(["legend","position"],"bottom"),tg=h(["legend","item","onclick"]),ug=h(["legend","equally"],!1),vg=h(["axis","rotated"],!1),wg=h(["axis","x","type"],"indexed"),xg=h(["axis","x","categories"],[]),yg=h(["axis","x","tick","centered"],!1),zg=h(["axis","x","tick","format"]),Ag=h(["axis","x","tick","culling"],{}),Bg=h(["axis","x","tick","culling","max"],"categorized"===wg?1/0:10),Cg=h(["axis","x","tick","count"]),Dg=h(["axis","x","tick","fit"],!1),Eg=h(["axis","x","max"]),Fg=h(["axis","x","min"]),Gg=h(["axis","x","default"]),Hg=h(["axis","x","label"],{}),Ig=h(["axis","y","show"],!0),Jg=h(["axis","y","max"]),Kg=h(["axis","y","min"]),Lg=h(["axis","y","center"]),Mg=h(["axis","y","label"],{}),Ng=h(["axis","y","inner"],!1),Og=h(["axis","y","tick","format"]),Pg=h(["axis","y","padding"],{}),Qg=h(["axis","y","ticks"],10),Rg=h(["axis","y2","show"],!1),Sg=h(["axis","y2","max"]),Tg=h(["axis","y2","min"]),Ug=h(["axis","y2","center"]),Vg=h(["axis","y2","label"],{}),Wg=h(["axis","y2","inner"],!1),Xg=h(["axis","y2","tick","format"]),Yg=h(["axis","y2","padding"],{}),Zg=h(["axis","y2","ticks"],10),$g=h(["grid","x","show"],!1),_g=h(["grid","x","type"],"tick"),ah=h(["grid","x","lines"],[]),bh=h(["grid","y","show"],!1),ch=h(["grid","y","lines"],[]),dh=h(["grid","y","ticks"],10),eh=h(["point","show"],!0),fh=eh?h(["point","r"],2.5):0,gh=h(["point","focus","line","enabled"],!0),hh=h(["point","focus","expand","enabled"],!0),ih=h(["point","focus","expand","r"],hh?4:fh),jh=h(["point","focus","select","r"],8),kh=h(["bar","width"]),lh=h(["bar","width","ratio"],.6),mh=h(["pie","label","show"],!0),nh=h(["pie","label","format"]),oh=h(["pie","onclick"],function(){}),ph=h(["pie","onmouseover"],function(){}),qh=h(["pie","onmouseout"],function(){}),rh=h(["donut","label","show"],!0),sh=h(["donut","label","format"]),th=h(["donut","title"],""),uh=h(["donut","onclick"],function(){}),vh=h(["donut","onmouseover"],function(){}),wh=h(["donut","onmouseout"],function(){}),xh=h(["regions"],[]),yh=h(["tooltip","show"],!0),zh=h(["tooltip","format","title"]),Ah=h(["tooltip","format","value"]),Bh=h(["tooltip","contents"],function(a,b,c,d){var e,g,h,i,j,k=zh?zh:b,l=Ah?Ah:c;for(g=0;g"+(h||0===h?""+h+"":"")),j=a[g].name,i=l(a[g].value,a[g].ratio),e+="",e+=""+j+"",e+=""+i+"",e+="");return e+""}),Ch=h(["tooltip","init","show"],!1),Dh=h(["tooltip","init","x"],0),Eh=h(["tooltip","init","position"],{top:"0px",left:"50px"}),Fh=("string"==typeof Ye?Ye.replace("#",""):Ye.id)+"-clip",Gh=Fh+"-xaxis",Hh=Fh+"-yaxis",Ih=i(Fh),Jh=i(Jh),Kh=i(Kh),Lh="timeseries"===wg,Mh="categorized"===wg,Nh=!Lh&&(Sf||$d(Tf)),Oh=null,Ph=!1,Qh=!1,Rh=!1,Sh=Vd(cg,qg),Th=function(){var a=[[Ve.time.format("%Y/%-m/%-d"),function(){return!0}],[Ve.time.format("%-m/%-d"),function(a){return a.getMonth()}],[Ve.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[Ve.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[Ve.time.format("%I %p"),function(a){return a.getHours()}],[Ve.time.format("%I:%M"),function(a){return a.getMinutes()}],[Ve.time.format(":%S"),function(a){return a.getSeconds()}],[Ve.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)}}(),Uh=[],Vh=vg?"left":"bottom",Wh=vg?Ng?"top":"bottom":Ng?"right":"left",Xh=vg?Wg?"bottom":"top":Wg?"left":"right",Yh=vg?"left":"bottom",Zh={main:function(){return"translate("+hf.left+","+hf.top+")"},context:function(){return"translate("+jf.left+","+jf.top+")"},legend:function(){return"translate("+kf.left+","+kf.top+")"},x:function(){return"translate(0,"+(vg?0:nf)+")"},y:function(){return"translate(0,"+(vg?nf:0)+")"},y2:function(){return"translate("+(vg?0:lf)+","+(vg?1:0)+")"},subx:function(){return"translate(0,"+(vg?0:of)+")"},arc:function(){return"translate("+lf/2+","+nf/2+")"}},$h="right"===sg,_h=0,ai=0,bi=0,ci=30,di=30,ei=5;zf=Ve.layout.pie().value(function(a){return a.values.reduce(function(a,b){return a+b.value},0)});var fi,gi=function(){var a=Ve.svg.line().x(vg?function(a){return V(a.id)(a.value)}:gd).y(vg?gd:function(a){return V(a.id)(a.value)});return function(b){var c,d,e=ie(b.values);return Ld(b)?(a.interpolate(Md(b)?"cardinal":"linear"),bg[b.id]?ue(e,If,V(b.id),bg[b.id]):a(e)):(c=If(e[0].x),d=V(b.id)(e[0].value),vg?"M "+d+" "+c:"M "+c+" "+d)}}(),hi=function(){var a;return a=vg?Ve.svg.area().x0(function(a){return V(a.id)(0)}).x1(function(a){return V(a.id)(a.value)}).y(gd):Ve.svg.area().x(gd).y0(function(a){return V(a.id)(0)}).y1(function(a){return V(a.id)(a.value)}),function(b){var c,d,e=ie(b.values);return Fd([b],"area")||Fd([b],"area-spline")?(a.interpolate(Md(b)?"cardinal":"linear"),a(e)):(c=If(e[0].x),d=V(b.id)(e[0].value),vg?"M "+d+" "+c:"M "+c+" "+d)}}(),ii=function(){var a=Ve.svg.line().x(vg?function(a){return W(a.id)(a.value)}:jd).y(vg?jd:function(a){return W(a.id)(a.value)});return function(b){var c=ie(b.values);return Ld(b)?a(c):"M "+Lf(c[0].x)+" "+W(b.id)(c[0].value)}}(),ji=function(){};fi=Ve.svg.brush().on("brush",De),fi.update=function(){return ni&&ni.select("."+f.brush).call(this),this},fi.scale=function(a){return vg?this.y(a):this.x(a)},bf&&(ji=Ve.behavior.zoom().on("zoomstart",function(){ji.altDomain=Ve.event.sourceEvent.altKey?If.orgDomain():null}).on("zoom",bf?Ee:null),ji.scale=function(a){return vg?this.y(a):this.x(a)},ji.orgScaleExtent=function(){var a=cf?cf:[1,10];return[a[0],Math.max(tc()/a[1],a[1])]},ji.updateScaleExtent=function(){var a=$b(If.orgDomain())/$b(ri),b=this.orgScaleExtent();return this.scaleExtent([b[0]*a,b[1]*a]),this});var ki,li,mi,ni,oi,pi,qi,ri,si,ti={};if(We.focus=function(a){function b(a){zc(a).transition().duration(100).style("opacity",1)}var c=ki.selectAll(Yc(a)),d=c.filter(Re),e=c.filter(Se);We.revert(),We.defocus(),b(d.classed(f.focused,!0)),b(e),Kd(We.data.targets)&&Kb(a,!0),Ne(a)},We.defocus=function(a){function b(a){zc(a).transition().duration(100).style("opacity",.3)}var c=ki.selectAll(Yc(a)),d=c.filter(Re),e=c.filter(Se);We.revert(),b(d.classed(f.focused,!1)),b(e),Kd(We.data.targets)&&Lb(a),Oe(a)},We.revert=function(a){function b(a){zc(a).transition().duration(100).style("opacity",1)}var c=ki.selectAll(Yc(a)),d=c.filter(Re),e=c.filter(Se);b(d.classed(f.focused,!1)),b(e),Kd(We.data.targets)&&Lb(a),Pe()},We.show=function(a){Dc(a),ki.selectAll(Yc(a)).transition().style("opacity",1),Ce({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!1})},We.hide=function(a){Cc(a),ki.selectAll(Yc(a)).transition().style("opacity",0),Ce({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!1})},We.toggle=function(a){yc(a)?We.hide(a):We.show(a)},We.unzoom=function(){fi.clear().update(),Ce({withUpdateXDomain:!0})},We.load=function(a){return a.xs&&ic(a.xs),"categories"in a&&Mh&&(xg=a.categories,Of.categories(xg)),"cacheIds"in a&&_b(a.cacheIds)?void Je(bc(a.cacheIds),a.done):void("unload"in a?Le("string"==typeof a.unload?[a.unload]:"boolean"==typeof a.unload&&a.unload?vc():a.unload,function(){Ke(a)}):Ke(a))},We.unload=function(a){Le(a?"string"==typeof a?[a]:a:vc(),function(){Ce({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})})},We.selected=function(a){return Ve.merge(mi.selectAll("."+f.shapes+Xc(a)).selectAll("."+f.shape).filter(function(){return Ve.select(this).classed(f.SELECTED)}).map(function(a){return a.map(function(a){return a.__data__})}))},We.select=function(a,b,c){dg&&mi.selectAll("."+f.shapes).selectAll("."+f.shape).each(function(e,g){var h=Ve.select(this),i="circle"===this.nodeName?ce:fe,j="circle"===this.nodeName?de:ge,k=eg||!a||a.indexOf(e.id)>=0,l=!b||b.indexOf(g)>=0,m=h.classed(f.SELECTED);k&&l?fg(e)&&!m&&i(h.classed(f.SELECTED,!0),e,g):d(c)&&c&&m&&j(h.classed(f.SELECTED,!1),e,g)})},We.unselect=function(a,b){dg&&mi.selectAll("."+f.shapes).selectAll("."+f.shape).each(function(c,d){var e=Ve.select(this),g="circle"===this.nodeName?de:ge,h=eg||!a||a.indexOf(c.id)>=0,i=!b||b.indexOf(d)>=0,j=e.classed(f.SELECTED);h&&i&&fg(c)&&j&&g(e.classed(f.SELECTED,!1),c,d)})},We.toLine=function(a){Ue(a,"line")},We.toSpline=function(a){Ue(a,"spline")},We.toBar=function(a){Ue(a,"bar")},We.toScatter=function(a){Ue(a,"scatter")},We.toArea=function(a){Ue(a,"area")},We.toAreaSpline=function(a){Ue(a,"area-spline")},We.toPie=function(a){Ue(a,"pie",{withTransform:!0})},We.toDonut=function(a){Ue(a,"donut",{withTransform:!0})},We.groups=function(a){return c(a)?Xf:(Xf=a,Ce(),Xf)},We.xgrids=function(a){return a?(ah=a,Ce(),ah):ah},We.xgrids.add=function(a){return a?We.xgrids(ah.concat(a)):void 0},We.xgrids.remove=function(a){var b=Te(a);return We.xgrids(ah.filter(b))},We.ygrids=function(a){return a?(ch=a,Ce(),ch):ch},We.ygrids.add=function(a){return a?We.ygrids(ch.concat(a)):void 0},We.ygrids.remove=function(a){var b=Te(a);return We.ygrids(ch.filter(b))},We.regions=function(a){return c(a)?xh:(xh=a,Ce(),xh)},We.regions.add=function(a){return c(a)?xh:(xh=xh.concat(a),Ce(),xh)},We.regions.remove=function(a,c){var e=[].concat(a);return c=d(c)?c:{},e.forEach(function(a){var d=b(c.duration)?c.duration:0;ki.selectAll("."+a).transition().duration(d).style("fill-opacity",0).remove(),xh=xh.filter(function(b){return b.classes.indexOf(a)<0})}),xh},We.data.get=function(a){var b=We.data.getAsTarget(a);return d(b)?b.values.map(function(a){return a.value}):void 0},We.data.getAsTarget=function(a){var b=xc(function(b){return b.id===a});return b.length>0?b[0]:void 0},We.data.names=function(a){return arguments.length?(Object.keys(a).forEach(function(b){Wf[b]=a[b]}),Qe(We.data.targets,{withTransition:!0}),Wf):Wf},We.x=function(a){return arguments.length&&(kc(We.data.targets,a),Ce({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),We.data.x},We.xs=function(a){return arguments.length&&(lc(We.data.targets,a),Ce({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),We.data.x},We.axis.labels=function(a){arguments.length&&(Object.keys(a).forEach(function(b){bb(b,a[b])}),Ab())},We.axis.max=function(a){arguments.length&&("object"==typeof a?(b(a.y)&&(Jg=+a.y),b(a.y2)&&(Sg=+a.y2)):Jg=Sg=+a,Ce())},We.axis.min=function(a){arguments.length&&("object"==typeof a?(b(a.y)&&(Kg=+a.y),b(a.y2)&&(Tg=+a.y2)):Kg=Tg=+a,Ce())},We.axis.range=function(a){arguments.length&&("undefined"!=typeof a.max&&We.axis.max(a.max),"undefined"!=typeof a.min&&We.axis.min(a.min))},We.resize=function(a){Ze=a?a.width:null,$e=a?a.height:null,He({withLegend:!0,withTransition:!1})},We.destroy=function(){We.data.targets=void 0,We.data.x={},qi.html(""),a.onresize=null},"url"in e.data)Ve.csv(e.data.url,function(a,b){ve(b)});else if("rows"in e.data)ve(nc(e.data.rows));else{if(!("columns"in e.data))throw Error("url or rows or columns is required.");ve(oc(e.data.columns))}return We},"function"==typeof a.define&&a.define.amd?a.define("c3",["d3"],e):a.c3=e}(window); \ No newline at end of file diff --git a/package.json b/package.json index b679294..5d200cd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "c3", - "version": "0.1.27", + "version": "0.1.28", "description": "D3-based reusable chart library", "main": "c3.js", "scripts": {