No color in value/info boxes?

1,254 views
Skip to first unread message

Devin Keane

unread,
Apr 27, 2017, 11:35:07 AM4/27/17
to Shiny - Web Framework for R
Hi,

I'm pretty new to Shiny and am developing a demo application for an individual retirement account management tool.  The app uses several R functions I wrote and several data inputs  which load up with the app.  The functions produce several basic portfolio performance values that I'm showing in reactive value/info boxes.  The app works, except no colors are displayed in any of the boxes. A sample of the ui and server side code for the relevant app tab. This is probably clumsy code and a simple problem, but I've searched and havent found a similar thread yet. If anyone can tell me why no color shows up in these that would be great.  

the actual app is here if you want to see the output: sigma401k.shinyapps.io/Shiny_demo/

You'll have to click the "Gather Your Account Information" and "See How You're Invested" action buttons to run the functions, and the next page will show all the colorless boxes. 

If this is unclear instruction please let me know. Thanks for any help!

on the ui side:

ui <-
    tagList(

        navbarPage(title = "sigma401k - Tactical Asset Allocation for Your 401(k)", theme = shinythemes::shinytheme("yeti"),

           tabsetPanel(id = "sigma401k",

#skip to tab with info/value boxes

        #tab 3 ---------------------------------------------------------------------------------------
           tabPanel(title = "Simulated Performance with sigma401k",


                    fluidRow(
                            column(8, tags$h3("Hypothetical Performance of Your Portfolio With sigma401k"), offset=4)),

                    fluidRow(class="blankRow1", tags$head(tags$style(".blankRow1{height:50px;}"))),

###removed some rows for brevity###

                    fluidRow(

                            column(3, valueBoxOutput("annual.plan.returns", width = 300)),
                            column(3, valueBoxOutput("annual.sigma.returns", width = 300))

                            ),

                    fluidRow(
                            column(3, infoBoxOutput("risk.profile")),
                            column(3, valueBoxOutput("plan.sd", width = 300),offset = 1),
                            column(3, valueBoxOutput("sigma.sd", width = 300))
                            ),

                    fluidRow(

                            column(3, valueBoxOutput("plan.best.year", width = 300),offset = 4),
                            column(3, valueBoxOutput("sigma.best.year", width = 300))
                    ),

                    fluidRow(

                            column(3, valueBoxOutput("plan.worst.year", width = 300),offset = 4),
                            column(3, valueBoxOutput("sigma.worst.year", width = 300))
                    ),

                    fluidRow(

                            column(3, valueBoxOutput("plan.drawdown", width = 300),offset = 4),
                            column(3, valueBoxOutput("sigma.drawdown", width = 300))
                    ),

and the server side for  these objects, which contain reactive functions:

        output$risk.profile <- renderInfoBox({
            infoBox(client.risk())})

        output$annual.sigma.returns <- renderValueBox({
                valueBox(sigma.return.fun(),
                         "Annual Return with sigma401k",
                         color = "aqua",
                         width = NULL)
        })

        output$annual.plan.returns <-  renderValueBox({
                valueBox(plan.return.fun(),
                         "Annual Return Based on Your Current Holdings",
                         color = "red",
                         width = NULL)
        })

        output$ending.plan.value <- renderInfoBox({input$start.backtest
                infoBox("With your current mix of investments, the portfolio value would have
                        grown to", paste("$",format(plan.final.value, big.mark=","),sep=""))
        })

        output$ending.sigma.value <- renderInfoBox({input$rerun  | input$start.backtest
                infoBox(ending.sigma())
        })

        output$difference <- renderValueBox({
                valueBox(paste0(difference.fun(), " (",diff.pct(),"%)",sep=""),
                         "Difference", color = "green",
                         icon = icon("line-chart", "fa-4x"),
                         width = NULL)
        })

        output$plan.sd <- renderValueBox({input$start.backtest
                valueBox(plan.return.sd(),
                         "Your portfolio's annualized volatility", color = "green",
                         icon = icon("barchart", "fa-3x"),
                         width = NULL)
        })

        output$sigma.sd <- renderValueBox({input$rerun  | input$start.backtest
                valueBox(sigma.return.sd(),
                         "sigma401k's annualized volatility", color = "green",
                         icon = icon("barchart", "fa-3x"),
                         width = NULL)
        })

        output$plan.best.year <- renderValueBox({input$start.backtest
                valueBox(plan.best(),
                paste0("Best Annual Return (", client.best.year,")", sep = ""), color = "green",
                     icon = icon("barchart", "fa-3x"),
                     width = NULL)
        })

        output$sigma.best.year <- renderValueBox({input$rerun  | input$start.backtest
                valueBox(sigma.best(),
                paste0("Best Annual Return (", best.year.index,")", sep = ""), color = "green",
                     icon = icon("barchart", "fa-3x"),
                     width = NULL)
        })

        output$plan.worst.year <- renderValueBox({input$start.backtest
            valueBox(plan.worst(),
                     paste0("Your Portfolio's Worst Year (", client.worst.year,")", sep = ""), color = "green",
                     icon = icon("barchart", "fa-3x"),
                     width = NULL)
        })

        output$sigma.worst.year <- renderValueBox({input$rerun  | input$start.backtest
            valueBox(sigma.worst(),
                     paste0("sigma401k's Worst Annual Return (", worst.year.index,")", sep = ""), color = "green",
                     icon = icon("barchart", "fa-3x"),
                     width = NULL)
        })

        output$plan.drawdown <- renderValueBox({input$start.backtest
            valueBox(plan.draw(),
                     "Your Portfolio's Worst Drawdown (Peak to Trough)", color = "green",
                     icon = icon("barchart", "fa-3x"),
                     width = NULL)
        })

        output$sigma.drawdown <- renderValueBox({input$rerun  | input$start.backtest
            valueBox(sigma.draw(),
                     "sigma401k's Worst Drawdown", color = "green",
                     icon = icon("barchart", "fa-3x"),
                     width = NULL)
        })


I'm using many packages for the work. Could that be an issue? 

library(shiny);library(shinydashboard);library(quantmod);library(PerformanceAnalytics)
library(Hmisc);library(RColorBrewer);library(readxl);library(scales)
library(dplyr);library(data.table);library(purrr);library(ggvis);library(stringr);library(tidyr)
library(dygraphs);library(ggplot2);library(readr)

Joe Cheng

unread,
Apr 27, 2017, 1:55:06 PM4/27/17
to Devin Keane, Shiny - Web Framework for R
The shinydashboard valueBox only look right when used within a shinydashboard page. They're not "portable" to other types of pages. This is because the dashboardPage call sets up CSS that valueBox relies on, while navbarPage/fluidPage/etc bring in a different set of CSS (bootstrap). You're not the first person to ask this though, it'd be nice to have an easy solution for this (that doesn't involve the app author writing custom CSS).

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/c10a9f97-a02d-4983-a435-391d8bb06fa5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Devin Keane

unread,
Apr 27, 2017, 2:33:09 PM4/27/17
to Shiny - Web Framework for R, inc...@gmail.com
Thanks for the quick response, that's good to know. Are there any similar objects that can be used for other types of pages?
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
0 new messages