I took this code from stackoverflow In flexdashboard, can a valueBox be clicked to update a text box like an actionButton? (thank you!) and decided to tweak it to display images instead of text on click of button as follows:
---
title: "valueBox Links"
output:
flexdashboard::flex_dashboard:
runtime: shiny
---
```{r setup, include=FALSE}
library(flexdashboard)
library(png)
```
Tab 1 - Test
======================================================================
Column
-------------------------------------
#### Three valueBoxes
### valueBox 1
```{r}
valueBox(1, caption = paste("I'm clickable!", actionButton("button1", " ", style =
"background-color:rgba(39, 128, 227, 0.0); border-color:rgba(39, 128, 227, 0.0);
position:
absolute; overflow: hidden; left: 0px; top: 0px; right: 0px; bottom: 0px;
width:100%")),
icon = "fa-thumbs-up", color = "success")
```
### valueBox 2
```{r}
valueBox(2, caption = paste("I'm clickable too!", actionButton("button2", " ", style
= "background-color:rgba(39, 128, 227, 0.0); border-color:rgba(39, 128, 227, 0.0);
position:
absolute; overflow: hidden; left: 0px; top: 0px; right: 0px; bottom: 0px;
width:100%")),
icon = "fa-tag", color = "warning")
```
### valueBox 3
```{r}
valueBox(3, caption = paste("ME TOO!", actionButton("button3", " ", style =
"background- color:rgba(0, 0, 0, 0.0); border-color:rgba(0, 0, 0, 0.0); position:
absolute; overflow:
hidden; left: 0px; top: 0px; right: 0px; bottom: 0px; width:100%")), icon = "fa-
random", color = "danger")
```
Column
-------------------------------------
### Image output
```{r}
imageOutput("image", height = "100px")
rv <- reactiveValues(data = NULL)
observeEvent(input$button1, {
rv$data <- readPNG('Picture1.png')
})
observeEvent(input$button2, {
rv$data <- readPNG('Picture2.png')
})
observeEvent(input$button3, {
rv$data <- readPNG('Picture3.png')
})
output$image <- renderImage({
rv$data
})
```
What would be the change in my current code to display pictures on the click of different horizontal tabs? Thank you