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