这是一个很好的显示层次结构的包。
在下面的代码中,他在工具提示中使用了图像。
org$tooltip <- paste0(
org$Employee,
"<br>Title:",
org$Title,
"<br><img src='https://source.unsplash.com/collection/385548/150x100'>"
)
collapsibleTreeNetwork(
org,
attribute = "Title",
fill = "Color",
nodeSize = "leafCount",
tooltipHtml = "tooltip"
)
Run Code Online (Sandbox Code Playgroud)
这里每个气泡都显示一个图像。
现在,例如 A Employee --> 应该显示图像 A。同样,它应该向所有员工展示。
是否可以。
任何建议将不胜感激。
谢谢莫汉五世
这里每个气泡都显示一个图像。[...] 我们可以向他们尊敬的员工泡泡动态展示这些图像吗?
根据包作者在 GitHub 上的示例,以下是每个节点具有不同图片的示例:
library(collapsibleTree)
org <- data.frame(
Manager = c(
NA, "Ana", "Ana", "Bill", "Bill", "Bill", "Claudette", "Claudette", "Danny",
"Fred", "Fred", "Grace", "Larry", "Larry", "Nicholas", "Nicholas"
),
Employee = c(
"Ana", "Bill", "Larry", "Claudette", "Danny", "Erika", "Fred", "Grace",
"Henri", "Ida", "Joaquin", "Kate", "Mindy", "Nicholas", "Odette", "Peter"
),
Title = c(
"President", "VP Operations", "VP Finance", "Director", "Director", "Scientist",
"Manager", "Manager", "Jr Scientist", "Operator", "Operator", "Associate",
"Analyst", "Director", "Accountant", "Accountant"
)
)
# Add in colors and sizes
org$Color <- org$Title
levels(org$Color) <- colorspace::rainbow_hcl(11)
org$tooltip <- sprintf("
%s<br>Title: %s<br><img src='%s'>",
org$Employee,
org$Title,
paste0("https://github.com/twitter/twemoji/blob/gh-pages/72x72/1f19", c(1, 1:9, letters[1:6]), ".png?raw=true")
)
collapsibleTreeNetwork(
org,
attribute = "Title",
fill = "Color",
nodeSize = "leafCount",
tooltipHtml = "tooltip"
)
Run Code Online (Sandbox Code Playgroud)