|
|
|
!function(a,b){"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):a.c3=b()}(this,function(){"use strict";function a(a,b){function c(a,b){a.attr("transform",function(a){return"translate("+Math.ceil(b(a)+v)+", 0)"})}function d(a,b){a.attr("transform",function(a){return"translate(0,"+Math.ceil(b(a))+")"})}function e(a){var b=a[0],c=a[a.length-1];return b<c?[b,c]:[c,b]}function f(a){var b,c,d=[];if(a.ticks)return a.ticks.apply(a,o);for(c=a.domain(),b=Math.ceil(c[0]);b<c[1];b++)d.push(b);return d.length>0&&d[0]>0&&d.unshift(d[0]-(d[1]-d[0])),d}function h(){var a,c=q.copy();return b.isCategory&&(a=q.domain(),c.domain([a[0],a[1]-1])),c}function i(a){var b=n?n(a):a;return void 0!==b?b:""}function j(a){if(g)return g;var b={h:11.5,w:5.5};return a.select("text").text(i).each(function(a){var c=this.getBoundingClientRect(),d=i(a),e=c.height,f=d?c.width/d.length:void 0;e&&f&&(b.h=e,b.w=f)}).text(""),g=b,b}function k(c){return b.withoutTransition?c:a.transition(c)}function l(g){g.each(function(){function g(a,c){function d(a,b){f=void 0;for(var h=1;h<b.length;h++)if(" "===b.charAt(h)&&(f=h),e=b.substr(0,h+1),g=U.w*e.length,c<g)return d(a.concat(b.substr(0,f||h)),b.slice(f?f+1:h));return a.concat(b)}var e,f,g,h=i(a),j=[];return"[object Array]"===Object.prototype.toString.call(h)?h:((!c||c<=0)&&(c=X?95:b.isCategory?Math.ceil(F(G[1])-F(G[0]))-12:110),d(j,h+""))}function n(a,b){var c=U.h;return 0===b&&(c="left"===r||"right"===r?-((V[a.index]-1)*(U.h/2)-3):".71em"),c}function o(a){var b=q(a)+(p?0:v);return L[0]<b&&b<L[1]?s:0}function w(a){return a?a>0?"start":"end":"middle"}function x(a){return a?"rotate("+a+")":""}function y(a){return a?8*Math.sin(Math.PI*(a/180)):0}function z(a){return a?11.5-a/15*2.5*(a>0?1:-1):W}var A,B,C,D=l.g=a.select(this),E=this.__chart__||q,F=this.__chart__=h(),G=u||f(F),H=D.selectAll(".tick").data(G,F),I=H.enter().insert("g",".domain").attr("class","tick").style("opacity",1e-6),J=H.exit().remove(),K=k(H).style("opacity",1),L=q.rangeExtent?q.rangeExtent():e(q.range()),M=D.selectAll(".domain").data([0]),N=(M.enter().append("path").attr("class","domain"),k(M));I.append("line"),I.append("text");var O=I.select("line"),P=K.select("line"),Q=I.select("text"),R=K.select("text");b.isCategory?(v=Math.ceil((F(1)-F(0))/2),B=p?0:v,C=p?v:0):v=B=0;var S,T,U=j(D.select(".tick")),V=[],W=Math.max(s,0)+t,X="left"===r||"right"===r;S=H.select("text"),T=S.selectAll("tspan").data(function(a,c){var d=b.tickMultiline?g(a,b.tickWidth):[].concat(i(a));return V[c]=d.length,d.map(function(a){return{index:c,splitted:a}})}),T.enter().append("tspan"),T.exit().remove(),T.text(function(a){return a.splitted});var Y=b.tickTextRotate;switch(r){case"bottom":A=c,O.attr("y2",s),Q.attr("y",W),P.attr("x1",B).attr("x2",B).attr("y2",o),R.attr("x",0).attr("y",z(Y)).style("text-anchor",w(Y)).attr("transform",x(Y)),T.attr("x",0).attr("dy",n).attr("dx",y(Y)),N.attr("d","M"+L[0]+","+m+"V0H"+L[1]+"V"+m);break;case"top":A=c,O.attr("y2",-s),Q.attr("y",-W),P.attr("x2",0).attr("y2",-s),R.attr("x",0).attr("y",-W),S.style("text-anchor","middle"),T.attr("x",0).attr("dy","0em"),N.attr("d","M"+L[0]+","+-m+"V0H"+L[1]+"V"+-m);break;case"left":A=d,O.attr("x2",-s),Q.attr("x",-W),P.attr("x2",-s).attr("y1",C).attr("y2",C),R.attr("x",-W).attr("y",v),S.style("text-anchor","end"),T.attr("x",-W).attr("dy",n),N.attr("d","M"+-m+","+L[0]+"H0V"+L[1]+"H"+-m);break;case"right":A=d,O.attr("x2",s),Q.attr("x",W),P.attr("x2",s).attr("y2",0),R.attr("x",W).attr("y",0),S.style("text-anchor","start"),T.attr("x",W).attr("dy",n),N.attr("d","M"+m+","+L[0]+"H0V"+L[1]+"H"+m)}if(F.rangeBand){var Z=F,$=Z.rangeBand()/2;E=F=function(a){return Z(a)+$}}else E.rangeBand?E=F:J.call(A,F);I.call(A,E),K.call(A,F)})}var m,n,o,p,q=a.scale.linear(),r="bottom",s=6,t=3,u=null,v=0,w=!0;return b=b||{},m=b.withOuterTick?6:0,l.scale=function(a){return arguments.length?(q=a,l):q},l.orient=function(a){return arguments.length?(r=a in{top:1,right:1,bottom:1,left:1}?a+"":"bottom",l):r},l.tickFormat=function(a){return arguments.length?(n=a,l):n},l.tickCentere
|