Spaces:
Running
Running
added a switch for individual payout charts
Browse files
app/app.R
CHANGED
@@ -301,7 +301,7 @@ ui <- shinydashboardPlus::dashboardPage(
|
|
301 |
|
302 |
br(),
|
303 |
|
304 |
-
h3(strong(textOutput(outputId = "
|
305 |
|
306 |
fluidRow(
|
307 |
class = "text-center",
|
@@ -325,6 +325,14 @@ ui <- shinydashboardPlus::dashboardPage(
|
|
325 |
),
|
326 |
|
327 |
tabPanel("Individual Models",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
328 |
br(),
|
329 |
shinycssloaders::withSpinner(plotlyOutput("plot_payout_individual"))
|
330 |
)
|
@@ -605,8 +613,12 @@ server <- function(input, output) {
|
|
605 |
# Reactive: Payout Value Boxes
|
606 |
# ============================================================================
|
607 |
|
608 |
-
output$
|
609 |
-
if (nrow(react_d_filter()) >= 1) "Payouts in NMR" else " "
|
|
|
|
|
|
|
|
|
610 |
})
|
611 |
|
612 |
output$payout_confirmed <- renderValueBox({
|
@@ -687,7 +699,7 @@ server <- function(input, output) {
|
|
687 |
labels = label_date_short(format = c("%Y", "%b", "%d"), sep = "\n")
|
688 |
) +
|
689 |
xlab(" \nDate (Round Resolved / Resolving)") +
|
690 |
-
ylab("Payout (NMR)")
|
691 |
|
692 |
# Generate plotly
|
693 |
ggplotly(p, tooltip = "text")
|
@@ -704,6 +716,9 @@ server <- function(input, output) {
|
|
704 |
# Get the number of unique models
|
705 |
n_model <- length(unique(d_filter$model))
|
706 |
|
|
|
|
|
|
|
707 |
# Base plot
|
708 |
p <- ggplot(d_filter,
|
709 |
aes(x = round, y = payout, fill = payout,
|
@@ -731,13 +746,13 @@ server <- function(input, output) {
|
|
731 |
scale_fill_scico(palette = "vikO", direction = -1, midpoint = 0) +
|
732 |
scale_x_continuous(breaks = breaks_pretty(5)) +
|
733 |
xlab(" \nTournament Round") +
|
734 |
-
ylab("
|
735 |
|
736 |
# Facet setting
|
737 |
if (n_model %% 5 == 0) {
|
738 |
-
p <- p + facet_wrap(. ~ model, ncol = 5)
|
739 |
} else {
|
740 |
-
p <- p + facet_wrap(. ~ model)
|
741 |
}
|
742 |
|
743 |
# Dynamic height adjustment
|
|
|
301 |
|
302 |
br(),
|
303 |
|
304 |
+
h3(strong(textOutput(outputId = "text_payout_all_models"))),
|
305 |
|
306 |
fluidRow(
|
307 |
class = "text-center",
|
|
|
325 |
),
|
326 |
|
327 |
tabPanel("Individual Models",
|
328 |
+
br(),
|
329 |
+
materialSwitch(inputId = "switch_scale_payout",
|
330 |
+
label = "Fixed Y-axis Scale",
|
331 |
+
value = TRUE,
|
332 |
+
status = "primary",
|
333 |
+
),
|
334 |
+
br(),
|
335 |
+
h3(strong(textOutput(outputId = "text_payout_ind_models"))),
|
336 |
br(),
|
337 |
shinycssloaders::withSpinner(plotlyOutput("plot_payout_individual"))
|
338 |
)
|
|
|
613 |
# Reactive: Payout Value Boxes
|
614 |
# ============================================================================
|
615 |
|
616 |
+
output$text_payout_all_models <- renderText({
|
617 |
+
if (nrow(react_d_filter()) >= 1) "Payouts in NMR (All Models)" else " "
|
618 |
+
})
|
619 |
+
|
620 |
+
output$text_payout_ind_models <- renderText({
|
621 |
+
if (nrow(react_d_filter()) >= 1) "Payouts in NMR (Individual Models)" else " "
|
622 |
})
|
623 |
|
624 |
output$payout_confirmed <- renderValueBox({
|
|
|
699 |
labels = label_date_short(format = c("%Y", "%b", "%d"), sep = "\n")
|
700 |
) +
|
701 |
xlab(" \nDate (Round Resolved / Resolving)") +
|
702 |
+
ylab("Realised / Pending Payout (NMR)")
|
703 |
|
704 |
# Generate plotly
|
705 |
ggplotly(p, tooltip = "text")
|
|
|
716 |
# Get the number of unique models
|
717 |
n_model <- length(unique(d_filter$model))
|
718 |
|
719 |
+
# Switch for facet_wrap
|
720 |
+
if (input$switch_scale_payout) facet_scale <- "fixed" else facet_scale <- "free_y"
|
721 |
+
|
722 |
# Base plot
|
723 |
p <- ggplot(d_filter,
|
724 |
aes(x = round, y = payout, fill = payout,
|
|
|
746 |
scale_fill_scico(palette = "vikO", direction = -1, midpoint = 0) +
|
747 |
scale_x_continuous(breaks = breaks_pretty(5)) +
|
748 |
xlab(" \nTournament Round") +
|
749 |
+
ylab("Realised / Pending Payout (NMR)")
|
750 |
|
751 |
# Facet setting
|
752 |
if (n_model %% 5 == 0) {
|
753 |
+
p <- p + facet_wrap(. ~ model, ncol = 5, scales = facet_scale)
|
754 |
} else {
|
755 |
+
p <- p + facet_wrap(. ~ model, scales = facet_scale)
|
756 |
}
|
757 |
|
758 |
# Dynamic height adjustment
|