1

我正在使用闪亮创建一个 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")
})

UI文件:库(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")
)
)))
4

1 回答 1

0

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

于 2015-04-15T10:21:34.713 回答