No auto resize of yaxis of highcharts in shiny

家住魔仙堡 提交于 2019-12-10 23:00:10

问题


I would like to include a highchart plot that automatically resizes its y-axis when groups are selected or deselected into a shiny application.

The following plot works fine in the viewer pane of Rstudio

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")

but it does not work, when I include it into a shiny application:

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")
    })
  }
))

Why is this?


回答1:


This is due to a clash between the version of highcharts running and the version of jquery. Shiny is using a later version of jquery. When you call highcharts outside shiny jquery 1.9.1 is being used. The error in the console when shiny is ran and a series is removed/added is

TypeError: invalid 'in' operand style

The version of highcharts is Highcharts JS v3.0.1 (2013-04-09). It maybe necessary to use a more uptodate version of highcharts as suggested http://forum.highcharts.com/viewtopic.php?f=9&t=22040

Referenced as a known bug on highcharts https://github.com/highslide-software/highcharts.com/issues/1890



来源:https://stackoverflow.com/questions/25513790/no-auto-resize-of-yaxis-of-highcharts-in-shiny

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!