christophergandrud / christophergandrud/networkD3

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

Open
#239 2 comments 0 reactions 0 assignees View on GitHub
enhancement feature request sankeyNetwork
Dominant language
R
Stars
659
Forks
259
PR merge metrics
No merged PRs in 30d

Description

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](https://github.com/christophergandrud/networkD3/files/2167765/TreatmentCoding1.txt)

[Sample_Data_Pair1.txt](https://github.com/christophergandrud/networkD3/files/2167766/Sample_Data_Pair1.txt)

Thank you!
Aaron

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at the sankeyNetwork entry point and trace how link hover labels are generated. The change is complete when callers can add study names to link labels and suppress the misleading right arrow; no specific source file or test is identified in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
d3js, r
Domain
data-visualization
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.