Skip to content

Commit

Permalink
[sankey] add ability to color links by a path variable (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjyetman authored Dec 23, 2023
1 parent 5ec51fe commit 77b81ef
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions inst/sankey_network.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ r2d3.onRender(function(data, div, width, height, options) {
const colorScheme = options.colorScheme ?? "schemeCategory10";
const linkColor = options.linkColor ?? "source-target";
const linkSort = options.linkSort ?? undefined;
const linkPath = options.linkPath ?? "path";
const nodeLabelFontFamily = options.nodeLabelFontFamily ?? "sans-serif";
const nodeLabelFontSize = options.nodeLabelFontSize ?? 10;
const tooltipTransitionDuration = options.tooltipTransitionDuration ?? 200;
Expand Down Expand Up @@ -145,6 +146,7 @@ r2d3.onRender(function(data, div, width, height, options) {
.attr("stroke", linkColor === "source-target" ? (d) => `url(#${d.uid})`
: linkColor === "source" ? (d) => color(d.source[nodeGroup])
: linkColor === "target" ? (d) => color(d.target[nodeGroup])
: linkColor === "path" ? (d) => color(d[linkPath])
: linkColor)
.attr("stroke-width", d => Math.max(1, d.width))
.on("mouseover", mouseover)
Expand Down

0 comments on commit 77b81ef

Please sign in to comment.