Sfoglia il codice sorgente

Now it's a real data frame!

master
Garrick Aden-Buie 6 anni fa
parent
commit
000de60582
3 ha cambiato i file con 25 aggiunte e 1 eliminazioni
  1. +9
    -0
      R/frappeChart.R
  2. +15
    -0
      dev/dev.Rmd
  3. +1
    -1
      inst/htmlwidgets/frappeChart.js

+ 9
- 0
R/frappeChart.R Vedi File

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

+ 15
- 0
dev/dev.Rmd Vedi File

}) })
} }
``` ```

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

+ 1
- 1
inst/htmlwidgets/frappeChart.js Vedi File

return acc return acc
}, {}) }, {})
data[labelsName] = label data[labelsName] = label
Shiny.setInputValue(el.id + '_selected', data)
Shiny.setInputValue(el.id + '_selected:frappeCharts-selected', data)
}) })
} }
}, },

Loading…
Annulla
Salva