Skip to content

Commit

Permalink
Merge pull request #42 from SanjayShetty01/change_slider
Browse files Browse the repository at this point in the history
changing the slider values
  • Loading branch information
SanjayShetty01 authored Oct 27, 2024
2 parents 481cbc3 + 66c97a4 commit 055856a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 25 deletions.
15 changes: 10 additions & 5 deletions app/view/components/sliderInputs.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
generateSliderInputs <- function(ns, prefix, numLevels, min, max, value) {
lapply(1:numLevels, function(level) {
shiny::sliderInput(ns(paste0(prefix, level)),
paste('Enter the number of the Animal in Level', level),
min = min, max = max, value = value, width = "250px")
generateSliderInputs <- function(ns, prefix, start, end, max_value) {
lapply(start:end, function(level) {
shiny::sliderInput(
ns(paste0(prefix, level)),
paste('Enter the number of the Animal you have bought in Level', level),
min = 0,
max = max_value[level],
value = 0,
width = "250px"
)
})
}
29 changes: 11 additions & 18 deletions app/view/dashboardModule.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ box::use(../../app/logic/calculateYield)
box::use(../../app/logic/investmentRecoveryTime)
box::use(../../app/logic/readFarmInfoData)

getAnimalShopSliderInputs <- function(start, end, max_value, ns) {
lapply(start:end, function(i) {
shiny::sliderInput(
ns(paste0('shop', i)),
paste('Enter the number of the Animal you have bought in Level', i),
min = 0,
max = max_value[i],
value = 0
)
})
}
# getAnimalShopSliderInputs <- function(start, end, max_value, ns) {
# lapply(start:end, function(i) {
# shiny::sliderInput(
# ns(paste0('shop', i)),
# paste('Enter the number of the Animal you have bought in Level', i),
# min = 0,
# max = max_value[i],
# value = 0
# )
# })
# }


shopAnalysisUI <- function(id){
Expand Down Expand Up @@ -52,13 +52,6 @@ shopAnalysisUI <- function(id){

)
)
# animalShopSliderInputs <- getAnimalShopSliderInputs(1, 20,
# c(30, 25, 25, 25, 25, 25,
# 20, 20, 20, 15, 15, 15,
# 15, 15, 15, 10, 10, 10,
# 10, 10), ns)
# shiny::flowLayout(do.call(shiny::tagList, animalShopSliderInputs))

}


Expand Down
9 changes: 7 additions & 2 deletions app/view/setupModule.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ box::use(./components/sliderInputs)
#' @export
incomeTabUI <- function(id){
ns <- shiny::NS(id)
sliderInputsUI <- sliderInputs$generateSliderInputs(
ns, "tab2-level", 20, 0 ,6, 0)

sliderInputsUI <- sliderInputs$generateSliderInputs(ns, "tab2-level" ,
1, 20,
c(30, 25, 25, 25, 25, 25,
20, 20, 20, 15, 15, 15,
15, 15, 15, 10, 10, 10,
10, 10))

shiny::fluidPage(

Expand Down

0 comments on commit 055856a

Please sign in to comment.