【问题标题】:R ggvis plot: using tooltip half my scatter points disappear when I hoverR ggvis plot:当我悬停时,使用工具提示一半的散点消失
【发布时间】:2014-08-02 21:54:35
【问题描述】:

我正在使用闪亮创建一个 ggvis 散点图。我在使用工具提示功能时遇到问题。当我将鼠标悬停在散点图上时,散点图上的一半点消失了。然后我可以看到剩余一半的工具提示信息。

有人有同样的问题吗?要重现错误,您可以从以下位置下载代码和源文件:

https://github.com/er3kim78/Shiny

Server File:
library(ggvis)
library(ggplot2)
library(dplyr)

#set working directory
setwd("C:/Users/EK/Desktop/Files/R Scripts/Shiny VRC")


# read the data
vrc<- read.csv("Data File Example.csv", header = TRUE, sep=",")
str(vrc)
vrc$Impr<-as.numeric(vrc$Impr)
str(vrc)

shinyServer(

function(input, output) {

main_plot <- reactive({ 
xvar<-switch(input$xvar, 
"Clicks" = vrc$Clicks,
"Cost" = vrc$Cost,
"Impr" = vrc$Impr)
yvar<-switch(input$yvar, 
"Clicks" = vrc$Clicks,
"Cost" = vrc$Cost,
"Impr" = vrc$Impr)

vrc%>%
ggvis(~xvar, ~yvar, opacity:=0.4, key:=~Keyword) %>%
layer_points() %>%
#    layer_text(text:=as.character(vrc$Account)) %>%  
add_tooltip(function(vrc){paste0("Keyword: ", vrc$Keyword,"<br>xvar: ",vrc$xvar, 
"<br>yvar:", vrc$yvar)},"hover")
#   plot(xvar, yvar)
})
main_plot %>% bind_shiny("plot1")
})

用户界面文件: 库(ggvis)

shinyUI(fluidPage(
titlePanel("Paid Search Report"),
fluidRow(
column(3,
wellPanel(
h2("Metrics"),
selectInput("xvar", "X-Axis Variable", axis_vars, selected = "Clicks"),
selectInput("yvar", "Y-Axis Variable", axis_vars, selected = "Cost")
)),
column(9,
ggvisOutput("plot1")
)
)))

【问题讨论】:

标签: r tooltip shiny ggvis


【解决方案1】:

我遇到了同样的问题,但只有几个点消失了,工具提示悬停也出了问题!将渲染从 svg 更改为 canvas 为我解决了这个问题。 可以使用set_options(renderer = "canvas") 来完成 ggvis 图。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-06-02
    • 2014-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多