Skip to content

Commit

Permalink
[sankey] add node and link sorting and iterations options (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjyetman authored Dec 23, 2023
1 parent c9d3abf commit 5ec51fe
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion inst/sankey_network.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ r2d3.onRender(function(data, div, width, height, options) {
const nodeWidth = options.nodeWidth ?? 24;
const nodePadding = options.nodePadding ?? 8;
const nodeGroup = options.nodeGroup ?? "group";
const nodeSort = options.nodeSort ?? undefined;
const iterations = options.iterations ?? 6;
const colorScheme = options.colorScheme ?? "schemeCategory10";
const linkColor = options.linkColor ?? "source-target";
const linkSort = options.linkSort ?? undefined;
const nodeLabelFontFamily = options.nodeLabelFontFamily ?? "sans-serif";
const nodeLabelFontSize = options.nodeLabelFontSize ?? 10;
const tooltipTransitionDuration = options.tooltipTransitionDuration ?? 200;
Expand All @@ -35,7 +38,10 @@ r2d3.onRender(function(data, div, width, height, options) {
.nodeAlign(d3[nodeAlign])
.nodeWidth(nodeWidth)
.nodePadding(nodePadding)
.extent([[1, 5], [width - 1, height - 5]]);
.extent([[1, 5], [width - 1, height - 5]])
.linkSort(eval(linkSort))
.nodeSort(eval(nodeSort))
.iterations(iterations);

const {nodes, links} = sankey({
nodes: data.nodes.map(d => Object.assign({}, d)),
Expand Down

0 comments on commit 5ec51fe

Please sign in to comment.