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

option to suppress default hovertext with plot_method = "ggplot" and node_type = "scatter" (with possible solution) #300

Open
mcsimenc opened this issue Dec 22, 2023 · 1 comment · May be fixed by #301

Comments

@mcsimenc
Copy link

mcsimenc commented Dec 22, 2023

Hi, when plot_method = "ggplot" and node_type = "scatter", there is always a string in the tooltip from these lines in R/plots.R:

mdf[["text"]] <- paste0(                                                         
  row, ": ", mdf[[1]], "<br>",                                                   
  col, ": ", mdf[[2]], "<br>",                                                   
  val, ": ", label_format_fun(mdf[[3]])                                          
)        

To add an option to control this, a couple conditionals can be added spanning lines 100 - 137, such as (tested):

  if(!suppress_default_hovertext)                                               
  {                                                                             
    mdf[["text"]] <- paste0(                                                    
      row, ": ", mdf[[1]], "<br>",                                              
      col, ": ", mdf[[2]], "<br>",                                              
      val, ": ", label_format_fun(mdf[[3]])                                     
    )                                                                           
  }                                                                             
                                                                                
  if (type == "heatmap") {                                                      
    geom <- "geom_tile"                                                         
    aes_mapping <- aes(fill = .data[[val]], text = text)                        
    geom_args <- list(                                                          
      color = grid_color,                                                       
      size = grid_size                                                          
    )                                                                           
  } else if (type == "scatter") {                                               
    geom <- "geom_point"                                                        
    geom_args <- list()                                                         
    if (!is.null(point_size_mat)) {                                             
      if(!suppress_default_hovertext)                                           
      {                                                                         
        mdf[["text"]] <- paste(                                                 
          mdf[["text"]], "<br>",                                                
          point_size_name, ": ", label_format_fun(mdf[[4]])                     
        )                                                                       
      }                                                                         
     aes_mapping <- aes(                                                        
       color = .data[[val]],                                                    
       text = text,                                                             
       size = .data[[point_size_name]]                                          
    )                                                                           
    } else {                                                                    
      geom_args[["size"]] <- grid_size                                          
      aes_mapping <- aes(                                                       
        color = .data[[val]],                                                   
        text = text                                                             
      )                                                                         
    }                                                                           
  }                                                                             
  if (!is.null(custom_hovertext)) {                                             
    if(!suppress_default_hovertext)                                             
    {                                                                           
      mdf[["text"]] <- paste0(mdf[["text"]], "<br>", custom_hovertext)          
    } else                                                                      
    {                                                                           
      mdf[["text"]] <- reshape2::melt(as.matrix(custom_hovertext))[[3]]         
    }                                                                           
  }
@mcsimenc mcsimenc changed the title option to suppress default hovertext with plot_method = "ggplot" and node_type = "scatter" option to suppress default hovertext with plot_method = "ggplot" and node_type = "scatter" (with possible solution) Dec 22, 2023
@talgalili
Copy link
Owner

talgalili commented Dec 22, 2023 via email

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

Successfully merging a pull request may close this issue.

2 participants