Comparing version 1.0.4 to 1.0.5
@@ -1,6 +0,6 @@ | ||
// https://d3js.org/d3-axis/ Version 1.0.4. Copyright 2016 Mike Bostock. | ||
// https://d3js.org/d3-axis/ Version 1.0.5. Copyright 2017 Mike Bostock. | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(factory((global.d3 = global.d3 || {}))); | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(factory((global.d3 = global.d3 || {}))); | ||
}(this, (function (exports) { 'use strict'; | ||
@@ -20,10 +20,8 @@ | ||
function translateX(scale0, scale1, d) { | ||
var x = scale0(d); | ||
return "translate(" + (isFinite(x) ? x : scale1(d)) + ",0)"; | ||
function translateX(x) { | ||
return "translate(" + x + ",0)"; | ||
} | ||
function translateY(scale0, scale1, d) { | ||
var y = scale0(d); | ||
return "translate(0," + (isFinite(y) ? y : scale1(d)) + ")"; | ||
function translateY(y) { | ||
return "translate(0," + y + ")"; | ||
} | ||
@@ -49,3 +47,6 @@ | ||
tickSizeOuter = 6, | ||
tickPadding = 3; | ||
tickPadding = 3, | ||
k = orient === top || orient === left ? -1 : 1, | ||
x, y = orient === left || orient === right ? (x = "x", "y") : (x = "y", "x"), | ||
transform = orient === top || orient === bottom ? translateX : translateY; | ||
@@ -56,3 +57,2 @@ function axis(context) { | ||
spacing = Math.max(tickSizeInner, 0) + tickPadding, | ||
transform = orient === top || orient === bottom ? translateX : translateY, | ||
range = scale.range(), | ||
@@ -68,5 +68,3 @@ range0 = range[0] + 0.5, | ||
line = tick.select("line"), | ||
text = tick.select("text"), | ||
k = orient === top || orient === left ? -1 : 1, | ||
x, y = orient === left || orient === right ? (x = "x", "y") : (x = "y", "x"); | ||
text = tick.select("text"); | ||
@@ -99,7 +97,7 @@ path = path.merge(path.enter().insert("path", ".tick") | ||
.attr("opacity", epsilon) | ||
.attr("transform", function(d) { return transform(position, this.parentNode.__axis || position, d); }); | ||
.attr("transform", function(d) { return isFinite(d = position(d)) ? transform(d) : this.getAttribute("transform"); }); | ||
tickEnter | ||
.attr("opacity", epsilon) | ||
.attr("transform", function(d) { return transform(this.parentNode.__axis || position, position, d); }); | ||
.attr("transform", function(d) { var p = this.parentNode.__axis; return transform(p && isFinite(p = p(d)) ? p : position(d)); }); | ||
} | ||
@@ -116,3 +114,3 @@ | ||
.attr("opacity", 1) | ||
.attr("transform", function(d) { return transform(position, position, d); }); | ||
.attr("transform", function(d) { return transform(position(d)); }); | ||
@@ -119,0 +117,0 @@ line |
@@ -1,2 +0,2 @@ | ||
// https://d3js.org/d3-axis/ Version 1.0.4. Copyright 2016 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,n,e){var r=t(e);return"translate("+(isFinite(r)?r:n(e))+",0)"}function e(t,n,e){var r=t(e);return"translate(0,"+(isFinite(r)?r:n(e))+")"}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(o){var s,_=null==c?a.ticks?a.ticks.apply(a,u):a.domain():c,v=null==l?a.tickFormat?a.tickFormat.apply(a,u):f:l,F=Math.max(g,0)+y,M=t===d||t===m?n:e,b=a.range(),z=b[0]+.5,A=b[b.length-1]+.5,V=(a.bandwidth?r:f)(a.copy()),H=o.selection?o.selection():o,S=H.selectAll(".domain").data([null]),j=H.selectAll(".tick").data(_,a).order(),w=j.exit(),N=j.enter().append("g").attr("class","tick"),O=j.select("line"),P=j.select("text"),B=t===d||t===h?-1:1,I=t===h||t===p?(s="x","y"):(s="y","x");S=S.merge(S.enter().insert("path",".tick").attr("class","domain").attr("stroke","#000")),j=j.merge(N),O=O.merge(N.append("line").attr("stroke","#000").attr(s+"2",B*g).attr(I+"1",.5).attr(I+"2",.5)),P=P.merge(N.append("text").attr("fill","#000").attr(s,B*F).attr(I,.5).attr("dy",t===d?"0em":t===m?"0.71em":"0.32em")),o!==H&&(S=S.transition(o),j=j.transition(o),O=O.transition(o),P=P.transition(o),w=w.transition(o).attr("opacity",x).attr("transform",function(t){return M(V,this.parentNode.__axis||V,t)}),N.attr("opacity",x).attr("transform",function(t){return M(this.parentNode.__axis||V,V,t)})),w.remove(),S.attr("d",t===h||t==p?"M"+B*k+","+z+"H0.5V"+A+"H"+B*k:"M"+z+","+B*k+"V0.5H"+A+"V"+B*k),j.attr("opacity",1).attr("transform",function(t){return M(V,V,t)}),O.attr(s+"2",B*g),P.attr(s,B*F).text(v),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=null,l=null,g=6,k=6,y=3;return o.scale=function(t){return arguments.length?(a=t,o):a},o.ticks=function(){return u=s.call(arguments),o},o.tickArguments=function(t){return arguments.length?(u=null==t?[]:s.call(t),o):u.slice()},o.tickValues=function(t){return arguments.length?(c=null==t?null:s.call(t),o):c&&c.slice()},o.tickFormat=function(t){return arguments.length?(l=t,o):l},o.tickSize=function(t){return arguments.length?(g=k=+t,o):g},o.tickSizeInner=function(t){return arguments.length?(g=+t,o):g},o.tickSizeOuter=function(t){return arguments.length?(k=+t,o):k},o.tickPadding=function(t){return arguments.length?(y=+t,o):y},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,x=1e-6;t.axisTop=o,t.axisRight=u,t.axisBottom=c,t.axisLeft=l,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
// https://d3js.org/d3-axis/ Version 1.0.5. 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})}); |
{ | ||
"name": "d3-axis", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Displays automatic reference lines for scales.", | ||
@@ -29,3 +29,3 @@ "keywords": [ | ||
"prepublish": "npm run test && uglifyjs --preamble \"$(preamble)\" build/d3-axis.js -c -m -o build/d3-axis.min.js", | ||
"postpublish": "VERSION=`node -e 'console.log(require(\"./package.json\").version)'`; git push && git push --tags && cd ../d3.github.com && git pull && cp ../d3-axis/build/d3-axis.js d3-axis.v1.js && cp ../d3-axis/build/d3-axis.min.js d3-axis.v1.min.js && git add d3-axis.v1.js d3-axis.v1.min.js && git commit -m \"d3-axis ${VERSION}\" && git push && cd - && zip -j build/d3-axis.zip -- LICENSE README.md build/d3-axis.js build/d3-axis.min.js" | ||
"postpublish": "git push && git push --tags && cd ../d3.github.com && git pull && cp ../d3-axis/build/d3-axis.js d3-axis.v1.js && cp ../d3-axis/build/d3-axis.min.js d3-axis.v1.min.js && git add d3-axis.v1.js d3-axis.v1.min.js && git commit -m \"d3-axis ${npm_package_version}\" && git push && cd - && zip -j build/d3-axis.zip -- LICENSE README.md build/d3-axis.js build/d3-axis.min.js" | ||
}, | ||
@@ -36,3 +36,3 @@ "devDependencies": { | ||
"package-preamble": "0.0", | ||
"rollup": "0.36", | ||
"rollup": "0.41", | ||
"tape": "4", | ||
@@ -39,0 +39,0 @@ "uglify-js": "2" |
@@ -26,3 +26,2 @@ # d3-axis | ||
d3.select("body").append("svg") | ||
.attr("class", "axis") | ||
.attr("width", 1440) | ||
@@ -35,6 +34,8 @@ .attr("height", 30) | ||
Once created, the orientation of an axis is fixed. To change the orientation, remove the old axis and create a new axis. | ||
The elements created by the axis are considered part of its public API. You can apply external stylesheets or modify the generated axis elements to [customize the axis appearance](https://bl.ocks.org/mbostock/3371592). | ||
The elements created by the axis are considered part of its public API. You can apply external stylesheets or modify the generated axis elements to customize the axis appearance. An axis consists of a [path element](https://www.w3.org/TR/SVG/paths.html#PathElement) of class “domain” representing the extent of the scale’s domain, followed by transformed [g elements](https://www.w3.org/TR/SVG/struct.html#Groups) of class “tick” representing each of the scale’s ticks. Each tick has a [line element](https://www.w3.org/TR/SVG/shapes.html#LineElement) to draw the tick line, and a [text element](https://www.w3.org/TR/SVG/text.html#TextElement) for the tick label. For example, here is a typical bottom-oriented axis: | ||
[<img alt="Custom Axis" src="https://raw.githubusercontent.com/d3/d3-axis/master/img/custom.png" width="420" height="219">](http://bl.ocks.org/mbostock/3371592) | ||
An axis consists of a [path element](https://www.w3.org/TR/SVG/paths.html#PathElement) of class “domain” representing the extent of the scale’s domain, followed by transformed [g elements](https://www.w3.org/TR/SVG/struct.html#Groups) of class “tick” representing each of the scale’s ticks. Each tick has a [line element](https://www.w3.org/TR/SVG/shapes.html#LineElement) to draw the tick line, and a [text element](https://www.w3.org/TR/SVG/text.html#TextElement) for the tick label. For example, here is a typical bottom-oriented axis: | ||
```html | ||
@@ -70,2 +71,4 @@ <g fill="none" font-size="10" font-family="sans-serif" text-anchor="middle"> | ||
The orientation of an axis is fixed; to change the orientation, remove the old axis and create a new axis. | ||
<a name="axisTop" href="#axisTop">#</a> d3.<b>axisTop</b>(<i>scale</i>) [<>](https://github.com/d3/d3-axis/blob/master/src/axis.js#L159 "Source") | ||
@@ -72,0 +75,0 @@ |
@@ -10,10 +10,8 @@ import {slice} from "./array"; | ||
function translateX(scale0, scale1, d) { | ||
var x = scale0(d); | ||
return "translate(" + (isFinite(x) ? x : scale1(d)) + ",0)"; | ||
function translateX(x) { | ||
return "translate(" + x + ",0)"; | ||
} | ||
function translateY(scale0, scale1, d) { | ||
var y = scale0(d); | ||
return "translate(0," + (isFinite(y) ? y : scale1(d)) + ")"; | ||
function translateY(y) { | ||
return "translate(0," + y + ")"; | ||
} | ||
@@ -39,3 +37,6 @@ | ||
tickSizeOuter = 6, | ||
tickPadding = 3; | ||
tickPadding = 3, | ||
k = orient === top || orient === left ? -1 : 1, | ||
x, y = orient === left || orient === right ? (x = "x", "y") : (x = "y", "x"), | ||
transform = orient === top || orient === bottom ? translateX : translateY; | ||
@@ -46,3 +47,2 @@ function axis(context) { | ||
spacing = Math.max(tickSizeInner, 0) + tickPadding, | ||
transform = orient === top || orient === bottom ? translateX : translateY, | ||
range = scale.range(), | ||
@@ -58,5 +58,3 @@ range0 = range[0] + 0.5, | ||
line = tick.select("line"), | ||
text = tick.select("text"), | ||
k = orient === top || orient === left ? -1 : 1, | ||
x, y = orient === left || orient === right ? (x = "x", "y") : (x = "y", "x"); | ||
text = tick.select("text"); | ||
@@ -89,7 +87,7 @@ path = path.merge(path.enter().insert("path", ".tick") | ||
.attr("opacity", epsilon) | ||
.attr("transform", function(d) { return transform(position, this.parentNode.__axis || position, d); }); | ||
.attr("transform", function(d) { return isFinite(d = position(d)) ? transform(d) : this.getAttribute("transform"); }); | ||
tickEnter | ||
.attr("opacity", epsilon) | ||
.attr("transform", function(d) { return transform(this.parentNode.__axis || position, position, d); }); | ||
.attr("transform", function(d) { var p = this.parentNode.__axis; return transform(p && isFinite(p = p(d)) ? p : position(d)); }); | ||
} | ||
@@ -106,3 +104,3 @@ | ||
.attr("opacity", 1) | ||
.attr("transform", function(d) { return transform(position, position, d); }); | ||
.attr("transform", function(d) { return transform(position(d)); }); | ||
@@ -109,0 +107,0 @@ line |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42002
12
187
297