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

New function for node size legend? #84

Open
AlexanderPico opened this issue Nov 21, 2019 · 2 comments
Open

New function for node size legend? #84

AlexanderPico opened this issue Nov 21, 2019 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@AlexanderPico
Copy link
Member

Could be something like...

# Set your current style name
style.name <- "galFiltered Style"

# Extract min and max node size
res<-cyrestGET(paste0("styles/",style.name,"/mappings/NODE_SIZE"))
size.col <- res$mappingColumn
min.size <- res$points[[1]]$equal
min.value <- res$points[[1]]$value
max.size <- res$points[[length(res$points)]]$equal
max.value <- res$points[[length(res$points)]]$value

# Prepare as data.frame
legend.df <-data.frame(c(min.size, max.size), c(min.value, max.value))
colnames(legend.df) <- c("legend.label",size.col)
rownames(legend.df) <- c("legend.size.min", "legend.size.max")

# Add legend nodes and data
addCyNodes(c("legend.size.min", "legend.size.max"))
loadTableData(legend.df)

# Style and position
setNodeColorBypass(c("legend.size.min", "legend.size.max"),"#000000")
setNodePropertyBypass(c("legend.size.min", "legend.size.max"), 
                      c("E,W,l,5,0", "E,W,l,5,0"),  # node_anchor, label_anchor, justification, x-offset, y-offset
                      "NODE_LABEL_POSITION")
setNodeLabelBypass(c("legend.size.min", "legend.size.max"), legend.df$legend.label)
setNodePropertyBypass("legend.size.max", 
                      as.numeric(max.size)/2 + as.numeric(min.size)/2 + 10, # vertical spacing
                      "NODE_Y_LOCATION")
setNodeFontSizeBypass(c("legend.size.min", "legend.size.max"), c(20,20))


@AlexanderPico AlexanderPico added the enhancement New feature or request label Nov 21, 2019
@AlexanderPico AlexanderPico added this to the 2.7.x milestone Nov 21, 2019
@AlexanderPico AlexanderPico self-assigned this Nov 21, 2019
@AlexanderPico
Copy link
Member Author

Note: should handle continuous, passthrough and discrete NODE_SIZE mappings

@AlexanderPico AlexanderPico modified the milestones: 2.7.x, 2.8 Apr 9, 2020
@AlexanderPico AlexanderPico modified the milestones: 2.8, 2.9, 2.10-rel, 2.11-dev Oct 15, 2020
@bdemchak
Copy link
Contributor

@AlexanderPico AlexanderPico modified the milestones: 2.11-dev, 2.13 (dev) May 10, 2021
@yihangx yihangx modified the milestones: 2.13-dev, 2.15-dev Sep 30, 2021
@AlexanderPico AlexanderPico removed this from the 2.15-dev milestone Mar 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants