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
2.9 KiB
2 lines
2.9 KiB
// https://d3js.org/d3-axis/ Version 1.0.8. 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+.5)+",0)"}function e(t){return"translate(0,"+(t+.5)+")"}function r(t){return function(n){return+t(n)}}function i(t){var n=Math.max(0,t.bandwidth()-1)/2;return t.round()&&(n=Math.round(n)),function(e){return+t(e)+n}}function a(){return!this.__axis}function o(t,o){function u(n){var e=null==l?o.ticks?o.ticks.apply(o,c):o.domain():l,u=null==s?o.tickFormat?o.tickFormat.apply(o,c):d:s,f=Math.max(k,0)+_,A=o.range(),F=+A[0]+.5,z=+A[A.length-1]+.5,V=(o.bandwidth?i:r)(o.copy()),H=n.selection?n.selection():n,S=H.selectAll(".domain").data([null]),j=H.selectAll(".tick").data(e,o).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(M+"2",v*k)),B=B.merge(O.append("text").attr("fill","#000").attr(M,v*f).attr("dy",t===m?"0em":t===h?"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",x).attr("transform",function(t){return isFinite(t=V(t))?b(t):this.getAttribute("transform")}),O.attr("opacity",x).attr("transform",function(t){var n=this.parentNode.__axis;return b(n&&isFinite(n=n(t))?n:V(t))})),w.remove(),S.attr("d",t===g||t==p?"M"+v*y+","+F+"H0.5V"+z+"H"+v*y:"M"+F+","+v*y+"V0.5H"+z+"V"+v*y),j.attr("opacity",1).attr("transform",function(t){return b(V(t))}),P.attr(M+"2",v*k),B.attr(M,v*f).text(u),H.filter(a).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",t===p?"start":t===g?"end":"middle"),H.each(function(){this.__axis=V})}var c=[],l=null,s=null,k=6,y=6,_=3,v=t===m||t===g?-1:1,M=t===g||t===p?"x":"y",b=t===m||t===h?n:e;return u.scale=function(t){return arguments.length?(o=t,u):o},u.ticks=function(){return c=f.call(arguments),u},u.tickArguments=function(t){return arguments.length?(c=null==t?[]:f.call(t),u):c.slice()},u.tickValues=function(t){return arguments.length?(l=null==t?null:f.call(t),u):l&&l.slice()},u.tickFormat=function(t){return arguments.length?(s=t,u):s},u.tickSize=function(t){return arguments.length?(k=y=+t,u):k},u.tickSizeInner=function(t){return arguments.length?(k=+t,u):k},u.tickSizeOuter=function(t){return arguments.length?(y=+t,u):y},u.tickPadding=function(t){return arguments.length?(_=+t,u):_},u}function u(t){return o(m,t)}function c(t){return o(p,t)}function l(t){return o(h,t)}function s(t){return o(g,t)}var f=Array.prototype.slice,d=function(t){return t},m=1,p=2,h=3,g=4,x=1e-6;t.axisTop=u,t.axisRight=c,t.axisBottom=l,t.axisLeft=s,Object.defineProperty(t,"__esModule",{value:!0})}); |