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

Customizing the label/text for each link in sankeyNetwork output? #239

Open
aaronxs opened this issue Jul 5, 2018 · 2 comments
Open

Customizing the label/text for each link in sankeyNetwork output? #239

aaronxs opened this issue Jul 5, 2018 · 2 comments

Comments

@aaronxs
Copy link

aaronxs commented Jul 5, 2018

Hi,

Thank you for such a great package!!

I am trying to create a network/flow diagram that shows how drugs are connected (through clinical trials). The nodes here are the drugs, the colour of the nodes represent the type of the drug. The links connecting the nodes (drugs) represent the trials involving the drugs so links with the same colour means they are the same clinical trial.

The question I have is: would it be possible to edit the texts currently showing when you hover around the links? I would like to add the name of the study to each link and also remove the little right arrow currently showing in the label of the links since it's kind of misleading in this case to say "Drug1 => Drug2".

Here are the codes and data sets I used in the example:

library(networkD3);library(tidyverse);library(magrittr)

# dataframe with the  treatments names (the nodes)
trt <- read.table("TreatmentCoding1.txt", stringsAsFactors = FALSE, header = T)
# dataframe with all the studies (the links)
datt <- read.table("Sample_Data_Pair1.txt", stringsAsFactors = FALSE, header = T)
datt %<>%
  # zero-indexing the treatments in links
  mutate(treat1 = treat1 - 1,
         treat2 = treat2 - 1)

sankeyNetwork(Links = datt,
              Source = "treat1", Target = "treat2", Value = "patient_count", LinkGroup = "study",
              Nodes = trt,
              NodeID = "name", NodeGroup = "drug_type", nodeWidth = 30,
              fontSize = 12,
              units = "patients")

TreatmentCoding1.txt

Sample_Data_Pair1.txt

Thank you!
Aaron

@aaronxs
Copy link
Author

aaronxs commented Jul 6, 2018

@timdisher thought you might be interested in this as well

@cjyetman
Copy link
Collaborator

This should follow the same strategy as determined for node tooltips in #251

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants