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.
2 lines
52 KiB
2 lines
52 KiB
!function(a){"use strict";function b(){function a(a,b){a.attr("transform",function(a){return"translate("+(b(a)+q)+", 0)"})}function b(a,b){a.attr("transform",function(a){return"translate(0,"+b(a)+")"})}function c(a){var b=a[0],c=a[a.length-1];return c>b?[b,c]:[c,b]}function d(a){for(var b=[],c=Math.ceil(a[0]);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,b){var c=a.length-1;return p>=c||b%Math.ceil(c/p)===0}function f(a){return a<t.length?t[a]:a}function h(a){var b=f(a);return r?r(b):b}function i(f){f.each(function(){var f,i,p=g.select(this),r=d(j.domain()),s=p.selectAll(".tick.major").data(r,String),t=s.enter().insert("g","path").attr("class","tick major").style("opacity",1e-6),u=g.transition(s.exit()).style("opacity",1e-6).remove(),v=g.transition(s).style("opacity",1),w=j.rangeExtent?j.rangeExtent():c(j.range()),x=p.selectAll(".domain").data([0]);x.enter().append("path").attr("class","domain");var y=g.transition(x),z=j.copy(),A=this.__chart__||z;this.__chart__=z,t.append("line"),t.append("text");var B=t.select("line"),C=v.select("line"),D=s.select("text"),E=t.select("text"),F=v.select("text");switch(q=(z(1)-z(0))/2,i=o?0:q,k){case"bottom":f=a,B.attr("y2",l),E.attr("y",Math.max(l,0)+n),C.attr("x1",i).attr("x2",i).attr("y2",l),F.attr("x",0).attr("y",Math.max(l,0)+n),D.attr("dy",".71em").style("text-anchor","middle"),D.text(function(a){return e(r,a)?h(a):""}),y.attr("d","M"+w[0]+","+m+"V0H"+w[1]+"V"+m);break;case"left":f=b,B.attr("x2",-l),E.attr("x",-(Math.max(l,0)+n)),C.attr("x2",-l).attr("y2",0),F.attr("x",-(Math.max(l,0)+n)).attr("y",q),D.attr("dy",".32em").style("text-anchor","end"),D.text(function(a){return e(r,a)?h(a):""}),y.attr("d","M"+-m+","+w[0]+"H0V"+w[1]+"H"+-m)}if(j.ticks)t.call(f,A),v.call(f,z),u.call(f,z);else{var G=z.rangeBand()/2,H=function(a){return z(a)+G};t.call(f,H),v.call(f,H)}})}var j=g.scale.linear(),k="bottom",l=6,m=6,n=3,o=!1,p=10,q=0,r=null,s=!0,t=[];return i.scale=function(a){return arguments.length?(j=a,i):j},i.orient=function(a){return arguments.length?(k=a in{top:1,right:1,bottom:1,left:1}?a+"":"bottom",i):k},i.categories=function(a){return arguments.length?(t=a,i):t},i.tickCentered=function(a){return arguments.length?(o=a,i):o},i.tickFormat=function(a){return arguments.length?(r=a,i):r},i.tickOffset=function(){return q},i.ticks=function(a){return arguments.length?(p=a,i):p},i.tickCulling=function(a){return arguments.length?(s=a,i):s},i}function c(a){return a||0===a}function d(a){return"undefined"==typeof a}function e(a){return"undefined"!=typeof a}var f=a.c3={},g=a.d3;f.generate=function(f){function h(a,b){if(!(a in f))throw Error(b)}function i(a,b){for(var c=f,d=0;d<a.length;d++){if(!(a[d]in c))return b;c=c[a[d]]}return c}function j(a){return"url("+document.URL.split("#")[0]+"#"+a}function k(){Ng.attr("transform",Cg.main),Ng.select(".x.axis").attr("transform",Cg.x),Ng.select(".y2.axis").attr("transform",Cg.y2),Ng.select(".chart-arcs").attr("transform",Cg.arc)}function l(){kf&&(Og.attr("transform",Cg.context),Og.select(".x.axis").attr("transform",Cg.subx))}function m(a){var b=a!==!1?250:0;nf&&Pg.transition().duration(b).attr("transform",Cg.legend)}function n(a){k(a),l(a),m(a)}function o(){re=r(),se=s(),te=E(),ue=D(),ke={top:rf&&If?20:0,right:u(),bottom:20+(rf?0:lf)+(Dg?F():te),left:(rf?lf+Fg:0)+t()},ne=re-ke.left-ke.right,pe=se-ke.top-ke.bottom,le={top:rf?ke.top:se-lf-(Dg?0:te),right:0/0,bottom:20+(Dg?0:te),left:rf?Eg:ke.left},oe=rf?ke.left-Eg-Fg:ne,qe=rf?pe:se-le.top-le.bottom,me={top:Dg?ke.top:se+F()-te,right:0/0,bottom:0,left:Dg?re-ue:0},p(),Dg&&Qc(Wd.data.targets)&&(me.left=ne/2+we)}function p(){we=pe/2,ve=.95*we,xe=Pc(Wd.data.targets)?.6*ve:0}function q(){var a=g.select(".y.axis").node().getBoundingClientRect(),b=g.select(_d).node().getBoundingClientRect();return a.right-b.left-t()}function r(){return ae?ae:w()}function s(){var a=be?be:x();return a>0?a:320}function t(){return Qc(Wd.data.targets)?0:ce?ce:Ef?1:v("y")}function u(){return Qc(Wd.data.targets)?0:de?de:Dg?ue*(If&&!rf?1.25:1):If?Mf||rf?1:v("y2"):1}function v(){var a=U();return a.isInner?40:60}function w(){return+g.select(_d).style("width").replace("px","")}function x(){return+g.select(_d).style("height").replace("px","")}function y(){return ne+2}function z(){return 80}function A(){return ke.left+20}function B(){return pe+2}function C(){var a=rf?pe:ne,b=ob(),c=Lb();return c>1?a*b/(c-1):a}function D(){return nf?Dg?150:re:0}function E(){return nf?Dg?se:40:0}function F(){var a=T();return a.isInner?5:20}function G(){var a,b;Ce=rf?1:0,De=rf?pe:ne,Ee=rf?0:pe,Fe=rf?ne:1,Ge=Ce,He=De,Ie=rf?0:qe,Je=rf?oe:1,Ke=I(Ce,De,Ke?Ke.domain():void 0,function(){return Qe.tickOffset()}),Le=J(Ee,Fe),Me=J(Ee,Fe),Ne=I(Ce,De,Sg,function(a){return a%1?0:Te.tickOffset()}),Oe=J(Ie,Je),Pe=J(Ie,Je),a=P(),b=Q(),Qe=M(Ke,yg,a,b),Te=M(Ne,Bg,a,b),Re=N(Le,zg,Ff,Hf),Se=N(Me,Ag,Nf,Pf),H()}function H(){ye=db(),ze=eb(),Ae=eb(.98)}function I(a,b,c,f){var h=(qg?g.time.scale():g.scale.linear()).range([a,b]);if(h.orgDomain=function(){return h.domain()},e(c)&&h.domain(c),d(f)&&(f=function(){return 0}),rg){var i,j=h;h=function(a){return j(a)+f(a)};for(i in j)h[i]=j[i];h.orgDomain=function(){return j.domain()},h.domain=function(a){return arguments.length?(j.domain(a),h):(a=j.domain(),[a[0],a[1]+1])}}return h}function J(a,b){return g.scale.linear().range([a,b])}function K(a){return"y2"===O(a)?Me:Le}function L(a){return"y2"===O(a)?Pe:Oe}function M(a,c,d,e){var f=(rg?b():g.svg.axis()).scale(a).orient(c);return f.tickFormat(d).ticks(e),rg?f.tickCentered(uf):f.tickOffset=function(){var a=rf?pe:ne;return a*ob()/Lb()/2},rg&&f.categories(tf),f}function N(a,b,c,d){return g.svg.axis().scale(a).orient(b).tickFormat(c).ticks(d).outerTickSize(0)}function O(a){return a in $e?$e[a]:"y"}function P(){var a=qg?xg:rg?Ub:null;return vf&&("function"==typeof vf?a=vf:qg&&(a=function(a){return g.time.format(vf)(a)})),a}function Q(){var a=Lb();return wf&&a>xf?xf:a}function R(a){return"string"==typeof a?a:a?a.text:null}function S(a,b){var c=a&&"object"==typeof a&&a.position?a.position:b;return{isInner:c.indexOf("inner")>=0,isOuter:c.indexOf("outer")>=0,isLeft:c.indexOf("left")>=0,isCenter:c.indexOf("center")>=0,isRight:c.indexOf("right")>=0,isTop:c.indexOf("top")>=0,isMiddle:c.indexOf("middle")>=0,isBottom:c.indexOf("bottom")>=0}}function T(){return S(zf,"inner-right")}function U(){return S(Df,"inner-top")}function V(){return R(zf)}function W(){return R(Df)}function X(){var a=T();return a.isLeft?0:a.isCenter?ne/2:ne}function Y(){var a=U();return a.isBottom?-pe:a.isMiddle?-pe/2:0}function Z(){var a=U();return a.isTop?"-0.5em":"0"}function $(){var a=T();return a.isInner?"-0.5em":"3.5em"}function _(){var a=U(),b=0;return g.selectAll(".y.axis .tick text").each(function(){var a=this.getBBox();b<a.width&&(b=a.width)}),a.isInner?"1.2em":-20-b}function ab(){var a=T();return a.isLeft?"start":a.isCenter?"middle":"end"}function bb(){var a=U();return a.isBottom?"start":a.isMiddle?"middle":"end"}function cb(a){var b=!1;return Be(Wd.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=g.svg.arc().outerRadius(ve).innerRadius(xe),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=g.svg.arc().outerRadius(we*(a?a:1)).innerRadius(xe);return function(a){var c=cb(a);return c?b(c):"M 0 0"}}function fb(a,b){return Xc(a.data)?ye(a,b):"M 0 0"}function gb(a){var b,c,d,e,f=cb(a),g="";return f&&(b=ye.centroid(f),c=b[0],d=b[1],e=Math.sqrt(c*c+d*d),g="translate("+c/e*ve*.8+","+d/e*ve*.8+")"),g}function hb(a){return(a.endAngle-a.startAngle)/(2*Math.PI)}function ib(a){var b;return dg?(b=hb(a),eg?eg(a.value,b):rc(a.v,b)):""}function jb(a,b){var c=Lg.selectAll(".chart-arc"+Sd(a)),d=Lg.selectAll(".-arc").filter(function(b){return b.data.id!==a});c.selectAll("path").transition().duration(50).attr("d",ze).transition().duration(100).attr("d",Ae).each(function(a){Wc(a.data)}),b||d.style("opacity",.3)}function kb(a){var b=Lg.selectAll(".chart-arc"+Sd(a));b.selectAll("path").transition().duration(50).attr("d",ye),Lg.selectAll(".-arc").style("opacity",1)}function lb(a){var b,c,d,e,f,h=Qb(a);if(Ze.length>0)for(f=Sb(a),b=0;b<Ze.length;b++)for(d=Ze[b][0],f&&h[d]&&h[d].forEach(function(a,b){h[d][b]=0>a?a:0}),c=1;c<Ze[b].length;c++)e=Ze[b][c],h[e]&&h[e].forEach(function(a,b){O(e)!==O(d)||!h[d]||f&&+a>0||(h[d][b]+=+a)});return g.min(Object.keys(h).map(function(a){return g.min(h[a])}))}function mb(a){var b,c,d,e,f,h=Qb(a);if(Ze.length>0)for(f=Tb(a),b=0;b<Ze.length;b++)for(d=Ze[b][0],f&&h[d]&&h[d].forEach(function(a,b){h[d][b]=a>0?a:0}),c=1;c<Ze[b].length;c++)e=Ze[b][c],h[e]&&h[e].forEach(function(a,b){O(e)!==O(d)||!h[d]||f&&0>+a||(h[d][b]+=+a)});return g.max(Object.keys(h).map(function(a){return g.max(h[a])}))}function nb(a){var b,d,e,f,g,h,i,j,k=Pb(function(b){return O(b.id)===a}),l="y2"===a?Kf:Bf,m="y2"===a?Jf:Af,n=c(l)?l:lb(k),o=c(m)?m:mb(k),p="y2"===a?Lf:Cf,q=kc()&&rf;return n===o&&(0>n?o=0:n=0),b=Math.abs(o-n),d=e=f=q?0:.1*b,p&&(g=Math.max(Math.abs(n),Math.abs(o)),o=g-p,n=p-g),"y"===a&&Gf&&(e=c(Gf.top)?Gf.top:d,f=c(Gf.bottom)?Gf.bottom:d),"y2"===a&&Of&&(e=c(Of.top)?Of.top:d,f=c(Of.bottom)?Of.bottom:d),q&&(h=lc(n,o),i=tb(Le.range()),j=[h[0]/i,h[1]/i],e+=b*(j[1]/(1-j[0]-j[1])),f+=b*(j[0]/(1-j[0]-j[1]))),Mc(k)&&!Sb(k)&&(f=n),[n-f,o+e]}function ob(a){var b=tb(Sg),c=tb(Ke.domain());return a||0===c?1:b/c}function pb(a){return g.min(a,function(a){return g.min(a.values,function(a){return a.x})})}function qb(a){return g.max(a,function(a){return g.max(a.values,function(a){return a.x})})}function rb(a,b){var c,d,e=b[0],f=b[1],g=Math.abs(e-f);return rg?d=0:Mc(a)?(c=Lb(),d=c>1?g/(c-1)/2:.5):d=.01*g,d}function sb(a){var b=[pb(a),qb(a)],c=b[0],d=b[1],e=rb(a,b),f=qg?new Date(c.getTime()-e):c-e,g=qg?new Date(d.getTime()+e):d+e;return[f,g]}function tb(a){return a[1]-a[0]}function ub(a){for(var b=0;b<a.length;b++)if(!(a[b]in Xd))return!1;return!0}function vb(a,b){Xd[a]=Ib(b)}function wb(a){for(var b=[],c=0;c<a.length;c++)a[c]in Xd&&b.push(Ib(Xd[a[c]]));return b}function xb(a){return"start"in a?Ke(qg?ad(a.start):a.start):0}function yb(a){var b=xb(a),c="end"in a?Ke(qg?ad(a.end):a.end):ne,d=c-b;return 0>d?0:d}function zb(a){return Ue&&a===Ue||Ve&&ed(Ve,a)}function Ab(a){return!zb(a)}function Bb(a){return Ue?Ue:Ve?Ve[a]:null}function Cb(a,b){return a in Wd.data.x&&Wd.data.x[a]&&Wd.data.x[a][b]?Wd.data.x[a][b]:b}function Db(a){Object.keys(a).forEach(function(b){Ve[b]=a[b]})}function Eb(a){var b;return a&&(b=Ye[a.id],a.name=b?b:a.id),a}function Fb(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 Gb(a){var b,c,e,f=[];for(b=0;b<a.length;b++)for(e=a[b][0],c=1;c<a[b].length;c++)d(f[c-1])&&(f[c-1]={}),f[c-1][e]=a[b][c];return f}function Hb(b){var c,d=g.keys(b[0]).filter(Ab),e=g.keys(b[0]).filter(zb);return qg&&0===e.length?(a.alert('data.x or data.xs must be specified when axis.x.type == "timeseries"'),[]):(sg&&d.forEach(function(a){var c=Bb(a);Wd.data.x[a]=e.indexOf(c)>=0?b.map(function(a){return a[c]}):Wd.data.x[Object.keys(Wd.data.x)[0]]}),c=d.map(function(a){var c=Xe(a);return{id:c,id_org:a,values:b.map(function(b,d){var e,f=Bb(a);return e=qg?ad(b[f]):sg?b[f]?+b[f]:Cb(a,d):d,b.x=e,{x:e,value:null===b[a]||isNaN(b[a])?null:+b[a],id:c}})}}),c.forEach(function(a){var b;a.values=a.values.sort(function(a,b){var c=a.x||0===a.x?a.x:1/0,d=b.x||0===b.x?b.x:1/0;return c-d}),b=0,a.values.forEach(function(a){a.index=b++})}),_e&&Kc(Nb(c).filter(function(a){return!(a in af)}),_e),c.forEach(function(a){vb(a.id_org,a)}),c)}function Ib(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 Jb(a){return a>0&&Wd.data.targets[0].values[a-1]?Wd.data.targets[0].values[a-1].x:void 0}function Kb(a){return a<Lb()-1?Wd.data.targets[0].values[a+1].x:void 0}function Lb(){return g.max(Wd.data.targets,function(a){return a.values.length})}function Mb(){var a,b=Wd.data.targets.length,c=0;return b>1?Wd.data.targets.forEach(function(b){b.values.length>c&&(a=b,c=b.values.length)}):a=b?Wd.data.targets[0]:null,a}function Nb(a){return a=d(a)?Wd.data.targets:a,a.map(function(a){return a.id})}function Ob(a){var b,c=Nb();for(b=0;b<c.length;b++)if(c[b]===a)return!0;return!1}function Pb(a){return e(a)?Wd.data.targets.filter(a):Wd.data.targets}function Qb(a){var b={};return a.forEach(function(a){b[a.id]=[],a.values.forEach(function(c){b[a.id].push(c.value)})}),b}function Rb(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 Sb(a){return Rb(a,function(a){return 0>a})}function Tb(a){return Rb(a,function(a){return a>0})}function Ub(a){return a<tf.length?tf[a]:a}function Vb(a){return"-text -text-"+a.id}function Wb(a){return"-texts -texts-"+a.id}function Xb(a){return"-shapes -shapes-"+a.id}function Yb(a){return Xb(a)+" -line -line-"+a.id}function Zb(a){return Xb(a)+" -circles -circles-"+a.id}function $b(a){return Xb(a)+" -bars -bars-"+a.id}function _b(a){return Xb(a.data)+" -arc -arc-"+a.data.id}function ac(a){return Xb(a)+" -area -area-"+a.id}function bc(a,b){return"-shape -shape-"+b}function cc(a,b){return bc(a,b)+" -circle -circle-"+b}function dc(a,b){return bc(a,b)+" -bar -bar-"+b}function ec(a,b){return"region region-"+b+" "+("classes"in a?[].concat(a.classes).join(" "):"")}function fc(a,b){return"event-rect event-rect-"+b}function gc(a){return Ug[a.id]?1:0}function hc(a){var b=jc(a);return gc(a)*b}function ic(a){return c(a.value)?Uc(a)?.5:1:0}function jc(a){return kc(a)?1:0}function kc(a){var b=a?a.id:null;return"boolean"==typeof bf&&bf?!0:"boolean"===bf[b]&&bf[b]?!0:bf[b]&&bf[b].show?!0:!1}function lc(a,b){var c=[],d=1.3;return g.select("svg").selectAll(".dummy").data([a,b]).enter().append("text").text(function(a){return a}).each(function(a,b){var e=this.getBBox();c[b]=e.width*d}).remove(),c}function mc(a){return a?Ke(a.x):null}function nc(a){return Ke(qg?ad(a.value):a.value)}function oc(a){return Le(a.value)}function pc(a){return Ne(a.x)}function qc(a){var b=Ff?Ff:function(a){return+a};return b(a)}function rc(a,b){return(100*b).toFixed(1)+"%"}function sc(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 tc(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=Ke(i.x)-b[0];return j>0?g=h:f=h,g-f===1?(e=[],a[f].x&&(e=e.concat(sc(a,f))),a[g].x&&(e=e.concat(sc(a,g))),vc(e,b)):tc(a,b,f,g)}function uc(a,b){var c;return c=a.map(function(a){return tc(a.values,b)}),vc(c,b)}function vc(a,b){var c,d;return a.forEach(function(a){var e=fd(a,b);(c>e||!c)&&(c=e,d=a)}),d}function wc(){return cf&&"desc"===cf.toLowerCase()}function xc(){return cf&&"asc"===cf.toLowerCase()}function yc(a){var b=xc(),c=wc();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 cf&&a.sort(cf),a}function zc(a,b){var d,e,f,g,h,i,j,k=Qc(Wd.data.targets),l=k?rc:qc,m=a.filter(function(a){return a&&c(a.value)});hg&&0!==m.length&&(Qg.html(kg(a,P(),l,wg)).style("visibility","hidden").style("display","block"),d=Qg.property("offsetWidth"),e=Qg.property("offsetHeight"),k?(g=ne/2+b[0],i=pe/2+b[1]+20):(rf?(f=q(),g=f+b[0]+100,h=g+d,j=r()-u(),i=Ke(m[0].x)+20):(f=q(),g=f+t()+Ke(m[0].x)+20,h=g+d,j=f+r()-u(),i=b[1]+15),h>j&&(g-=d+60),i+e>s()&&(i-=e+30)),Qg.style("top",i+"px").style("left",g+"px").style("visibility","visible"))}function Ac(){Qg.style("display","none")}function Bc(a){var b=a.filter(function(a){return a&&c(a.value)});hg&&(Nc(Wd.data.targets)||Qc(Wd.data.targets)||Ng.selectAll("line.xgrid-focus").style("visibility","visible").data([b[0]]).attr(rf?"y1":"x1",mc).attr(rf?"y2":"x2",mc))}function Cc(){Ng.select("line.xgrid-focus").style("visibility","hidden")}function Dc(a){return a.x||0===a.x?Ke(a.x):null}function Ec(a){return K(a.id)(a.value)}function Fc(){var a,b,c={},e=0;return Pb(Tc).forEach(function(f){for(a=0;a<Ze.length;a++)if(!(Ze[a].indexOf(f.id)<0))for(b=0;b<Ze[a].length;b++)if(Ze[a][b]in c){c[f.id]=c[Ze[a][b]];break}d(c[f.id])&&(c[f.id]=e++)}),c.__max__=e-1,c}function Gc(a,b,c,d){var e=d?Ne:Ke;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 Hc(a){return function(b){var c=a?L(b.id):K(b.id);return c(b.value)}}function Ic(a,b){var c=yc(Pb(Tc)),d=c.map(function(a){return a.id});return function(e,f){var g=b?L(e.id):K(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 Jc(a,b){return b?2*a.tickOffset()*.6/b:0}function Kc(a,b){var c=d(a)?Nb():a;"string"==typeof c&&(c=[c]);for(var e=0;e<c.length;e++)Ug[c[e]]=b===af[c[e]],af[c[e]]=b}function Lc(a,b){var c=!1;return a.forEach(function(a){af[a.id]===b&&(c=!0),a.id in af||"line"!==b||(c=!0)}),c}function Mc(a){return Lc(a,"bar")}function Nc(a){return Lc(a,"scatter")}function Oc(a){return Lc(a,"pie")}function Pc(a){return Lc(a,"donut")}function Qc(a){return Oc(a)||Pc(a)}function Rc(a){var b="string"==typeof a?a:a.id;return!(b in af)||"line"===af[b]||"spline"===af[b]||"area"===af[b]||"area-spline"===af[b]}function Sc(a){var b="string"==typeof a?a:a.id;return"spline"===af[b]||"area-spline"===af[b]}function Tc(a){var b="string"==typeof a?a:a.id;return"bar"===af[b]}function Uc(a){var b="string"==typeof a?a:a.id;return"scatter"===af[b]}function Vc(a){var b="string"==typeof a?a:a.id;return"pie"===af[b]}function Wc(a){var b="string"==typeof a?a:a.id;return"donut"===af[b]}function Xc(a){return Vc(a)||Wc(a)}function Yc(a){return Tc(a)?a.values:[]}function Zc(a){return Rc(a)||Uc(a)?a.values:[]}function $c(a){return Tc(a)||Rc(a)?a.values:[]}function _c(a,b){var c=[],d=a,e=null!==b?b:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"];return function(b){return b in d?a[b]:(-1===c.indexOf(b)&&c.push(b),e[c.indexOf(b)%e.length])}}function ad(a){var b;if(!a)throw Error(a+" can not be parsed as d3.time with format "+We+". Maybe 'x' of this data is not defined. See data.x or data.xs option.");if(b=g.time.format(We).parse(a),!b)throw Error("Failed to parse '"+a+"' with format "+We);return b}function bd(a,b){var c=g.mouse(a),d=g.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 cd(a){var b=g.mouse(a),c=g.select(a),d=1*c.attr("x"),e=1*c.attr("y"),f=1*c.attr("width"),h=d-10,i=d+f+10,j=e-10;return h<b[0]&&b[0]<i&&j<b[1]}function dd(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 ed(a,b){var c=!1;return Object.keys(a).forEach(function(d){a[d]===b&&(c=!0)}),c}function fd(a,b){return Math.pow(Ke(a.x)-b[0],2)+Math.pow(Le(a.value)-b[1],2)}function gd(a,b,c){bg(a,b),Ng.select(".selected-circles-"+b.id).selectAll(".selected-circle-"+c).data([b]).enter().append("circle").attr("class",function(){return"selected-circle selected-circle-"+c}).attr("cx",rf?Ec:Dc).attr("cy",rf?Dc:Ec).attr("stroke",function(){return wg(b.id)}).attr("r",1.4*_f).transition().duration(100).attr("r",_f)}function hd(a,b,c){cg(a,b),Ng.select(".selected-circles-"+b.id).selectAll(".selected-circle-"+c).transition().duration(100).attr("r",0).remove()}function id(a,b,c,d){a?gd(b,c,d):hd(b,c,d)}function jd(){}function kd(){}function ld(a,b,c,d){a?jd(b,c,d):kd(b,c,d)}function md(a){return a.filter(function(a){return c(a.value)})}function nd(a,b){return(b?Ng.selectAll(".-circles-"+b):Ng).selectAll(".-circle"+(c(a)?"-"+a:""))}function od(a,b){nd(a,b).classed(Yd,!0).attr("r",$f)}function pd(a){nd(a).filter(function(){return g.select(this).classed(Yd)}).classed(Yd,!1).attr("r",Xf)}function qd(a){return Ng.selectAll(".-bar"+(c(a)?"-"+a:""))}function rd(a){qd(a).classed(Yd,!1)}function sd(a){qd(a).classed(Yd,!1)}function td(a,b){var c=xd(a,b);return function(a,b){var d=c(a,b),e=rf?1:0,f=rf?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 ud(a,b){var c=xd(a,!1),d=b?vd:wd;return function(a,b){return d(c(a,b),a,this)}}function vd(a,b){var c;return rf?(c=Tc(b)?4:6,a[2][1]+c*(b.value<0?-1:1)):a[0][0]+(a[2][0]-a[0][0])/2}function wd(a,b,c){var d=c.getBBox();return rf?(a[0][0]+a[2][0]+.6*d.height)/2:a[2][1]+(b.value<0?d.height:Tc(b)?-3:-6)}function xd(a,b){var c=a.__max__+1,d=Jc(Qe,c),e=Gc(d,c,a,!!b),f=Hc(!!b),g=Ic(a,!!b),h=b?L:K;return function(a,b){var c=h(a.id)(0),i=g(a,b)||c,j=e(a),k=f(a);return rf&&(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 yd(a,b,c,f){var g,h,i,j,k,l,m,n,o,p,q,r=-1,s="M",t=[];if(e(f))for(g=0;g<f.length;g++)t[g]={},t[g].start=d(f[g].start)?a[0].x:qg?ad(f[g].start):f[g].start,t[g].end=d(f[g].end)?a[a.length-1].x:qg?ad(f[g].end):f[g].end;for(p=rf?function(a){return c(a.value)}:function(a){return b(a.x)},q=rf?function(a){return b(a.x)}:function(a){return c(a.value)},i=qg?function(a,d,e,f){var g=a.x.getTime(),h=d.x-a.x,i=new Date(g+h*e),j=new Date(g+h*(e+f));return"M"+b(i)+" "+c(k(e))+" "+b(j)+" "+c(k(e+f))}:function(a,d,e,f){return"M"+b(j(e))+" "+c(k(e))+" "+b(j(e+f))+" "+c(k(e+f))},g=0;g<a.length;g++){if(d(t)||!dd(a[g].x,t))s+=" "+p(a[g])+" "+q(a[g]);else{j=I(a[g-1].x,a[g].x),k=J(a[g-1].value,a[g].value),l=b(a[g].x)-b(a[g-1].x),m=c(a[g].value)-c(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 zd(b){var c,d,e;if(Rg=g.select(_d),Rg.empty())return void a.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');if(Rg.html(""),Wd.data.x={},Wd.data.targets=Hb(b),o(),G(),Ke.domain(g.extent(sb(Wd.data.targets))),Le.domain(nb("y")),Me.domain(nb("y2")),Ne.domain(Ke.domain()),Oe.domain(Le.domain()),Pe.domain(Me.domain()),Sg=Ke.domain(),Gg.scale(Ne),ee&&Kg.scale(Ke),Lg=g.select(_d).append("svg").attr("width",ne+ke.left+ke.right).attr("height",pe+ke.top+ke.bottom).on("mouseenter",he).on("mouseleave",ie),Mg=Lg.append("defs"),Mg.append("clipPath").attr("id",og).append("rect").attr("width",ne).attr("height",pe),Mg.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1).attr("y",-20).attr("width",y).attr("height",z),Mg.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-ke.left+1).attr("width",A).attr("height",B),Ng=Lg.append("g").attr("transform",Cg.main),Og=kf?Lg.append("g").attr("transform",Cg.context):null,Pg=nf?Lg.append("g").attr("transform",Cg.legend):null,Qg=g.select(_d).style("position","relative").append("div").style("position","absolute").style("z-index","10").style("display","none"),Ng.append("g").attr("class","x axis").attr("clip-path",rf?"":j("xaxis-clip")).attr("transform",Cg.x).append("text").attr("class","-axis-x-label").attr("dy",$).style("text-anchor",ab).text(rf?W:V),Ng.append("g").attr("class","y axis").attr("clip-path",rf?j("yaxis-clip"):"").append("text").attr("class","-axis-y-label").attr("transform","rotate(-90)").attr("dx",Z).style("text-anchor",bb).text(rf?V:W),If&&Ng.append("g").attr("class","y2 axis").attr("transform",Cg.y2),d=Ng.append("g").attr("clip-path",pg).attr("class","grid"),Qf&&d.append("g").attr("class","xgrids"),Sf&&d.append("g").attr("class","xgrid-lines"),Yf&&d.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",rf?0:-10).attr("x2",rf?ne:-10).attr("y1",rf?-10:ke.top).attr("y2",rf?-10:pe),Tf&&d.append("g").attr("class","ygrids"),Uf&&d.append("g").attr("class","ygrid-lines"),Ng.append("g").attr("clip-path",pg).attr("class","regions"),Ng.append("g").attr("clip-path",pg).attr("class","chart"),c=Ng.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",ee?rf?"ns-resize":"ew-resize":null),Ng.select(".chart").append("g").attr("class","chart-bars"),Ng.select(".chart").append("g").attr("class","chart-lines"),Ng.select(".chart").append("g").attr("class","chart-arcs").attr("transform",Cg.arc).append("text").attr("class","chart-arcs-title").style("text-anchor","middle").text(fg),Ng.select(".chart").append("g").attr("class","chart-texts"),ee&&Ng.insert("rect",ge?null:"g.grid").attr("class","zoom-rect").attr("width",ne).attr("height",pe).style("opacity",0).style("cursor",rf?"ns-resize":"ew-resize").call(Kg).on("dblclick.zoom",null),null!==yf&&Gg.extent("function"!=typeof yf?yf:yf(sb())),kf&&(Og.append("g").attr("clip-path",pg).attr("class","chart"),Og.select(".chart").append("g").attr("class","chart-bars"),Og.select(".chart").append("g").attr("class","chart-lines"),Og.append("g").attr("clip-path",pg).attr("class","x brush").call(Gg).selectAll("rect").attr(rf?"width":"height",rf?oe:qe),Og.append("g").attr("class","x axis").attr("transform",Cg.subx).attr("clip-path",rf?j("yaxis-clip"):"")),nf&&Qd(Wd.data.targets),Ld(Wd.data.targets),Gd({withTransform:!0,withUpdateXDomain:!0}),lg){if(qg&&"string"==typeof mg){for(mg=ad(mg),e=0;e<Wd.data.targets[0].values.length&&Wd.data.targets[0].values[e].x-mg!==0;e++);mg=e}Qg.html(kg(Wd.data.targets.map(function(a){return Eb(a.values[mg])}),P(),qc,wg)),Qg.style("top",ng.top).style("left",ng.left).style("display","block")}null==a.onresize&&(a.onresize=Jd()),a.onresize.add&&a.onresize.add(Kd)}function Ad(a){a.append("rect").attr("class",fc).style("cursor",ff&&gf?"pointer":null).on("mouseover",function(a,b){if(!ug&&!Qc(Wd.data.targets)){var c,d,e=Wd.data.targets.map(function(a){return Eb(a.values[b])});if(Object.keys(Ye).length>0){d=[];for(var f in Ye)for(c=0;c<e.length;c++)if(e[c].id===f){d.push(e[c]),e.shift(c);break}e=d.concat(e)}Zf&&od(b),rd(b),Bc(e)}}).on("mouseout",function(a,b){Qc(Wd.data.targets)||(Cc(),Ac(),pd(b),sd())}).on("mousemove",function(a,b){var c;ug||Qc(Wd.data.targets)||(c=Wd.data.targets.map(function(a){return Eb(a.values[b])}),zc(c,g.mouse(this)),ff&&(gf||Ng.selectAll(".-shape-"+b).filter(function(a){return hf(a)}).each(function(){var a=g.select(this).classed(Yd,!0);"circle"===this.nodeName&&a.attr("r",$f),Lg.select(".event-rect-"+b).style("cursor",null)}).filter(function(){var a=g.select(this);return"circle"===this.nodeName?bd(this,_f):"rect"===this.nodeName?cd(this,a.attr("x"),a.attr("y")):void 0}).each(function(){var a=g.select(this);a.classed(Yd)||(a.classed(Yd,!0),"circle"===this.nodeName&&a.attr("r",_f)),Lg.select(".event-rect-"+b).style("cursor","pointer")})))}).on("click",function(a,b){return Qc(Wd.data.targets)?void 0:vg?void(vg=!1):void Ng.selectAll(".-shape-"+b).each(function(a){Cd(this,a,b)})}).call(g.behavior.drag().origin(Object).on("drag",function(){Dd(g.mouse(this))}).on("dragstart",function(){Ed(g.mouse(this))}).on("dragend",function(){Fd()})).call(Kg).on("dblclick.zoom",null)}function Bd(a){a.append("rect").attr("x",0).attr("y",0).attr("width",ne).attr("height",pe).attr("class","event-rect").on("mouseout",function(){Qc(Wd.data.targets)||(Cc(),Ac(),pd())}).on("mousemove",function(){var a,b,c;ug||Qc(Wd.data.targets)||(a=g.mouse(this),b=uc(Wd.data.targets,a),c=[Eb(b)],zc(c,a),Zf&&(pd(),od(b.index,b.id)),Bc(c),fd(b,a)<100?Lg.select(".event-rect").style("cursor","pointer"):Lg.select(".event-rect").style("cursor",null))}).on("click",function(){var a,b;Qc(Wd.data.targets)||(a=g.mouse(this),b=uc(Wd.data.targets,a),fd(b,a)<100&&Ng.select(".-circles-"+b.id).select(".-circle-"+b.index).each(function(){Cd(this,b,b.index)}))}).call(g.behavior.drag().origin(Object).on("drag",function(){Dd(g.mouse(this))}).on("dragstart",function(){Ed(g.mouse(this))}).on("dragend",function(){Fd()})).call(Kg).on("dblclick.zoom",null)}function Cd(a,b,c){var d,e=g.select(a),f=e.classed(Zd),h=!1;"circle"===a.nodeName?(h=bd(a,1.5*_f),d=id):"rect"===a.nodeName&&(h=cd(a),d=ld),(gf||h)&&(ff&&hf(b)&&(jf||Ng.selectAll(a.nodeName).each(function(a,b){d(!1,this,a,b)}),e.classed(Zd,!f),d(!f,e,b,c)),ag(b,e))}function Dd(a){var b,c,d,e,f,h,i,j;Qc(Wd.data.targets)||ff&&(!ee||Kg.altDomain)&&(b=tg[0],c=tg[1],d=a[0],e=a[1],f=Math.min(b,d),h=Math.max(b,d),i=gf?ke.top:Math.min(c,e),j=gf?pe:Math.max(c,e),Ng.select(".dragarea").attr("x",f).attr("y",i).attr("width",h-f).attr("height",j-i),Ng.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return hf(a)}).each(function(a,b){var c,d,e,k,l=g.select(this),m=l.classed(Zd),n=l.classed($d),o=!1;"circle"===this.nodeName?(c=1*l.attr("cx"),d=1*l.attr("cy"),k=id,o=c>f&&h>c&&d>i&&j>d):"rect"===this.nodeName&&(c=1*l.attr("x"),d=1*l.attr("y"),e=1*l.attr("width"),k=ld,o=c+e>f&&h>c&&j>d),o^n&&(l.classed($d,!n),l.classed(Zd,!m),k(!m,l,a,b))}))}function Ed(a){Qc(Wd.data.targets)||ff&&(tg=a,Ng.select(".chart").append("rect").attr("class","dragarea").style("opacity",.1),ug=!0)}function Fd(){Qc(Wd.data.targets)||ff&&(Ng.select(".dragarea").transition().duration(100).style("opacity",0).remove(),Ng.selectAll(".-shape").classed($d,!1),ug=!1)}function Gd(a){var b,d,f,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,D,E,F,G,H=Fc(),I=Qc(Wd.data.targets);if(a=e(a)?a:{},u=e(a.withY)?a.withY:!0,v=e(a.withSubchart)?a.withSubchart:!0,w=e(a.withTransition)?a.withTransition:!0,x=e(a.withTransform)?a.withTransform:!1,y=e(a.withUpdateXDomain)?a.withUpdateXDomain:!1,z=e(a.withUpdateOrgXDomain)?a.withUpdateOrgXDomain:!1,F=w?je:0,G=e(a.durationForExit)?a.durationForExit:F,z&&(Ke.domain(g.extent(sb(Wd.data.targets))),Sg=Ke.domain(),ee&&Kg.scale(Ke).updateScaleExtent(),Ne.domain(Ke.domain()),Gg.scale(Ne)),y&&(Ke.domain(Gg.empty()?Sg:Gg.extent()),ee&&Kg.scale(Ke).updateScaleExtent()),Le.domain(nb("y")),Me.domain(nb("y2")),Ng.select(".x.axis").style("opacity",I?0:1).transition().duration(F).call(rf?Re:Qe),Ng.select(".y.axis").style("opacity",I?0:1).transition().duration(F).call(rf?Qe:Re),Ng.select(".y2.axis").style("opacity",I?0:1).transition().call(Se),A=td(H),D=ud(H,!0),E=ud(H,!1),Ng.select(".x.axis .-axis-x-label").attr("x",X),Ng.select(".y.axis .-axis-y-label").attr("x",Y).attr("dy",_),Oe.domain(Le.domain()),Pe.domain(Me.domain()),Qg.style("display","none"),Ng.select("line.xgrid-focus").style("visibility","hidden").attr("y2",pe),Qf){if("year"===Rf){d=[];for(var J=sb(),K=J[0].getFullYear(),L=J[1].getFullYear(),M=K;L>=M;M++)d.push(new Date(M+"-01-01 00:00:00"))}else d=Ke.ticks(10);b=Ng.select(".xgrids").selectAll(".xgrid").data(d),b.enter().append("line").attr("class","xgrid"),b.attr("x1",rf?0:function(a){return Ke(a)-Qe.tickOffset()}).attr("x2",rf?ne:function(a){return Ke(a)-Qe.tickOffset()}).attr("y1",rf?function(a){return Ke(a)-Qe.tickOffset()}:ke.top).attr("y2",rf?function(a){return Ke(a)-Qe.tickOffset()}:pe).style("opacity",function(){return+g.select(this).attr(rf?"y1":"x1")===(rf?pe:0)?0:1}),b.exit().remove()}Sf&&(f=Ng.select(".xgrid-lines").selectAll(".xgrid-line").data(Sf),h=f.enter().append("g").attr("class",function(a){return"xgrid-line xgrid-line-"+(a["class"]?a["class"]:"")}),h.append("line").style("opacity",0),h.append("text").attr("text-anchor","end").attr("transform",rf?"":"rotate(-90)").attr("dx",rf?0:-ke.top).attr("dy",-5).style("opacity",0),f.select("line").transition().duration(F).attr("x1",rf?0:nc).attr("x2",rf?ne:nc).attr("y1",rf?nc:ke.top).attr("y2",rf?nc:pe).style("opacity",1),f.select("text").transition().duration(F).attr("x",rf?ne:0).attr("y",nc).text(function(a){return a.text}).style("opacity",1),f.exit().transition().duration(F).style("opacity",0).remove()),u&&Tf&&(i=Ng.select(".ygrids").selectAll(".ygrid").data(Le.ticks(Vf)),i.enter().append("line").attr("class","ygrid"),i.attr("x1",rf?Le:0).attr("x2",rf?Le:ne).attr("y1",rf?0:Le).attr("y2",rf?pe:Le),i.exit().remove()),u&&Uf&&(j=Ng.select(".ygrid-lines").selectAll(".ygrid-line").data(Uf),k=j.enter().append("g").attr("class",function(a){return"ygrid-line ygrid-line-"+(a.class?a.class:"")}),k.append("line").style("opacity",0),k.append("text").attr("text-anchor","end").attr("transform",rf?"rotate(-90)":"").attr("dx",rf?0:-ke.top).attr("dy",-5).style("opacity",0),j.select("line").transition().duration(F).attr("x1",rf?oc:0).attr("x2",rf?oc:ne).attr("y1",rf?0:oc).attr("y2",rf?pe:oc).style("opacity",1),j.select("text").transition().duration(F).attr("x",rf?0:ne).attr("y",oc).text(function(a){return a.text |
|
}).style("opacity",1),j.exit().transition().duration(F).style("opacity",0).remove()),m=Ng.selectAll(".-bars").selectAll(".-bar").data(Yc),m.enter().append("path").attr("d",A).style("stroke","none").style("opacity",0).style("fill",function(a){return wg(a.id)}).attr("class",dc),m.style("opacity",gc).transition().duration(F).attr("d",A).style("opacity",1),m.exit().transition().duration(G).style("opacity",0).remove(),o=Ng.selectAll(".-texts").selectAll(".-text").data($c),o.enter().append("text").attr("class",Vb).attr("text-anchor",function(a){return rf?a.value<0?"end":"start":"middle"}).style("stroke","none").style("fill-opacity",0).text(function(a){return qc(a.value)}),o.style("fill-opacity",hc).transition().duration(F).attr("x",D).attr("y",E).style("fill-opacity",jc),o.exit().transition().duration(G).style("fill-opacity",0).remove(),Ng.selectAll(".-line").style("opacity",gc).transition().duration(F).attr("d",Hg).style("opacity",1),Ng.selectAll(".-area").style("opacity",0).transition().duration(F).attr("d",Ig).style("opacity",Tg),l=Ng.selectAll(".-circles").selectAll(".-circle").data(Zc),l.enter().append("circle").attr("class",cc).style("opacity",0).attr("r",Xf),l.style("opacity",gc).transition().duration(F).style("opacity",ic).attr("cx",rf?Ec:Dc).attr("cy",rf?Dc:Ec),l.exit().remove(),Ng.selectAll(".chart-arc").select(".-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=cb(a);if(!b)return function(){return"M 0 0"};var c=g.interpolate(this._current,b);return this._current=c(0),function(a){return fb(c(a),!0)}}).attr("transform",x?"scale(1)":"").style("opacity",1),Ng.selectAll(".chart-arc").select("text").attr("transform",gb).style("opacity",0).transition().duration(F).text(ib).style("opacity",function(a){return Xc(a.data)?1:0}),Ng.select(".chart-arcs-title").style("opacity",Pc(Wd.data.targets)?1:0),kf&&(null!==g.event&&"zoom"===g.event.type&&Gg.extent(Ke.orgDomain()).update(),v&&(Og.select(".x.axis").style("opacity",I?0:1).transition().duration(F).call(Te),Gg.empty()||Gg.extent(Ke.orgDomain()).update(),B=td(H,!0),p=Og.selectAll(".-bars").selectAll(".-bar").data(Yc),p.enter().append("path").attr("d",B).style("stroke","none").style("fill",function(a){return wg(a.id)}).attr("class",dc),p.style("opacity",gc).transition().duration(F).attr("d",B).style("opacity",1),p.exit().transition().duration(F).style("opacity",0).remove(),Og.selectAll(".-line").style("opacity",gc).transition().duration(F).attr("d",Jg).style("opacity",1))),Ng.selectAll(".selected-circles").filter(function(a){return Tc(a)}).selectAll("circle").remove(),Ng.selectAll(".selected-circle").transition().duration(F).attr("cx",rf?Ec:Dc).attr("cy",rf?Dc:Ec),Ve?(q=Ng.select(".event-rects").selectAll(".event-rect").data([0]),Bd(q.enter()),q.attr("x",0).attr("y",0).attr("width",ne).attr("height",pe)):(sg?(t=function(a,b){var c=Jb(b),d=Kb(b);return(Ke(d?d:a.x+50)-Ke(c?c:a.x-50))/2},s=function(a,b){var c=Jb(b);return(Ke(a.x)+Ke(c?c:a.x-50))/2}):(t=C(),s=function(a){return Ke(a.x)-t/2}),r=Mb(),Ng.select(".event-rects").datum(r?r.values:[]),q=Ng.select(".event-rects").selectAll(".event-rect").data(function(a){return a}),Ad(q.enter()),q.attr("class",fc).attr("x",rf?0:s).attr("y",rf?s:0).attr("width",rf?ne:t).attr("height",rf?t:pe),q.exit().remove()),n=Ng.select(".regions").selectAll("rect.region").data(gg),n.enter().append("rect").style("fill-opacity",0),n.attr("class",ec).attr("x",rf?0:xb).attr("y",rf?xb:ke.top).attr("width",rf?ne:yb).attr("height",rf?yb:pe).transition().duration(F).style("fill-opacity",function(a){return c(a.opacity)?a.opacity:.1}),n.exit().transition().duration(F).style("fill-opacity",0).remove(),nf&&Qd(Wd.data.targets,{withTransition:w}),Nb().forEach(function(a){Ug[a]=!0})}function Hd(){Gd({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}function Id(){return"mousemove"===g.event.sourceEvent.type&&Kg.altDomain?(Ke.domain(Kg.altDomain),void Kg.scale(Ke).updateScaleExtent()):(rg&&Ke.orgDomain()[0]===Sg[0]&&Ke.domain([Sg[0]-1e-10,Ke.orgDomain()[1]]),Gd({withTransition:!1,withY:!1,withSubchart:!1}),void("mousemove"===g.event.sourceEvent.type&&(vg=!0)))}function Jd(){function a(){b.forEach(function(a){a()})}var b=[];return a.add=function(a){b.push(a)},a}function Kd(a){var b,c;a=e(a)?a:{},b=e(a.withTransition)?a.withTransition:!1,c=e(a.withTransform)?a.withTransform:!1,o(),G(),Gg.scale(Ne),ee&&Kg.scale(Ke),Lg.attr("width",re).attr("height",se),Lg.select("#"+og).select("rect").attr("width",ne).attr("height",pe),Lg.select("#xaxis-clip").select("rect").attr("width",y),Lg.select(".zoom-rect").attr("width",ne).attr("height",pe),n(b),Gd({withTransition:b,withUpdateXDomain:!0,withTransform:c,durationForExit:0})}function Ld(a){var b,c,d,e,f,h,i,j,k,l,m,n;i=Ng.select(".chart-texts").selectAll(".chart-text").data(a),j=i.enter().append("g").attr("class",function(a){return"chart-text target target-"+a.id}).style("pointer-events","none"),j.append("g").attr("class",Wb).style("fill",function(a){return wg(a.id)}),e=Ng.select(".chart-bars").selectAll(".chart-bar").data(a),d=e.enter().append("g").attr("class",function(a){return"chart-bar target target-"+a.id}).style("pointer-events","none"),d.append("g").attr("class",$b).style("fill",function(a){return wg(a.id)}).style("stroke","none").style("cursor",function(a){return hf(a)?"pointer":null}),c=Ng.select(".chart-lines").selectAll(".chart-line").data(a),b=c.enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}).style("pointer-events","none"),b.append("path").attr("class",Yb).style("opacity",0).style("stroke",function(a){return wg(a.id)}),b.append("path").attr("class",ac).style("opacity",function(){return Tg=+g.select(this).style("opacity"),0}).style("fill",function(a){return wg(a.id)}),b.append("g").attr("class",function(a){return"selected-circles selected-circles-"+a.id}),b.append("g").attr("class",Zb).style("fill",function(a){return wg(a.id)}).style("cursor",function(a){return hf(a)?"pointer":null}),a.forEach(function(a){var b=Rd(a.id);Ng.selectAll(".selected-circles"+b).selectAll(".selected-circle").each(function(b){b.value=a.values[b.x].value})}),h=Ng.select(".chart-arcs").selectAll(".chart-arc").data(Be(a)),f=h.enter().append("g").attr("class",function(a){return"chart-arc target target-"+a.data.id}),f.append("path").attr("class",_b).style("opacity",0).style("fill",function(a){return wg(a.data.id)}).style("cursor",function(a){return hf(a)?"pointer":null}).each(function(a){this._current=a}).on("mouseover",function(a){jb(a.data.id),Nd(a.data.id)}).on("mousemove",function(a){var b=[Eb({id:a.data.id,value:a.value,ratio:hb(a)})];zc(b,g.mouse(this))}).on("mouseout",function(a){kb(a.data.id),Pd(),Ac()}),f.append("text").attr("dy",".35em").style("opacity",0).style("text-anchor","middle").style("pointer-events","none"),kf&&(n=Og.select(".chart-bars").selectAll(".chart-bar").data(a),m=n.enter().append("g").attr("class",function(a){return"chart-bar target target-"+a.id}),m.append("g").attr("class",$b).style("fill",function(a){return wg(a.id)}),l=Og.select(".chart-lines").selectAll(".chart-line").data(a),k=l.enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}),k.append("path").attr("class",Yb).style("opacity",0).style("stroke",function(a){return wg(a.id)})),nf&&Qd(a),Lg.selectAll(".target").transition().style("opacity",1)}function Md(a,b){Wd.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}}),Wd.data.targets=Wd.data.targets.concat(a),Ld(Wd.data.targets),Gd({withUpdateOrgXDomain:!0,withUpdateXDomain:!0}),b()}function Nd(a){var b=Lg.selectAll(".legend-item"),c=function(b){return!a||b===a},d=function(a){return!c(a)};b.filter(d).transition().duration(100).style("opacity",.3),b.filter(c).transition().duration(100).style("opacity",1)}function Od(a){var b=Lg.selectAll(".legend-item"),c=function(b){return!a||b===a},d=function(a){return!c(a)};b.filter(d).transition().duration(100).style("opacity",1),b.filter(c).transition().duration(100).style("opacity",.3)}function Pd(){Lg.selectAll(".legend-item").transition().duration(100).style("opacity",1)}function Qd(a,b){function c(a,b){return qf?w[a]*b:v[a]}function f(a,b){return qf?x[a]*b:v[a]}function h(b,c){var d,e,f=b.getBBox(),h=10*Math.ceil((f.width+t)/10),i=10*Math.ceil((f.height+s)/10),j=Dg?i:h,k=Dg?te:ue;w[c]=h,x[c]=i,qf?(d=g.max(Object.keys(w).map(function(a){return w[a]})),e=g.max(Object.keys(x).map(function(a){return x[a]})),h>=d&&(Object.keys(w).forEach(function(a){w[a]=h}),Dg||(p=(ue-h*Object.keys(a).length)/2)),i>=e&&(Object.keys(x).forEach(function(a){x[a]=i}),Dg&&(p=(te-i*Object.keys(a).length)/2))):(v[c]=u,u+=j,p=(k-u)/2)}var i,j,k,l,m,n,o,p,q,r=Nb(a),s=4,t=30,u=0,v={},w={},x={};b=d(b)?{}:b,q=e(b.withTransition)?b.withTransition:!0,Dg?(j=function(){return.2*ue},m=function(a,b){return p+f(a,b)}):(j=function(a,b){return p+c(a,b)},m=function(){return.2*te}),k=function(a,b){return j(a,b)+14},n=function(a,b){return m(a,b)+9},l=function(a,b){return j(a,b)-4},o=function(a,b){return m(a,b)-7},i=Pg.selectAll(".legend-item").data(r).enter().append("g").attr("class",function(a){return"legend-item legend-item-"+a}).style("cursor","pointer").on("click",function(a){pf(a)}).on("mouseover",function(a){Nd(a),Wd.focus(a)}).on("mouseout",function(){Pd(),Wd.revert()}),i.append("text").text(function(a){return e(Ye[a])?Ye[a]:a}).each(function(a){h(this,a)}).style("pointer-events","none").attr("x",Dg?k:-200).attr("y",Dg?-200:m),i.append("rect").attr("class","legend-item-event").style("fill-opacity",0).attr("x",Dg?l:-200).attr("y",Dg?-200:o).attr("width",function(a){return w[a]}).attr("height",function(a){return x[a]}),i.append("rect").attr("class","legend-item-tile").style("pointer-events","none").style("fill",function(a){return wg(a)}).attr("x",Dg?k:-200).attr("y",Dg?-200:n).attr("width",10).attr("height",10),Pg.selectAll("text").data(r).each(function(a){h(this,a)}).transition().duration(q?250:0).attr("x",k).attr("y",n),Pg.selectAll("rect.legend-item-event").data(r).transition().duration(q?250:0).attr("x",l).attr("y",o),Pg.selectAll("rect.legend-item-tile").data(r).transition().duration(q?250:0).attr("x",j).attr("y",m)}function Rd(a){return a?"-"+a.replace(/\./g,"\\."):""}function Sd(a){return".target"+Rd(a)}function Td(a){return Ob(a.id)}function Ud(a){return"data"in a&&Ob(a.data.id)}function Vd(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 Wd={data:{}},Xd={},Yd="_expanded_",Zd="_selected_",$d="_included_",_d=i(["bindto"],"#chart"),ae=i(["size","width"],null),be=i(["size","height"],null),ce=i(["padding","left"],null),de=i(["padding","right"],null),ee=i(["zoom","enabled"],!1),fe=i(["zoom","extent"],null),ge=i(["zoom","privileged"],!1),he=i(["onenter"],function(){}),ie=i(["onleave"],function(){}),je=i(["transition","duration"],350);h("data","data is required in config");var ke,le,me,ne,oe,pe,qe,re,se,te,ue,ve,we,xe,ye,ze,Ae,Be,Ce,De,Ee,Fe,Ge,He,Ie,Je,Ke,Le,Me,Ne,Oe,Pe,Qe,Re,Se,Te,Ue=i(["data","x"],null),Ve=i(["data","xs"],null),We=i(["data","x_format"],"%Y-%m-%d"),Xe=i(["data","id_converter"],function(a){return a}),Ye=i(["data","names"],{}),Ze=i(["data","groups"],[]),$e=i(["data","axes"],{}),_e=i(["data","type"],null),af=i(["data","types"],{}),bf=i(["data","labels"],{}),cf=i(["data","order"],null),df=i(["data","regions"],{}),ef=i(["data","colors"],{}),ff=i(["data","selection","enabled"],!1),gf=i(["data","selection","grouped"],!1),hf=i(["data","selection","isselectable"],function(){return!0}),jf=i(["data","selection","multiselected"],!0),kf=i(["subchart","show"],!1),lf=kf?i(["subchart","size","height"],60):0,mf=i(["color","pattern"],null),nf=i(["legend","show"],!0),of=i(["legend","position"],"bottom"),pf=i(["legend","item","onclick"],function(){}),qf=i(["legend","equally"],!1),rf=i(["axis","rotated"],!1),sf=i(["axis","x","type"],"indexed"),tf=i(["axis","x","categories"],[]),uf=i(["axis","x","tick","centered"],!1),vf=i(["axis","x","tick","format"],null),wf=i(["axis","x","tick","culling"],"categorized"===sf?!1:!0),xf=i(["axis","x","tick","count"],10),yf=i(["axis","x","default"],null),zf=i(["axis","x","label"],null),Af=i(["axis","y","max"],null),Bf=i(["axis","y","min"],null),Cf=i(["axis","y","center"],null),Df=i(["axis","y","label"],null),Ef=i(["axis","y","inner"],!1),Ff=i(["axis","y","tick","format"],null),Gf=i(["axis","y","padding"],null),Hf=i(["axis","y","ticks"],10),If=i(["axis","y2","show"],!1),Jf=i(["axis","y2","max"],null),Kf=i(["axis","y2","min"],null),Lf=i(["axis","y2","center"],null),Mf=i(["axis","y2","inner"],!1),Nf=i(["axis","y2","tick","format"],null),Of=i(["axis","y2","padding"],null),Pf=i(["axis","y2","ticks"],10),Qf=i(["grid","x","show"],!1),Rf=i(["grid","x","type"],"tick"),Sf=i(["grid","x","lines"],null),Tf=i(["grid","y","show"],!1),Uf=i(["grid","y","lines"],null),Vf=i(["grid","y","ticks"],10),Wf=i(["point","show"],!0),Xf=Wf?i(["point","r"],2.5):0,Yf=i(["point","focus","line","enabled"],!0),Zf=i(["point","focus","expand","enabled"],!0),$f=i(["point","focus","expand","r"],Zf?4:Xf),_f=i(["point","focus","select","r"],8),ag=i(["point","onclick"],function(){}),bg=i(["point","onselected"],function(){}),cg=i(["point","onunselected"],function(){}),dg=i(["arc","label","show"],!0),eg=i(["arc","label","format"],null),fg=i(["arc","title"],""),gg=i(["regions"],[]),hg=i(["tooltip","show"],!0),ig=i(["tooltip","format","title"],null),jg=i(["tooltip","format","value"],null),kg=i(["tooltip","contents"],function(a,b,c,d){var e,f,g,h,i,j=ig?ig:b,k=jg?jg:c;for(f=0;f<a.length;f++)a[f]&&(a[f].value||0===a[f].value)&&(e||(g=j?j(a[f].x):a[f].x,e="<table class='-tooltip'>"+(g?"<tr><th colspan='2'>"+g+"</th></tr>":"")),i=a[f].name,h=k(a[f].value,a[f].ratio),e+="<tr class='-tooltip-name-"+a[f].id+"'><td class='name'><span style='background-color:"+d(a[f].id)+"'></span>"+i+"</td><td class='value'>"+h+"</td></tr>");return e+"</table>"}),lg=i(["tooltip","init","show"],!1),mg=i(["tooltip","init","x"],0),ng=i(["tooltip","init","position"],{top:"0px",left:"50px"}),og=_d.replace("#","")+"-clip",pg=j(og),qg="timeseries"===sf,rg="categorized"===sf,sg=!qg&&(Ue||Ve),tg=null,ug=!1,vg=!1,wg=_c(ef,mf),xg=function(){var a=[[g.time.format("%Y/%-m/%-d"),function(){return!0}],[g.time.format("%-m/%-d"),function(a){return a.getMonth()}],[g.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[g.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[g.time.format("%I %p"),function(a){return a.getHours()}],[g.time.format("%I:%M"),function(a){return a.getMinutes()}],[g.time.format(":%S"),function(a){return a.getSeconds()}],[g.time.format(".%L"),function(a){return a.getMilliseconds()}]];return function(b){for(var c=a.length-1,d=a[c];!d[1](b);)d=a[--c];return d[0](b)}}(),yg=rf?"left":"bottom",zg=rf?Ef?"top":"bottom":Ef?"right":"left",Ag=rf?Mf?"bottom":"top":Mf?"left":"right",Bg=rf?"left":"bottom",Cg={main:function(){return"translate("+ke.left+","+ke.top+")"},context:function(){return"translate("+le.left+","+le.top+")"},legend:function(){return"translate("+me.left+","+me.top+")"},y2:function(){return"translate("+(rf?0:ne)+","+(rf?1:0)+")"},x:function(){return"translate(0,"+pe+")"},subx:function(){return"translate(0,"+(rf?0:qe)+")"},arc:function(){return"translate("+ne/2+","+pe/2+")"}},Dg="right"===of,Eg=40,Fg=20;Be=g.layout.pie().value(function(a){return a.values.reduce(function(a,b){return a+b.value},0)});var Gg,Hg=function(){var a=g.svg.line().x(rf?function(a){return K(a.id)(a.value)}:mc).y(rf?mc:function(a){return K(a.id)(a.value)});return function(b){var c,d,e=md(b.values);return Rc(b)?(a.interpolate(Sc(b)?"cardinal":"linear"),df[b.id]?yd(e,Ke,K(b.id),df[b.id]):a(e)):(c=Ke(e[0].x),d=K(b.id)(e[0].value),rf?"M "+d+" "+c:"M "+c+" "+d)}}(),Ig=function(){var a;return a=rf?g.svg.area().x0(function(a){return K(a.id)(0)}).x1(function(a){return K(a.id)(a.value)}).y(mc):g.svg.area().x(mc).y0(function(a){return K(a.id)(0)}).y1(function(a){return K(a.id)(a.value)}),function(b){var c,d,e=md(b.values);return Lc([b],"area")||Lc([b],"area-spline")?(a.interpolate(Sc(b)?"cardinal":"linear"),a(e)):(c=Ke(e[0].x),d=K(b.id)(e[0].value),rf?"M "+d+" "+c:"M "+c+" "+d)}}(),Jg=function(){var a=g.svg.line().x(rf?function(a){return L(a.id)(a.value)}:pc).y(rf?pc:function(a){return L(a.id)(a.value)});return function(b){var c=md(b.values);return Rc(b)?a(c):"M "+Ne(c[0].x)+" "+L(b.id)(c[0].value)}}(),Kg=function(){};Gg=g.svg.brush().on("brush",Hd),Gg.update=function(){return Og&&Og.select(".x.brush").call(this),this},Gg.scale=function(a){return rf?this.y(a):this.x(a)},ee&&(Kg=g.behavior.zoom().on("zoomstart",function(){Kg.altDomain=g.event.sourceEvent.altKey?Ke.orgDomain():null}).on("zoom",ee?Id:null),Kg.scale=function(a){return rf?this.y(a):this.x(a)},Kg.orgScaleExtent=function(){var a=fe?fe:[1,10];return[a[0],Math.max(Lb()/a[1],a[1])]},Kg.updateScaleExtent=function(){var a=tb(Ke.orgDomain())/tb(Sg),b=this.orgScaleExtent();return this.scaleExtent([b[0]*a,b[1]*a]),this});var Lg,Mg,Ng,Og,Pg,Qg,Rg,Sg,Tg,Ug={};if(Wd.focus=function(a){function b(a){a.transition().duration(100).style("opacity",1)}var c=Lg.selectAll(Sd(a)),d=c.filter(Td),e=c.filter(Ud);Wd.revert(),Wd.defocus(),b(d.classed("focused",!0)),b(e),Qc(Wd.data.targets)&&jb(a,!0),Nd(a)},Wd.defocus=function(a){function b(a){a.transition().duration(100).style("opacity",.3)}var c=Lg.selectAll(Sd(a)),d=c.filter(Td),e=c.filter(Ud);Wd.revert(),b(d.classed("focused",!1)),b(e),Qc(Wd.data.targets)&&kb(a),Od(a)},Wd.revert=function(a){function b(a){a.transition().duration(100).style("opacity",1)}var c=Lg.selectAll(Sd(a)),d=c.filter(Td),e=c.filter(Ud);b(d.classed("focused",!1)),b(e),Qc(Wd.data.targets)&&kb(a),Pd()},Wd.show=function(a){Lg.selectAll(Sd(a)).transition().style("opacity",1)},Wd.hide=function(a){Lg.selectAll(Sd(a)).transition().style("opacity",0)},Wd.unzoom=function(){Gg.clear().update(),Gd({withUpdateXDomain:!0})},Wd.load=function(a){if("function"!=typeof a.done&&(a.done=function(){}),a.xs&&Db(a.xs),"categories"in a&&rg&&(tf=a.categories,Qe.categories(tf)),"cacheIds"in a&&ub(a.cacheIds))return void Md(wb(a.cacheIds),a.done);if("data"in a)Md(Hb(a.data),a.done);else if("url"in a)g.csv(a.url,function(b,c){Md(Hb(c),a.done)});else if("rows"in a)Md(Hb(Fb(a.rows)),a.done);else{if(!("columns"in a))throw Error("url or rows or columns is required.");Md(Hb(Gb(a.columns)),a.done)}},Wd.unload=function(a){Wd.data.targets=Wd.data.targets.filter(function(b){return b.id!==a}),Lg.selectAll(Sd(a)).transition().style("opacity",0).remove(),nf&&(Lg.selectAll(".legend-item"+Rd(a)).remove(),Qd(Wd.data.targets)),Wd.data.targets.length>0&&Gd({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})},Wd.selected=function(a){var b=Rd(a);return g.merge(Ng.selectAll(".-shapes"+b).selectAll(".-shape").filter(function(){return g.select(this).classed(Zd)}).map(function(a){return a.map(function(a){return a.__data__})}))},Wd.select=function(a,b,c){ff&&Ng.selectAll(".-shapes").selectAll(".-shape").each(function(f,h){var i="circle"===this.nodeName?gd:jd,j="circle"===this.nodeName?hd:kd;b.indexOf(h)>=0?hf(f)&&(gf||d(a)||a.indexOf(f.id)>=0)&&i(g.select(this).classed(Zd,!0),f,h):e(c)&&c&&j(g.select(this).classed(Zd,!1),f,h)})},Wd.unselect=function(a,b){ff&&Ng.selectAll(".-shapes").selectAll(".-shape").each(function(c,e){var f="circle"===this.nodeName?hd:kd;(d(b)||b.indexOf(e)>=0)&&hf(c)&&(gf||d(a)||a.indexOf(c.id)>=0)&&f(g.select(this).classed(Zd,!1),c,e)})},Wd.toLine=function(a){Kc(a,"line"),Kd({withTransition:!0})},Wd.toSpline=function(a){Kc(a,"spline"),Kd({withTransition:!0})},Wd.toBar=function(a){Kc(a,"bar"),Kd({withTransition:!0})},Wd.toScatter=function(a){Kc(a,"scatter"),Kd({withTransition:!0})},Wd.toArea=function(a){Kc(a,"area"),Kd({withTransition:!0})},Wd.toAreaSpline=function(a){Kc(a,"area-spline"),Kd({withTransition:!0})},Wd.toPie=function(a){Kc(a,"pie"),Kd({withTransition:!0,withTransform:!0})},Wd.toDonut=function(a){Kc(a,"donut"),Kd({withTransition:!0,withTransform:!0})},Wd.groups=function(a){return d(a)?Ze:(Ze=a,Gd(),Ze)},Wd.xgrids=function(a){return a?(Sf=a,Gd(),Sf):Sf},Wd.xgrids.add=function(a){return a?Wd.xgrids(Sf.concat(a)):void 0},Wd.xgrids.remove=function(a){var b=Vd(a);return Wd.xgrids(Sf.filter(b))},Wd.ygrids=function(a){return a?(Uf=a,Gd(),Uf):Uf},Wd.ygrids.add=function(a){return a?Wd.ygrids(Uf.concat(a)):void 0},Wd.ygrids.remove=function(a){var b=Vd(a);return Wd.ygrids(Uf.filter(b))},Wd.regions=function(a){return d(a)?gg:(gg=a,Gd(),gg)},Wd.regions.add=function(a){return d(a)?gg:(gg=gg.concat(a),Gd(),gg)},Wd.regions.remove=function(a,b){var d=[].concat(a);return b=e(b)?b:{},d.forEach(function(a){var d=c(b.duration)?b.duration:0;Lg.selectAll("."+a).transition().duration(d).style("fill-opacity",0).remove(),gg=gg.filter(function(b){return b.classes.indexOf(a)<0})}),gg},Wd.data.get=function(a){var b=Wd.data.getAsTarget(a);return e(b)?b.values.map(function(a){return a.value}):void 0},Wd.data.getAsTarget=function(a){var b=Pb(function(b){return b.id===a});return b.length>0?b[0]:void 0},Wd.resize=function(a){ae=a?a.width:null,be=a?a.height:null,Kd()},Wd.destroy=function(){Wd.data.targets=void 0,Wd.data.x={},Rg.html(""),a.onresize=null},"url"in f.data)g.csv(f.data.url,function(a,b){zd(b)});else if("rows"in f.data)zd(Fb(f.data.rows));else{if(!("columns"in f.data))throw Error("url or rows or columns is required.");zd(Gb(f.data.columns))}return Wd}}(window); |