Socket
Socket
Sign inDemoInstall

d3-axis

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-axis - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

89

build/d3-axis.js

@@ -7,3 +7,3 @@ (function (global, factory) {

var version = "0.3.1";
var version = "0.3.2";

@@ -52,4 +52,4 @@ var slice = Array.prototype.slice;

range = scale.range(),
range0 = range[0],
range1 = range[range.length - 1],
range0 = range[0] + 0.5,
range1 = range[range.length - 1] + 0.5,
position = (scale.bandwidth ? center : identity)(scale.copy()),

@@ -62,50 +62,63 @@ selection = context.selection ? context.selection() : context,

line = tick.select("line"),
text = tick.select("text");
text = tick.select("text"),
k = orient === top || orient === left ? -1 : 1,
x, y = orient === left || orient === right ? (x = "x", "y") : (x = "y", "x");
path = path.merge(path.enter().append("path").attr("class", "domain"));
path = path.merge(path.enter().append("path")
.attr("class", "domain")
.attr("stroke", "#000"));
tick = tick.merge(tickEnter);
line = line.merge(tickEnter.append("line"));
text = text.merge(tickEnter.append("text"));
line = line.merge(tickEnter.append("line")
.attr("stroke", "#000")
.attr(x + "2", k * tickSizeInner));
text = text.merge(tickEnter.append("text")
.attr("fill", "#000")
.attr(x, k * spacing));
if (context !== selection) {
path = path.transition(context);
tick = tick.transition(context);
tickExit = tickExit.transition(context).style("opacity", epsilon).attr("transform", function(d) { return transform(position, this.parentNode.__axis || position, d); });
tickEnter.style("opacity", epsilon).attr("transform", function(d) { return transform(this.parentNode.__axis || position, position, d); });
line = line.transition(context);
text = text.transition(context);
tickExit = tickExit.transition(context)
.attr("opacity", epsilon)
.attr("transform", function(d) { return transform(position, this.parentNode.__axis || position, d); });
tickEnter
.attr("opacity", epsilon)
.attr("transform", function(d) { return transform(this.parentNode.__axis || position, position, d); });
}
tick.style("opacity", 1).attr("transform", function(d) { return transform(position, position, d); });
tickExit.remove();
text.text(format);
switch (orient) {
case top: {
path.attr("d", "M" + range0 + "," + -tickSizeOuter + "V0H" + range1 + "V" + -tickSizeOuter);
line.attr("x2", 0).attr("y2", -tickSizeInner);
text.attr("x", 0).attr("y", -spacing).attr("dy", "0em").style("text-anchor", "middle");
break;
}
case right: {
path.attr("d", "M" + tickSizeOuter + "," + range0 + "H0V" + range1 + "H" + tickSizeOuter);
line.attr("y2", 0).attr("x2", tickSizeInner);
text.attr("y", 0).attr("x", spacing).attr("dy", ".32em").style("text-anchor", "start");
break;
}
case bottom: {
path.attr("d", "M" + range0 + "," + tickSizeOuter + "V0H" + range1 + "V" + tickSizeOuter);
line.attr("x2", 0).attr("y2", tickSizeInner);
text.attr("x", 0).attr("y", spacing).attr("dy", ".71em").style("text-anchor", "middle");
break;
}
case left: {
path.attr("d", "M" + -tickSizeOuter + "," + range0 + "H0V" + range1 + "H" + -tickSizeOuter);
line.attr("y2", 0).attr("x2", -tickSizeInner);
text.attr("y", 0).attr("x", -spacing).attr("dy", ".32em").style("text-anchor", "end");
break;
}
}
path
.attr("d", orient === left || orient == right
? "M" + k * tickSizeOuter + "," + range0 + "H0.5V" + range1 + "H" + k * tickSizeOuter
: "M" + range0 + "," + k * tickSizeOuter + "V0.5H" + range1 + "V" + k * tickSizeOuter)
selection.each(function() { this.__axis = position; });
tick
.attr("opacity", 1)
.attr("transform", function(d) { return transform(position, position, d); });
line
.attr(x + "2", k * tickSizeInner)
.attr(y + "1", 0.5)
.attr(y + "2", 0.5);
text
.attr(x, k * spacing)
.attr(y, 0.5)
.attr("dy", orient === top ? "0em" : orient === bottom ? ".71em" : ".32em")
.text(format);
selection
.attr("fill", "none")
.attr("font-size", 10)
.attr("font-family", "sans-serif")
.attr("text-anchor", orient === right ? "start" : orient === left ? "end" : "middle")
.each(function() { this.__axis = position; });
}

@@ -112,0 +125,0 @@

@@ -1,1 +0,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 a(t){var n=t.bandwidth()/2;return function(e){return t(e)+n}}function i(t,i){function c(c){var d=null==l?i.ticks?i.ticks.apply(i,o):i.domain():l,k=null==s?i.tickFormat?i.tickFormat.apply(i,o):n:s,v=Math.max(u,0)+g,_=t===f||t===x?e:r,V=i.range(),b=V[0],H=V[V.length-1],F=(i.bandwidth?a:n)(i.copy()),M=c.selection?c.selection():c,A=M.selectAll(".domain").data([null]),w=M.selectAll(".tick").data(d,i).order(),z=w.exit(),S=w.enter().append("g",".domain").attr("class","tick"),N=w.select("line"),j=w.select("text");switch(A=A.merge(A.enter().append("path").attr("class","domain")),w=w.merge(S),N=N.merge(S.append("line")),j=j.merge(S.append("text")),c!==M&&(A=A.transition(c),w=w.transition(c),z=z.transition(c).style("opacity",m).attr("transform",function(t){return _(F,this.parentNode.__axis||F,t)}),S.style("opacity",m).attr("transform",function(t){return _(this.parentNode.__axis||F,F,t)}),N=N.transition(c),j=j.transition(c)),w.style("opacity",1).attr("transform",function(t){return _(F,F,t)}),z.remove(),j.text(k),t){case f:A.attr("d","M"+b+","+-h+"V0H"+H+"V"+-h),N.attr("x2",0).attr("y2",-u),j.attr("x",0).attr("y",-v).attr("dy","0em").style("text-anchor","middle");break;case y:A.attr("d","M"+h+","+b+"H0V"+H+"H"+h),N.attr("y2",0).attr("x2",u),j.attr("y",0).attr("x",v).attr("dy",".32em").style("text-anchor","start");break;case x:A.attr("d","M"+b+","+h+"V0H"+H+"V"+h),N.attr("x2",0).attr("y2",u),j.attr("x",0).attr("y",v).attr("dy",".71em").style("text-anchor","middle");break;case p:A.attr("d","M"+-h+","+b+"H0V"+H+"H"+-h),N.attr("y2",0).attr("x2",-u),j.attr("y",0).attr("x",-v).attr("dy",".32em").style("text-anchor","end")}M.each(function(){this.__axis=F})}var o=[],l=null,s=null,u=6,h=6,g=3;return c.scale=function(t){return arguments.length?(i=t,c):i},c.ticks=function(){return o=d.call(arguments),c},c.tickArguments=function(t){return arguments.length?(o=null==t?[]:d.call(t),c):o.slice()},c.tickValues=function(t){return arguments.length?(l=null==t?null:d.call(t),c):l&&l.slice()},c.tickFormat=function(t){return arguments.length?(s=t,c):s},c.tickSize=function(t){return arguments.length?(u=h=+t,c):u},c.tickSizeInner=function(t){return arguments.length?(u=+t,c):u},c.tickSizeOuter=function(t){return arguments.length?(h=+t,c):h},c.tickPadding=function(t){return arguments.length?(g=+t,c):g},c}function c(t){return i(f,t)}function o(t){return i(y,t)}function l(t){return i(x,t)}function s(t){return i(p,t)}var u="0.3.1",d=Array.prototype.slice,f=1,y=2,x=3,p=4,m=1e-6;t.version=u,t.axisTop=c,t.axisRight=o,t.axisBottom=l,t.axisLeft=s});
!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});
export var name = "d3-axis";
export var version = "0.3.1";
export var version = "0.3.2";
export var description = "Displays automatic reference lines for scales.";

