Created
March 28, 2019 15:48
-
-
Save cpsievert/a4f0c8c31bcc2deeb1f6817cfe3a2515 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "dash" | |
output: flexdashboard::flex_dashboard | |
runtime: shiny_prerendered | |
--- | |
```{r setup, include=FALSE} | |
library(tidyverse) | |
library(plotly) | |
# data sets | |
three_samples <- tibble(first_set = rnorm(3), | |
second_set = rnorm(3), | |
third_set = rnorm(3)) | |
``` | |
SideBar {.sidebar} | |
--- | |
```{r} | |
radioButtons("radio", "set seed", choices = c("first_set" , | |
"second_set", | |
"third_set"), | |
selected = "first_set") | |
``` | |
Column | |
----------------------------------------------------------------------- | |
### Chart A | |
```{r} | |
plotlyOutput("p") | |
``` | |
```{r, context="server"} | |
output$p <- renderPlotly( | |
plot_ly(x = c("a", "b", "c"), y = three_samples$first_set) %>% | |
layout(yaxis = list(range = c(-4, 4))) | |
) | |
``` | |
```{r, context="server"} | |
observeEvent(input$radio, { | |
y <- three_samples[[input$radio]] | |
plotlyProxy("p", session) %>% | |
plotlyProxyInvoke("restyle", "y", list(y)) | |
}) | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment