如何在 rCharts 中创建一个空图?

How to create an empty plot in rCharts?

我正在尝试将 rCharts 输出添加到闪亮的应用程序。如果输入无效,那么我不想输出任何东西 - 所以我希望能够 return NULL 或者以某种方式在输出中有一个 "empty plot" 。但是我不知道如何在 rCharts 中创建一个空图。

这是我的代码,示例是直接从 README 中提取的,但我注释掉了情节代码并 returned NULL 而不是

library(shiny)
library(rCharts)

ui <- pageWithSidebar(
  headerPanel("rCharts: Interactive Charts from R using polychart.js"),

  sidebarPanel(
    selectInput(inputId = "x",
                label = "Choose X",
                choices = c('SepalLength', 'SepalWidth', 'PetalLength', 'PetalWidth'),
                selected = "SepalLength"),
    selectInput(inputId = "y",
                label = "Choose Y",
                choices = c('SepalLength', 'SepalWidth', 'PetalLength', 'PetalWidth'),
                selected = "SepalWidth")
  ),
  mainPanel(
    showOutput("myChart", "polycharts")
  )
)

server<- function(input, output) {
  output$myChart <- renderChart({
    # names(iris) = gsub("\.", "", names(iris))
    # p1 <- rPlot(input$x, input$y, data = iris, color = "Species", 
    #             facet = "Species", type = 'point')
    # p1$addParams(dom = 'myChart')
    # return(p1)
    return(NULL)
  })
}

shinyApp(ui, server)

showOutput 期望返回一个正确的对象,那么为什么要返回那个 class.

的空对象
output$myChart <- renderChart({
        mychart <- Polycharts$new()
        return(mychart)
})