-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
d3-sankey-circular #3406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
d3-sankey-circular #3406
Changes from 12 commits
03a3cb5
2504dc3
fd19907
bde2a79
5f89d78
1ad9586
ee7088a
5418d25
be1acc8
067869f
f8bf7fe
54523db
ed87295
c1404fb
d268b73
09d2aa6
3e5b160
3ed9ba5
00e5d28
f63e2b5
6fb3fb4
51085c4
9ca4d5d
d1d852a
2382d74
04a186c
dee73b8
b3bcdd6
4539d28
225d310
9b36090
48a8b1b
777dc97
ebe613b
04d53ff
003704c
3625234
59dbef4
4ed7634
ba2a485
063784a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,15 +58,19 @@ | |
}, | ||
"dependencies": { | ||
"3d-view": "^2.0.0", | ||
"@plotly/d3-sankey": "^0.5.1", | ||
"alpha-shape": "^1.0.0", | ||
"array-range": "^1.0.1", | ||
"canvas-fit": "^1.5.0", | ||
"color-normalize": "^1.3.0", | ||
"convex-hull": "^1.0.3", | ||
"country-regex": "^1.1.0", | ||
"d3": "^3.5.12", | ||
"d3-sankey": "git://github.com/antoinerg/d3-sankey.git#4f37ed8d3578b545a8569ecd74583f373768e900", | ||
"d3-sankey-circular": "git://github.com/antoinerg/d3-sankey-circular.git#a298acf674f0a9c7158243d45814cd8060dad728", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minimal changes over latest d3-sankey-circular tomshanley/d3-sankey-circular@master...antoinerg:support-update There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those changes got merged in 🚀 ! |
||
"d3-array": "1", | ||
etpinard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"d3-collection": "1", | ||
"d3-force": "^1.0.6", | ||
"d3-interpolate": "1", | ||
"delaunay-triangulate": "^1.1.6", | ||
"es6-promise": "^3.0.2", | ||
"fast-isnumeric": "^1.1.2", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/** | ||
* Copyright 2012-2019, Plotly, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var Lib = require('../../lib'); | ||
var isArrayOrTypedArray = Lib.isArrayOrTypedArray; | ||
var isIndex = Lib.isIndex; | ||
|
||
module.exports = function(trace) { | ||
etpinard marked this conversation as resolved.
Show resolved
Hide resolved
|
||
var nodeSpec = trace.node; | ||
var linkSpec = trace.link; | ||
|
||
var links = []; | ||
var hasLinkColorArray = isArrayOrTypedArray(linkSpec.color); | ||
var linkedNodes = {}; | ||
|
||
var nodeCount = nodeSpec.label.length; | ||
var i; | ||
for(i = 0; i < linkSpec.value.length; i++) { | ||
var val = linkSpec.value[i]; | ||
// remove negative values, but keep zeros with special treatment | ||
var source = linkSpec.source[i]; | ||
var target = linkSpec.target[i]; | ||
if(!(val > 0 && isIndex(source, nodeCount) && isIndex(target, nodeCount))) { | ||
continue; | ||
} | ||
|
||
source = +source; | ||
target = +target; | ||
linkedNodes[source] = linkedNodes[target] = true; | ||
|
||
var label = ''; | ||
if(linkSpec.label && linkSpec.label[i]) label = linkSpec.label[i]; | ||
|
||
links.push({ | ||
pointNumber: i, | ||
label: label, | ||
color: hasLinkColorArray ? linkSpec.color[i] : linkSpec.color, | ||
source: source, | ||
target: target, | ||
value: +val | ||
}); | ||
} | ||
|
||
var hasNodeColorArray = isArrayOrTypedArray(nodeSpec.color); | ||
var nodes = []; | ||
var removedNodes = false; | ||
var nodeIndices = {}; | ||
|
||
for(i = 0; i < nodeCount; i++) { | ||
if(linkedNodes[i]) { | ||
var l = nodeSpec.label[i]; | ||
nodeIndices[i] = nodes.length; | ||
nodes.push({ | ||
pointNumber: i, | ||
label: l, | ||
color: hasNodeColorArray ? nodeSpec.color[i] : nodeSpec.color | ||
}); | ||
} else removedNodes = true; | ||
} | ||
|
||
// need to re-index links now, since we didn't put all the nodes in | ||
if(removedNodes) { | ||
for(i = 0; i < links.length; i++) { | ||
links[i].source = nodeIndices[links[i].source]; | ||
links[i].target = nodeIndices[links[i].target]; | ||
} | ||
} | ||
|
||
return { | ||
links: links, | ||
nodes: nodes | ||
}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minimal changes over latest d3-sankey d3/d3-sankey@master...antoinerg:fix-large-padding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. So we no longer need https://github.com/plotly/d3-sankey ? I thought i read that we made changes in our
@plotly/d3-sankey
that got rejected byd3/d3-sankey
.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those changes were minimal. One of the biggest was that we generated the SVG path for the links in it. As you found out in this PR, we can do this operation in plotly.js instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok that make sense. Do you think we have a shot at getting
d3/d3-sankey@master...antoinerg:fix-large-padding
merged into
d3/d3-sankey
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There hasn't been anything merged into
master
ind3/d3-sankey
since Jul 13, 2017 so I'm not sure... I opened a PR almost a month ago d3/d3-sankey#63 and there has been no activity since then.