Socket
Socket
Sign inDemoInstall

d3-sankey

Package Overview
Dependencies
Maintainers
2
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-sankey - npm Package Compare versions

Comparing version 0.12.1 to 0.12.2

18

dist/d3-sankey.js

@@ -1,2 +0,2 @@

// https://github.com/d3/d3-sankey v0.12.1 Copyright 2019 Mike Bostock
// https://github.com/d3/d3-sankey v0.12.2 Copyright 2019 Mike Bostock
(function (global, factory) {

@@ -88,3 +88,3 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-array'), require('d3-shape')) :

let dx = 24; // nodeWidth
let py = 8; // nodePadding
let dy = 8, py; // nodePadding
let id = defaultId;

@@ -131,3 +131,3 @@ let align = justify;

sankey.nodePadding = function(_) {
return arguments.length ? (py = +_, sankey) : py;
return arguments.length ? (dy = py = +_, sankey) : dy;
};

@@ -178,6 +178,5 @@

for (const node of nodes) {
node.value = Math.max(
d3Array.sum(node.sourceLinks, value),
d3Array.sum(node.targetLinks, value)
);
node.value = node.fixedValue === undefined
? Math.max(d3Array.sum(node.sourceLinks, value), d3Array.sum(node.targetLinks, value))
: node.fixedValue;
}

@@ -264,2 +263,3 @@ }

const columns = computeNodeLayers(graph);
py = Math.min(dy, (y1 - y0) / (d3Array.max(columns, c => c.length) - 1));
initializeNodeBreadths(columns);

@@ -416,6 +416,6 @@ for (let i = 0; i < iterations; ++i) {

exports.sankeyCenter = center;
exports.sankeyJustify = justify;
exports.sankeyLeft = left;
exports.sankeyLinkHorizontal = sankeyLinkHorizontal;
exports.sankeyRight = right;
exports.sankeyJustify = justify;
exports.sankeyLinkHorizontal = sankeyLinkHorizontal;

@@ -422,0 +422,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

@@ -1,2 +0,2 @@

// https://github.com/d3/d3-sankey v0.12.1 Copyright 2019 Mike Bostock
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-array"),require("d3-shape")):"function"==typeof define&&define.amd?define(["exports","d3-array","d3-shape"],t):t((n=n||self).d3=n.d3||{},n.d3,n.d3)}(this,function(n,t,e){"use strict";function o(n){return n.target.depth}function r(n,t){return n.sourceLinks.length?n.depth:t-1}function i(n){return function(){return n}}function s(n,t){return u(n.source,t.source)||n.index-t.index}function f(n,t){return u(n.target,t.target)||n.index-t.index}function u(n,t){return n.y0-t.y0}function c(n){return n.value}function l(n){return n.index}function a(n){return n.nodes}function d(n){return n.links}function h(n,t){const e=n.get(t);if(!e)throw new Error("missing: "+t);return e}function g({nodes:n}){for(const t of n){let n=t.y0,e=n;for(const e of t.sourceLinks)e.y0=n+e.width/2,n+=e.width;for(const n of t.targetLinks)n.y1=e+n.width/2,e+=n.width}}function y(n){return[n.source.x1,n.y0]}function k(n){return[n.target.x0,n.y1]}n.sankey=function(){let n,e,o=0,y=0,k=1,p=1,L=24,w=8,x=l,m=r,v=a,b=d,M=6;function S(){const e={nodes:v.apply(null,arguments),links:b.apply(null,arguments)};return function({nodes:n,links:t}){for(const[t,e]of n.entries())e.index=t,e.sourceLinks=[],e.targetLinks=[];const e=new Map(n.map((t,e)=>[x(t,e,n),t]));for(const[n,o]of t.entries()){o.index=n;let{source:t,target:r}=o;"object"!=typeof t&&(t=o.source=h(e,t)),"object"!=typeof r&&(r=o.target=h(e,r)),t.sourceLinks.push(o),r.targetLinks.push(o)}}(e),function({nodes:n}){for(const e of n)e.value=Math.max(t.sum(e.sourceLinks,c),t.sum(e.targetLinks,c))}(e),function({nodes:n}){const t=n.length;let e=new Set(n),o=new Set,r=0;for(;e.size;){for(const n of e){n.depth=r;for(const{target:t}of n.sourceLinks)o.add(t)}if(++r>t)throw new Error("circular link");e=o,o=new Set}}(e),function({nodes:n}){const t=n.length;let e=new Set(n),o=new Set,r=0;for(;e.size;){for(const n of e){n.height=r;for(const{source:t}of n.targetLinks)o.add(t)}if(++r>t)throw new Error("circular link");e=o,o=new Set}}(e),function(e){const r=function({nodes:e}){const r=t.max(e,n=>n.depth)+1,i=(k-o-L)/(r-1),s=new Array(r);for(const n of e){const t=Math.max(0,Math.min(r-1,Math.floor(m.call(null,n,r))));n.layer=t,n.x0=o+t*i,n.x1=n.x0+L,s[t]?s[t].push(n):s[t]=[n]}if(n)for(const t of s)t.sort(n);return s}(e);!function(n){const e=t.min(n,n=>(p-y-(n.length-1)*w)/t.sum(n,c));for(const t of n){let n=y;for(const o of t){o.y0=n,o.y1=n+o.value*e,n=o.y1+w;for(const n of o.sourceLinks)n.width=n.value*e}n=(p-n+w)/(t.length+1);for(let e=0;e<t.length;++e){const o=t[e];o.y0+=n*(e+1),o.y1+=n*(e+1)}P(t)}}(r);for(let n=0;n<M;++n){const t=Math.pow(.99,n),e=Math.max(1-t,(n+1)/M);j(r,t,e),z(r,t,e)}}(e),g(e),e}function z(t,e,o){for(let r=1,i=t.length;r<i;++r){const i=t[r];for(const n of i){let t=0,o=0;for(const{source:e,value:r}of n.targetLinks){let i=r*(n.layer-e.layer);t+=_(e,n)*i,o+=i}if(!(o>0))continue;let r=(t/o-n.y0)*e;n.y0+=r,n.y1+=r,H(n)}void 0===n&&i.sort(u),E(i,o)}}function j(t,e,o){for(let r=t.length-2;r>=0;--r){const i=t[r];for(const n of i){let t=0,o=0;for(const{target:e,value:r}of n.sourceLinks){let i=r*(e.layer-n.layer);t+=C(n,e)*i,o+=i}if(!(o>0))continue;let r=(t/o-n.y0)*e;n.y0+=r,n.y1+=r,H(n)}void 0===n&&i.sort(u),E(i,o)}}function E(n,t){const e=n.length>>1,o=n[e];A(n,o.y0-w,e-1,t),q(n,o.y1+w,e+1,t),A(n,p,n.length-1,t),q(n,y,0,t)}function q(n,t,e,o){for(;e<n.length;++e){const r=n[e],i=(t-r.y0)*o;i>1e-6&&(r.y0+=i,r.y1+=i),t=r.y1+w}}function A(n,t,e,o){for(;e>=0;--e){const r=n[e],i=(r.y1-t)*o;i>1e-6&&(r.y0-=i,r.y1-=i),t=r.y0-w}}function H({sourceLinks:n,targetLinks:t}){if(void 0===e){for(const{source:{sourceLinks:n}}of t)n.sort(f);for(const{target:{targetLinks:t}}of n)t.sort(s)}}function P(n){if(void 0===e)for(const{sourceLinks:t,targetLinks:e}of n)t.sort(f),e.sort(s)}function _(n,t){let e=n.y0-(n.sourceLinks.length-1)*w/2;for(const{target:o,width:r}of n.sourceLinks){if(o===t)break;e+=r+w}for(const{source:o,width:r}of t.targetLinks){if(o===n)break;e-=r}return e}function C(n,t){let e=t.y0-(t.targetLinks.length-1)*w/2;for(const{source:o,width:r}of t.targetLinks){if(o===n)break;e+=r+w}for(const{target:o,width:r}of n.sourceLinks){if(o===t)break;e-=r}return e}return S.update=function(n){return g(n),n},S.nodeId=function(n){return arguments.length?(x="function"==typeof n?n:i(n),S):x},S.nodeAlign=function(n){return arguments.length?(m="function"==typeof n?n:i(n),S):m},S.nodeSort=function(t){return arguments.length?(n=t,S):n},S.nodeWidth=function(n){return arguments.length?(L=+n,S):L},S.nodePadding=function(n){return arguments.length?(w=+n,S):w},S.nodes=function(n){return arguments.length?(v="function"==typeof n?n:i(n),S):v},S.links=function(n){return arguments.length?(b="function"==typeof n?n:i(n),S):b},S.linkSort=function(n){return arguments.length?(e=n,S):e},S.size=function(n){return arguments.length?(o=y=0,k=+n[0],p=+n[1],S):[k-o,p-y]},S.extent=function(n){return arguments.length?(o=+n[0][0],k=+n[1][0],y=+n[0][1],p=+n[1][1],S):[[o,y],[k,p]]},S.iterations=function(n){return arguments.length?(M=+n,S):M},S},n.sankeyCenter=function(n){return n.targetLinks.length?n.depth:n.sourceLinks.length?t.min(n.sourceLinks,o)-1:0},n.sankeyLeft=function(n){return n.depth},n.sankeyRight=function(n,t){return t-1-n.height},n.sankeyJustify=r,n.sankeyLinkHorizontal=function(){return e.linkHorizontal().source(y).target(k)},Object.defineProperty(n,"__esModule",{value:!0})});
// https://github.com/d3/d3-sankey v0.12.2 Copyright 2019 Mike Bostock
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-array"),require("d3-shape")):"function"==typeof define&&define.amd?define(["exports","d3-array","d3-shape"],t):t((n=n||self).d3=n.d3||{},n.d3,n.d3)}(this,function(n,t,e){"use strict";function o(n){return n.target.depth}function r(n,t){return n.sourceLinks.length?n.depth:t-1}function i(n){return function(){return n}}function s(n,t){return u(n.source,t.source)||n.index-t.index}function f(n,t){return u(n.target,t.target)||n.index-t.index}function u(n,t){return n.y0-t.y0}function c(n){return n.value}function l(n){return n.index}function a(n){return n.nodes}function d(n){return n.links}function h(n,t){const e=n.get(t);if(!e)throw new Error("missing: "+t);return e}function g({nodes:n}){for(const t of n){let n=t.y0,e=n;for(const e of t.sourceLinks)e.y0=n+e.width/2,n+=e.width;for(const n of t.targetLinks)n.y1=e+n.width/2,e+=n.width}}function y(n){return[n.source.x1,n.y0]}function k(n){return[n.target.x0,n.y1]}n.sankey=function(){let n,e,o,y=0,k=0,p=1,L=1,w=24,x=8,m=l,v=r,M=a,b=d,S=6;function z(){const o={nodes:M.apply(null,arguments),links:b.apply(null,arguments)};return function({nodes:n,links:t}){for(const[t,e]of n.entries())e.index=t,e.sourceLinks=[],e.targetLinks=[];const e=new Map(n.map((t,e)=>[m(t,e,n),t]));for(const[n,o]of t.entries()){o.index=n;let{source:t,target:r}=o;"object"!=typeof t&&(t=o.source=h(e,t)),"object"!=typeof r&&(r=o.target=h(e,r)),t.sourceLinks.push(o),r.targetLinks.push(o)}}(o),function({nodes:n}){for(const e of n)e.value=void 0===e.fixedValue?Math.max(t.sum(e.sourceLinks,c),t.sum(e.targetLinks,c)):e.fixedValue}(o),function({nodes:n}){const t=n.length;let e=new Set(n),o=new Set,r=0;for(;e.size;){for(const n of e){n.depth=r;for(const{target:t}of n.sourceLinks)o.add(t)}if(++r>t)throw new Error("circular link");e=o,o=new Set}}(o),function({nodes:n}){const t=n.length;let e=new Set(n),o=new Set,r=0;for(;e.size;){for(const n of e){n.height=r;for(const{source:t}of n.targetLinks)o.add(t)}if(++r>t)throw new Error("circular link");e=o,o=new Set}}(o),function(o){const r=function({nodes:n}){const o=t.max(n,n=>n.depth)+1,r=(p-y-w)/(o-1),i=new Array(o);for(const t of n){const n=Math.max(0,Math.min(o-1,Math.floor(v.call(null,t,o))));t.layer=n,t.x0=y+n*r,t.x1=t.x0+w,i[n]?i[n].push(t):i[n]=[t]}if(e)for(const n of i)n.sort(e);return i}(o);n=Math.min(x,(L-k)/(t.max(r,n=>n.length)-1)),function(e){const o=t.min(e,e=>(L-k-(e.length-1)*n)/t.sum(e,c));for(const t of e){let e=k;for(const r of t){r.y0=e,r.y1=e+r.value*o,e=r.y1+n;for(const n of r.sourceLinks)n.width=n.value*o}e=(L-e+n)/(t.length+1);for(let n=0;n<t.length;++n){const o=t[n];o.y0+=e*(n+1),o.y1+=e*(n+1)}V(t)}}(r);for(let n=0;n<S;++n){const t=Math.pow(.99,n),e=Math.max(1-t,(n+1)/S);E(r,t,e),j(r,t,e)}}(o),g(o),o}function j(n,t,o){for(let r=1,i=n.length;r<i;++r){const i=n[r];for(const n of i){let e=0,o=0;for(const{source:t,value:r}of n.targetLinks){let i=r*(n.layer-t.layer);e+=_(t,n)*i,o+=i}if(!(o>0))continue;let r=(e/o-n.y0)*t;n.y0+=r,n.y1+=r,P(n)}void 0===e&&i.sort(u),q(i,o)}}function E(n,t,o){for(let r=n.length-2;r>=0;--r){const i=n[r];for(const n of i){let e=0,o=0;for(const{target:t,value:r}of n.sourceLinks){let i=r*(t.layer-n.layer);e+=C(n,t)*i,o+=i}if(!(o>0))continue;let r=(e/o-n.y0)*t;n.y0+=r,n.y1+=r,P(n)}void 0===e&&i.sort(u),q(i,o)}}function q(t,e){const o=t.length>>1,r=t[o];H(t,r.y0-n,o-1,e),A(t,r.y1+n,o+1,e),H(t,L,t.length-1,e),A(t,k,0,e)}function A(t,e,o,r){for(;o<t.length;++o){const i=t[o],s=(e-i.y0)*r;s>1e-6&&(i.y0+=s,i.y1+=s),e=i.y1+n}}function H(t,e,o,r){for(;o>=0;--o){const i=t[o],s=(i.y1-e)*r;s>1e-6&&(i.y0-=s,i.y1-=s),e=i.y0-n}}function P({sourceLinks:n,targetLinks:t}){if(void 0===o){for(const{source:{sourceLinks:n}}of t)n.sort(f);for(const{target:{targetLinks:t}}of n)t.sort(s)}}function V(n){if(void 0===o)for(const{sourceLinks:t,targetLinks:e}of n)t.sort(f),e.sort(s)}function _(t,e){let o=t.y0-(t.sourceLinks.length-1)*n/2;for(const{target:r,width:i}of t.sourceLinks){if(r===e)break;o+=i+n}for(const{source:n,width:r}of e.targetLinks){if(n===t)break;o-=r}return o}function C(t,e){let o=e.y0-(e.targetLinks.length-1)*n/2;for(const{source:r,width:i}of e.targetLinks){if(r===t)break;o+=i+n}for(const{target:n,width:r}of t.sourceLinks){if(n===e)break;o-=r}return o}return z.update=function(n){return g(n),n},z.nodeId=function(n){return arguments.length?(m="function"==typeof n?n:i(n),z):m},z.nodeAlign=function(n){return arguments.length?(v="function"==typeof n?n:i(n),z):v},z.nodeSort=function(n){return arguments.length?(e=n,z):e},z.nodeWidth=function(n){return arguments.length?(w=+n,z):w},z.nodePadding=function(t){return arguments.length?(x=n=+t,z):x},z.nodes=function(n){return arguments.length?(M="function"==typeof n?n:i(n),z):M},z.links=function(n){return arguments.length?(b="function"==typeof n?n:i(n),z):b},z.linkSort=function(n){return arguments.length?(o=n,z):o},z.size=function(n){return arguments.length?(y=k=0,p=+n[0],L=+n[1],z):[p-y,L-k]},z.extent=function(n){return arguments.length?(y=+n[0][0],p=+n[1][0],k=+n[0][1],L=+n[1][1],z):[[y,k],[p,L]]},z.iterations=function(n){return arguments.length?(S=+n,z):S},z},n.sankeyCenter=function(n){return n.targetLinks.length?n.depth:n.sourceLinks.length?t.min(n.sourceLinks,o)-1:0},n.sankeyJustify=r,n.sankeyLeft=function(n){return n.depth},n.sankeyLinkHorizontal=function(){return e.linkHorizontal().source(y).target(k)},n.sankeyRight=function(n,t){return t-1-n.height},Object.defineProperty(n,"__esModule",{value:!0})});
{
"name": "d3-sankey",
"version": "0.12.1",
"version": "0.12.2",
"description": "Visualize flow between nodes in a directed acyclic network.",

@@ -23,2 +23,6 @@ "keywords": [

},
"files": [
"dist/**/*.js",
"src/**/*.js"
],
"scripts": {

@@ -28,14 +32,14 @@ "pretest": "rollup -c",

"prepublishOnly": "rm -rf dist && yarn test",
"postpublish": "git push && git push --tags && zip -j dist/d3-sankey.zip -- LICENSE README.md dist/d3-sankey.js dist/d3-sankey.min.js"
"postpublish": "git push && git push --tags && zip -j dist/${npm_package_name}.zip -- LICENSE README.md dist/${npm_package_name}.js dist/${npm_package_name}.min.js"
},
"dependencies": {
"d3-array": ">=1 <=2",
"d3-array": "1 - 2",
"d3-shape": "^1.2.0"
},
"devDependencies": {
"eslint": "5",
"eslint": "6",
"rollup": "1",
"rollup-plugin-terser": "4",
"rollup-plugin-terser": "5",
"tape": "4"
}
}

@@ -66,3 +66,3 @@ # d3-sankey

* *node*.targetLinks - the array of incoming [links](#sankey_links) which have this node as their target
* *node*.value - the node’s value; the sum of *link*.value for the node’s incoming [links](#sankey_links)
* *node*.value - the node’s value; this is the sum of *link*.value for the node’s incoming [links](#sankey_links), or *node*.fixedValue if defined
* *node*.index - the node’s zero-based index within the array of nodes

@@ -69,0 +69,0 @@ * *node*.depth - the node’s zero-based graph depth, derived from the graph topology

@@ -57,3 +57,3 @@ import {max, min, sum} from "d3-array";

let dx = 24; // nodeWidth
let py = 8; // nodePadding
let dy = 8, py; // nodePadding
let id = defaultId;

@@ -100,3 +100,3 @@ let align = justify;

sankey.nodePadding = function(_) {
return arguments.length ? (py = +_, sankey) : py;
return arguments.length ? (dy = py = +_, sankey) : dy;
};

@@ -147,6 +147,5 @@

for (const node of nodes) {
node.value = Math.max(
sum(node.sourceLinks, value),
sum(node.targetLinks, value)
);
node.value = node.fixedValue === undefined
? Math.max(sum(node.sourceLinks, value), sum(node.targetLinks, value))
: node.fixedValue;
}

@@ -233,2 +232,3 @@ }

const columns = computeNodeLayers(graph);
py = Math.min(dy, (y1 - y0) / (max(columns, c => c.length) - 1));
initializeNodeBreadths(columns);

@@ -235,0 +235,0 @@ for (let i = 0; i < iterations; ++i) {

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