mirror of https://github.com/masayuki0812/c3.git
Quite good looking graph derived from d3.js
http://c3js.org
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3 lines
66 KiB
3 lines
66 KiB
!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.31"},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",eventRectsSingle:"c3-event-rects-single",eventRectsMultiple:"c3-event-rects-multiple",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",legendItemHidden:"c3-legend-item-hidden",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;c<a.length;c++){if("object"==typeof g&&!(a[c]in g))return b;if(d=c===a.length-1,f=g[a[c]],!d&&"object"!=typeof f||d&&"object"!=typeof b&&"object"==typeof f&&null!==f)return b;g=f}return g}function i(a){return"url("+document.URL.split("#")[0]+"#"+a+")"}function j(a){var b=a!==!1?250:0;Si.attr("transform",Di.main),Si.select("."+f.axisX).transition().duration(b).attr("transform",Di.x),Si.select("."+f.axisY).transition().duration(b).attr("transform",Di.y),Si.select("."+f.axisY2).attr("transform",Di.y2),Si.select("."+f.chartArcs).attr("transform",Di.arc)}function k(){Jg&&(Ti.attr("transform",Di.context),Ti.select("."+f.axisX).attr("transform",Di.subx))}function l(a){var b=a!==!1?250:0;Ui.transition().duration(b).attr("transform",Di.legend)}function m(a){j(a),k(a),l(a)}function n(){var a=Q(),b=P();Kf=r(),Lf=s(),Df={top:Sg?w("y2"):Ki,right:u(),bottom:w(Sg?"y":"x")+(Sg?0:Kg)+(Ei?0:a),left:(Sg?Kg+Ji:0)+t()},Gf=Kf-Df.left-Df.right,If=Lf-Df.top-Df.bottom,0>Gf&&(Gf=0),0>If&&(If=0),Ef={top:Sg?Df.top:Lf-Kg-(Ei?0:a),right:0/0,bottom:20+(Ei?0:a),left:Sg?Ii:Df.left},Hf=Sg?Df.left-Ii-Ji:Gf,Jf=Sg?If:Lf-Ef.top-Ef.bottom,0>Hf&&(Hf=0),0>Jf&&(Jf=0),Ff={top:Ei?0:Lf-a,right:0/0,bottom:0,left:Ei?Kf-b:0},p(),Ei&&Yd(of.data.targets)&&(Ff.left=Gf/2+Nf)}function o(){Si.select("line."+f.xgridFocus).attr("x1",Sg?0:-10).attr("x2",Sg?Gf:-10).attr("y1",Sg?-10:Df.top).attr("y2",Sg?-10:If)}function p(){Nf=If/2,Mf=.95*Nf,Of=Xd(of.data.targets)?.6*Mf:0}function q(){var a=Sg?f.axisX:f.axisY,b=nf.select("."+a).node(),c=b?b.getBoundingClientRect():{right:0},d=nf.select(qf).node().getBoundingClientRect(),e=c.right-d.left-t();return e>0?e:0}function r(){return rf?rf:x()}function s(){var a=sf?sf:y();return a>0?a:320}function t(){return Yd(of.data.targets)?0:tf?tf:Sg||!gh||lh?1:v("y")}function u(){var a=1;return Yd(of.data.targets)?0:uf?uf:Ei?P()+(ph&&!Sg?v("y2"):a):ph?uh||Sg?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||gh?"y2"!==a||ph?(gb(a).isInner?30:40)+("y2"===a?-10:0):Ki:Mg&&!Ei?10:1}function x(){return+nf.select(qf).style("width").replace("px","")}function y(){return+nf.select(qf).style("height").replace("px","")}function z(a){return a?-5:-(Df.left-1)}function A(a){return a?-20:-1}function B(){return z(!Sg)}function C(){return A(!Sg)}function D(){return z(Sg)}function E(){return A(Sg)}function F(a){return a?Gf+2+4:Df.left+20}function G(a){return a?80:If+2}function H(){return F(!Sg)}function I(){return G(!Sg)}function J(){return F(Sg)}function K(){return G(Sg)}function L(){var a=Sg?If:Gf,b=vc(),c=Vb()*(Ud(of.data.targets)?(b-(ni?.25:1))/b:.98);return b>1?a*c/(b-1):a}function M(a){Fi=a}function N(a){Gi=a}function O(a){Hi=a}function P(){return Mg?Ei?Gi*(Fi+1):Kf:0}function Q(){return Mg?Ei?Lf:Hi*(Fi+1):0}function R(){var a,b=!_f;Tf=Sg?1:0,Uf=Sg?If:Gf,Vf=Sg?0:If,Wf=Sg?Gf:1,Xf=Tf,Yf=Uf,Zf=Sg?0:Jf,$f=Sg?Hf:1,_f=T(Tf,Uf,b?void 0:_f.domain(),function(){return fg.tickOffset()}),ag=U(Vf,Wf),bg=U(Vf,Wf),cg=T(Tf,Uf,Xi,function(a){return a%1?0:ig.tickOffset()}),dg=U(Zf,$f),eg=U(Zf,$f),a=$(),fg=X(_f,zi,a),ig=X(cg,Ci,a),gg=Y(ag,Ai,mh,oh),hg=Y(bg,Bi,vh,xh),b||(Li.scale(cg),vf&&Pi.scale(_f)),S()}function S(){Pf=Db(),Qf=Eb(),Rf=Eb(.98)}function T(a,b,e,f){var g=(mi?nf.time.scale():nf.scale.linear()).range([a,b]);if(g.orgDomain=function(){return g.domain()},d(e)&&g.domain(e),c(f)&&(f=function(){return 0}),ni){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 nf.scale.linear().range([a,b])}function V(a){return"y2"===Z(a)?bg:ag}function W(a){return"y2"===Z(a)?eg:dg}function X(a,b,c){var d=(ni?Bb():nf.svg.axis()).scale(a).orient(b);return d.tickFormat(c),ni?(d.tickCentered(Wg),ne(Yg)&&(Yg=!1)):d.tickOffset=function(){var a=Sg?If:Gf;return a*Vb()/vc()/2},ni&&d.categories(Vg),d}function Y(a,b,c,d){return nf.svg.axis().scale(a).orient(b).tickFormat(c).ticks(d).outerTickSize(0)}function Z(a){return a in qg?qg[a]:"y"}function $(){var a=mi?wi:ni?Oc:function(a){return 0>a?a.toFixed(0):a};return Xg&&("function"==typeof Xg?a=Xg:mi&&(a=function(a){return a?vi(Xg)(a):""})),a}function _(a){var b;return"y"===a?b=kh:"y2"===a?b=th:"x"===a&&(b=fh),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?kh=b:"y2"===a?th=b:"x"===a&&(fh=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",Sg?"inner-top":"inner-right")}function eb(){return cb("y",Sg?"inner-right":"inner-top")}function fb(){return cb("y2",Sg?"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?Gf/2:Gf:b.isBottom?-If:b.isMiddle?-If/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(!Sg,db())}function ob(){return kb(Sg,eb())}function pb(){return kb(Sg,fb())}function qb(){return lb(!Sg,db())}function rb(){return lb(Sg,eb())}function sb(){return lb(Sg,fb())}function tb(){var a=db();return Sg?a.isInner?"1.2em":-30-zb("x"):a.isInner?"-0.5em":"3em"}function ub(){var a=eb();return Sg?a.isInner?"-0.5em":"3em":a.isInner?"1.2em":-20-zb("y")}function vb(){var a=fb();return Sg?a.isInner?"1.2em":"-2.2em":a.isInner?"-0.5em":30+zb("y2")}function wb(){return mb(!Sg,db())}function xb(){return mb(Sg,eb())}function yb(){return mb(Sg,fb())}function zb(a){var b=0,c="x"===a?f.axisX:"y"===a?f.axisY:f.axisY2;return nf.selectAll("."+c+" .tick text").each(function(){var a=this.getBoundingClientRect();b<a.width&&(b=a.width)}),20>b?20:b}function Ab(){Si.select("."+f.axisX+" ."+f.axisXLabel).attr("x",nb).text(hb),Si.select("."+f.axisY+" ."+f.axisYLabel).attr("x",ob).attr("dy",ub).text(ib),Si.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)+o)+", 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]);c<a[1];c++)b.push(c);return b.length>0&&b[0]>0&&b.unshift(b[0]-(b[1]-b[0])),b}function e(a){return a<r.length?r[a]:a}function f(a){var b=e(a);return p?p(b):b}function g(e){e.each(function(){var e,g,n=nf.select(this),p=d(h.domain()),q=n.selectAll(".tick.major").data(p,String),r=q.enter().insert("g","path").attr("class","tick major").style("opacity",1e-6),s=nf.transition(q.exit()).style("opacity",1e-6).remove(),t=nf.transition(q).style("opacity",1),u=h.rangeExtent?h.rangeExtent():c(h.range()),v=n.selectAll(".domain").data([0]);v.enter().append("path").attr("class","domain");var w=nf.transition(v),x=h.copy(),y=this.__chart__||x;this.__chart__=x,r.append("line"),r.append("text");var z=r.select("line"),A=t.select("line"),B=q.select("text"),C=r.select("text"),D=t.select("text");switch(o=(x(1)-x(0))/2,g=m?0:o,i){case"bottom":e=a,z.attr("y2",j),C.attr("y",Math.max(j,0)+l),A.attr("x1",g).attr("x2",g).attr("y2",j),D.attr("x",0).attr("y",Math.max(j,0)+l),B.attr("dy",".71em").style("text-anchor","middle"),B.text(f),w.attr("d","M"+u[0]+","+k+"V0H"+u[1]+"V"+k);break;case"left":e=b,z.attr("x2",-j),C.attr("x",-(Math.max(j,0)+l)),A.attr("x2",-j).attr("y2",0),D.attr("x",-(Math.max(j,0)+l)).attr("y",o),B.attr("dy",".32em").style("text-anchor","end"),B.text(f),w.attr("d","M"+-k+","+u[0]+"H0V"+u[1]+"H"+-k)}if(h.ticks)r.call(e,y),t.call(e,x),s.call(e,x);else{var E=x.rangeBand()/2,F=function(a){return x(a)+E};r.call(e,F),t.call(e,F)}})}var h=nf.scale.linear(),i="bottom",j=6,k=6,l=3,m=!1,n=10,o=0,p=null,q=!0,r=[];return g.scale=function(a){return arguments.length?(h=a,g):h},g.orient=function(a){return arguments.length?(i=a in{top:1,right:1,bottom:1,left:1}?a+"":"bottom",g):i},g.categories=function(a){return arguments.length?(r=a,g):r},g.tickCentered=function(a){return arguments.length?(m=a,g):m},g.tickFormat=function(a){return arguments.length?(p=a,g):p},g.tickOffset=function(){return o},g.ticks=function(a){return arguments.length?(n=a,g):n},g.tickCulling=function(a){return arguments.length?(q=a,g):q},g.tickValues=function(){},g}function Cb(a){var b=!1;return Sf(Dc(of.data.targets)).forEach(function(c){return b||c.data.id!==a.data.id?void 0:(b=!0,void(a=c))}),b?a:null}function Db(){var a=nf.svg.arc().outerRadius(Mf).innerRadius(Of),b=function(b,c){var d;return c?a(b):(d=Cb(b),d?a(d):"M 0 0")};return b.centroid=a.centroid,b}function Eb(a){var b=nf.svg.arc().outerRadius(Nf*(a?a:1)).innerRadius(Of);return function(a){var c=Cb(a);return c?b(c):"M 0 0"}}function Fb(a,b){return de(a.data)?Pf(a,b):"M 0 0"}function Gb(a){var b,c,d,e,f=Cb(a),g="";return f&&(b=Pf.centroid(f),c=b[0],d=b[1],e=Math.sqrt(c*c+d*d),g="translate("+c/e*Mf*.8+","+d/e*Mf*.8+")"),g}function Hb(a){return a?(a.endAngle-a.startAngle)/(2*Math.PI):null}function Ib(a){return lc({id:a.data.id,value:a.value,ratio:Hb(a)})}function Jb(a){var b,c,d,e;return Mb()?(b=Cb(a),c=b?b.value:null,d=Hb(b),e=Nb(),e?e(c,d):sd(c,d)):""}function Kb(a,b){var c=Qi.selectAll("."+f.chartArc+hd(a)),d=Qi.selectAll("."+f.arc).filter(function(b){return b.data.id!==a});he(a)&&c.selectAll("path").transition().duration(50).attr("d",Qf).transition().duration(100).attr("d",Rf).each(function(a){ce(a.data)}),b||d.style("opacity",.3)}function Lb(a){var b=Qi.selectAll("."+f.chartArc+hd(a));b.selectAll("path").transition().duration(50).attr("d",Pf),Qi.selectAll("."+f.arc).style("opacity",1)}function Mb(){return Xd(of.data.targets)?Th:Nh}function Nb(){return Xd(of.data.targets)?Uh:Oh}function Ob(){return Xd(of.data.targets)?Wh:""}function Pb(){var a=Xd(of.data.targets)?Xh:Qh;return"function"==typeof a?a:function(){}}function Qb(){var a=Xd(of.data.targets)?Yh:Rh;return"function"==typeof a?a:function(){}}function Rb(){var a=Xd(of.data.targets)?Zh:Sh;return"function"==typeof a?a:function(){}}function Sb(a){var b,c,d,e,f,g,h=xc(a),i=Kc(a);if(pg.length>0)for(g=Mc(a),b=0;b<pg.length;b++)if(e=pg[b].filter(function(a){return h.indexOf(a)>=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;c<e.length;c++)f=e[c],i[f]&&i[f].forEach(function(a,b){Z(f)!==Z(d)||!i[d]||g&&+a>0||(i[d][b]+=+a)});return nf.min(Object.keys(i).map(function(a){return nf.min(i[a])}))}function Tb(a){var b,c,d,e,f,g,h=xc(a),i=Kc(a);if(pg.length>0)for(g=Nc(a),b=0;b<pg.length;b++)if(e=pg[b].filter(function(a){return h.indexOf(a)>=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<e.length;c++)f=e[c],i[f]&&i[f].forEach(function(a,b){Z(f)!==Z(d)||!i[d]||g&&0>+a||(i[d][b]+=+a)});return nf.max(Object.keys(i).map(function(a){return nf.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?rh:ih,n="y2"===c?qh:hh,o=b(m)?m:Sb(l),p=b(n)?n:Tb(l),q="y2"===c?sh:jh,r=pd()&&Sg;return 0===l.length?"y2"===c?bg.domain():ag.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=qd(o,p),j=$b(ag.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&&nh&&(f=b(nh.top)?nh.top:e,g=b(nh.bottom)?nh.bottom:e),"y2"===c&&wh&&(f=b(wh.top)?wh.top:e,g=b(wh.bottom)?wh.bottom:e),Ud(l)&&!Mc(l)&&(g=o),[o-g,p+f])}function Vb(a){var b=$b(Xi),c=$b(_f.domain());return a||0===c?1:b/c}function Wb(a){return ch?ch:nf.min(a,function(a){return nf.min(a.values,function(a){return a.x})})}function Xb(a){return bh?bh:nf.max(a,function(a){return nf.max(a.values,function(a){return a.x})})}function Yb(a,c){var d,e,f,g,h=c[0],i=c[1],j=Math.abs(h-i);return ni?e=0:Ud(a)?(d=vc(),e=d>1?j/(d-1)/2:.5):e=.01*j,"object"==typeof dh&&oe(dh)?(f=b(dh.left)?dh.left:e,g=b(dh.right)?dh.right:e):f=g="number"==typeof dh?dh:e,{left:f,right:g}}function Zb(a){var b=[Wb(a),Xb(a)],c=b[0],d=b[1],e=Yb(a,b),f=0,g=0;return(c||0===c)&&(f=mi?new Date(c.getTime()-e.left):c-e.left),(d||0===d)&&(g=mi?new Date(d.getTime()+e.right):d+e.right),[f,g]}function $b(a){return a[1]-a[0]}function _b(a){for(var b=0;b<a.length;b++)if(!(a[b]in pf))return!1;return!0}function ac(a,b){pf[a]=sc(b)}function bc(a){for(var b=[],c=0;c<a.length;c++)a[c]in pf&&b.push(sc(pf[a[c]]));return b}function cc(a){return"start"in a?_f(mi?je(a.start):a.start):0}function dc(a){var b=cc(a),c="end"in a?_f(mi?je(a.end):a.end):Gf,d=c-b;return 0>d?0:d}function ec(a){return jg&&a===jg||oe(kg)&&pe(kg,a)}function fc(a){return!ec(a)}function gc(a){return jg?jg:oe(kg)?kg[a]:null}function hc(a,b){var c,d=b&&oe(b)?xc(b):[];return d.forEach(function(b){gc(b)===a&&(c=of.data.xs[b])}),c}function ic(a,b){return a in of.data.xs&&of.data.xs[a]&&of.data.xs[a][b]?of.data.xs[a][b]:b}function jc(a){Object.keys(a).forEach(function(b){kg[b]=a[b]})}function kc(a){return 1===nf.set(Object.keys(a).map(function(b){return a[b]})).size()}function lc(a){var b;return a&&(b=ng[a.id],a.name=b?b:a.id),a}function mc(a,b){a.forEach(function(a){a.values.forEach(function(c,d){c.x=oc(b[d],a.id,d)}),of.data.xs[a.id]=b})}function nc(a,b){a.forEach(function(a){b[a.id]&&mc([a],b[a.id])})}function oc(a,b,c){var d;return d=mi?a?a instanceof Date?a:je(a):je(ic(b,c)):oi&&!ni?a?+a:ic(b,c):c}function pc(a){var b,c,d=a[0],e={},f=[];for(b=1;b<a.length;b++){for(e={},c=0;c<a[b].length;c++)e[d[c]]=a[b][c];f.push(e)}return f}function qc(a){var b,d,e,f=[];for(b=0;b<a.length;b++)for(e=a[b][0],d=1;d<a[b].length;d++)c(f[d-1])&&(f[d-1]={}),f[d-1][e]=a[b][d];return f}function rc(a){var c,d=nf.keys(a[0]).filter(fc),e=nf.keys(a[0]).filter(ec);return d.forEach(function(c){var d,f=gc(c);oi||mi?e.indexOf(f)>=0?of.data.xs[c]=a.map(function(a){return a[f]}).filter(b):jg?(d=Object.keys(of.data.xs),of.data.xs[c]=d.length>0?of.data.xs[d[0]]:void 0):oe(kg)&&(of.data.xs[c]=hc(f,of.data.targets)):of.data.xs[c]=a.map(function(a,b){return b})}),d.forEach(function(a){if(!of.data.xs[a])throw new Error('x is not defined for id = "'+a+'".')}),c=d.map(function(b,c){var d=mg(b);return{id:d,id_org:b,values:a.map(function(a,e){var f=gc(b),g=a[f],h=oc(g,b,e);return oi&&ni&&0===c&&g&&(0===e&&(Vg=[]),Vg.push(g)),("undefined"==typeof a[b]||of.data.xs[b].length<=e)&&(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})}}),c.forEach(function(a){var b;a.values=a.values.sort(function(a,b){var c=a.x||0===a.x?a.x:1/0,d=b.x||0===b.x?b.x:1/0;return c-d}),b=0,a.values.forEach(function(a){a.index=b++})}),rg&&Sd(xc(c).filter(function(a){return!(a in sg)}),rg),c.forEach(function(a){ac(a.id_org,a)}),c}function sc(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 tc(a){return a>0&&of.data.targets[0].values[a-1]?of.data.targets[0].values[a-1].x:void 0}function uc(a){return a<vc()-1?of.data.targets[0].values[a+1].x:void 0}function vc(){return nf.max(of.data.targets,function(a){return a.values.length})}function wc(){var a,b=of.data.targets.length,c=0;return b>1?of.data.targets.forEach(function(b){b.values.length>c&&(a=b,c=b.values.length)}):a=b?of.data.targets[0]:null,a}function xc(a){return a.map(function(a){return a.id})}function yc(a){return a?"string"==typeof a?[a]:a:xc(of.data.targets)}function zc(a,b){var c,d=xc(a);for(c=0;c<d.length;c++)if(d[c]===b)return!0;return!1}function Ac(a){return d(a)?of.data.targets.filter(a):of.data.targets}function Bc(a){return xi.indexOf(a)<0}function Cc(a){return yi.indexOf(a)<0}function Dc(a){return a.filter(function(a){return Bc(a.id)})}function Ec(a){var b=nf.set(nf.merge(a.map(function(a){return a.values.map(function(a){return a.x})}))).values();return b.map(mi?function(a){return new Date(a)}:function(a){return+a})}function Fc(a){var b,c,d,e,f,g,h,i=a;if(!_g&&$g)if(b="function"==typeof $g?$g():$g,1===b)i=[a[0]];else if(2===b)i=[a[0],a[a.length-1]];else if(b>2){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(mi?new Date(h):h);i.push(d)}return mi||(i=i.sort(function(a,b){return a-b})),i}function Gc(a){xi=xi.concat(a)}function Hc(a){xi=xi.filter(function(b){return a.indexOf(b)<0})}function Ic(a){yi=yi.concat(a)}function Jc(a){yi=yi.filter(function(b){return a.indexOf(b)<0})}function Kc(a){var b={};return a.forEach(function(a){b[a.id]=[],a.values.forEach(function(c){b[a.id].push(c.value)})}),b}function Lc(a,b){var c,d,e,f=Object.keys(a);for(c=0;c<f.length;c++)for(e=a[f[c]].values,d=0;d<e.length;d++)if(b(e[d].value))return!0;return!1}function Mc(a){return Lc(a,function(a){return 0>a})}function Nc(a){return Lc(a,function(a){return a>0})}function Oc(a){return a<Vg.length?Vg[a]:a}function Pc(a,b){return" "+a+" "+a+gd(b)}function Qc(a){return Pc(f.text,a.id)}function Rc(a){return Pc(f.texts,a.id)}function Sc(a,b){return Pc(f.shape,b)}function Tc(a){return Pc(f.shapes,a.id)}function Uc(a){return Tc(a)+Pc(f.line,a.id)}function Vc(a,b){return Sc(a,b)+Pc(f.circle,b)}function Wc(a){return Tc(a)+Pc(f.circles,a.id)}function Xc(a,b){return Sc(a,b)+Pc(f.bar,b)}function Yc(a){return Tc(a)+Pc(f.bars,a.id)}function Zc(a){return Tc(a.data)+Pc(f.arc,a.data.id)}function $c(a){return Tc(a)+Pc(f.area,a.id)}function _c(a,b){return Pc(f.region,b)+" "+("class"in a?a.class:"")}function ad(a,b){return Pc(f.eventRect,b)}function bd(a){var b=og[a],c="";return b&&(c=" "+f.target+"-"+b),Pc(f.target,a)+c}function cd(a){return f.chartText+bd(a.id)}function dd(a){return f.chartLine+bd(a.id)}function ed(a){return f.chartBar+bd(a.id)}function fd(a){return f.chartArc+bd(a.data.id)}function gd(a){return a||0===a?"-"+(a.replace?a.replace(/([^a-zA-Z0-9-_])/g,"-"):a):""}function hd(a){return"."+f.target+gd(a)}function id(a){return a.map(function(a){return hd(a)})}function jd(a){return"."+f.legendItem+gd(a)}function kd(a){return a.map(function(a){return jd(a)})}function ld(a){return null!==a.value&&Zi[a.id]?1:0}function md(a){var b=od(a);return ld(a)*b}function nd(a){return b(a.value)?ae(a)?.5:1:0}function od(){return pd()?1:0}function pd(){return"boolean"==typeof tg&&tg?!0:"object"==typeof tg&&oe(tg)?!0:!1}function qd(a,b){var c=[],d=1.3;return nf.select("svg").selectAll(".dummy").data([a,b]).enter().append("text").text(function(a){return a}).each(function(a,b){c[b]=this.getBoundingClientRect().width*d}).remove(),c}function rd(a){var c=mh?mh:function(a){return b(a)?+a:""};return c(a)}function sd(a,b){return(100*b).toFixed(1)+"%"}function td(a){var c=function(a){return b(a)?+a:""},d=Z(a),e=c;return"function"==typeof tg.format?e=tg.format:"object"==typeof tg.format&&"function"==typeof tg.format[d]&&(e=tg.format[d]),e}function ud(a){return a?_f(a.x):null}function vd(a){return _f(mi?je(a.value):a.value)}function wd(a){var b=a.axis&&"y2"===a.axis?bg:ag;return b(a.value)}function xd(a){return cg(a.x)}function yd(a,b){var c,d=a[b].x,e=[];for(c=b-1;c>=0&&d===a[c].x;c--)e.push(a[c]);for(c=b;c<a.length&&d===a[c].x;c++)e.push(a[c]);return e}function zd(a,b,c,d){var e,f=c?c:0,g=d?d:a.length-1,h=Math.floor((g-f)/2)+f,i=a[h],j=_f(i.x)-b[Sg?1:0];return j>0?g=h:f=h,g-f===1||0===f&&0===g?(e=[],a[f].x&&(e=e.concat(yd(a,f))),a[g].x&&(e=e.concat(yd(a,g))),Bd(e,b)):zd(a,b,f,g)}function Ad(a,b){var c;return c=a.map(function(a){return zd(a.values,b)}),Bd(c,b)}function Bd(a,b){var c,d;return a.forEach(function(a){var e=qe(a,b);(c>e||!c)&&(c=e,d=a)}),d}function Cd(a,b){return nf.merge(a.map(function(a){return a.values})).filter(function(a){return a.x===b})}function Dd(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 Ed(){return ug&&"desc"===ug.toLowerCase()}function Fd(){return ug&&"asc"===ug.toLowerCase()}function Gd(a){var b=Fd(),c=Ed();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 ug&&a.sort(ug),a}function Hd(a,c){var d,e,f,g,h,i,j,k=Yd(of.data.targets),l=k?sd:rd,m=a.filter(function(a){return a&&b(a.value)});_h&&0!==m.length&&(Vi.html(ci(a,$(),l,ui)).style("display","block"),d=Vi.property("offsetWidth"),e=Vi.property("offsetHeight"),k?(g=Gf/2+c[0],i=If/2+c[1]+20):(Sg?(f=q(),g=f+c[0]+100,h=g+d,j=r()-u(),i=_f(m[0].x)+20):(f=q(),g=f+t()+_f(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)),Vi.style("top",i+"px").style("left",g+"px"))}function Id(){Vi.style("display","none")}function Jd(a){var c=a.filter(function(a){return a&&b(a.value)});_h&&(Vd(of.data.targets)||Yd(of.data.targets)||Si.selectAll("line."+f.xgridFocus).style("visibility","visible").data([c[0]]).attr(Sg?"y1":"x1",ud).attr(Sg?"y2":"x2",ud))}function Kd(){Si.select("line."+f.xgridFocus).style("visibility","hidden")}function Ld(a){return a.x||0===a.x?_f(a.x):null}function Md(a){return V(a.id)(a.value)}function Nd(){var a,b,d={},e=0;return Dc(Ac(_d)).forEach(function(f){for(a=0;a<pg.length;a++)if(!(pg[a].indexOf(f.id)<0))for(b=0;b<pg[a].length;b++)if(pg[a][b]in d){d[f.id]=d[pg[a][b]];break}c(d[f.id])&&(d[f.id]=e++)}),d.__max__=e-1,d}function Od(a,b,c,d){var e=d?cg:_f;return function(d){var f=d.id in c?c[d.id]:0;return d.x||0===d.x?e(d.x)-a*(b/2-f):0}}function Pd(a){return function(b){var c=a?W(b.id):V(b.id);return c(b.value)}}function Qd(a,b){var c=Gd(Dc(Ac(_d))),d=c.map(function(a){return a.id});return function(e,f){var g=b?W(e.id):V(e.id),h=g(0),i=h;return c.forEach(function(b){b.id!==e.id&&a[b.id]===a[e.id]&&d.indexOf(b.id)<d.indexOf(e.id)&&b.values[f].value*e.value>0&&(i+=g(b.values[f].value)-h)}),i}}function Rd(a,b){return Lh?Lh:b?2*a.tickOffset()*Mh/b:0}function Sd(a,b){yc(a).forEach(function(a){Zi[a]=b===sg[a],sg[a]=b})}function Td(a,b){var c=!1;return a.forEach(function(a){sg[a.id]===b&&(c=!0),a.id in sg||"line"!==b||(c=!0)}),c}function Ud(a){return Td(a,"bar")}function Vd(a){return Td(a,"scatter")}function Wd(a){return Td(a,"pie")}function Xd(a){return Td(a,"donut")}function Yd(a){return Wd(a)||Xd(a)}function Zd(a){var b="string"==typeof a?a:a.id;return!(b in sg)||"line"===sg[b]||"spline"===sg[b]||"area"===sg[b]||"area-spline"===sg[b]}function $d(a){var b="string"==typeof a?a:a.id;return"spline"===sg[b]||"area-spline"===sg[b]}function _d(a){var b="string"==typeof a?a:a.id;return"bar"===sg[b]}function ae(a){var b="string"==typeof a?a:a.id;return"scatter"===sg[b]}function be(a){var b="string"==typeof a?a:a.id;return"pie"===sg[b]}function ce(a){var b="string"==typeof a?a:a.id;return"donut"===sg[b]}function de(a){return be(a)||ce(a)}function ee(a){return _d(a)?a.values:[]}function fe(a){return Zd(a)||ae(a)?a.values:[]}function ge(a){return _d(a)||Zd(a)?a.values:[]}function he(a){return ce(a)&&Vh||be(a)&&Ph}function ie(a,b,c){var d=[];return function(e){var f,g=e.id||e;return a[g]instanceof Function?f=a[g](e):g in a?f=a[g]:(d.indexOf(g)<0&&d.push(g),f=b[d.indexOf(g)%b.length]),c instanceof Function?c(f,e):f}}function je(b){var c;try{c=lg?nf.time.format(lg).parse(b):new Date(b)}catch(d){a.console.error("Failed to parse x '"+b+"' to Date with format "+lg)}return c}function ke(a,b){var c=nf.mouse(a),d=nf.select(a),e=1*d.attr("cx"),f=1*d.attr("cy");return Math.sqrt(Math.pow(e-c[0],2)+Math.pow(f-c[1],2))<b}function le(a){var b=nf.mouse(a),c=a.getBoundingClientRect(),d=a.pathSegList.getItem(0),e=a.pathSegList.getItem(1),f=d.x,g=Math.min(d.y,e.y),h=c.width,i=c.height,j=2,k=f-j,l=f+h+j,m=g+i+j,n=g-j;return k<b[0]&&b[0]<l&&n<b[1]&&b[1]<m}function me(a,b){var c;for(c=0;c<b.length;c++)if(b[c].start<a&&a<=b[c].end)return!0;return!1}function ne(a){return!a||"string"==typeof a&&0===a.length||"object"==typeof a&&0===Object.keys(a).length}function oe(a){return Object.keys(a).length>0}function pe(a,b){var c=!1;return Object.keys(a).forEach(function(d){a[d]===b&&(c=!0)}),c}function qe(a,b){var c="y"===Z(a.id)?ag:bg,d=Sg?1:0,e=Sg?0:1;return Math.pow(_f(a.x)-b[d],2)+Math.pow(c(a.value)-b[e],2)}function re(a,b){var c=0;a.each(function(){++c}).each("end",function(){--c||b.apply(this,arguments)})}function se(a,b,c){Fg(b,a.node()),Si.select("."+f.selectedCircles+gd(b.id)).selectAll("."+f.selectedCircle+"-"+c).data([b]).enter().append("circle").attr("class",function(){return Pc(f.selectedCircle,c)}).attr("cx",Sg?Md:Ld).attr("cy",Sg?Ld:Md).attr("stroke",function(){return ui(b)}).attr("r",1.4*Jh).transition().duration(100).attr("r",Jh)}function te(a,b,c){Gg(b,a.node()),Si.select("."+f.selectedCircles+gd(b.id)).selectAll("."+f.selectedCircle+"-"+c).transition().duration(100).attr("r",0).remove()}function ue(a,b,c,d){a?se(b,c,d):te(b,c,d)}function ve(a,b){Fg(b,a.node()),a.transition().duration(100).style("fill",function(){return nf.rgb(ui(b)).darker(1)})}function we(a,b){Gg(b,a.node()),a.transition().duration(100).style("fill",function(){return ui(b)})}function xe(a,b,c,d){a?ve(b,c,d):we(b,c,d)}function ye(a){return a.filter(function(a){return b(a.value)})}function ze(a,c){return(c?Si.selectAll("."+f.circles+gd(c)):Si).selectAll("."+f.circle+(b(a)?"-"+a:""))}function Ae(a,b){ze(a,b).classed(f.EXPANDED,!0).attr("r",Ih)}function Be(a){ze(a).filter(function(){return nf.select(this).classed(f.EXPANDED)}).classed(f.EXPANDED,!1).attr("r",Fh)}function Ce(a){return Si.selectAll("."+f.bar+(b(a)?"-"+a:""))}function De(a){Ce(a).classed(f.EXPANDED,!0)}function Ee(a){Ce(a).classed(f.EXPANDED,!1)}function Fe(a,b){var c=Je(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 Ge(a,b){var c=Je(a,!1),d=b?He:Ie;return function(a,b){return d(c(a,b),a,this)}}function He(a,b){var c;return Sg?(c=_d(b)?4:6,a[2][1]+c*(b.value<0?-1:1)):a[0][0]+(a[2][0]-a[0][0])/2}function Ie(a,b,c){var d=c.getBoundingClientRect();return Sg?(a[0][0]+a[2][0]+.6*d.height)/2:a[2][1]+(b.value<0?d.height:_d(b)?-3:-6)}function Je(a,b){var c=a.__max__+1,d=Rd(fg,c),e=Od(d,c,a,!!b),f=Pd(!!b),g=Qd(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 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 Ke(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<f.length;g++)t[g]={},t[g].start=c(f[g].start)?a[0].x:mi?je(f[g].start):f[g].start,t[g].end=c(f[g].end)?a[a.length-1].x:mi?je(f[g].end):f[g].end;for(p=Sg?function(a){return e(a.value)}:function(a){return b(a.x)},q=Sg?function(a){return b(a.x)}:function(a){return e(a.value)},i=mi?function(a,c,d,f){var g=a.x.getTime(),h=c.x-a.x,i=new Date(g+h*d),j=new Date(g+h*(d+f));return"M"+b(i)+" "+e(k(d))+" "+b(j)+" "+e(k(d+f))}:function(a,c,d,f){return"M"+b(j(d))+" "+e(k(d))+" "+b(j(d+f))+" "+e(k(d+f))},g=0;g<a.length;g++){if(c(t)||!me(a[g].x,t))s+=" "+p(a[g])+" "+q(a[g]);else{j=T(a[g-1].x,a[g].x),k=U(a[g-1].value,a[g].value),l=b(a[g].x)-b(a[g-1].x),m=e(a[g].value)-e(a[g-1].value),n=Math.sqrt(Math.pow(l,2)+Math.pow(m,2)),o=2/n;var u=2*o;for(h=o;1>=h;h+=u)s+=i(a[g-1],a[g],h,o)}r=a[g].x}return s}function Le(b){var c,d,e;if(Wi=nf.select(qf),Wi.empty())throw new Error('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');if(Wi.html(""),Wi.classed("c3",!0),of.data.xs={},of.data.targets=rc(b),n(),R(),_f.domain(nf.extent(Zb(of.data.targets))),ag.domain(Ub(of.data.targets,"y")),bg.domain(Ub(of.data.targets,"y2")),cg.domain(_f.domain()),dg.domain(ag.domain()),eg.domain(bg.domain()),Xi=_f.domain(),Li.scale(cg),vf&&Pi.scale(_f),Qi=Wi.append("svg").attr("width",Gf+Df.left+Df.right).attr("height",If+Df.top+Df.bottom).on("mouseenter",yf).on("mouseleave",zf),Ri=Qi.append("defs"),Ri.append("clipPath").attr("id",gi).append("rect").attr("width",Gf).attr("height",If),Ri.append("clipPath").attr("id",hi).append("rect").attr("x",B).attr("y",C).attr("width",H).attr("height",I),Ri.append("clipPath").attr("id",ii).append("rect").attr("x",D).attr("y",E).attr("width",J).attr("height",K),Si=Qi.append("g").attr("transform",Di.main),Ti=Jg?Qi.append("g").attr("transform",Di.context):null,Ui=Qi.append("g").attr("transform",Di.legend),Mg||(Ui.style("visibility","hidden"),yi=xc(of.data.targets)),Vi=nf.select(qf).style("position","relative").append("div").style("position","absolute").style("pointer-events","none").style("z-index","10").style("display","none"),hf(xc(of.data.targets),{withTransform:!1,withTransitionForTransform:!1}),Si.append("g").attr("class",f.axisX).attr("clip-path",Sg?"":ki).attr("transform",Di.x).append("text").attr("class",f.axisXLabel).attr("transform",Sg?"rotate(-90)":"").attr("dx",qb).attr("dy",tb).style("text-anchor",wb),gh&&Si.append("g").attr("class",f.axisY).attr("clip-path",Sg?li:"").attr("transform",Di.y).append("text").attr("class",f.axisYLabel).attr("transform",Sg?"":"rotate(-90)").attr("dx",rb).attr("dy",ub).style("text-anchor",xb),ph&&Si.append("g").attr("class",f.axisY2).attr("transform",Di.y2).append("text").attr("class",f.axisY2Label).attr("transform",Sg?"":"rotate(-90)").attr("dx",sb).style("text-anchor",yb),d=Si.append("g").attr("clip-path",ji).attr("class",f.grid),yh&&d.append("g").attr("class",f.xgrids),oe(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),oe(Ch)&&d.append("g").attr("class",f.ygridLines),Si.append("g").attr("clip-path",ji).attr("class",f.regions),Si.append("g").attr("clip-path",ji).attr("class",f.chart),c=Si.select("."+f.chart).append("g").attr("class",f.eventRects).style("fill-opacity",0).style("cursor",vf?Sg?"ns-resize":"ew-resize":null),Si.select("."+f.chart).append("g").attr("class",f.chartBars),Si.select("."+f.chart).append("g").attr("class",f.chartLines),Si.select("."+f.chart).append("g").attr("class",f.chartArcs).attr("transform",Di.arc).append("text").attr("class",f.chartArcsTitle).style("text-anchor","middle").text(Ob()),Si.select("."+f.chart).append("g").attr("class",f.chartTexts),vf&&Si.insert("rect",xf?null:"g."+f.grid).attr("class",f.zoomRect).attr("width",Gf).attr("height",If).style("opacity",0).style("cursor",Sg?"ns-resize":"ew-resize").call(Pi).on("dblclick.zoom",null),eh&&Li.extent("function"!=typeof eh?eh:eh(Zb())),Jg&&(Ti.append("g").attr("clip-path",ji).attr("class",f.chart),Ti.select("."+f.chart).append("g").attr("class",f.chartBars),Ti.select("."+f.chart).append("g").attr("class",f.chartLines),Ti.append("g").attr("clip-path",ji).attr("class",f.brush).call(Li).selectAll("rect").attr(Sg?"width":"height",Sg?Hf:Jf),Ti.append("g").attr("class",f.axisX).attr("transform",Di.subx).attr("clip-path",Sg?"":ki)),Ye(of.data.targets),Sg?Si.select("."+f.axisX).style("opacity",0).call(fg):(Si.select("."+f.axisY).style("opacity",0).call(gg),Si.select("."+f.axisY2).style("opacity",0).call(hg)),Se({withTransform:!0,withUpdateXDomain:!0,withUpdateOrgXDomain:!0,withTransitionForAxis:!1}),di){if(mi&&"string"==typeof ei){for(ei=je(ei),e=0;e<of.data.targets[0].values.length&&of.data.targets[0].values[e].x-ei!==0;e++);ei=e |
|
}Vi.html(ci(of.data.targets.map(function(a){return lc(a.values[ei])}),$(),rd,ui)),Vi.style("top",fi.top).style("left",fi.left).style("display","block")}null==a.onresize&&(a.onresize=Ve()),a.onresize.add&&(a.onresize.add(Af),a.onresize.add(function(){Xe({withLegend:!0,withTransition:!1,withTransitionForTransform:!1})}),a.onresize.add(Bf))}function Me(a){a.append("rect").attr("class",ad).style("cursor",yg&&zg?"pointer":null).on("mouseover",function(a,b){if(!qi&&!Yd(of.data.targets)){var c,d,e=of.data.targets.map(function(a){return lc(a.values[b])});if(Object.keys(ng).length>0){d=[];for(var g in ng)for(c=0;c<e.length;c++)if(e[c].id===g){d.push(e[c]),e.shift(c);break}e=d.concat(e)}Hh&&Ae(b),De(b),Si.selectAll("."+f.shape+"-"+b).each(function(a){Dg(a)})}}).on("mouseout",function(a,b){Yd(of.data.targets)||(Kd(),Id(),Be(b),Ee(),Si.selectAll("."+f.shape+"-"+b).each(function(a){Eg(a)}))}).on("mousemove",function(a,b){var c;qi||Yd(of.data.targets)||(c=Dc(of.data.targets).map(function(a){return lc(a.values[b])}),Hd(c,nf.mouse(this)),Jd(c),yg&&(zg||Si.selectAll("."+f.shape+"-"+b).filter(function(a){return Ag(a)}).each(function(){var a=nf.select(this).classed(f.EXPANDED,!0);"circle"===this.nodeName&&a.attr("r",Ih),Qi.select("."+f.eventRect+"-"+b).style("cursor",null)}).filter(function(){return"circle"===this.nodeName?ke(this,Jh):"path"===this.nodeName?le(this):void 0}).each(function(){var a=nf.select(this);a.classed(f.EXPANDED)||(a.classed(f.EXPANDED,!0),"circle"===this.nodeName&&a.attr("r",Jh)),Qi.select("."+f.eventRect+"-"+b).style("cursor","pointer")})))}).on("click",function(a,b){return Yd(of.data.targets)?void 0:ri?void(ri=!1):void Si.selectAll("."+f.shape+"-"+b).each(function(a){Oe(this,a,b)})}).call(nf.behavior.drag().origin(Object).on("drag",function(){Pe(nf.mouse(this))}).on("dragstart",function(){Qe(nf.mouse(this))}).on("dragend",function(){Re()})).call(Pi).on("dblclick.zoom",null)}function Ne(a){a.append("rect").attr("x",0).attr("y",0).attr("width",Gf).attr("height",If).attr("class",f.eventRect).on("mouseout",function(){Yd(of.data.targets)||(Kd(),Id(),Be())}).on("mousemove",function(){var a,b,c,d;qi||Yd(of.data.targets)||(a=nf.mouse(this),b=Ad(of.data.targets,a),c=Cd(of.data.targets,b.x),d=c.map(function(a){return lc(a)}),Hd(d,a),Hh&&(Be(),Ae(b.index,b.id)),Jd(d),qe(b,a)<100?(Qi.select("."+f.eventRect).style("cursor","pointer"),si||(Dg(b),si=!0)):(Qi.select("."+f.eventRect).style("cursor",null),Eg(b),si=!1))}).on("click",function(){var a,b;Yd(of.data.targets)||(a=nf.mouse(this),b=Ad(of.data.targets,a),qe(b,a)<100&&Si.select("."+f.circles+"-"+gd(b.id)).select("."+f.circle+"-"+b.index).each(function(){Oe(this,b,b.index)}))}).call(nf.behavior.drag().origin(Object).on("drag",function(){Pe(nf.mouse(this))}).on("dragstart",function(){Qe(nf.mouse(this))}).on("dragend",function(){Re()})).call(Pi).on("dblclick.zoom",null)}function Oe(a,b,c){var d,e=nf.select(a),g=e.classed(f.SELECTED),h=!1;"circle"===a.nodeName?(h=ke(a,1.5*Jh),d=ue):"path"===a.nodeName&&(h=le(a),d=xe),(zg||h)&&(yg&&Ag(b)&&(Bg||Si.selectAll("."+f.shapes+(zg?gd(b.id):"")).selectAll("."+f.shape).each(function(a,b){var c=nf.select(this);c.classed(f.SELECTED)&&d(!1,c.classed(f.SELECTED,!1),a,b)}),e.classed(f.SELECTED,!g),d(!g,e,b,c)),Cg(b,a))}function Pe(a){var b,c,d,e,g,h,i,j;Yd(of.data.targets)||yg&&(!vf||Pi.altDomain)&&Bg&&(b=pi[0],c=pi[1],d=a[0],e=a[1],g=Math.min(b,d),h=Math.max(b,d),i=zg?Df.top:Math.min(c,e),j=zg?If:Math.max(c,e),Si.select("."+f.dragarea).attr("x",g).attr("y",i).attr("width",h-g).attr("height",j-i),Si.selectAll("."+f.shapes).selectAll("."+f.shape).filter(function(a){return Ag(a)}).each(function(a,b){var c,d,e,k,l,m,n=nf.select(this),o=n.classed(f.SELECTED),p=n.classed(f.INCLUDED),q=!1;"circle"===this.nodeName?(c=1*n.attr("cx"),d=1*n.attr("cy"),l=ue,q=c>g&&h>c&&d>i&&j>d):"path"===this.nodeName&&(m=Dd(this),c=m.x,d=m.y,e=m.width,k=m.height,l=xe,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 Qe(a){Yd(of.data.targets)||yg&&(pi=a,Si.select("."+f.chart).append("rect").attr("class",f.dragarea).style("opacity",.1),qi=!0,Hg())}function Re(){Yd(of.data.targets)||yg&&(Si.select("."+f.dragarea).transition().duration(100).style("opacity",0).remove(),Si.selectAll("."+f.shape).classed(f.INCLUDED,!1),qi=!1,Ig())}function Se(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,Q,R,S,T=Nd(),U=Yd(of.data.targets),V=Dc(of.data.targets);if(0!==V.length){if(a=d(a)?a:{},y=d(a.withY)?a.withY:!0,z=d(a.withSubchart)?a.withSubchart:!0,A=d(a.withTransition)?a.withTransition:!0,E=d(a.withTransform)?a.withTransform:!1,F=d(a.withUpdateXDomain)?a.withUpdateXDomain:!1,G=d(a.withUpdateOrgXDomain)?a.withUpdateOrgXDomain:!1,H=d(a.withLegend)?a.withLegend:!1,B=d(a.withTransitionForExit)?a.withTransitionForExit:A,C=d(a.withTransitionForAxis)?a.withTransitionForAxis:A,D=d(a.withTransitionForHorizontalAxis)?a.withTransitionForHorizontalAxis:A,N=A?Cf:0,O=B?N:0,P=C?N:0,H&&Mg&&hf(xc(of.data.targets),a),G&&(_f.domain(nf.extent(Zb(V))),Xi=_f.domain(),vf&&Pi.scale(_f).updateScaleExtent(),cg.domain(_f.domain()),Li.scale(cg)),F&&(_f.domain(Li.empty()?Xi:Li.extent()),vf&&Pi.scale(_f).updateScaleExtent()),ag.domain(Ub(V,"y")),bg.domain(Ub(V,"y2")),Vd(V)||(Q=ah?ah:Fc(Ec(V)),fg.tickValues(Q),ig.tickValues(Q)),c=Si.select("."+f.axisX).style("opacity",U?0:1),(Sg||D)&&(c=c.transition().duration(P)),c.call(fg),e=Si.select("."+f.axisY).style("opacity",U?0:1),(!Sg||D)&&(e=e.transition().duration(P)),e.call(gg),Si.select("."+f.axisY2).style("opacity",U?0:1).transition().duration(P).call(hg),F)if(Yg&&Q){for(R=1;R<Q.length;R++)if(Q.length/R<Zg){S=R;break}nf.selectAll("."+f.axisX+" .tick text").each(function(a){var b=Q.indexOf(a);b>=0&&nf.select(this).style("display",b%S?"none":"block")})}else nf.selectAll("."+f.axisX+" .tick text").style("display","block");if(I=Fe(T),K=Ge(T,!0),M=Ge(T,!1),Ab(),dg.domain(ag.domain()),eg.domain(bg.domain()),Vi.style("display","none"),o(),Si.select("line."+f.xgridFocus).style("visibility","hidden"),yh){if("year"===zh){h=[];for(var W=Zb(),X=W[0].getFullYear(),Y=W[1].getFullYear(),Z=X;Y>=Z;Z++)h.push(new Date(Z+"-01-01 00:00:00"))}else h=_f.ticks(10);g=Si.select("."+f.xgrids).selectAll("."+f.xgrid).data(h),g.enter().append("line").attr("class",f.xgrid),g.attr("x1",Sg?0:function(a){return _f(a)-fg.tickOffset()}).attr("x2",Sg?Gf:function(a){return _f(a)-fg.tickOffset()}).attr("y1",Sg?function(a){return _f(a)-fg.tickOffset()}:Df.top).attr("y2",Sg?function(a){return _f(a)-fg.tickOffset()}:If).style("opacity",function(){return+nf.select(this).attr(Sg?"y1":"x1")===(Sg?If:0)?0:1}),g.exit().remove()}oe(Ah)&&(i=Si.select("."+f.xgridLines).selectAll("."+f.xgridLine).data(Ah),j=i.enter().append("g").attr("class",function(a){return f.xgridLine+(a.class?a.class:"")}),j.append("line").style("opacity",0),j.append("text").attr("text-anchor","end").attr("transform",Sg?"":"rotate(-90)").attr("dx",Sg?0:-Df.top).attr("dy",-5).style("opacity",0),i.select("line").transition().duration(N).attr("x1",Sg?0:vd).attr("x2",Sg?Gf:vd).attr("y1",Sg?vd:Df.top).attr("y2",Sg?vd:If).style("opacity",1),i.select("text").transition().duration(N).attr("x",Sg?Gf:0).attr("y",vd).text(function(a){return a.text}).style("opacity",1),i.exit().transition().duration(N).style("opacity",0).remove()),y&&Bh&&(k=Si.select("."+f.ygrids).selectAll("."+f.ygrid).data(ag.ticks(Dh)),k.enter().append("line").attr("class",f.ygrid),k.attr("x1",Sg?ag:0).attr("x2",Sg?ag:Gf).attr("y1",Sg?0:ag).attr("y2",Sg?If:ag),k.exit().remove()),y&&oe(Ch)&&(l=Si.select("."+f.ygridLines).selectAll("."+f.ygridLine).data(Ch),m=l.enter().append("g").attr("class",function(a){return f.ygridLine+(a.class?a.class:"")}),m.append("line").style("opacity",0),m.append("text").attr("text-anchor","end").attr("transform",Sg?"rotate(-90)":"").attr("dx",Sg?0:-Df.top).attr("dy",-5).style("opacity",0),l.select("line").transition().duration(N).attr("x1",Sg?wd:0).attr("x2",Sg?wd:Gf).attr("y1",Sg?0:wd).attr("y2",Sg?If:wd).style("opacity",1),l.select("text").transition().duration(N).attr("x",Sg?0:Gf).attr("y",wd).text(function(a){return a.text}).style("opacity",1),l.exit().transition().duration(N).style("opacity",0).remove()),p=Si.selectAll("."+f.bars).selectAll("."+f.bar).data(ee),p.enter().append("path").attr("d",I).style("stroke","none").style("opacity",0).style("fill",function(a){return ui(a)}).attr("class",Xc),p.style("opacity",ld).transition().duration(N).attr("d",I).style("opacity",1),p.exit().transition().duration(O).style("opacity",0).remove(),r=Si.selectAll("."+f.texts).selectAll("."+f.text).data(ge),r.enter().append("text").attr("class",Qc).attr("text-anchor",function(a){return Sg?a.value<0?"end":"start":"middle"}).style("stroke","none").style("fill-opacity",0),r.text(function(a){return td(a.id)(a.value)}).style("fill-opacity",md).transition().duration(N).attr("x",K).attr("y",M).style("fill-opacity",od),r.exit().transition().duration(O).style("fill-opacity",0).remove(),Si.selectAll("."+f.line).style("opacity",ld).transition().duration(N).attr("d",Mi).style("opacity",1),Si.selectAll("."+f.area).style("opacity",0).transition().duration(N).attr("d",Ni).style("opacity",Yi),n=Si.selectAll("."+f.circles).selectAll("."+f.circle).data(fe),n.enter().append("circle").attr("class",Vc).style("opacity",0).attr("r",Fh),n.style("opacity",ld).transition().duration(N).style("opacity",nd).attr("cx",Sg?Md:Ld).attr("cy",Sg?Ld:Md),n.exit().remove(),Si.selectAll("."+f.chartArc).select("."+f.arc).attr("transform",E?"scale(0)":"").style("opacity",function(a){return a===this._current?0:1}).transition().duration(N).attrTween("d",function(a){var b,c=Cb(a);return c?(b=nf.interpolate(this._current,c),this._current=b(0),function(a){return Fb(b(a),!0)}):function(){return"M 0 0"}}).attr("transform",E?"scale(1)":"").style("opacity",1),Si.selectAll("."+f.chartArc).select("text").attr("transform",Gb).style("opacity",0).transition().duration(N).text(Jb).style("opacity",function(a){return Bc(a.data.id)&&de(a.data)?1:0}),Si.select("."+f.chartArcsTitle).style("opacity",Xd(of.data.targets)?1:0),Jg&&(null!==nf.event&&"zoom"===nf.event.type&&Li.extent(_f.orgDomain()).update(),z&&(Ti.select("."+f.axisX).style("opacity",U?0:1).transition().duration(N).call(ig),Li.empty()||Li.extent(_f.orgDomain()).update(),J=Fe(T,!0),s=Ti.selectAll("."+f.bars).selectAll("."+f.bar).data(ee),s.enter().append("path").attr("d",J).style("stroke","none").style("fill",function(a){return ui(a)}).attr("class",Xc),s.style("opacity",ld).transition().duration(N).attr("d",J).style("opacity",1),s.exit().transition().duration(N).style("opacity",0).remove(),Ti.selectAll("."+f.line).style("opacity",ld).transition().duration(N).attr("d",Oi).style("opacity",1))),Si.selectAll("."+f.selectedCircles).filter(function(a){return _d(a)}).selectAll("circle").remove(),Si.selectAll("."+f.selectedCircle).transition().duration(N).attr("cx",Sg?Md:Ld).attr("cy",Sg?Ld:Md),t=Si.select("."+f.eventRects),oe(kg)&&!kc(kg)?(t.classed(f.eventRectsMultiple)||t.classed(f.eventRectsMultiple,!0).classed(f.eventRectsSingle,!1).selectAll("."+f.eventRect).remove(),u=Si.select("."+f.eventRects).selectAll("."+f.eventRect).data([0]),Ne(u.enter()),u.attr("x",0).attr("y",0).attr("width",Gf).attr("height",If)):(t.classed(f.eventRectsSingle)||t.classed(f.eventRectsMultiple,!1).classed(f.eventRectsSingle,!0).selectAll("."+f.eventRect).remove(),oi&&!ni?(x=function(a,b){var c=tc(b),d=uc(b),e=of.data.xs[a.id][b];return(_f(d?d:e+50)-_f(c?c:e-50))/2},w=function(a,b){var c=tc(b),d=of.data.xs[a.id][b];return(_f(d)+_f(c?c:d-50))/2}):(x=L(),w=function(a){return _f(a.x)-x/2}),v=wc(),Si.select("."+f.eventRects).datum(v?v.values:[]),u=Si.select("."+f.eventRects).selectAll("."+f.eventRect).data(function(a){return a}),Me(u.enter()),u.attr("class",ad).attr("x",Sg?0:w).attr("y",Sg?w:0).attr("width",Sg?Gf:x).attr("height",Sg?x:If),u.exit().remove()),q=Si.select("."+f.regions).selectAll("rect."+f.region).data($h),q.enter().append("rect").style("fill-opacity",0),q.attr("class",_c).attr("x",Sg?0:cc).attr("y",Sg?cc:Df.top).attr("width",Sg?Gf:dc).attr("height",Sg?dc:If).transition().duration(N).style("fill-opacity",function(a){return b(a.opacity)?a.opacity:.1}),q.exit().transition().duration(N).style("fill-opacity",0).remove(),xc(of.data.targets).forEach(function(a){Zi[a]=!0})}}function Te(){Se({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}function Ue(){return"mousemove"===nf.event.sourceEvent.type&&Pi.altDomain?(_f.domain(Pi.altDomain),void Pi.scale(_f).updateScaleExtent()):(ni&&_f.orgDomain()[0]===Xi[0]&&_f.domain([Xi[0]-1e-10,_f.orgDomain()[1]]),Se({withTransition:!1,withY:!1,withSubchart:!1}),void("mousemove"===nf.event.sourceEvent.type&&(ri=!0)))}function Ve(){function a(){b.forEach(function(a){a()})}var b=[];return a.add=function(a){b.push(a)},a}function We(){Qi.attr("width",Kf).attr("height",Lf),Qi.select("#"+gi).select("rect").attr("width",Gf).attr("height",If),Qi.select("#"+hi).select("rect").attr("width",H),Qi.select("#"+ii).select("rect").attr("width",J),Qi.select("."+f.zoomRect).attr("width",Gf).attr("height",If)}function Xe(a){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(),We(),m(a.withTransition),Se(a)}function Ye(a){var b,c,d,e,g,h,i,j,k,l,m,n;i=Si.select("."+f.chartTexts).selectAll("."+f.chartText).data(a).attr("class",cd),j=i.enter().append("g").attr("class",cd).style("pointer-events","none"),j.append("g").attr("class",Rc).style("fill",function(a){return ui(a)}),e=Si.select("."+f.chartBars).selectAll("."+f.chartBar).data(a).attr("class",ed),d=e.enter().append("g").attr("class",ed).style("pointer-events","none"),d.append("g").attr("class",Yc).style("fill",function(a){return ui(a)}).style("stroke","none").style("cursor",function(a){return Ag(a)?"pointer":null}),c=Si.select("."+f.chartLines).selectAll("."+f.chartLine).data(a).attr("class",dd),b=c.enter().append("g").attr("class",dd).style("pointer-events","none"),b.append("path").attr("class",Uc).style("opacity",0).style("stroke",function(a){return ui(a)}),b.append("path").attr("class",$c).style("opacity",function(){return Yi=+nf.select(this).style("opacity"),0}).style("fill",function(a){return ui(a)}),b.append("g").attr("class",function(a){return Pc(f.selectedCircles,a.id)}),b.append("g").attr("class",Wc).style("fill",function(a){return ui(a)}).style("cursor",function(a){return Ag(a)?"pointer":null}),a.forEach(function(a){Si.selectAll("."+f.selectedCircles+gd(a.id)).selectAll("."+f.selectedCircle).each(function(b,c){b.value=a.values[c].value})}),h=Si.select("."+f.chartArcs).selectAll("."+f.chartArc).data(Sf(a)).attr("class",fd),g=h.enter().append("g").attr("class",fd),g.append("path").attr("class",Zc).style("opacity",0).style("fill",function(a){return ui(a.data)}).style("cursor",function(a){return Ag(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),cf(c.data.id),e(d,b)}).on("mousemove",function(a){var b=Cb(a),c=[Ib(b)];Hd(c,nf.mouse(this))}).on("mouseout",function(a,b){var c=Cb(a),d=Ib(c),e=Rb();Lb(c.data.id),ef(),Id(),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"),Jg&&(n=Ti.select("."+f.chartBars).selectAll("."+f.chartBar).data(a).attr("class",ed),m=n.enter().append("g").attr("class",ed),m.append("g").attr("class",Yc).style("fill",function(a){return ui(a)}),l=Ti.select("."+f.chartLines).selectAll("."+f.chartLine).data(a).attr("class",dd),k=l.enter().append("g").attr("class",dd),k.append("path").attr("class",Uc).style("opacity",0).style("stroke",function(a){return ui(a)})),Qi.selectAll("."+f.target).filter(function(a){return Bc(a.id)}).transition().style("opacity",1)}function Ze(a,b){(b.type||b.types)&&a.forEach(function(a){b.types?Sd(a.id,b.types[a.id]):Sd(a.id,b.type)}),of.data.targets.forEach(function(b){for(var c=0;c<a.length;c++)if(b.id===a[c].id){b.values=a[c].values,a.splice(c,1);break}}),of.data.targets=of.data.targets.concat(a),Ye(of.data.targets),Se({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0}),"function"==typeof b.done&&b.done()}function $e(a){if("data"in a)Ze(rc(a.data),a);else if("url"in a)nf.csv(a.url,function(b,c){Ze(rc(c),a)});else if("rows"in a)Ze(rc(pc(a.rows)),a);else{if(!("columns"in a))throw Error("url or rows or columns is required.");Ze(rc(qc(a.columns)),a)}}function _e(a,b){return"function"!=typeof b&&(b=function(){}),a=a.filter(function(a){return zc(of.data.targets,a)}),a&&0!==a.length?(Qi.selectAll(a.map(function(a){return hd(a)})).transition().style("opacity",0).remove().call(re,b),void a.forEach(function(a){Zi[a]=!1,Ui.selectAll("."+f.legendItem+gd(a)).remove(),of.data.targets=of.data.targets.filter(function(b){return b.id!==a})})):void b()}function af(a){var b=Ui.select(jd(a));return b.style("opacity",null),b.classed(f.legendItemHidden)?b.style("opacity"):1}function bf(a,b){var c=Ui.selectAll("."+f.legendItem).filter(function(){return!nf.select(this).classed(f.legendItemHidden)}),d=function(b){return!a||b===a},e=function(a){return!d(a)};c.filter(e).transition().duration(100).style("opacity",b?.3:af),c.filter(d).transition().duration(100).style("opacity",b?af:.3)}function cf(a){bf(a,!0)}function df(a){bf(a,!1)}function ef(){Ui.selectAll("."+f.legendItem).transition().duration(100).style("opacity",af)}function ff(a){Jc(a),Ui.selectAll(kd(a)).style("visibility","visible").transition().style("opacity",af),hf(xc(of.data.targets))}function gf(a){Ic(a),Ui.selectAll(kd(a)).style("opacity",0).style("visibility","hidden"),hf(xc(of.data.targets))}function hf(a,b){function c(b,c,d){function e(a,b){b||(f=(l-w-k)/2,v>f&&(f=(l-k)/2,w=0,C++)),B[a]=C,A[C]=f,x[a]=w,w+=k}var f,g,h=b.getBoundingClientRect(),i=10*Math.ceil((h.width+s)/10),j=10*Math.ceil((h.height+r)/10),k=Ei?j:i,l=Ei?Q():P();return d&&(w=0,C=0,t=0,u=0),Mg&&!Cc(c)?void(y[c]=z[c]=B[c]=x[c]=0):(y[c]=i,z[c]=j,(!t||i>=t)&&(t=i),(!u||j>=u)&&(u=j),g=Ei?u:t,void(Rg?(Object.keys(y).forEach(function(a){y[a]=t}),Object.keys(z).forEach(function(a){z[a]=u}),f=(l-g*a.length)/2,v>f?(w=0,C=0,a.forEach(function(a){e(a)})):e(c,!0)):e(c)))}var e,g,h,i,j,k,l,o,p,q,r=4,s=26,t=0,u=0,v=10,w=0,x={},y={},z={},A=[0],B={},C=0;b=b||{},o=d(b.withTransition)?b.withTransition:!0,p=d(b.withTransitionForTransform)?b.withTransitionForTransform:!0,q=d(b.withTransformAll)?b.withTransformAll:!0,Ei?(e=function(a){return t*(.2+B[a])},i=function(a){return A[B[a]]+x[a]}):(e=function(a){return A[B[a]]+x[a]},i=function(a){return u*(.2+B[a])}),g=function(a,b){return e(a,b)+14},j=function(a,b){return i(a,b)+9},h=function(a,b){return e(a,b)-4},k=function(a,b){return i(a,b)-7},l=Ui.selectAll("."+f.legendItem).data(a).enter().append("g").attr("class",function(a){return Pc(f.legendItem,a)}).style("visibility",function(a){return Cc(a)?"visible":"hidden"}).style("cursor","pointer").on("click",function(a){"function"==typeof Og?Og(a):of.toggle(a)}).on("mouseover",function(a){of.focus(a),"function"==typeof Pg&&Pg(a)}).on("mouseout",function(a){of.revert(),"function"==typeof Qg&&Qg(a)}),l.append("text").text(function(a){return d(ng[a])?ng[a]:a}).each(function(a,b){c(this,a,0===b)}).style("pointer-events","none").attr("x",Ei?g:-200).attr("y",Ei?-200:j),l.append("rect").attr("class",f.legendItemEvent).style("fill-opacity",0).attr("x",Ei?h:-200).attr("y",Ei?-200:k).attr("width",function(a){return y[a]}).attr("height",function(a){return z[a]}),l.append("rect").attr("class",f.legendItemTile).style("pointer-events","none").style("fill",function(a){return ui(a)}).attr("x",Ei?g:-200).attr("y",Ei?-200:i).attr("width",10).attr("height",10),Ui.selectAll("text").data(a).text(function(a){return d(ng[a])?ng[a]:a}).each(function(a,b){c(this,a,0===b)}).transition().duration(o?250:0).attr("x",g).attr("y",j),Ui.selectAll("rect."+f.legendItemEvent).data(a).transition().duration(o?250:0).attr("x",h).attr("y",k),Ui.selectAll("rect."+f.legendItemTile).data(a).transition().duration(o?250:0).attr("x",e).attr("y",i),N(t),O(u),M(C),n(),R(),We(),q&&m(p)}function jf(a){return zc(of.data.targets,a.id)}function kf(a){return"data"in a&&zc(of.data.targets,a.data.id)}function lf(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 mf(a,b,c){var d=!Yd(of.data.targets);Sd(a,b),Xe(c?c:{withTransitionForAxis:d})}var nf=a.d3?a.d3:a.require?a.require("d3"):void 0,of={data:{},axis:{},legend:{}},pf={},qf=h(["bindto"],"#chart"),rf=h(["size","width"]),sf=h(["size","height"]),tf=h(["padding","left"]),uf=h(["padding","right"]),vf=h(["zoom","enabled"],!1),wf=h(["zoom","extent"]),xf=h(["zoom","privileged"],!1),yf=h(["onenter"],function(){}),zf=h(["onleave"],function(){}),Af=h(["onresize"],function(){}),Bf=h(["onresized"],function(){}),Cf=h(["transition","duration"],350);g("data","data is required in config");var Df,Ef,Ff,Gf,Hf,If,Jf,Kf,Lf,Mf,Nf,Of,Pf,Qf,Rf,Sf,Tf,Uf,Vf,Wf,Xf,Yf,Zf,$f,_f,ag,bg,cg,dg,eg,fg,gg,hg,ig,jg=h(["data","x"]),kg=h(["data","xs"],{}),lg=h(["data","x_format"]),mg=h(["data","id_converter"],function(a){return a}),ng=h(["data","names"],{}),og=h(["data","classes"],{}),pg=h(["data","groups"],[]),qg=h(["data","axes"],{}),rg=h(["data","type"]),sg=h(["data","types"],{}),tg=h(["data","labels"],{}),ug=h(["data","order"]),vg=h(["data","regions"],{}),wg=h(["data","color"]),xg=h(["data","colors"],{}),yg=h(["data","selection","enabled"],!1),zg=h(["data","selection","grouped"],!1),Ag=h(["data","selection","isselectable"],function(){return!0}),Bg=h(["data","selection","multiple"],!0),Cg=h(["data","onclick"],function(){}),Dg=h(["data","onenter"],function(){}),Eg=h(["data","onleave"],function(){}),Fg=h(["data","onselected"],function(){}),Gg=h(["data","onunselected"],function(){}),Hg=h(["data","ondragstart"],function(){}),Ig=h(["data","ondragend"],function(){}),Jg=h(["subchart","show"],!1),Kg=Jg?h(["subchart","size","height"],60):0,Lg=h(["color","pattern"],[]),Mg=h(["legend","show"],!0),Ng=h(["legend","position"],"bottom"),Og=h(["legend","item","onclick"]),Pg=h(["legend","item","onmouseover"]),Qg=h(["legend","item","onmouseout"]),Rg=h(["legend","equally"],!1),Sg=h(["axis","rotated"],!1),Tg=h(["axis","x","type"],"indexed"),Ug=h(["axis","x","localtime"],!0),Vg=h(["axis","x","categories"],[]),Wg=h(["axis","x","tick","centered"],!1),Xg=h(["axis","x","tick","format"]),Yg=h(["axis","x","tick","culling"],{}),Zg=h(["axis","x","tick","culling","max"],10),$g=h(["axis","x","tick","count"]),_g=h(["axis","x","tick","fit"],!1),ah=h(["axis","x","tick","values"],null),bh=h(["axis","x","max"]),ch=h(["axis","x","min"]),dh=h(["axis","x","padding"],{}),eh=h(["axis","x","default"]),fh=h(["axis","x","label"],{}),gh=h(["axis","y","show"],!0),hh=h(["axis","y","max"]),ih=h(["axis","y","min"]),jh=h(["axis","y","center"]),kh=h(["axis","y","label"],{}),lh=h(["axis","y","inner"],!1),mh=h(["axis","y","tick","format"]),nh=h(["axis","y","padding"],{}),oh=h(["axis","y","ticks"],10),ph=h(["axis","y2","show"],!1),qh=h(["axis","y2","max"]),rh=h(["axis","y2","min"]),sh=h(["axis","y2","center"]),th=h(["axis","y2","label"],{}),uh=h(["axis","y2","inner"],!1),vh=h(["axis","y2","tick","format"]),wh=h(["axis","y2","padding"],{}),xh=h(["axis","y2","ticks"],10),yh=h(["grid","x","show"],!1),zh=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(["line","connect_null"],!1),Lh=h(["bar","width"]),Mh=h(["bar","width","ratio"],.6),Nh=h(["pie","label","show"],!0),Oh=h(["pie","label","format"]),Ph=h(["pie","expand"],!0),Qh=h(["pie","onclick"],function(){}),Rh=h(["pie","onmouseover"],function(){}),Sh=h(["pie","onmouseout"],function(){}),Th=h(["donut","label","show"],!0),Uh=h(["donut","label","format"]),Vh=h(["donut","expand"],!0),Wh=h(["donut","title"],""),Xh=h(["donut","onclick"],function(){}),Yh=h(["donut","onmouseover"],function(){}),Zh=h(["donut","onmouseout"],function(){}),$h=h(["regions"],[]),_h=h(["tooltip","show"],!0),ai=h(["tooltip","format","title"]),bi=h(["tooltip","format","value"]),ci=h(["tooltip","contents"],function(a,b,c,d){var e,g,h,i,j,k=ai?ai:b,l=bi?bi:c;for(g=0;g<a.length;g++)a[g]&&(a[g].value||0===a[g].value)&&(e||(h=k?k(a[g].x):a[g].x,e="<table class='"+f.tooltip+"'>"+(h||0===h?"<tr><th colspan='2'>"+h+"</th></tr>":"")),j=a[g].name,i=l(a[g].value,a[g].ratio),e+="<tr class='"+f.tooltipName+"-"+a[g].id+"'>",e+="<td class='name'><span style='background-color:"+d(a[g].id)+"'></span>"+j+"</td>",e+="<td class='value'>"+i+"</td>",e+="</tr>");return e+"</table>"}),di=h(["tooltip","init","show"],!1),ei=h(["tooltip","init","x"],0),fi=h(["tooltip","init","position"],{top:"0px",left:"50px"}),gi=("string"==typeof qf?qf.replace("#",""):qf.id)+"-clip",hi=gi+"-xaxis",ii=gi+"-yaxis",ji=i(gi),ki=i(hi),li=i(ii),mi="timeseries"===Tg,ni="categorized"===Tg,oi=!mi&&(jg||oe(kg)),pi=null,qi=!1,ri=!1,si=!1,ti=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],ui=ie(xg,oe(Lg)?Lg:ti,wg),vi=Ug?nf.time.format:nf.time.format.utc,wi=function(){var a=[[vi("%Y/%-m/%-d"),function(){return!0}],[vi("%-m/%-d"),function(a){return a.getMonth()}],[vi("%-m/%-d"),function(a){return 1!==a.getDate()}],[vi("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[vi("%I %p"),function(a){return a.getHours()}],[vi("%I:%M"),function(a){return a.getMinutes()}],[vi(":%S"),function(a){return a.getSeconds()}],[vi(".%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)}}(),xi=[],yi=[],zi=Sg?"left":"bottom",Ai=Sg?lh?"top":"bottom":lh?"right":"left",Bi=Sg?uh?"bottom":"top":uh?"left":"right",Ci=Sg?"left":"bottom",Di={main:function(){return"translate("+Df.left+","+Df.top+")"},context:function(){return"translate("+Ef.left+","+Ef.top+")"},legend:function(){return"translate("+Ff.left+","+Ff.top+")"},x:function(){return"translate(0,"+(Sg?0:If)+")"},y:function(){return"translate(0,"+(Sg?If:0)+")"},y2:function(){return"translate("+(Sg?0:Gf)+","+(Sg?1:0)+")"},subx:function(){return"translate(0,"+(Sg?0:Jf)+")"},arc:function(){return"translate("+Gf/2+","+If/2+")"}},Ei="right"===Ng,Fi=0,Gi=0,Hi=0,Ii=30,Ji=30,Ki=5;Sf=nf.layout.pie().value(function(a){return a.values.reduce(function(a,b){return a+b.value},0)});var Li,Mi=function(){var a=nf.svg.line().x(Sg?function(a){return V(a.id)(a.value)}:ud).y(Sg?ud:function(a){return V(a.id)(a.value)});return Kh||(a=a.defined(function(a){return null!=a.value})),function(b){var c,d,e=Kh?ye(b.values):b.values;return Zd(b)?(a.interpolate($d(b)?"cardinal":"linear"),vg[b.id]?Ke(e,_f,V(b.id),vg[b.id]):a(e)):(c=e[0]?_f(e[0].x):0,d=e[0]?V(b.id)(e[0].value):0,Sg?"M "+d+" "+c:"M "+c+" "+d)}}(),Ni=function(){var a;return a=Sg?nf.svg.area().x0(function(a){return V(a.id)(0)}).x1(function(a){return V(a.id)(a.value)}).y(ud):nf.svg.area().x(ud).y0(function(a){return V(a.id)(0)}).y1(function(a){return V(a.id)(a.value)}),function(b){var c,d,e=ye(b.values);return Td([b],"area")||Td([b],"area-spline")?(a.interpolate($d(b)?"cardinal":"linear"),a(e)):(c=e[0]?_f(e[0].x):0,d=e[0]?V(b.id)(e[0].value):0,Sg?"M "+d+" "+c:"M "+c+" "+d)}}(),Oi=function(){var a=nf.svg.line().x(Sg?function(a){return W(a.id)(a.value)}:xd).y(Sg?xd:function(a){return W(a.id)(a.value)});return function(b){var c=ye(b.values);return Zd(b)?a(c):"M "+cg(c[0].x)+" "+W(b.id)(c[0].value)}}(),Pi=function(){};Li=nf.svg.brush().on("brush",Te),Li.update=function(){return Ti&&Ti.select("."+f.brush).call(this),this},Li.scale=function(a){return Sg?this.y(a):this.x(a)},vf&&(Pi=nf.behavior.zoom().on("zoomstart",function(){Pi.altDomain=nf.event.sourceEvent.altKey?_f.orgDomain():null}).on("zoom",vf?Ue:null),Pi.scale=function(a){return Sg?this.y(a):this.x(a)},Pi.orgScaleExtent=function(){var a=wf?wf:[1,10];return[a[0],Math.max(vc()/a[1],a[1])]},Pi.updateScaleExtent=function(){var a=$b(_f.orgDomain())/$b(Xi),b=this.orgScaleExtent();return this.scaleExtent([b[0]*a,b[1]*a]),this});var Qi,Ri,Si,Ti,Ui,Vi,Wi,Xi,Yi,Zi={};if(of.focus=function(a){function b(a){Dc(a).transition().duration(100).style("opacity",1)}var c=Qi.selectAll(hd(a)),d=c.filter(jf),e=c.filter(kf);of.revert(),of.defocus(),b(d.classed(f.focused,!0)),b(e),Yd(of.data.targets)&&Kb(a,!0),cf(a)},of.defocus=function(a){function b(a){Dc(a).transition().duration(100).style("opacity",.3)}var c=Qi.selectAll(hd(a)),d=c.filter(jf),e=c.filter(kf);of.revert(),b(d.classed(f.focused,!1)),b(e),Yd(of.data.targets)&&Lb(a),df(a)},of.revert=function(a){function b(a){Dc(a).transition().duration(100).style("opacity",1)}var c=Qi.selectAll(hd(a)),d=c.filter(jf),e=c.filter(kf);b(d.classed(f.focused,!1)),b(e),Yd(of.data.targets)&&Lb(a),ef()},of.show=function(a,b){a=yc(a),b=b||{},Hc(a),Qi.selectAll(id(a)).transition().style("opacity",1),b.withLegend?ff(a):Ui.selectAll(kd(a)).classed(f.legendItemHidden,!1),Se({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withTransitionForHorizontalAxis:!1})},of.hide=function(a,b){a=yc(a),b=b||{},Gc(a),Qi.selectAll(id(a)).transition().style("opacity",0),b.withLegend?gf(a):Ui.selectAll(kd(a)).classed(f.legendItemHidden,!0),Se({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withTransitionForHorizontalAxis:!1})},of.toggle=function(a){Bc(a)?of.hide(a):of.show(a)},of.unzoom=function(){Li.clear().update(),Se({withUpdateXDomain:!0})},of.load=function(a){return a.xs&&jc(a.xs),"classes"in a&&Object.keys(a.classes).forEach(function(b){og[b]=a.classes[b]}),"categories"in a&&ni&&(Vg=a.categories,fg.categories(Vg)),"cacheIds"in a&&_b(a.cacheIds)?void Ze(bc(a.cacheIds),a.done):void("unload"in a?_e(yc("boolean"==typeof a.unload&&a.unload?null:a.unload),function(){$e(a)}):$e(a))},of.unload=function(a){_e(yc(a),function(){Se({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})})},of.selected=function(a){return nf.merge(Si.selectAll("."+f.shapes+gd(a)).selectAll("."+f.shape).filter(function(){return nf.select(this).classed(f.SELECTED)}).map(function(a){return a.map(function(a){return a.__data__})}))},of.select=function(a,b,c){yg&&Si.selectAll("."+f.shapes).selectAll("."+f.shape).each(function(e,g){var h=nf.select(this),i="circle"===this.nodeName?se:ve,j="circle"===this.nodeName?te:we,k=zg||!a||a.indexOf(e.id)>=0,l=!b||b.indexOf(g)>=0,m=h.classed(f.SELECTED);k&&l?Ag(e)&&!m&&i(h.classed(f.SELECTED,!0),e,g):d(c)&&c&&m&&j(h.classed(f.SELECTED,!1),e,g)})},of.unselect=function(a,b){yg&&Si.selectAll("."+f.shapes).selectAll("."+f.shape).each(function(c,d){var e=nf.select(this),g="circle"===this.nodeName?te:we,h=zg||!a||a.indexOf(c.id)>=0,i=!b||b.indexOf(d)>=0,j=e.classed(f.SELECTED);h&&i&&Ag(c)&&j&&g(e.classed(f.SELECTED,!1),c,d)})},of.toLine=function(a){mf(a,"line")},of.toSpline=function(a){mf(a,"spline")},of.toBar=function(a){mf(a,"bar")},of.toScatter=function(a){mf(a,"scatter")},of.toArea=function(a){mf(a,"area")},of.toAreaSpline=function(a){mf(a,"area-spline")},of.toPie=function(a){mf(a,"pie",{withTransform:!0})},of.toDonut=function(a){mf(a,"donut",{withTransform:!0})},of.groups=function(a){return c(a)?pg:(pg=a,Se(),pg)},of.xgrids=function(a){return a?(Ah=a,Se(),Ah):Ah},of.xgrids.add=function(a){return a?of.xgrids(Ah.concat(a)):void 0},of.xgrids.remove=function(a){var b=lf(a);return of.xgrids(Ah.filter(b))},of.ygrids=function(a){return a?(Ch=a,Se(),Ch):Ch},of.ygrids.add=function(a){return a?of.ygrids(Ch.concat(a)):void 0},of.ygrids.remove=function(a){var b=lf(a);return of.ygrids(Ch.filter(b))},of.regions=function(a){return c(a)?$h:($h=a,Se(),$h)},of.regions.add=function(a){return c(a)?$h:($h=$h.concat(a),Se(),$h) |
|
},of.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;Qi.selectAll("."+a).transition().duration(d).style("fill-opacity",0).remove(),$h=$h.filter(function(b){return b.classes.indexOf(a)<0})}),$h},of.data.get=function(a){var b=of.data.getAsTarget(a);return d(b)?b.values.map(function(a){return a.value}):void 0},of.data.getAsTarget=function(a){var b=Ac(function(b){return b.id===a});return b.length>0?b[0]:void 0},of.data.names=function(a){return arguments.length?(Object.keys(a).forEach(function(b){ng[b]=a[b]}),hf(xc(of.data.targets),{withTransition:!0}),ng):ng},of.x=function(a){return arguments.length&&(mc(of.data.targets,a),Se({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),of.data.xs},of.xs=function(a){return arguments.length&&(nc(of.data.targets,a),Se({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),of.data.xs},of.axis.labels=function(a){arguments.length&&(Object.keys(a).forEach(function(b){bb(b,a[b])}),Ab())},of.axis.max=function(a){arguments.length&&("object"==typeof a?(b(a.y)&&(hh=+a.y),b(a.y2)&&(qh=+a.y2)):hh=qh=+a,Se())},of.axis.min=function(a){arguments.length&&("object"==typeof a?(b(a.y)&&(ih=+a.y),b(a.y2)&&(rh=+a.y2)):ih=rh=+a,Se())},of.axis.range=function(a){arguments.length&&("undefined"!=typeof a.max&&of.axis.max(a.max),"undefined"!=typeof a.min&&of.axis.min(a.min))},of.legend.show=function(a){Mg||(Mg=!0,Ui.style("visibility","visible")),ff(yc(a)),Se({withTransitionForHorizontalAxis:!1})},of.legend.hide=function(a){Mg&&ne(a)&&(Mg=!1,Ui.style("visibility","hidden")),gf(yc(a)),Se({withTransitionForHorizontalAxis:!1})},of.resize=function(a){rf=a?a.width:null,sf=a?a.height:null,Xe({withLegend:!0,withTransition:!1,withTransitionForTransform:!1})},of.destroy=function(){of.data.targets=void 0,of.data.xs={},Wi.html(""),a.onresize=null},"url"in e.data)nf.xhr(e.data.url,function(a,b){var c,d=nf.csv.parseRows(b.response);1===d.length?(c=[{}],d[0].forEach(function(a){c[0][a]=null})):c=nf.csv.parse(b.response),Le(c)});else if("rows"in e.data)Le(pc(e.data.rows));else{if(!("columns"in e.data))throw Error("url or rows or columns is required.");Le(qc(e.data.columns))}return of},"function"==typeof a.define&&a.define.amd?a.define("c3",["d3"],e):a.c3=e}(window); |