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