4
votes

I have an app with two Highcharts plot, when I start the app the width of the two plots are correct, but everytime I change the mean input, the width of the first plot is set to the width of the second, like this :

When I start the app :

enter image description here

When I change the input :

enter image description here

My code to produce the app :

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

I use rCharts_0.4.5 and shiny_0.9.1.

Thanks !

1
Well initially...you have no enclosures that react or observe.miles2know
my earlier comment was more about programming. I'd check out bootstrap page orientation...My go to is to define well panels within columns.miles2know

1 Answers

0
votes

Replace these lines:

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

as follows:

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

This should help.