rCharts d3pie 没有出现在闪亮的应用程序中

rCharts d3pie not showing up in shiny app

我正在使用 d3pie rChart。当我在 rStudio 查看器中查看它时它起作用了。当我尝试将其输入闪亮的应用程序时,出现错误:

addResourcePath(LIB$name, LIB$url) 错误:找不到对象 'LIB'

它要我告诉它我在 showOutput('chart1','LIB') 中使用的库(例如 Nvd3、Highcharts),但我不确定要使用哪个库.

同样,当我将 d3pie 图表另存为 html 文件时,它无法在我的浏览器中打开。有解决办法吗?

数据:

x <- data.frame(table = as.factor(c("A","B","C","D","E","F")), 
     value = c(518,39,337,304,56,7))

d3pie 代码:

require(magrittr)
require(dplyr)
require(rCharts)
rPie <- rCharts$new()
rPie$setLib("http://timelyportfolio.github.io/rChartsExtra/d3pie")
rPie$addParams(
  chartspec = list(
    header = list(
      title = list(
        text = "Breakdown of 2014 Revenue Sources"
      )
    )
    ,data = list(
      content = x
    )
  )
)
rPie

server.R:

require(rCharts)
require(reshape)
require(magrittr)
require(dplyr)

x <- data.frame(table = as.factor(c("A","B","C","D","E","F")), 
                value = c(518,39,337,304,56,7))

shinyServer(function(input, output) {
  output$chart1 <- renderChart2({
    rPie <- rCharts$new()
    rPie$setLib("http://timelyportfolio.github.io/rChartsExtra/d3pie")
    cat(add_lib_assets(rPie$lib,cdn=T))
    rPie$addParams(
      chartspec = list(
        header = list(
          title = list(
            text = "This is the title"
          )
        )
        , data = list(
          content = x
        )
      )
    )
    rPie$set(dom = "chart1")
    return(rPie)
  })
})

ui.R:

require(rCharts)

shinyUI(fluidPage(
  titlePanel("Shiny App"),

  mainPanel(
               showOutput('chart1')
      ) 
    )
  )

要使其在 shiny 中运行,您需要将 d3pie 添加为 showOutput 中的库:

showOutput('chart1','d3pie')

您还可以将 extra libraries 和 copy/paste d3pie 文件夹下载到 server.Rui.R 所在的同一文件夹中。