New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Capture user input #16
Comments
It's your lucky day! This is already implemented. Just copy the following into a script and run run it and you should have a working demo. Currently it returns the drawn y-values corresponding the x-locations in your supplied data post your cutoff. Is this what you're looking for? #
# A small demo app for the shinydrawr function
#
# devtools::install_github("nstrayer/shinysense")
library(shiny)
library(shinythemes)
library(shinysense)
library(tidyverse)
ui <- fluidPage(
theme = shinytheme("flatly"),
titlePanel("shinydrawr demo"),
p("Try and guess the rest of the chart below"),
hr(),
fluidRow(
column(width = 8,
shinydrawrUI("outbreak_stats")),
column(width = 3, offset = 1,
h2("Drawn values:"), tableOutput("displayDrawn"))
)
)
server <- function(input, output) {
random_data <- data_frame(time = 1:30,
metric = time * sin(time / 6) + rnorm(30))
#server side call of the drawr module
drawChart <- callModule(
shinydrawr,
"outbreak_stats",
data = random_data,
draw_start = 15,
x_key = "time",
y_key = "metric",
y_max = 20,
y_min = -50
)
#logic for what happens after a user has drawn their values. Note this will fire on editing again too.
observeEvent(drawChart(), {
drawnValues = drawChart()
drawn_data <- random_data %>%
filter(time >= 15) %>%
mutate(drawn = drawnValues)
output$displayDrawn <- renderTable(drawn_data)
})
}
# Run the application
shinyApp(ui = ui, server = server) |
Almost there :) Let's say I wan't to plot the data as points and then get the user to draw the best fit, but with points as well. Is that possible? I have two use cases:
|
Ah I see. That is a good idea and one I've been meaning to get around to. Tagging this with an enhancement tag and will hopefully get around to it soon enough. |
Nice work on the package!
This is a feature request. It would be great if I could capture and save the user input from shinydrawr. I don't know much about JavaScript so I have no clue about the implementation of it, but it's a feature that would be really useful to me, as I could benchmark user assumptions with real data.
The text was updated successfully, but these errors were encountered: