rCharts spiderweb plot rendered in Shiny as line plot

87 views Asked by At

The spiderweb plot created using the code below renders well within the Rstudio plot panel as shown below.

enter image description here

However, it appears as line plot when rendered using Shiny as below. 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>

Any ideas to have the plot displayed in Shiny as it should be? The plot is rendered ok according to related post but the difference is that in my case the UI is built entirely using HTML while they use ui.R instead.

1

There are 1 answers

0
amo On

What is needed is to add

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

and it now works.