我想包含一个 highchart 图,当在 Shiny 的应用程序中选择或取消选择组时,该图会自动调整其 y 轴大小。
以下绘图在 Rstudio 的查看器 Pane 中运行良好
library(rCharts)
dat <- data.frame(expand.grid(group = letters[1:3], x = letters[4:6]), y = c(0.1,1:8))
hPlot(x = "x", y = "y", groups = "group", data = dat, type = "line")
但是当我将它包含到一个 Shiny 的应用程序中时它不起作用:
library(shiny)
runApp(shinyApp(
ui = fluidPage(
mainPanel(showOutput("h", 'highcharts'))
),
server = function(input, output) {
output$h <- renderChart2({
dat <- data.frame(expand.grid(group = letters[1:3], x = letters[4:6]),
y = c(0.1,1:8))
hPlot(x = "x", y = "y", groups = "group", data = dat, type = "line")
})
}
))
这是为什么?
最佳答案
这是由于运行的 highcharts 版本与 jquery 版本冲突造成的。 Shiny 使用的是更高版本的 jquery。当您在 Shiny 的jquery 1.9.1之外调用highcharts时,正在使用。当运行shiny并删除/添加一系列时,控制台中的错误是
TypeError: invalid 'in' operand style
highcharts的版本是Highcharts JS v3.0.1(2013-04-09)
。可能有必要按照建议使用更新版本的 highcharts http://forum.highcharts.com/viewtopic.php?f=9&t=22040
被称为 highcharts 上的已知错误 https://github.com/highslide-software/highcharts.com/issues/1890
关于r - Shiny 的 Highcharts 的 y 轴没有自动调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25513790/