rCharts不会在闪亮的app中呈现情节

时间:2015-06-18 15:47:39

标签: r plot shiny rcharts

我正在使用以下简单的闪亮应用代码片段来绘制主pannel中的输出。但它并没有像预期的那样呈现情节。它在浏览器中不显示任何内容。但是当我只运行mPlot部分时,它会在所有交互中正确显示RStudio中的图。

ui.R
library(shiny)
library(rCharts)

ui<-fluidPage(
  headerPanel("Economics data with rCharts"),
  mainPanel(
    showOutput("myChart","polycharts")
  )
)

server.R
library(shiny)
library(rCharts)
require(datasets)

server<-function(input,output){
  output$myChart<-renderChart({
    data(economics, package = 'ggplot2')
    econ <- transform(economics, date = as.character(date))
    m1 <- mPlot(x = 'date', y = c('psavert', 'uempmed'), type = 'Line',
                data = econ)
    m1$set(pointSize = 0, lineWidth = 1)
    return(m1)
  })

}

1 个答案:

答案 0 :(得分:3)

嗨,你使用错误的JS库,它是morris,而不是polycharts,尝试:

# ui.R
library(shiny)
library(rCharts)

ui<-fluidPage(
  headerPanel("Economics data with rCharts"),
  mainPanel(
    showOutput("myChart","morris")
  )
)

# server.R
library(shiny)
library(rCharts)
require(datasets)

server<-function(input,output){
  output$myChart<-renderChart2({
    data(economics, package = 'ggplot2')
    econ <- transform(economics, date = as.character(date))
    m1 <- mPlot(x = 'date', y = c('psavert', 'uempmed'), type = 'Line',
                data = econ)
    m1$set(pointSize = 0, lineWidth = 1)
    return(m1)
  })

}

shinyApp(ui = ui, server = server)