@@ -12,2 +12,2 @@ export var keywords = ["d3","axis","scale","visualization"];

export var dependencies = {"d3-scale":"~0.7.0","d3-selection":"~0.7.0","d3-transition":"~0.2.0"};
export var devDependencies = {"json2module":"0.0","rollup":"0.26","tape":"4","uglify-js":"2"};
export var devDependencies = {"eslint":"2","json2module":"0.0","rollup":"0.26","tape":"4","uglify-js":"2"};
{
"name": "d3-axis",
"version": "0.3.1",
"version": "0.3.2",
"description": "Displays automatic reference lines for scales.",

@@ -35,2 +35,3 @@ "keywords": [

"devDependencies": {
"eslint": "2",
"json2module": "0.0",

@@ -37,0 +38,0 @@ "rollup": "0.26",

@@ -7,3 +7,3 @@ # d3-axis

If you use NPM, `npm install d3-axis`. Otherwise, download the [latest release](https://github.com/d3/d3-axis/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-axis.v0.3.min.js) or as part of [D3 4.0 alpha](https://github.com/mbostock/d3/tree/4). (Some dependencies are optional.) AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3_axis` global is exported:
If you use NPM, `npm install d3-axis`. Otherwise, download the [latest release](https://github.com/d3/d3-axis/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-axis.v0.3.min.js) or as part of [D3 4.0](https://github.com/d3/d3). (Some dependencies are optional.) AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3_axis` global is exported:

@@ -10,0 +10,0 @@ ```html

@@ -41,4 +41,4 @@ import {slice} from "./array";

range = scale.range(),
range0 = range[0],
range1 = range[range.length - 1],
range0 = range[0] + 0.5,
range1 = range[range.length - 1] + 0.5,
position = (scale.bandwidth ? center : identity)(scale.copy()),

@@ -51,50 +51,63 @@ selection = context.selection ? context.selection() : context,

line = tick.select("line"),
text = tick.select("text");
text = tick.select("text"),
k = orient === top || orient === left ? -1 : 1,
x, y = orient === left || orient === right ? (x = "x", "y") : (x = "y", "x");
path = path.merge(path.enter().append("path").attr("class", "domain"));
path = path.merge(path.enter().append("path")
.attr("class", "domain")
.attr("stroke", "#000"));
tick = tick.merge(tickEnter);
line = line.merge(tickEnter.append("line"));
text = text.merge(tickEnter.append("text"));
line = line.merge(tickEnter.append("line")
.attr("stroke", "#000")
.attr(x + "2", k * tickSizeInner));
text = text.merge(tickEnter.append("text")
.attr("fill", "#000")
.attr(x, k * spacing));
if (context !== selection) {
path = path.transition(context);
tick = tick.transition(context);
tickExit = tickExit.transition(context).style("opacity", epsilon).attr("transform", function(d) { return transform(position, this.parentNode.__axis || position, d); });
tickEnter.style("opacity", epsilon).attr("transform", function(d) { return transform(this.parentNode.__axis || position, position, d); });
line = line.transition(context);
text = text.transition(context);
tickExit = tickExit.transition(context)
.attr("opacity", epsilon)
.attr("transform", function(d) { return transform(position, this.parentNode.__axis || position, d); });
tickEnter
.attr("opacity", epsilon)
.attr("transform", function(d) { return transform(this.parentNode.__axis || position, position, d); });
}
tick.style("opacity", 1).attr("transform", function(d) { return transform(position, position, d); });
tickExit.remove();
text.text(format);
switch (orient) {
case top: {
path.attr("d", "M" + range0 + "," + -tickSizeOuter + "V0H" + range1 + "V" + -tickSizeOuter);
line.attr("x2", 0).attr("y2", -tickSizeInner);
text.attr("x", 0).attr("y", -spacing).attr("dy", "0em").style("text-anchor", "middle");
break;
}
case right: {
path.attr("d", "M" + tickSizeOuter + "," + range0 + "H0V" + range1 + "H" + tickSizeOuter);
line.attr("y2", 0).attr("x2", tickSizeInner);
text.attr("y", 0).attr("x", spacing).attr("dy", ".32em").style("text-anchor", "start");
break;
}
case bottom: {
path.attr("d", "M" + range0 + "," + tickSizeOuter + "V0H" + range1 + "V" + tickSizeOuter);
line.attr("x2", 0).attr("y2", tickSizeInner);
text.attr("x", 0).attr("y", spacing).attr("dy", ".71em").style("text-anchor", "middle");
break;
}
case left: {
path.attr("d", "M" + -tickSizeOuter + "," + range0 + "H0V" + range1 + "H" + -tickSizeOuter);
line.attr("y2", 0).attr("x2", -tickSizeInner);
text.attr("y", 0).attr("x", -spacing).attr("dy", ".32em").style("text-anchor", "end");
break;
}
}
path
.attr("d", orient === left || orient == right
? "M" + k * tickSizeOuter + "," + range0 + "H0.5V" + range1 + "H" + k * tickSizeOuter
: "M" + range0 + "," + k * tickSizeOuter + "V0.5H" + range1 + "V" + k * tickSizeOuter)
selection.each(function() { this.__axis = position; });
tick
.attr("opacity", 1)
.attr("transform", function(d) { return transform(position, position, d); });
line
.attr(x + "2", k * tickSizeInner)
.attr(y + "1", 0.5)
.attr(y + "2", 0.5);
text
.attr(x, k * spacing)
.attr(y, 0.5)
.attr("dy", orient === top ? "0em" : orient === bottom ? ".71em" : ".32em")
.text(format);
selection
.attr("fill", "none")
.attr("font-size", 10)
.attr("font-family", "sans-serif")
.attr("text-anchor", orient === right ? "start" : orient === left ? "end" : "middle")
.each(function() { this.__axis = position; });
}

@@ -101,0 +114,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc