rcharts nplot只显示运行时闪亮的情节

Seb*_*ort 3 r shiny rcharts

当我使用Shiny运行rCharts时,仅在我的本地控制台中显示该图的顶部.我完全不知道为什么会这样,我正在运行rCharts和Shiny的最新开发版本.任何帮助将不胜感激!

下面的两个文件应该完全重现问题.在此先感谢塞巴斯蒂安

## server.R
require(rCharts)
library(RCurl)
options(RCHART_WIDTH = 800)
shinyServer(function(input, output) {
output$myChart <- renderChart({
x <- getURL("https://raw.github.com/sebastianbarfort/vaa/master/vaa_.csv")
df___ <- read.csv(text = x)
p2 <- nPlot(Economy ~ Immigration, group = 'X.1', data = df___, 
               type = 'scatterChart')
p2$chart(color = c('red', 'blue', 'green',"yellow","yellow","yellow","yellow","yellow"))
p2$set(dom = "myChart")
return(p2)
})
})


##ui.R
require(rCharts) 
shinyUI(pageWithSidebar(
headerPanel("xxx"),
sidebarPanel(
selectInput(inputId = "x",
            label = "Choose X",
            choices = c("CL", "Economy", "Education", "Envrionment",    "EU",
                        "FP",   "Health",   "Immigration"),
            selected = "Economy"),
selectInput(inputId = "y",
            label = "Choose Y",
            choices = c("CL", "Economy", "Education", "Envrionment",  "EU",
                        "FP",   "Health",   "Immigration"),                
            selected = "Immigration")
),
mainPanel(
showOutput("myChart","Nvd3")
)
))
Run Code Online (Sandbox Code Playgroud)

如果从Github加载csv失败(如果加载RCurl则不应该加载),这里是Github上数据的直接链接:https: //github.com/sebastianbarfort/vaa/blob/master/vaa_.csv

Ram*_*ath 7

这是一个快速解决方案.将您的mainPanel行修改为以下内容.图表div需要设置最小高度才能正确显示.我已经推出修正来纠正这个问题,但它仍然有一个小错误.本周我将对rCharts进行更全面的修复,这应该解决这个问题,并且不保证你添加该tags$style行.

mainPanel(
  div(class='wrapper',
    tags$style(".Nvd3{ height: 400px;}"),
    showOutput("myChart","Nvd3")
  )
)
Run Code Online (Sandbox Code Playgroud)

注意.在使用Shiny时,最好使用非公式接口,因为Shiny输入被解释为字符串.未来版本可能会放宽此要求.因此,例如,初始化图的线将是

p2 <- nPlot(x = input$x, y = input$y, group = 'X.1', 
  data = df___, type = 'scatterChart')
Run Code Online (Sandbox Code Playgroud)

编辑.如果您dev安装了rCharts版本(dev分支),您可以添加基本控件,就像您在应用程序中一样,而不需要Shiny.这是你怎么做的.此功能仍处于试验阶段,随着我继续简化代码库,API将发生变化,因此请谨慎使用.

require(rCharts)
require(RCurl)
x <- getURL("https://raw.github.com/sebastianbarfort/vaa/master/vaa_.csv")
df___ <- read.csv(text = x)
p2 <- nPlot(Economy ~ Immigration, 
  group = 'X.1', 
  data = df___, 
  type = 'scatterChart'
)
p2$chart(color = c('red', 'blue', 'green',"yellow","yellow","yellow",
  "yellow","yellow")
)
p2$addControls("x", value = "Immigration", values = names(df___)[-c(1:2)])
p2$addControls("y", value = "Economy", values = names(df___)[-c(1:2)])
Run Code Online (Sandbox Code Playgroud)