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

Nodes Font Color #287

Closed
higor-gomes93 opened this issue Sep 20, 2021 · 3 comments
Closed

Nodes Font Color #287

higor-gomes93 opened this issue Sep 20, 2021 · 3 comments

Comments

@higor-gomes93
Copy link

Hi! I'm having trouble with my nodes labels. Nodes and nodes labels have the same colors when using forceNetwork. This was addressed in this issue , but I couldn't solve my problem. Any thoughs on how to solve this?

@cjyetman
Copy link
Collaborator

This works for me...

library(networkD3)
library(htmlwidgets)

net <- forceNetwork(Links = MisLinks, Nodes = MisNodes, Source = "source",
             Target = "target", Value = "value", NodeID = "name",
             Group = "group", opacity = 1, fontSize = 24, 
             fontFamily = "helvetica", opacityNoHover = 1)

customJS <- 
  'function() { 
    d3.selectAll(".node text").attr("stroke-width", ".5px").attr("stroke", "#fff");
  }'

htmlwidgets::onRender(net, customJS)

can you provide a minimal reproducible example to demonstrate the problem you're having?

@higor-gomes93
Copy link
Author

That really worked for me, cjyetman! Thank you very much. Any clues on how to change de text colour inside the customJS function?

@cjyetman
Copy link
Collaborator

cjyetman commented Sep 22, 2021

I don't know for sure the attribute or CSS names and values off the top of my head, but you can add more commands like

.attr("font-color", "blue")

or

.style("font-color", "blue")

to the existing chain above

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

No branches or pull requests

2 participants