forked from d3/d3.github.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
d3-axis.v0.3.min.js
1 lines (1 loc) · 2.73 KB
/
d3-axis.v0.3.min.js
1
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.d3_axis=t.d3_axis||{})}(this,function(t){"use strict";function n(t){return t}function e(t,n,e){var r=t(e);return"translate("+(isFinite(r)?r:n(e))+",0)"}function r(t,n,e){var r=t(e);return"translate(0,"+(isFinite(r)?r:n(e))+")"}function i(t){var n=t.bandwidth()/2;return function(e){return t(e)+n}}function a(t,a){function o(o){var f,y=null==u?a.ticks?a.ticks.apply(a,c):a.domain():u,v=null==l?a.tickFormat?a.tickFormat.apply(a,c):n:l,_=Math.max(s,0)+k,F=t===d||t===m?e:r,z=a.range(),A=z[0]+.5,V=z[z.length-1]+.5,b=(a.bandwidth?i:n)(a.copy()),H=o.selection?o.selection():o,M=H.selectAll(".domain").data([null]),S=H.selectAll(".tick").data(y,a).order(),w=S.exit(),N=S.enter().append("g",".domain").attr("class","tick"),j=S.select("line"),B=S.select("text"),I=t===d||t===h?-1:1,L=t===h||t===p?(f="x","y"):(f="y","x");M=M.merge(M.enter().append("path").attr("class","domain").attr("stroke","#000")),S=S.merge(N),j=j.merge(N.append("line").attr("stroke","#000").attr(f+"2",I*s)),B=B.merge(N.append("text").attr("fill","#000").attr(f,I*_)),o!==H&&(M=M.transition(o),S=S.transition(o),j=j.transition(o),B=B.transition(o),w=w.transition(o).attr("opacity",x).attr("transform",function(t){return F(b,this.parentNode.__axis||b,t)}),N.attr("opacity",x).attr("transform",function(t){return F(this.parentNode.__axis||b,b,t)})),w.remove(),M.attr("d",t===h||t==p?"M"+I*g+","+A+"H0.5V"+V+"H"+I*g:"M"+A+","+I*g+"V0.5H"+V+"V"+I*g),S.attr("opacity",1).attr("transform",function(t){return F(b,b,t)}),j.attr(f+"2",I*s).attr(L+"1",.5).attr(L+"2",.5),B.attr(f,I*_).attr(L,.5).attr("dy",t===d?"0em":t===m?".71em":".32em").text(v),H.attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",t===p?"start":t===h?"end":"middle").each(function(){this.__axis=b})}var c=[],u=null,l=null,s=6,g=6,k=3;return o.scale=function(t){return arguments.length?(a=t,o):a},o.ticks=function(){return c=f.call(arguments),o},o.tickArguments=function(t){return arguments.length?(c=null==t?[]:f.call(t),o):c.slice()},o.tickValues=function(t){return arguments.length?(u=null==t?null:f.call(t),o):u&&u.slice()},o.tickFormat=function(t){return arguments.length?(l=t,o):l},o.tickSize=function(t){return arguments.length?(s=g=+t,o):s},o.tickSizeInner=function(t){return arguments.length?(s=+t,o):s},o.tickSizeOuter=function(t){return arguments.length?(g=+t,o):g},o.tickPadding=function(t){return arguments.length?(k=+t,o):k},o}function o(t){return a(d,t)}function c(t){return a(p,t)}function u(t){return a(m,t)}function l(t){return a(h,t)}var s="0.3.2",f=Array.prototype.slice,d=1,p=2,m=3,h=4,x=1e-6;t.version=s,t.axisTop=o,t.axisRight=c,t.axisBottom=u,t.axisLeft=l});