dataIn <- tibble(
labels = c("12am-3am", "3am-6pm", "6am-9am", "9am-12am", "12pm-3pm", "3pm-6pm", "6pm-9pm", "9am-12am"),
rstudio = seq(10, 80, 10),
other = runif(8) * 40
)
type <- "line"
labels <- dataIn$labels
dataSeries <- dataIn[, setdiff(names(dataIn), "labels")]
datasets <- list()
for (column in names(dataSeries)) {
datasets <- c(datasets, list(list(
name = column,
type = type,
values = dataSeries[[column]]
)))
}
processData <- function(dataIn, type = "line") {
labels <- dataIn$labels
dataSeries <- dataIn[, setdiff(names(dataIn), "labels")]
datasets <- list()
for (column in names(dataSeries)) {
datasets <- c(datasets, list(list(
name = column,
type = type,
values = dataSeries[[column]]
)))
}
list(
labels = labels,
datasets = datasets
)
}
# R/frappeChart.R
frappeChart <- function(data, type = "line", width = NULL, height = NULL, elementId = NULL) {
# forward options using x
x = list(
data = processData(data, type)
)
# create widget
htmlwidgets::createWidget(
name = 'frappeChart',
x,
width = width,
height = height,
package = 'frappeCharts',
elementId = elementId
)
}
processData <- function(dataIn, type = "line") {
labels <- dataIn$labels
dataSeries <- dataIn[, setdiff(names(dataIn), "labels")]
datasets <- list()
for (column in names(dataSeries)) {
datasets <- c(datasets, list(list(
name = column,
type = type,
values = dataSeries[[column]]
)))
}
list(
labels = labels,
datasets = datasets
)
}
---
title: HTML Widgets Rock
output: js4shiny::html_document_plain
---
```{r, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
```{r}
data <- tibble::tibble(
labels = c("12am-3am", "3am-6pm", "6am-9am", "9am-12am", "12pm-3pm", "3pm-6pm", "6pm-9pm", "9am-12am"),
rstudio = seq(10, 80, 10),
other = runif(8) * 40
)
frappeCharts::frappeChart(data)
```
renderValue: function(x) {
console.log(el.id)
// TODO: code to render the widget, e.g.
let chart = new frappe.Chart(el, {
title: 'rstudio::conf is the best',
data: x.data,
type: 'line',
height: 250,
width: 500
})
}
frappeChart <- function(data, type = "line", is_navigable = TRUE, width = NULL, height = NULL, elementId = NULL) {
# forward options using x
x = list(
data = processData(data, type),
isNavigable = is_navigable
)
# create widget
htmlwidgets::createWidget(
name = 'frappeChart',
x,
width = width,
height = height,
package = 'frappeCharts',
elementId = elementId
)
}
devtools::install_github('gadenbuie/js4shiny-frappeCharts', repos = NULL)
dependencies = TRUE
, then it also installed golem
for you
devtools::install_github("gadenbuie/js4shiny-frappeCharts@pkg")
@ColinFay I got lost at https://github.com/ColinFay/shinynotifyjs#calling-custom-handler Hm... were we supposed to edit the R/app_server.R
file? I tried
#' @import shiny
app_server <- function(input, output,session) {
# List the first level callModules here
session$sendCustomMessage("fun", arg)
}
But that lead me to an error when running dev/run_dev.R
(Error in writeImpl: Text to be written must be a length-one character vector
)
library(shiny)
library(htmltools)
typingSpeedInput <- function(inputId, label, placeholder = NULL) {
div(
class = "form-group typing-speed",
tags$label(class = "control-label", `for` = inputId, label),
tags$textarea(id = inputId, class = "form-control", placeholder = placeholder)
)
}
ui <- fluidPage(
typingSpeedInput("typing", "Type here ..."),
verbatimTextOutput("debug")
)
server <- function(input, output, session) {
output$debug <- renderPrint(input$typing)
}
shinyApp(ui, server)