diff --git a/R/sankeyNetwork.R b/R/sankeyNetwork.R index 839c5d4f..14c3e465 100644 --- a/R/sankeyNetwork.R +++ b/R/sankeyNetwork.R @@ -28,6 +28,7 @@ #' @param fontFamily font family for the node text labels. #' @param nodeWidth numeric width of each node. #' @param nodePadding numeric essentially influences the width height. +#' @param nodeStrokeWidth numeric width of the stroke around nodes. #' @param margin an integer or a named \code{list}/\code{vector} of integers #' for the plot margins. If using a named \code{list}/\code{vector}, #' the positions \code{top}, \code{right}, \code{bottom}, \code{left} @@ -74,8 +75,8 @@ sankeyNetwork <- function(Links, Nodes, Source, Target, Value, NodeID, NodeGroup = NodeID, LinkGroup = NULL, units = "", - colourScale = JS("d3.scale.category20()"), fontSize = 7, - fontFamily = NULL, nodeWidth = 15, nodePadding = 10, margin = NULL, + colourScale = JS("d3.scale.category20()"), fontSize = 7, fontFamily = NULL, + nodeWidth = 15, nodePadding = 10, nodeStrokeWidth = 1, margin = NULL, height = NULL, width = NULL, iterations = 32, sinksRight = TRUE) { # Check if data is zero indexed @@ -131,8 +132,8 @@ sankeyNetwork <- function(Links, Nodes, Source, Target, Value, # create options options = list(NodeID = NodeID, NodeGroup = NodeGroup, LinkGroup = LinkGroup, colourScale = colourScale, fontSize = fontSize, fontFamily = fontFamily, - nodeWidth = nodeWidth, nodePadding = nodePadding, units = units, - margin = margin, iterations = iterations, sinksRight = sinksRight) + nodeWidth = nodeWidth, nodePadding = nodePadding, nodeStrokeWidth = nodeStrokeWidth, + units = units, margin = margin, iterations = iterations, sinksRight = sinksRight) # create widget htmlwidgets::createWidget(name = "sankeyNetwork", x = list(links = LinksDF, diff --git a/inst/htmlwidgets/sankeyNetwork.js b/inst/htmlwidgets/sankeyNetwork.js index 6b64ed83..54b24133 100644 --- a/inst/htmlwidgets/sankeyNetwork.js +++ b/inst/htmlwidgets/sankeyNetwork.js @@ -178,6 +178,7 @@ HTMLWidgets.widget({ .style("fill", function(d) { return d.color = color_node(d); }) .style("stroke", function(d) { return d3.rgb(d.color).darker(2); }) + .style("stroke-width", options.nodeStrokeWidth) .style("opacity", 0.9) .style("cursor", "move") .append("title") diff --git a/man/sankeyNetwork.Rd b/man/sankeyNetwork.Rd index a13f6c26..b8c685b1 100644 --- a/man/sankeyNetwork.Rd +++ b/man/sankeyNetwork.Rd @@ -11,8 +11,8 @@ specifically for Sankey diagrams \url{http://bost.ocks.org/mike/sankey/}. sankeyNetwork(Links, Nodes, Source, Target, Value, NodeID, NodeGroup = NodeID, LinkGroup = NULL, units = "", colourScale = JS("d3.scale.category20()"), fontSize = 7, fontFamily = NULL, nodeWidth = 15, nodePadding = 10, - margin = NULL, height = NULL, width = NULL, iterations = 32, - sinksRight = TRUE) + nodeStrokeWidth = 1, margin = NULL, height = NULL, width = NULL, + iterations = 32, sinksRight = TRUE) } \arguments{ \item{Links}{a data frame object with the links between the nodes. It should @@ -57,6 +57,8 @@ scale for the nodes. See \item{nodePadding}{numeric essentially influences the width height.} +\item{nodeStrokeWidth}{numeric width of the stroke around nodes.} + \item{margin}{an integer or a named \code{list}/\code{vector} of integers for the plot margins. If using a named \code{list}/\code{vector}, the positions \code{top}, \code{right}, \code{bottom}, \code{left}