jofaichow commited on
Commit
b6ac129
·
1 Parent(s): 873355a

fixed switch

Browse files
Files changed (1) hide show
  1. app/app.R +14 -5
app/app.R CHANGED
@@ -716,9 +716,6 @@ server <- function(input, output) {
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,
@@ -750,9 +747,21 @@ server <- function(input, output) {
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
 
716
  # Get the number of unique models
717
  n_model <- length(unique(d_filter$model))
718
 
 
 
 
719
  # Base plot
720
  p <- ggplot(d_filter,
721
  aes(x = round, y = payout, fill = payout,
 
747
 
748
  # Facet setting
749
  if (n_model %% 5 == 0) {
750
+
751
+ if (input$switch_scale_payout) {
752
+ p <- p + facet_wrap(. ~ model, ncol = 5, scales = "fixed")
753
+ } else {
754
+ p <- p + facet_wrap(. ~ model, ncol = 5, scales = "free_y")
755
+ }
756
+
757
  } else {
758
+
759
+ if (input$switch_scale_payout) {
760
+ p <- p + facet_wrap(. ~ model, scales = "fixed")
761
+ } else {
762
+ p <- p + facet_wrap(. ~ model, scales = "free_y")
763
+ }
764
+
765
  }
766
 
767
  # Dynamic height adjustment