Last active
March 27, 2019 05:18
-
-
Save jtag04/98d8295af8d9953e3c6656e2aa4d9824 to your computer and use it in GitHub Desktop.
Remaking Carson Sievert's updating a reactive plotly chart example
This file contains 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 | |
--- | |
```{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} | |
# the slow way... | |
plotly_object <- reactive( | |
plot_ly(x = c("a", "b", "c"), | |
y = three_samples %>% pull(input$radio) | |
) %>% | |
layout(yaxis = list(range = c(-4, 4))) | |
) | |
renderPlotly( | |
plotly_object() | |
) | |
# the fast way... apparently using... | |
# new_plotly_object <- plotlyProxy(plotly_object) %>% | |
# plotlyProxyInvoke("restyle", "y", data_for_plot()) | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment