| @@ -70,3 +70,12 @@ renderFrappeChart <- function(expr, env = parent.frame(), quoted = FALSE) { | |||
| updateFrappeChart <- function(inputId, data, session = shiny::getDefaultReactiveDomain()) { | |||
| 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) | |||
| } | |||
| ) | |||
| } | |||
| @@ -578,3 +578,18 @@ To make this work we will: | |||
| }) | |||
| } | |||
| ``` | |||
| 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) | |||
| } | |||
| ) | |||
| } | |||
| ``` | |||
| @@ -49,7 +49,7 @@ HTMLWidgets.widget({ | |||
| return acc | |||
| }, {}) | |||
| data[labelsName] = label | |||
| Shiny.setInputValue(el.id + '_selected', data) | |||
| Shiny.setInputValue(el.id + '_selected:frappeCharts-selected', data) | |||
| }) | |||
| } | |||
| }, | |||