Closed JianWang2016 closed 7 years ago
Could someone please take a look at this? Thanks much.
Try changing the below Shiny.onInputChange(\'myValues\', event.item.values); to Shiny.onInputChange(myValues, event.item.values); or Shiny.onInputChange("myValues", event.item.values);
Perhaps some module bad definition. This simple example working fine with rAmCharts 2.1.2
, actually on github, but coming in next day on CRAN. 2.1.1
have some bug on listeners.
require(shiny)
require(rAmCharts)
server <- function(input, output, session) {
output$amb <- renderAmCharts({
pipeR::pipeline(
amBoxplot(iris[, -5]),
addListener(name = 'clickGraphItem',
expression = paste('function (event) {',
'Shiny.onInputChange("myValues", event.item.values);',
'}'))
)
})
observe({
print(input$myValues)
})
}
ui <- fluidPage(
amChartsOutput("amb")
)
shinyApp(ui = ui, server = server)
Hi, I am trying to capture rAmCharts click event in shiny. The example works great until the codes are adapted for shiny modules. Any advice on how to change shiny.onInputChange() javascript is greatly appreciated.
Here is the code from rAmCharts Getting Started section:
` require(shiny)
shinyApp( ui = fluidPage( amChartsOutput(outputId = "amchart"), fluidRow( column(width = 1, strong("Values: ")), column(width = 3, verbatimTextOutput("click")) ) ),
server = function(input, output) { output$amchart <- renderAmCharts({
build the chart
} ) ` Here is the module UI and Server codes in a file named testClickModule.R. The graph still displays but the click event is not registered. I get a sense that the name space is the culprit but didn't manage to get it working after testing session$ns.
` clickMeUI <- function(id) { ns <- NS(id)
tagList( amChartsOutput(outputId = ns("amchart")), fluidRow( column(width = 1, strong("Values: ")), column(width = 3, verbatimTextOutput(ns("click"))) ) ) }
clickMe <- function(input, output, session) {
}
`
Here is the app.R using the module defined above
` library(shiny) library(rAmCharts)
source("testClickModule.R", local=TRUE)
ui <- fixedPage( h2("Module example"), clickMeUI("testClick") )
server <- function(input, output, session) { callModule(clickMe, "testClick")
}
shinyApp(ui, server) `