【问题标题】:Shiny: Increase highchart size on button click闪亮:在按钮单击时增加高图大小
【发布时间】:2016-07-27 13:43:33
【问题描述】:

我想在单击缩放按钮时增加高图的大小。我尝试使用下面的代码来增加大小,但到目前为止我还没有实现我想要做的事情。我实际上希望高图在单击缩放按钮时展开并占据整页。到目前为止,我已经编写了以下代码,但它似乎不起作用。谁能告诉我我做错了什么?

require(shiny)
require(rCharts)

ui <- fluidPage(


  tags$script('Shiny.addCustomMessageHandler("ZoomPlot", function(variableName){
              document.getElementById(variableName).style.height = "1000px";
              });
              '),

  headerPanel("Test app"),
  actionButton("test", "Zoom"),

  div(class = "chart-container",  showOutput("viz", "highcharts"))
)



server <- shinyServer(function(input, output, session) {
  output$viz <- renderChart2({
    a <- highchartPlot(Sepal.Length ~ Sepal.Width, data=iris)
    a
  })

  observeEvent(input$test,{
    session$sendCustomMessage(type = 'ZoomPlot', message = "viz")
  })
})

shinyApp(ui, server)

【问题讨论】:

    标签: r highcharts shiny rcharts


    【解决方案1】:

    你可以只使用像服务器端这样的

    server <- shinyServer(function(input, output, session) {
      hh=reactive({
        if(input$test>0 ) {1000}else{400}
       })
      output$viz <- renderChart2({
        a <- highchartPlot(Sepal.Length ~ Sepal.Width, data=iris)
        a$set(height = hh()
              )
        a
      })
    
    })
    

    【讨论】:

      猜你喜欢
      • 2014-08-06
      • 2023-04-05
      • 2014-09-15
      • 2011-11-07
      • 2018-11-27
      • 1970-01-01
      • 2019-11-07
      • 2018-10-09
      • 2018-05-23
      相关资源
      最近更新 更多