rCharts spiderweb在Shiny中呈现为线图

问题描述 投票:0回答:1

使用下面的代码创建的spiderweb图在Rstudio绘图面板中很好地呈现,如下所示。

enter image description here

但是,当使用Shiny渲染时,它显示为线条图,如下所示。 enter image description here

library(rCharts)

shinyServer(function(input,output){
  output$plot <- renderChart2({

    plot <- Highcharts$new()
    table = data.frame(id = c("a1","g3","k5","y9","z11"),
                       value = c(252,345,421,189,236))
    plot$chart(polar = TRUE, type = "line")
    plot$xAxis(categories=table$id, tickmarkPlacement= 'on', lineWidth= 0)
    plot$yAxis(gridLineInterpolation= 'polygon', lineWidth= 0, min= 0)
    plot$series(data = toJSONArray2(table[,c("id","value")], json = F, names = F),
                name = "Series", pointPlacement="on")
    plot
  })
})

HTML:

<head>
    <script src="js/jquery.min.js"></script>
    <link rel="stylesheet" href="shared/shiny.css" type="text/css" />
    <script src="shared/shiny.js" type="text/javascript"></script>
    <script src="js/highcharts.js" type="text/javascript"></script>
</head>
<body>
 <div id="plot" class="shiny-html-output rChart highcharts" style="width: 4px; height: 60px"></div>
<body>

有什么想法让情节显示在Shiny中应该是什么?根据related post,情节呈现正常但不同之处在于,在我的情况下,UI完全使用HTML构建,而使用ui.R代替。

shiny rcharts
1个回答
0
投票

需要的是添加

 <script src="js/highcharts-more.js" type="text/javascript"></script>

它现在有效。

© www.soinside.com 2019 - 2024. All rights reserved.