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

Color one node different than the others #29

Open
andreavargasmon opened this issue Jul 20, 2022 · 0 comments
Open

Color one node different than the others #29

andreavargasmon opened this issue Jul 20, 2022 · 0 comments

Comments

@andreavargasmon
Copy link

andreavargasmon commented Jul 20, 2022

I'm using sigmajs R package in a shiny app and I would like to color one node diferently than the others to highlight it.

I was trying:

network <- reactive({
          graph_from_data_frame(d = edges(),
                                vertices = nodes(),
                                directed = FALSE)
        })

output$org_plot <- renderSigmajs(
      
      sigmajs() %>%
        sg_from_igraph(network()) %>%
        sg_settings(drawLabels = TRUE, drawEdgeLabels = FALSE) %>%
        sg_layout(layout = igraph::layout_nicely) %>%
        sg_settings(
          minNodeSize = 3,
          maxNodeSize = 9,
          edgeColor = "default",
          defaultEdgeColor = "#d3d3d3",
          labelThreshold = 5           
        ) %>% 
        sg_neighbours()
  )
  
observeEvent(input$filter_org_list, {
  
  nodes_color <- node_size_label() %>% 
    mutate(color = case_when(
      id == input$filter_org_list ~ "red",
      TRUE ~ "black"
    ))
  
  sigmajsProxy("change") %>% 
    sg_change_nodes_p(nodes_color, color, "color")
})

where input$filter_org_list is the node I want to highlight.

The above doesn't work as expected, it changes all nodes to black.

Is it possible to do what I want? Am I doing something wrong?

@andreavargasmon andreavargasmon changed the title Color one node different that the others Color one node different than the others Jul 20, 2022
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

1 participant