Skip to content

rHighcharts issue : bar chart #5

@ochees

Description

@ochees

Hello,

I post an issue concerning rcharts (highchart) library and shinydashboard in rCharts repository. I need this kind of visualisation and I didn't find a solution. Here, the problem :

This is an example of application mixing shinydashboard and Highchart. There are two problems :
-first, with an initial input of 50, the app doesn't display the plot. The user must click on the label "Series 1" to load the plot. Not intuitive.
-with a variable numeric input, the plot is totally blank and doesn't response anymore to the input user.
The problem is the same when using an action button and isolate function or not.

library(shiny)
library(shinydashboard)
library(rCharts)

ui <- dashboardPage(
  dashboardHeader(title = "Basic dashboard"),
  dashboardSidebar(),
  dashboardBody(
    # Boxes need to be put in a row (or column)
    fluidRow(
      box(title = "Slider", status = "primary",sliderInput("slider", "Slider input:", 1, 100, 50)),
      box(title = "Load", status = "primary",actionButton("actionButton","Load",icon=icon("refresh"))),
      box(title = "Plot", status = "primary",showOutput("chart", "highcharts"))
      )
    )
  )
)

server <- function(input, output) {
output$chart <- renderChart2({
input$actionButton
a <- Highcharts$new()
a$chart(width=500,height=500)
a$series(data = list(
list(x = 0, y = isolate(input$slider), capital = "Stockholm", country = "Sweden"),
list(x = 1, y = isolate(input$slider)+10, capital = "Copenhagen", country = "Denmark"),
list(x = 2, y = isolate(input$slider)+20, capital = "Oslo", country = "Norway")
), type = "bar"
)
a$xAxis(categories = c("Sweden", "Denmark", "Norway"))
a$addParams(dom = "chart")
return(a)
})
}
shinyApp(ui, server)

Maybe it's a bad interaction between shinydashboard and rCharts ? this app works well using a classic shiny structure or a type of graph "column".

Besides, i would know if it's possible to draw in this kind of graph a vertical (for a bar chart) or horizontal (column chart), parallel to x axis, as a limit ? I saw something with the plotLines command in highcharts js. In the same way, is it possible to add text on chart with R ?

Thanks a lot,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions