【问题标题】:An error occurred rendering the PivotTable results呈现数据透视表结果时发生错误
【发布时间】:2015-11-13 14:06:42
【问题描述】:

我尝试用

创建闪亮的应用程序

rpivotTablenvd3 rcharts

一切正常,但是当我尝试从枢轴显示任何图表时 我得到错误

An error occurred rendering the PivotTable results.

但如果我只使用 rpivotTable 图表在数据透视表中工作,我认为在一个闪亮的应用程序中使用 rpivotTablenvd3 rcharts 时会出现问题。

示例

用户界面

library(shiny)
library(rCharts)
library(rpivotTable)
shinyUI(fluidPage(
  showOutput('plot1',lib = "nvd3"),
  rpivotTableOutput('pivot1', width = "100%", height = "500px"))  
)

服务器

library(shiny)
library(rCharts)
library(rpivotTable)

df=data.frame(A=c(1:10),B=c(-10:-1),C=c("x",rep(c("x","y","z"),3)))
shinyServer(function(input, output, session) {
  output$pivot1 <- renderRpivotTable({
    rpivotTable(data =df ,
                width="100%", height="500px")
  })

  output$plot1=renderChart2({
    myform <- as.formula(paste('A','~','B'))

    n2 <- nPlot(myform,  group ="C", data = df, type = 'multiBarChart')
    n2$chart(margin = list(left = 100))
    n2$chart(reduceXTicks = F)
    n2$set(width = 800, height = 500) 

    print(n2)
  })
  })

给我

如果我在 pivot 作品中只使用 rpivotTable 图表

当我查看检查时,我看到了

TypeError: a.axisTimeFormat.multi is not a function
    at e.i.initParams (c3.min.js:1)
    at e.i.init (c3.min.js:1)
    at new d (c3.min.js:1)
    at Object.k.generate (c3.min.js:1)
    at Object.renderer (c3_renderers.coffee:129)
    at t.fn.pivot (pivot.coffee:546)
    at pivot.coffee:835

有办法解决吗?

包版本:

rpivotTable_0.1.5.7                    
rCharts_0.4.2    
shiny_0.12.2.9005 

谢谢!

【问题讨论】:

标签: r shiny pivot-table rcharts


【解决方案1】:

正如 cmets 中所指出的,这是由于 n3 库的双重加载造成的。为了避免这个问题(这更像是一个 hack 而不是修复),您可以在 iframe 中绘制 rcharts 框架以避免 jscss 问题。

为此,您可以使用uiOutput/renderUI 作为闪亮部分,使用show 输出rCharts

这是一个例子:

library(shiny)
library(rCharts)
library(rpivotTable)

df=data.frame(A=c(1:10),B=c(-10:-1),C=c("x",rep(c("x","y","z"),3)))

ui <-shinyUI(fluidPage(
        uiOutput('plot1'),
        rpivotTableOutput('pivot1')  
))


server <- shinyServer(function(input, output, session) {
        output$pivot1 <- renderRpivotTable({
                rpivotTable(data =df)
        })

        output$plot1=renderUI({
                myform <- as.formula(paste('A','~','B'))
                n2 <- nPlot(myform,  group ="C", data = df, type = 'multiBarChart')
                n2$chart(margin = list(left = 100))
                n2$chart(reduceXTicks = F)
                HTML(paste(capture.output(n2$show('iframesrc', cdn = TRUE)), collapse = '\n'))

        })
})

shinyApp(ui,server)

【讨论】:

  • 谢谢,我想这是我需要的
  • @NicE 解决方案很棒,值得投票。问题的根源在于相同 JS 库需要不同版本的两个包。另一种解决方案是 fork rpivotTable 并更改 yaml 等中的版本。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-09-16
  • 2012-10-09
相关资源
最近更新 更多