【问题标题】:rCharts in shiny : width with 2 chartsrCharts 闪亮:2 个图表的宽度
【发布时间】:2014-10-01 15:12:21
【问题描述】:

我有一个带有两个 Highcharts 绘图的应用程序,当我启动应用程序时,两个绘图的宽度是正确的,但是每次我更改 mean 输入时,第一个绘图的宽度设置为第二个绘图的宽度,像这样:

当我启动应用程序时:

当我改变输入时:

我生成应用程序的代码:

library(rCharts)
library(shiny)

runApp(list(
  ui = fluidPage(
    title = "App title",
    titlePanel(strong("App title", style="color: steelblue")),
    sidebarLayout(
      sidebarPanel(width = 2,
                   br()),
      mainPanel(width = 10, 
                tabsetPanel(
                  tabPanel("Tab 1",
                           selectInput(inputId = "input_mean", label = "Mean : ", choices = c(20:30)),
                           fluidRow(
                             column(8,
                                    showOutput(outputId = "chart1", lib = "highcharts")
                                    , br(), br(), br(), br(), br(), br(), br(), br(), br(), br(), br()),
                             column(4,
                                    showOutput(outputId = "chart2", lib = "highcharts"))
                             )
                           )
                  )
                )
      )
    ),
  server = function(input, output) {

    my_data <- reactive({
      rnorm(n = 30, mean = as.numeric(input$input_mean))
    })

    output$chart1 <- renderChart2({
      my_data = my_data()
      h2 <- Highcharts$new()
      h2$chart(type="line")
      h2$series(data=my_data, name = "One", marker = list(symbol = 'circle'), color = "lightblue")
      h2$set(width = 800, height = 400)
      return(h2)
    })
    output$chart2 <- renderChart2({
      my_data = my_data()
      my_mean = as.numeric(input$input_mean)
      part = data.frame(V1 = c("Sup", "Inf"), V2 = c(sum(my_data>my_mean), sum(my_data<my_mean)))
      p = hPlot(x = "V1", y = "V2", data = part, type = "pie")
      p$tooltip(pointFormat = "{series.name}: <b>{point.percentage:.1f}%</b>")
      p$params$width <- 200
      p$params$height <- 200
      return(p)
    })
  }
))

我使用 rCharts_0.4.5 和 shiny_0.9.1。

谢谢!

【问题讨论】:

  • 一开始...你没有反应或观察的外壳。
  • 我之前的评论更多是关于编程的。我会检查引导页面方向...我的目标是在列中定义良好的面板。

标签: r shiny rcharts


【解决方案1】:

替换这些行:

h2$chart(type="line")
h2$set(width = 800, height = 400)

如下:

h2$chart(type="line", width = 800, height = 400)

这应该会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多