DS4PS / cpp-526-sum-2021

Coure shell for CPP 526.
https://ds4ps.org/cpp-526-sum-2021/
MIT License
1 stars 3 forks source link

Final Project: Value Box Issue - Only displaying numbers for value box, not actual box with formatting #42

Open dholford opened 3 years ago

dholford commented 3 years ago

So I've been trying to get some value boxes on one of my tabs to highlight a few of the statistics shown on the graph.

I've been able to get the graphs side by side underneath where the value boxes will go, and I've been able to get the values to show up. However, none of the formatting (color, icon, or an actual box) is showing up. As pictured below (this is showing all three value box values, I have the code for the first value box below):

ValueBox

Here is the code:

`Row


renderValueBox({

  d7 <- sum.injury.dat %>%
    filter(Collisionmanner == input$Collision)

  A.Rate <- round(d7$P.accidents,1)

  valueBox(A.Rate,
           icon = "fa-car-crash",
           color = "warning")

})`
jamisoncrawford commented 3 years ago

Does it work with a different color, e.g. "danger" or "primary"?

dholford commented 3 years ago

No, I've tried different colors in different boxes and haven't been able to get any of them to work.

I also tried valueBoxOutput(), as that was one of the things I found in my searching, but that led to a whole slew of other errors.

jamisoncrawford commented 3 years ago

On a traditional Shiny app, you would assign the renderValueBox() to an object in the server.R file and you would call it for display in valueBoxOutput() in the ui.R file. However, the Markdown-esque approach used with package flexdashboard defenestrates that.

Since I'm far more familiar with Shiny apps this is a bit difficult to diagnose. Please email me your script and I'll take a look.

lecy commented 3 years ago

Pro tip: try to work the sentence, “the Markdown-esque approach used with package flexdashboard defenestrates that” into job interviews whenever possible. :-)

jamisoncrawford commented 3 years ago

@dholford strangely, this is because the valueBox() label must be done outside the code chunk using Markdown subtitle formatting with ###, and this must be done for each value box.

Row 
-------------------------------------

### Test 1

```{r}
renderValueBox({

  d7 <- sum.injury.dat %>%
    filter(Collisionmanner == input$Collision)

  A.Rate <- round(d7$P.accidents,1)

  valueBox(A.Rate,
           icon = "fa-car-crash",
           color = "warning")

})

Test 2

renderValueBox({

  d7 <- sum.injury.dat %>%
    filter(Collisionmanner == input$Collision)

  I.Rate <- round(d7$P.injury,1)

  valueBox(I.Rate,
           icon = "fa-briefcase-medical",
           color = "danger")

})

Test 3

renderValueBox({

  d7 <- sum.injury.dat %>%
    filter(Collisionmanner == input$Collision)

  Rate.Difference <- round((d7$P.accidents - d7$P.injury),1)

  valueBox(Rate.Difference,
           icon = "fa-calculator",
           color = ifelse(test = Rate.Difference < 0, 
                          yes = "danger", 
                          no = "primary"))

})


![image](https://user-images.githubusercontent.com/15643196/128761949-75d70d34-3859-4866-b4a0-c5a137831aba.png)
dholford commented 3 years ago

Got it! Thank you!

I was able to replicate it on my end.