1

I'm trying to make a workaround with ggiraph to create an interactive network with ggraph. What I want is to be able to highlight the edges upon hovering and display some info.

I created a sample graph and managed to get the interactive part for the edge.id's running, but the hover behavious for segment highlighting doesn't work. In the code below, I'm trying to increate the opacity of the segment and change the color to blue. None of line and segment options in the girafe_css function seem to do this.

library(ggplot2)
library(ggiraph)
library(tidygraph)
library(ggraph)

bull.graph = create_notable("bull") %>% as_tbl_graph()

pp = ggraph(bull.graph) + 
    geom_node_point() + 
    geom_edge_link(alpha = 0.3)

edge.connections = get_edges()(pp$data)

ppiraph = pp + 
    geom_segment_interactive(aes(x = x, y = y, xend = xend, yend = yend,
                                 tooltip = edge.id),
                             data = edge.connections, linewidth = 2, alpha = 0.2)

girafe(ggobj = ppiraph,
       opts_hover(css = girafe_css(
           segment = "color:blue; stroke-width:3px; opacity:1",
           line = "color:blue; stroke-width:3px; opacity:1"
           ) ))
Progman
  • 16,827
  • 6
  • 33
  • 48

0 Answers0