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