From 77b81efa655fd5164c3aa3ac781c9ce5e5df02fe Mon Sep 17 00:00:00 2001 From: CJ Yetman Date: Sat, 23 Dec 2023 12:46:45 +0100 Subject: [PATCH] [sankey] add ability to color links by a path variable (#12) --- inst/sankey_network.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/inst/sankey_network.js b/inst/sankey_network.js index 4729033..301ceaf 100644 --- a/inst/sankey_network.js +++ b/inst/sankey_network.js @@ -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; @@ -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)