Socket
Socket
Sign inDemoInstall

d3-sankey

Package Overview
Dependencies
4
Maintainers
2
Versions
33
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.10.4 to 0.11.0

29

dist/d3-sankey.js

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

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

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

sort,
linkSort,
nodes = defaultNodes,

@@ -125,2 +126,6 @@ links = defaultLinks,

sankey.linkSort = function(_) {
return arguments.length ? (linkSort = _, sankey) : linkSort;
};
sankey.size = function(_) {

@@ -217,7 +222,7 @@ return arguments.length ? (x0 = y0 = 0, x1 = +_[0], y1 = +_[1], sankey) : [x1 - x0, y1 - y0];

const b = (i + 1) / n;
reorderLinks();
reorderLinks(graph);
relaxRightToLeft(a);
resolveCollisionsTopToBottom(b);
resolveCollisionsBottomToTop(b);
reorderLinks();
reorderLinks(graph);
relaxLeftToRight(a);

@@ -246,10 +251,6 @@ resolveCollisionsTopToBottom(b);

});
}
function reorderLinks() {
columns.forEach(function(nodes) {
nodes.forEach(function(node) {
node.sourceLinks.sort(ascendingTargetBreadth);
node.targetLinks.sort(ascendingSourceBreadth);
});
if (linkSort != null) graph.nodes.forEach(function(node) {
node.sourceLinks.sort(linkSort);
node.targetLinks.sort(linkSort);
});

@@ -333,7 +334,11 @@ }

function computeLinkBreadths(graph) {
graph.nodes.forEach(function(node) {
function reorderLinks(graph) {
if (linkSort === undefined) graph.nodes.forEach(function(node) {
node.sourceLinks.sort(ascendingTargetBreadth);
node.targetLinks.sort(ascendingSourceBreadth);
});
}
function computeLinkBreadths(graph) {
reorderLinks(graph);
graph.nodes.forEach(function(node) {

@@ -340,0 +345,0 @@ var y0 = node.y0, y1 = y0;

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

// https://github.com/d3/d3-sankey v0.10.4 Copyright 2019 Mike Bostock
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-array"),require("d3-collection"),require("d3-shape")):"function"==typeof define&&define.amd?define(["exports","d3-array","d3-collection","d3-shape"],t):t((n=n||self).d3=n.d3||{},n.d3,n.d3,n.d3)}(this,function(n,t,e,r){"use strict";function o(n){return n.target.depth}function i(n,t){return n.sourceLinks.length?n.depth:t-1}function u(n){return function(){return n}}function c(n,t){return s(n.source,t.source)||n.index-t.index}function f(n,t){return s(n.target,t.target)||n.index-t.index}function s(n,t){return n.y0-t.y0}function a(n){return n.value}function h(n){return n.index}function l(n){return n.nodes}function d(n){return n.links}function y(n,t){var e=n.get(t);if(!e)throw new Error("missing: "+t);return e}function g(n){return[n.source.x1,n.y0]}function k(n){return[n.target.x0,n.y1]}n.sankey=function(){var n,r=0,o=0,g=1,k=1,p=24,L=8,E=h,v=i,x=l,w=d,m=6;function b(){var i={nodes:x.apply(null,arguments),links:w.apply(null,arguments)};return function(n){n.nodes.forEach(function(n,t){n.index=t,n.sourceLinks=[],n.targetLinks=[]});var t=e.map(n.nodes,E);n.links.forEach(function(n,e){n.index=e;var r=n.source,o=n.target;"object"!=typeof r&&(r=n.source=y(t,r)),"object"!=typeof o&&(o=n.target=y(t,o)),r.sourceLinks.push(n),o.targetLinks.push(n)})}(i),function(n){n.nodes.forEach(function(n){n.value=Math.max(t.sum(n.sourceLinks,a),t.sum(n.targetLinks,a))})}(i),function(n){var t,e,o,i=n.nodes.length;for(t=n.nodes,e=[],o=0;t.length;++o,t=e,e=[]){if(o>i)throw new Error("circular link");t.forEach(function(n){n.depth=o,n.sourceLinks.forEach(function(n){e.indexOf(n.target)<0&&e.push(n.target)})})}for(t=n.nodes,e=[],o=0;t.length;++o,t=e,e=[]){if(o>i)throw new Error("circular link");t.forEach(function(n){n.height=o,n.targetLinks.forEach(function(n){e.indexOf(n.source)<0&&e.push(n.source)})})}var u=(g-r-p)/(o-1);n.nodes.forEach(function(n){n.layer=Math.max(0,Math.min(o-1,Math.floor(v.call(null,n,o)))),n.x1=(n.x0=r+n.layer*u)+p})}(i),function(r){var i,u=e.nest().key(function(n){return n.x0}).sortKeys(t.ascending).entries(r.nodes).map(function(n){return n.values});i=t.min(u,function(n){return(k-o-(n.length-1)*L)/t.sum(n,a)}),u.forEach(function(t){null!=n&&t.sort(n);let e=o;t.forEach(function(n){n.y0=e,n.y1=e+n.value*i,e=n.y1+L})}),r.links.forEach(function(n){n.width=n.value*i});for(var h=0,l=m;h<l;++h){const n=Math.pow(.99,h),t=(h+1)/l;d(),g(n),p(t),E(t),d(),y(n),p(t),E(t)}function d(){u.forEach(function(n){n.forEach(function(n){n.sourceLinks.sort(f),n.targetLinks.sort(c)})})}function y(n){u.slice(1).forEach(function(t){t.forEach(function(t){let e=0,r=0;for(const{source:n,value:o}of t.targetLinks){let i=o*(t.layer-n.layer);e+=j(n,t)*i,r+=i}if(!(r>0))return;let o=(e/r-t.y0)*n;t.y0+=o,t.y1+=o})})}function g(n){u.slice(0,-1).reverse().forEach(function(t){t.forEach(function(t){let e=0,r=0;for(const{target:n,value:o}of t.sourceLinks){let i=o*(n.layer-t.layer);e+=q(t,n)*i,r+=i}if(!(r>0))return;let o=(e/r-t.y0)*n;t.y0+=o,t.y1+=o})})}function p(t){u.forEach(function(e){var r,i,u,c=o,f=e.length;for(void 0===n&&e.sort(s),u=0;u<f;++u)r=e[u],(i=(c-r.y0)*t)>1e-6&&(r.y0+=i,r.y1+=i),c=r.y1+L})}function E(t){u.forEach(function(e){var r,o,i,u=k,c=e.length;for(void 0===n&&e.sort(s),i=c-1;i>=0;--i)r=e[i],(o=(r.y1-u)*t)>1e-6&&(r.y0-=o,r.y1-=o),u=r.y0-L})}}(i),M(i),i}function M(n){n.nodes.forEach(function(n){n.sourceLinks.sort(f),n.targetLinks.sort(c)}),n.nodes.forEach(function(n){var t=n.y0,e=t;n.sourceLinks.forEach(function(n){n.y0=t+n.width/2,t+=n.width}),n.targetLinks.forEach(function(n){n.y1=e+n.width/2,e+=n.width})})}function j(n,t){let e=n.y0-(n.sourceLinks.length-1)*L/2;for(const{target:r,width:o}of n.sourceLinks){if(r===t)break;e+=o+L}for(const{source:r,width:o}of t.targetLinks){if(r===n)break;e-=o}return e}function q(n,t){let e=t.y0-(t.targetLinks.length-1)*L/2;for(const{source:r,width:o}of t.targetLinks){if(r===n)break;e+=o+L}for(const{target:r,width:o}of n.sourceLinks){if(r===t)break;e-=o}return e}return b.update=function(n){return M(n),n},b.nodeId=function(n){return arguments.length?(E="function"==typeof n?n:u(n),b):E},b.nodeAlign=function(n){return arguments.length?(v="function"==typeof n?n:u(n),b):v},b.nodeSort=function(t){return arguments.length?(n=t,b):n},b.nodeWidth=function(n){return arguments.length?(p=+n,b):p},b.nodePadding=function(n){return arguments.length?(L=+n,b):L},b.nodes=function(n){return arguments.length?(x="function"==typeof n?n:u(n),b):x},b.links=function(n){return arguments.length?(w="function"==typeof n?n:u(n),b):w},b.size=function(n){return arguments.length?(r=o=0,g=+n[0],k=+n[1],b):[g-r,k-o]},b.extent=function(n){return arguments.length?(r=+n[0][0],g=+n[1][0],o=+n[0][1],k=+n[1][1],b):[[r,o],[g,k]]},b.iterations=function(n){return arguments.length?(m=+n,b):m},b},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=i,n.sankeyLinkHorizontal=function(){return r.linkHorizontal().source(g).target(k)},Object.defineProperty(n,"__esModule",{value:!0})});
// https://github.com/d3/d3-sankey v0.11.0 Copyright 2019 Mike Bostock
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("d3-array"),require("d3-collection"),require("d3-shape")):"function"==typeof define&&define.amd?define(["exports","d3-array","d3-collection","d3-shape"],t):t((n=n||self).d3=n.d3||{},n.d3,n.d3,n.d3)}(this,function(n,t,e,r){"use strict";function o(n){return n.target.depth}function i(n,t){return n.sourceLinks.length?n.depth:t-1}function u(n){return function(){return n}}function c(n,t){return s(n.source,t.source)||n.index-t.index}function f(n,t){return s(n.target,t.target)||n.index-t.index}function s(n,t){return n.y0-t.y0}function a(n){return n.value}function l(n){return n.index}function h(n){return n.nodes}function d(n){return n.links}function y(n,t){var e=n.get(t);if(!e)throw new Error("missing: "+t);return e}function g(n){return[n.source.x1,n.y0]}function k(n){return[n.target.x0,n.y1]}n.sankey=function(){var n,r,o=0,g=0,k=1,p=1,L=24,E=8,v=l,x=i,w=h,m=d,b=6;function M(){var i={nodes:w.apply(null,arguments),links:m.apply(null,arguments)};return function(n){n.nodes.forEach(function(n,t){n.index=t,n.sourceLinks=[],n.targetLinks=[]});var t=e.map(n.nodes,v);n.links.forEach(function(n,e){n.index=e;var r=n.source,o=n.target;"object"!=typeof r&&(r=n.source=y(t,r)),"object"!=typeof o&&(o=n.target=y(t,o)),r.sourceLinks.push(n),o.targetLinks.push(n)})}(i),function(n){n.nodes.forEach(function(n){n.value=Math.max(t.sum(n.sourceLinks,a),t.sum(n.targetLinks,a))})}(i),function(n){var t,e,r,i=n.nodes.length;for(t=n.nodes,e=[],r=0;t.length;++r,t=e,e=[]){if(r>i)throw new Error("circular link");t.forEach(function(n){n.depth=r,n.sourceLinks.forEach(function(n){e.indexOf(n.target)<0&&e.push(n.target)})})}for(t=n.nodes,e=[],r=0;t.length;++r,t=e,e=[]){if(r>i)throw new Error("circular link");t.forEach(function(n){n.height=r,n.targetLinks.forEach(function(n){e.indexOf(n.source)<0&&e.push(n.source)})})}var u=(k-o-L)/(r-1);n.nodes.forEach(function(n){n.layer=Math.max(0,Math.min(r-1,Math.floor(x.call(null,n,r)))),n.x1=(n.x0=o+n.layer*u)+L})}(i),function(o){var i,u=e.nest().key(function(n){return n.x0}).sortKeys(t.ascending).entries(o.nodes).map(function(n){return n.values});i=t.min(u,function(n){return(p-g-(n.length-1)*E)/t.sum(n,a)}),u.forEach(function(t){null!=n&&t.sort(n);let e=g;t.forEach(function(n){n.y0=e,n.y1=e+n.value*i,e=n.y1+E})}),o.links.forEach(function(n){n.width=n.value*i}),null!=r&&o.nodes.forEach(function(n){n.sourceLinks.sort(r),n.targetLinks.sort(r)});for(var c=0,f=b;c<f;++c){const n=Math.pow(.99,c),t=(c+1)/f;j(o),h(n),d(t),y(t),j(o),l(n),d(t),y(t)}function l(n){u.slice(1).forEach(function(t){t.forEach(function(t){let e=0,r=0;for(const{source:n,value:o}of t.targetLinks){let i=o*(t.layer-n.layer);e+=z(n,t)*i,r+=i}if(!(r>0))return;let o=(e/r-t.y0)*n;t.y0+=o,t.y1+=o})})}function h(n){u.slice(0,-1).reverse().forEach(function(t){t.forEach(function(t){let e=0,r=0;for(const{target:n,value:o}of t.sourceLinks){let i=o*(n.layer-t.layer);e+=O(t,n)*i,r+=i}if(!(r>0))return;let o=(e/r-t.y0)*n;t.y0+=o,t.y1+=o})})}function d(t){u.forEach(function(e){var r,o,i,u=g,c=e.length;for(void 0===n&&e.sort(s),i=0;i<c;++i)r=e[i],(o=(u-r.y0)*t)>1e-6&&(r.y0+=o,r.y1+=o),u=r.y1+E})}function y(t){u.forEach(function(e){var r,o,i,u=p,c=e.length;for(void 0===n&&e.sort(s),i=c-1;i>=0;--i)r=e[i],(o=(r.y1-u)*t)>1e-6&&(r.y0-=o,r.y1-=o),u=r.y0-E})}}(i),q(i),i}function j(n){void 0===r&&n.nodes.forEach(function(n){n.sourceLinks.sort(f),n.targetLinks.sort(c)})}function q(n){j(n),n.nodes.forEach(function(n){var t=n.y0,e=t;n.sourceLinks.forEach(function(n){n.y0=t+n.width/2,t+=n.width}),n.targetLinks.forEach(function(n){n.y1=e+n.width/2,e+=n.width})})}function z(n,t){let e=n.y0-(n.sourceLinks.length-1)*E/2;for(const{target:r,width:o}of n.sourceLinks){if(r===t)break;e+=o+E}for(const{source:r,width:o}of t.targetLinks){if(r===n)break;e-=o}return e}function O(n,t){let e=t.y0-(t.targetLinks.length-1)*E/2;for(const{source:r,width:o}of t.targetLinks){if(r===n)break;e+=o+E}for(const{target:r,width:o}of n.sourceLinks){if(r===t)break;e-=o}return e}return M.update=function(n){return q(n),n},M.nodeId=function(n){return arguments.length?(v="function"==typeof n?n:u(n),M):v},M.nodeAlign=function(n){return arguments.length?(x="function"==typeof n?n:u(n),M):x},M.nodeSort=function(t){return arguments.length?(n=t,M):n},M.nodeWidth=function(n){return arguments.length?(L=+n,M):L},M.nodePadding=function(n){return arguments.length?(E=+n,M):E},M.nodes=function(n){return arguments.length?(w="function"==typeof n?n:u(n),M):w},M.links=function(n){return arguments.length?(m="function"==typeof n?n:u(n),M):m},M.linkSort=function(n){return arguments.length?(r=n,M):r},M.size=function(n){return arguments.length?(o=g=0,k=+n[0],p=+n[1],M):[k-o,p-g]},M.extent=function(n){return arguments.length?(o=+n[0][0],k=+n[1][0],g=+n[0][1],p=+n[1][1],M):[[o,g],[k,p]]},M.iterations=function(n){return arguments.length?(b=+n,M):b},M},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=i,n.sankeyLinkHorizontal=function(){return r.linkHorizontal().source(g).target(k)},Object.defineProperty(n,"__esModule",{value:!0})});
{
"name": "d3-sankey",
"version": "0.10.4",
"version": "0.11.0",
"description": "Visualize flow between nodes in a directed acyclic network.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -47,2 +47,3 @@ import {ascending, min, sum} from "d3-array";

sort,
linkSort,
nodes = defaultNodes,

@@ -95,2 +96,6 @@ links = defaultLinks,

sankey.linkSort = function(_) {
return arguments.length ? (linkSort = _, sankey) : linkSort;
};
sankey.size = function(_) {

@@ -187,7 +192,7 @@ return arguments.length ? (x0 = y0 = 0, x1 = +_[0], y1 = +_[1], sankey) : [x1 - x0, y1 - y0];

const b = (i + 1) / n;
reorderLinks();
reorderLinks(graph);
relaxRightToLeft(a);
resolveCollisionsTopToBottom(b);
resolveCollisionsBottomToTop(b);
reorderLinks();
reorderLinks(graph);
relaxLeftToRight(a);

@@ -216,10 +221,6 @@ resolveCollisionsTopToBottom(b);

});
}
function reorderLinks() {
columns.forEach(function(nodes) {
nodes.forEach(function(node) {
node.sourceLinks.sort(ascendingTargetBreadth);
node.targetLinks.sort(ascendingSourceBreadth);
});
if (linkSort != null) graph.nodes.forEach(function(node) {
node.sourceLinks.sort(linkSort);
node.targetLinks.sort(linkSort);
});

@@ -303,7 +304,11 @@ }

function computeLinkBreadths(graph) {
graph.nodes.forEach(function(node) {
function reorderLinks(graph) {
if (linkSort === undefined) graph.nodes.forEach(function(node) {
node.sourceLinks.sort(ascendingTargetBreadth);
node.targetLinks.sort(ascendingSourceBreadth);
});
}
function computeLinkBreadths(graph) {
reorderLinks(graph);
graph.nodes.forEach(function(node) {

@@ -310,0 +315,0 @@ var y0 = node.y0, y1 = y0;

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc