-
Notifications
You must be signed in to change notification settings - Fork 268
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
Customizing the label/text for each link in ForceNetwork output? #271
Comments
Yes, but only by writing custom JavaScript code to make it work. That is not a built-in feature. |
Thank you. On an unrelated note, just in case you've much experience with shinyapps, I've been having trouble deploying at networkd3 online:
|
here's an example of changing the node label text on library(networkD3)
library(htmlwidgets)
MisNodes$initials <- gsub('[[:lower:]]', '', MisNodes$name)
network <-
forceNetwork(Links = MisLinks, Nodes = MisNodes, Source = "source",
Target = "target", Value = "value", NodeID = "initials",
Group = "group", opacity = 1, opacityNoHover = 1)
network$x$nodes$initials <- MisNodes$initials
network$x$nodes$fullname <- MisNodes$name
name_switch_js <-
"function(el, x) {
var nodes = el.getElementsByClassName('node');
[...nodes].map(node => node.addEventListener('mouseover', function(ev) {
d3.select(ev.target.parentNode).select('text').text(d => d.fullname);
}, false));
[...nodes].map(node => node.addEventListener('mouseout', function(ev) {
d3.select(ev.target.parentNode).select('text').text(d => d.initials);
}, false));
}
"
onRender(network, name_switch_js) |
champion, thank you!
…On Mon, 20 Apr 2020 at 00:29, CJ Yetman ***@***.***> wrote:
Closed #271 <#271>.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#271 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACN6ETOMX3KXMSCOT2H2NSDRNMDEDANCNFSM4MIPZEAA>
.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would it be possible to show custom lablel text for both unhovered and hovered nodes? E.g. for a coauthor network, initials when unhovered, full names when hovered. I'm looking to use this package for visualising networks of COVID19 publications clustered by authors, topics and citations (openVirus).
(Related to #239 and #243)
The text was updated successfully, but these errors were encountered: