| updateFrappeChart <- function(inputId, data, session = shiny::getDefaultReactiveDomain()) { | updateFrappeChart <- function(inputId, data, session = shiny::getDefaultReactiveDomain()) { | ||||
| session$sendCustomMessage("frappeCharts:update", list(id = inputId, data = data)) | session$sendCustomMessage("frappeCharts:update", list(id = inputId, data = data)) | ||||
| } | } | ||||
| .onLoad <- function(libname, pkgname) { | |||||
| shiny::registerInputHandler( | |||||
| type = "frappeCharts-selected", | |||||
| fun = function(value, session, inputName) { | |||||
| as.data.frame(value, stringsAsFactors = FALSE) | |||||
| } | |||||
| ) | |||||
| } |
| }) | }) | ||||
| } | } | ||||
| ``` | ``` | ||||
| 1. But now in Shiny it needs to go from a list to a data.frame. | |||||
| To do this we use `shiny::registerInputHandler()` in R and | |||||
| give the input event a type: `inputId_selected:frappeCharts-selected`. | |||||
| ```r | |||||
| .onLoad <- function(libname, pkgname) { | |||||
| shiny::registerInputHandler( | |||||
| type = "frappeCharts-selected", | |||||
| fun = function(value, session, inputName) { | |||||
| as.data.frame(value, stringsAsFactors = FALSE) | |||||
| } | |||||
| ) | |||||
| } | |||||
| ``` |
| return acc | return acc | ||||
| }, {}) | }, {}) | ||||
| data[labelsName] = label | data[labelsName] = label | ||||
| Shiny.setInputValue(el.id + '_selected', data) | |||||
| Shiny.setInputValue(el.id + '_selected:frappeCharts-selected', data) | |||||
| }) | }) | ||||
| } | } | ||||
| }, | }, |