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.2 to 0.10.3

58

dist/d3-sankey.js

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

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

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

// Returns the target.y0 that would produce a straight link from source to target.
function targetTop(source, target) {
let y = source.y0;
for (const {target: node, width} of source.sourceLinks) {
if (node === target) break;
y += width;
}
for (const {source: node, width} of target.targetLinks) {
if (node === source) break;
y -= width;
}
return y;
}
// Returns the source.y0 that would produce a straight link from source to target.
function sourceTop(source, target) {
let y = target.y0;
for (const {source: node, width} of target.targetLinks) {
if (node === source) break;
y += width;
}
for (const {target: node, width} of source.sourceLinks) {
if (node === target) break;
y -= width;
}
return y;
}
function Sankey() {

@@ -374,2 +346,30 @@ var x0 = 0, y0 = 0, x1 = 1, y1 = 1, // extent

// Returns the target.y0 that would produce an ideal link from source to target.
function targetTop(source, target) {
let y = source.y0;
for (const {target: node, width} of source.sourceLinks) {
if (node === target) break;
y += width + py;
}
for (const {source: node, width} of target.targetLinks) {
if (node === source) break;
y -= width;
}
return y;
}
// Returns the source.y0 that would produce an ideal link from source to target.
function sourceTop(source, target) {
let y = target.y0;
for (const {source: node, width} of target.targetLinks) {
if (node === source) break;
y += width + py;
}
for (const {target: node, width} of source.sourceLinks) {
if (node === target) break;
y -= width;
}
return y;
}
return sankey;

@@ -376,0 +376,0 @@ }

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

// https://github.com/d3/d3-sankey v0.10.2 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,t){let e=n.y0;for(const{target:r,width:o}of n.sourceLinks){if(r===t)break;e+=o}for(const{source:r,width:o}of t.targetLinks){if(r===n)break;e-=o}return e}function k(n,t){let e=t.y0;for(const{source:r,width:o}of t.targetLinks){if(r===n)break;e+=o}for(const{target:r,width:o}of n.sourceLinks){if(r===t)break;e-=o}return e}function p(n){return[n.source.x1,n.y0]}function E(n){return[n.target.x0,n.y1]}n.sankey=function(){var n,r=0,o=0,p=1,E=1,L=24,v=8,x=h,w=i,m=l,b=d,M=6;function j(){var i={nodes:m.apply(null,arguments),links:b.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,x);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=(p-r-L)/(o-1);n.nodes.forEach(function(n){n.layer=Math.max(0,Math.min(o-1,Math.floor(w.call(null,n,o)))),n.x1=(n.x0=r+n.layer*u)+L})}(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(E-o-(n.length-1)*v)/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+v})}),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(),p(n),L(t),x(t),d(),y(n),L(t),x(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+=g(n,t)*i,r+=i}if(!(r>0))return;let o=(e/r-t.y0)*n;t.y0+=o,t.y1+=o})})}function p(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+=k(t,n)*i,r+=i}if(!(r>0))return;let o=(e/r-t.y0)*n;t.y0+=o,t.y1+=o})})}function L(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+v})}function x(t){u.forEach(function(e){var r,o,i,u=E,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-v})}}(i),q(i),i}function q(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 j.update=function(n){return q(n),n},j.nodeId=function(n){return arguments.length?(x="function"==typeof n?n:u(n),j):x},j.nodeAlign=function(n){return arguments.length?(w="function"==typeof n?n:u(n),j):w},j.nodeSort=function(t){return arguments.length?(n=t,j):n},j.nodeWidth=function(n){return arguments.length?(L=+n,j):L},j.nodePadding=function(n){return arguments.length?(v=+n,j):v},j.nodes=function(n){return arguments.length?(m="function"==typeof n?n:u(n),j):m},j.links=function(n){return arguments.length?(b="function"==typeof n?n:u(n),j):b},j.size=function(n){return arguments.length?(r=o=0,p=+n[0],E=+n[1],j):[p-r,E-o]},j.extent=function(n){return arguments.length?(r=+n[0][0],p=+n[1][0],o=+n[0][1],E=+n[1][1],j):[[r,o],[p,E]]},j.iterations=function(n){return arguments.length?(M=+n,j):M},j},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(p).target(E)},Object.defineProperty(n,"__esModule",{value:!0})});
// https://github.com/d3/d3-sankey v0.10.3 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,E=8,L=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,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)})}(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)*E)/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+E})}),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),L(t),d(),y(n),p(t),L(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+E})}function L(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-E})}}(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;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 q(n,t){let e=t.y0;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 b.update=function(n){return M(n),n},b.nodeId=function(n){return arguments.length?(L="function"==typeof n?n:u(n),b):L},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?(E=+n,b):E},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})});
{
"name": "d3-sankey",
"version": "0.10.2",
"version": "0.10.3",
"description": "Visualize flow between nodes in a directed acyclic network.",

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

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

// Returns the target.y0 that would produce a straight link from source to target.
function targetTop(source, target) {
let y = source.y0;
for (const {target: node, width} of source.sourceLinks) {
if (node === target) break;
y += width;
}
for (const {source: node, width} of target.targetLinks) {
if (node === source) break;
y -= width;
}
return y;
}
// Returns the source.y0 that would produce a straight link from source to target.
function sourceTop(source, target) {
let y = target.y0;
for (const {source: node, width} of target.targetLinks) {
if (node === source) break;
y += width;
}
for (const {target: node, width} of source.sourceLinks) {
if (node === target) break;
y -= width;
}
return y;
}
export default function Sankey() {

@@ -344,3 +316,31 @@ var x0 = 0, y0 = 0, x1 = 1, y1 = 1, // extent

// Returns the target.y0 that would produce an ideal link from source to target.
function targetTop(source, target) {
let y = source.y0;
for (const {target: node, width} of source.sourceLinks) {
if (node === target) break;
y += width + py;
}
for (const {source: node, width} of target.targetLinks) {
if (node === source) break;
y -= width;
}
return y;
}
// Returns the source.y0 that would produce an ideal link from source to target.
function sourceTop(source, target) {
let y = target.y0;
for (const {source: node, width} of target.targetLinks) {
if (node === source) break;
y += width + py;
}
for (const {target: node, width} of source.sourceLinks) {
if (node === target) break;
y -= width;
}
return y;
}
return sankey;
}
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