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.9.0 to 0.9.1

40

dist/d3-sankey.js

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

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

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

computeNodeDepths(graph);
computeNodeBreadths(graph, iterations);
computeNodeBreadths(graph);
computeLinkBreadths(graph);

@@ -171,5 +171,6 @@ return graph;

function computeNodeDepths(graph) {
var nodes, next, x;
var nodes, next, x, n = graph.nodes.length;
for (nodes = graph.nodes, next = [], x = 0; nodes.length; ++x, nodes = next, next = []) {
if (x > n) throw new Error("circular link");
nodes.forEach(function(node) {

@@ -186,2 +187,3 @@ node.depth = x;

for (nodes = graph.nodes, next = [], x = 0; nodes.length; ++x, nodes = next, next = []) {
if (x > n) throw new Error("circular link");
nodes.forEach(function(node) {

@@ -242,10 +244,12 @@ node.height = x;

for (const {target, width, value} of node.sourceLinks.sort(ascendingTargetBreadth)) {
let offset = 0;
for (const link of target.targetLinks) {
if (link.source === node) break;
offset += link.width + py / 2;
if (value > 0) {
let dy = 0;
for (const {source, width} of target.targetLinks) {
if (source === node) break;
dy += width + py / 2;
}
dy = (y - dy - target.y0) * alpha * (value / Math.min(node.value, target.value));
target.y0 += dy;
target.y1 += dy;
}
const dy = (y - offset - target.y0) * alpha * (value / Math.min(node.value, target.value));
target.y0 += dy;
target.y1 += dy;
y += width + py / 2;

@@ -262,10 +266,12 @@ }

for (const {source, width, value} of node.targetLinks.sort(ascendingSourceBreadth)) {
let offset = 0;
for (const link of source.sourceLinks) {
if (link.target === node) break;
offset += link.width + py / 2;
if (value > 0) {
let dy = 0;
for (const {target, width} of source.sourceLinks) {
if (target === node) break;
dy += width + py / 2;
}
dy = (y - dy - source.y0) * alpha * (value / Math.min(node.value, source.value));
source.y0 += dy;
source.y1 += dy;
}
const dy = (y - offset - source.y0) * alpha * (value / Math.min(node.value, source.value));
source.y0 += dy;
source.y1 += dy;
y += width + py / 2;

@@ -272,0 +278,0 @@ }

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

// https://github.com/d3/d3-sankey v0.9.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 u(n,t){return n.sourceLinks.length?n.depth:t-1}function i(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 d(n){return n.nodes}function l(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,v=8,L=h,E=u,x=d,m=l,w=6;function M(){var u={nodes:x.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,L);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)})}(u),function(n){n.nodes.forEach(function(n){n.value=Math.max(t.sum(n.sourceLinks,a),t.sum(n.targetLinks,a))})}(u),function(n){var t,e,o;for(t=n.nodes,e=[],o=0;t.length;++o,t=e,e=[])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=[])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.x1=(n.x0=r+Math.max(0,Math.min(o-1,Math.floor(E.call(null,n,o))))*u)+p})}(u),function(r){var u,i=e.nest().key(function(n){return n.x0}).sortKeys(t.ascending).entries(r.nodes).map(function(n){return n.values});u=t.min(i,function(n){return(k-o-(n.length-1)*v)/t.sum(n,a)}),i.forEach(function(t){null!=n&&t.sort(n),t.forEach(function(n,t){n.y1=(n.y0=t)+n.value*u})}),r.links.forEach(function(n){n.width=n.value*u}),g();for(var h=.9,d=w;d>0;--d,h*=.9)y(h),g(),l(h),g();function l(n){i.forEach(function(t){t.forEach(function(t){let e=t.y0;for(const{target:r,width:o,value:u}of t.sourceLinks.sort(f)){let i=0;for(const n of r.targetLinks){if(n.source===t)break;i+=n.width+v/2}const c=(e-i-r.y0)*n*(u/Math.min(t.value,r.value));r.y0+=c,r.y1+=c,e+=o+v/2}})})}function y(n){i.slice().reverse().forEach(function(t){t.forEach(function(t){let e=t.y0;for(const{source:r,width:o,value:u}of t.targetLinks.sort(c)){let i=0;for(const n of r.sourceLinks){if(n.target===t)break;i+=n.width+v/2}const c=(e-i-r.y0)*n*(u/Math.min(t.value,r.value));r.y0+=c,r.y1+=c,e+=o+v/2}})})}function g(){i.forEach(function(t){var e,r,u,i=o,c=t.length;for(void 0===n&&t.sort(s),u=0;u<c;++u)e=t[u],(r=i-e.y0)>0&&(e.y0+=r,e.y1+=r),i=e.y1+v;if((r=i-v-k)>0)for(i=e.y0-=r,e.y1-=r,u=c-2;u>=0;--u)e=t[u],(r=e.y1+v-i)>0&&(e.y0-=r,e.y1-=r),i=e.y0})}}(u),b(u),u}function b(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})})}return M.update=function(n){return b(n),n},M.nodeId=function(n){return arguments.length?(L="function"==typeof n?n:i(n),M):L},M.nodeAlign=function(n){return arguments.length?(E="function"==typeof n?n:i(n),M):E},M.nodeSort=function(t){return arguments.length?(n=t,M):n},M.nodeWidth=function(n){return arguments.length?(p=+n,M):p},M.nodePadding=function(n){return arguments.length?(v=+n,M):v},M.nodes=function(n){return arguments.length?(x="function"==typeof n?n:i(n),M):x},M.links=function(n){return arguments.length?(m="function"==typeof n?n:i(n),M):m},M.size=function(n){return arguments.length?(r=o=0,g=+n[0],k=+n[1],M):[g-r,k-o]},M.extent=function(n){return arguments.length?(r=+n[0][0],g=+n[1][0],o=+n[0][1],k=+n[1][1],M):[[r,o],[g,k]]},M.iterations=function(n){return arguments.length?(w=+n,M):w},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=u,n.sankeyLinkHorizontal=function(){return r.linkHorizontal().source(g).target(k)},Object.defineProperty(n,"__esModule",{value:!0})});
// https://github.com/d3/d3-sankey v0.9.1 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 d(n){return n.nodes}function l(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,v=8,E=h,L=i,x=d,m=l,w=6;function M(){var i={nodes:x.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,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.x1=(n.x0=r+Math.max(0,Math.min(o-1,Math.floor(L.call(null,n,o))))*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)*v)/t.sum(n,a)}),u.forEach(function(t){null!=n&&t.sort(n),t.forEach(function(n,t){n.y1=(n.y0=t)+n.value*i})}),r.links.forEach(function(n){n.width=n.value*i}),g();for(var h=.9,d=w;d>0;--d,h*=.9)y(h),g(),l(h),g();function l(n){u.forEach(function(t){t.forEach(function(t){let e=t.y0;for(const{target:r,width:o,value:i}of t.sourceLinks.sort(f)){if(i>0){let o=0;for(const{source:n,width:e}of r.targetLinks){if(n===t)break;o+=e+v/2}o=(e-o-r.y0)*n*(i/Math.min(t.value,r.value)),r.y0+=o,r.y1+=o}e+=o+v/2}})})}function y(n){u.slice().reverse().forEach(function(t){t.forEach(function(t){let e=t.y0;for(const{source:r,width:o,value:i}of t.targetLinks.sort(c)){if(i>0){let o=0;for(const{target:n,width:e}of r.sourceLinks){if(n===t)break;o+=e+v/2}o=(e-o-r.y0)*n*(i/Math.min(t.value,r.value)),r.y0+=o,r.y1+=o}e+=o+v/2}})})}function g(){u.forEach(function(t){var e,r,i,u=o,c=t.length;for(void 0===n&&t.sort(s),i=0;i<c;++i)e=t[i],(r=u-e.y0)>0&&(e.y0+=r,e.y1+=r),u=e.y1+v;if((r=u-v-k)>0)for(u=e.y0-=r,e.y1-=r,i=c-2;i>=0;--i)e=t[i],(r=e.y1+v-u)>0&&(e.y0-=r,e.y1-=r),u=e.y0})}}(i),b(i),i}function b(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})})}return M.update=function(n){return b(n),n},M.nodeId=function(n){return arguments.length?(E="function"==typeof n?n:u(n),M):E},M.nodeAlign=function(n){return arguments.length?(L="function"==typeof n?n:u(n),M):L},M.nodeSort=function(t){return arguments.length?(n=t,M):n},M.nodeWidth=function(n){return arguments.length?(p=+n,M):p},M.nodePadding=function(n){return arguments.length?(v=+n,M):v},M.nodes=function(n){return arguments.length?(x="function"==typeof n?n:u(n),M):x},M.links=function(n){return arguments.length?(m="function"==typeof n?n:u(n),M):m},M.size=function(n){return arguments.length?(r=o=0,g=+n[0],k=+n[1],M):[g-r,k-o]},M.extent=function(n){return arguments.length?(r=+n[0][0],g=+n[1][0],o=+n[0][1],k=+n[1][1],M):[[r,o],[g,k]]},M.iterations=function(n){return arguments.length?(w=+n,M):w},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.9.0",
"version": "0.9.1",
"description": "Visualize flow between nodes in a directed acyclic network.",

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

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

computeNodeDepths(graph);
computeNodeBreadths(graph, iterations);
computeNodeBreadths(graph);
computeLinkBreadths(graph);

@@ -141,5 +141,6 @@ return graph;

function computeNodeDepths(graph) {
var nodes, next, x;
var nodes, next, x, n = graph.nodes.length;
for (nodes = graph.nodes, next = [], x = 0; nodes.length; ++x, nodes = next, next = []) {
if (x > n) throw new Error("circular link");
nodes.forEach(function(node) {

@@ -156,2 +157,3 @@ node.depth = x;

for (nodes = graph.nodes, next = [], x = 0; nodes.length; ++x, nodes = next, next = []) {
if (x > n) throw new Error("circular link");
nodes.forEach(function(node) {

@@ -212,10 +214,12 @@ node.height = x;

for (const {target, width, value} of node.sourceLinks.sort(ascendingTargetBreadth)) {
let offset = 0;
for (const link of target.targetLinks) {
if (link.source === node) break;
offset += link.width + py / 2;
if (value > 0) {
let dy = 0;
for (const {source, width} of target.targetLinks) {
if (source === node) break;
dy += width + py / 2;
}
dy = (y - dy - target.y0) * alpha * (value / Math.min(node.value, target.value));
target.y0 += dy;
target.y1 += dy;
}
const dy = (y - offset - target.y0) * alpha * (value / Math.min(node.value, target.value));
target.y0 += dy;
target.y1 += dy;
y += width + py / 2;

@@ -232,10 +236,12 @@ }

for (const {source, width, value} of node.targetLinks.sort(ascendingSourceBreadth)) {
let offset = 0;
for (const link of source.sourceLinks) {
if (link.target === node) break;
offset += link.width + py / 2;
if (value > 0) {
let dy = 0;
for (const {target, width} of source.sourceLinks) {
if (target === node) break;
dy += width + py / 2;
}
dy = (y - dy - source.y0) * alpha * (value / Math.min(node.value, source.value));
source.y0 += dy;
source.y1 += dy;
}
const dy = (y - offset - source.y0) * alpha * (value / Math.min(node.value, source.value));
source.y0 += dy;
source.y1 += dy;
y += width + py / 2;

@@ -242,0 +248,0 @@ }

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