Skip to content

Commit

Permalink
import {methods} and namespace methods::hasArg() (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjyetman authored Dec 15, 2023
1 parent f11418a commit 209e12e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.2
Imports:
jsonlite (>= 0.9.6),
methods,
r2d3
Suggests:
ape,
Expand Down
24 changes: 12 additions & 12 deletions R/sankey_network.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ sankey_network <- function(data, width = NULL, height = NULL, ..., viewer = "bro
json_verabitm = TRUE)

options <- list(
linkStrokeOpacity = ifelse(hasArg(linkStrokeOpacity), list(...)$linkStrokeOpacity, 0.3),
linkMixBlendMode = ifelse(hasArg(linkMixBlendMode), list(...)$linkMixBlendMode, "multiply"),
linkPath = ifelse(hasArg(linkPath), list(...)$linkPath, "d3.sankeyLinkHorizontal()"),
linkColor = ifelse(hasArg(linkColor), list(...)$linkColor, "source-target"),
nodeAlign = ifelse(hasArg(nodeAlign), list(...)$nodeAlign, "justify"),
nodeGroup = ifelse(hasArg(nodeGroup), list(...)$nodeGroup, "group"),
nodeWidth = ifelse(hasArg(nodeWidth), list(...)$nodeWidth, 15),
nodePadding = ifelse(hasArg(nodePadding), list(...)$nodePadding, 10),
nodeLabelPadding = ifelse(hasArg(nodeLabelPadding), list(...)$nodeLabelPadding, 6),
nodeLabelFontFamily = ifelse(hasArg(nodeLabelFontFamily), list(...)$nodeLabelFontFamily, "sans-serif"),
nodeLabelFontSize = ifelse(hasArg(nodeLabelFontSize), list(...)$nodeLabelFontSize, 10),
colors = ifelse(hasArg(color), list(...)$color, "d3.schemeCategory10")
linkStrokeOpacity = ifelse(methods::hasArg("linkStrokeOpacity"), list(...)$linkStrokeOpacity, 0.3),
linkMixBlendMode = ifelse(methods::hasArg("linkMixBlendMode"), list(...)$linkMixBlendMode, "multiply"),
linkPath = ifelse(methods::hasArg("linkPath"), list(...)$linkPath, "d3.sankeyLinkHorizontal()"),
linkColor = ifelse(methods::hasArg("linkColor"), list(...)$linkColor, "source-target"),
nodeAlign = ifelse(methods::hasArg("nodeAlign"), list(...)$nodeAlign, "justify"),
nodeGroup = ifelse(methods::hasArg("nodeGroup"), list(...)$nodeGroup, "group"),
nodeWidth = ifelse(methods::hasArg("nodeWidth"), list(...)$nodeWidth, 15),
nodePadding = ifelse(methods::hasArg("nodePadding"), list(...)$nodePadding, 10),
nodeLabelPadding = ifelse(methods::hasArg("nodeLabelPadding"), list(...)$nodeLabelPadding, 6),
nodeLabelFontFamily = ifelse(methods::hasArg("nodeLabelFontFamily"), list(...)$nodeLabelFontFamily, "sans-serif"),
nodeLabelFontSize = ifelse(methods::hasArg("nodeLabelFontSize"), list(...)$nodeLabelFontSize, 10),
colors = ifelse(methods::hasArg("color"), list(...)$color, "d3.schemeCategory10")
)

r2d3::r2d3(
Expand Down

0 comments on commit 209e12e

Please sign in to comment.