问题
I've got some problems using spiderweb graphs from rCharts. Graph is not displaying as it should be. Any ideas ?
library(shiny)
library(rCharts)
runApp(
list(ui = fluidPage(
tags$head(tags$script(src = "https://code.highcharts.com/highcharts.js"),
tags$script(src = "https://code.highcharts.com/highcharts-more.js"),
tags$script(src = "https://code.highcharts.com/modules/exporting.js"),
tags$script(src = "https://code.highcharts.com/modules/heatmap.js")
),
titlePanel(""),
tabsetPanel(
tabPanel("Highcharts Spiderweb",
showOutput("Spiderweb","highcharts"))
)
),
# server side
server = function(input, output){
output$Spiderweb <- 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
})
}
)
)

Thanks for helping :)
回答1:
Try removing the tags$head, showOutput
will load them, right now the Highcharts libs are being loaded twice, and highcharts error 16 is raised.
Also, when you assign the series, you don't need the JSON array, data=table[,"value"]
works fine.
Here is the modified code:
library(shiny)
library(rCharts)
runApp(
list(ui = fluidPage(
titlePanel(""),
tabsetPanel(
tabPanel("Highcharts Spiderweb",
showOutput("Spiderweb","highcharts"))
)
),
# server side
server = function(input, output){
output$Spiderweb <- 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 = table[,"value"],
name = "Series", pointPlacement="on")
plot
})
}
)
)
Gives this:

来源:https://stackoverflow.com/questions/28282646/problems-with-spiderweb-graph-from-highcharts-in-r