R ggvis font and parameters of interactive text in scatter plot (hover) -


i know if there way modify characteristics of text shown on "hover" using ggvis.

i have created scatter plot based on template found on internet , modified needs.

the script follows:

library(shiny) library(ggvis)  mydata <- data mydata$id <- 1:nrow(mydata)  # add id column use ask key   all_values <- function(x) {   if(is.null(x)) return(null)   row <- mydata[mydata$id == x$id, ]   paste0(         names(row), ": ", format(row), collapse = "\n"         ) }  # factor location mydata %>% ggvis(~a, ~b, key := ~id) %>%   layer_points(fill = ~factor(location)) %>%   scale_numeric("x", trans = "log", expand=0) %>%   scale_numeric("y", trans = "log", expand=0) %>%   add_axis("x", title = "blabla1") %>%   add_axis("y", title = "blabla2") %>%   add_tooltip(all_values, "hover") 

what know how format text shown interactively on scatter plot.

mainly to:

  1. go on new line after each parameter shown (the command "\n" in collapse , paste0 doesn't seem work)
  2. how put in bold example names(row)

you have use appropriate html tags in paste0():

  • for new line: collapse = "<br />"
  • for bold: "<b>", names(row), "</b>:"

since didn't provide reproducible example, here's 1 mtcars:

mtc <- mtcars mtc$id <- 1:nrow(mtc)  # add id column use ask key  all_values <- function(x) {   if(is.null(x)) return(null)   row <- mtc[mtc$id == x$id, ]   paste0("<b>", names(row), "</b>:", format(row), collapse = "<br />") }  mtc %>%    ggvis(x = ~wt, y = ~mpg, key := ~id) %>%   layer_points() %>%   add_tooltip(all_values, "hover") 

enter image description here


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -