Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to specify symbol and symbol size for edges in network graphs #466

Merged
merged 3 commits into from
Oct 2, 2022

Conversation

liubao210
Copy link

First of all, I've been using this package in my company for two years, it's an awesome package, I recommend it to many colleagues, thank you to all the contributors !!!

But today I found the original parameter edge symbolSize cannot be used because the value of symbolSize is incorrectly assigned to c(5, 20) at line 292 of file R/utils.R. So :

1. I delete this wrong setting, than we can set a generic symbol and symbol size of edges in e_graph()

nodes <- data.frame(
  name = paste0(LETTERS, 1:100),
  value = rnorm(100, 10, 2),
  size = rep(c(10,5), 50),
  grp = rep(c("grp1", "grp2"), 50),
  stringsAsFactors = FALSE
)

edges <- data.frame(
  source = sample(nodes$name, 200, replace = TRUE),
  target = sample(nodes$name, 200, replace = TRUE),
  value = 1,
  size = rep(c(5, 1), 100),
  stringsAsFactors = FALSE
)

e_charts() |>
  e_graph(
    label = list(show = T, position = "right"), 
    edgeSymbol = c("circle", "arrow"),
    edgeSymbolSize = c(5, 3),
    lineStyle = list(curveness = 0.2),
    draggable = T,
    roam = T
  ) |>
  e_graph_nodes(nodes, name, value, size, grp) |>
  e_graph_edges(edges, source, target, value, size)

2. Add ability for dynamic edge symbol and symbol size, which can be setted in e_graph_edges()

nodes <- data.frame(
  name = paste0(LETTERS, 1:100),
  value = rnorm(100, 10, 2),
  size = rep(c(10,5), 50),
  grp = rep(c("grp1", "grp2"), 50),
  stringsAsFactors = FALSE
)

edges <- data.frame(
  source = sample(nodes$name, 200, replace = TRUE),
  target = sample(nodes$name, 200, replace = TRUE),
  value = 1,
  size = rep(c(5, 1), 100),
  symbolSource = "circle",
  symbolTarget = "arrow",
  symbolSizeSource = rep(c(5,20), 100),
  symbolSizeTarget = rep(c(1,10), 100),
  symbolSize = rep(c(15,10), 100),
  stringsAsFactors = FALSE
)

e_charts() |>
  e_graph(
    label = list(show = T, position = "right"), 
    lineStyle = list(curveness = 0.2),
    draggable = T,
    roam = T
  ) |>
  e_graph_nodes(nodes, name, value, size, grp) |>
  e_graph_edges(edges, source, target, value, size, symbolSource, symbolTarget, symbolSizeSource, symbolSizeTarget)

图片

@JohnCoene JohnCoene merged commit 442cedc into JohnCoene:master Oct 2, 2022
@JohnCoene
Copy link
Owner

Thank you!

munoztd0 added a commit that referenced this pull request Jun 13, 2023
build graph edges was brocken so I reverted #466

#466 is not implemented anymore until it is fixed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants