Skip to content

Commit

Permalink
fix #166
Browse files Browse the repository at this point in the history
  • Loading branch information
eblondel committed Apr 14, 2023
1 parent 86a4877 commit 3bc6d3a
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 13 deletions.
8 changes: 4 additions & 4 deletions shiny/shiny-calipseo/assets/core/fishing_roles.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ filter_category <- function(data,input,column_indexes){
}


pyramid_df <- function(data, subset = NULL){
prepare_pyramid_data <- function(data, subset = NULL){

data <- data[,-2]

Expand All @@ -39,12 +39,12 @@ pyramid_df <- function(data, subset = NULL){



plot_df <- function(category, fill){
plot_pyramid_data <- function(category, fill){

age <- Age_comp(category[,c('Gender','DOB', 'Edulevel')], Prep = TRUE)

Male <- pyramid_df(age, subset = i18n("INDIVIDUAL_OVERVIEW_LABEL_MALE"))
Female <- pyramid_df(age, subset = i18n("INDIVIDUAL_OVERVIEW_LABEL_FEMALE"))
Male <- prepare_pyramid_data(age, subset = i18n("INDIVIDUAL_OVERVIEW_LABEL_MALE"))
Female <- prepare_pyramid_data(age, subset = i18n("INDIVIDUAL_OVERVIEW_LABEL_FEMALE"))

pyramid_df <- rbind(Female,Male)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

"INDIVIDUAL_BREAKDOWN_TITLE_FISHER" : "Fisher",
"INDIVIDUAL_BREAKDOWN_TITLE_NONFISHER" : "Non Fisher",
"INDIVIDUAL_BREAKDOWN_LABEL_NODATA" : "No data",

/*individual_breakdown labels*/
"INDIVIDUAL_TYPE" :"Type of Individual",
Expand Down
17 changes: 14 additions & 3 deletions shiny/shiny-calipseo/modules/core/individual_breakdown_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ individual_breakdown_server <- function(id, pool) {

moduleServer(id, function(input, output, session) {

ns <- session$ns

ind_overview <- accessIndividualOverview(pool)
non_fisher <- ind_overview[ind_overview$Category =='nonfisher',]

Expand Down Expand Up @@ -93,7 +95,10 @@ individual_breakdown_server <- function(id, pool) {
})


output$fisher_age_gender <- renderPlotly({plot_df(dat, fill = i18n("INDIVIDUAL_OVERVIEW_LABEL_GENDER"))})
output$fisher_age_gender <- renderPlotly({plot_pyramid_data(dat, fill = i18n("INDIVIDUAL_OVERVIEW_LABEL_GENDER"))})
output$fisher_age_gender_wrapper <- renderUI({
plotlyOutput(ns("fisher_age_gender"))
})


}else{
Expand All @@ -110,8 +115,14 @@ individual_breakdown_server <- function(id, pool) {

})

output$fisher_age_gender <- renderPlotly({plot_df(non_fisher, fill = i18n("INDIVIDUAL_OVERVIEW_LABEL_GENDER"))})

output$fisher_age_gender <- renderPlotly({plot_pyramid_data(non_fisher, fill = i18n("INDIVIDUAL_OVERVIEW_LABEL_GENDER"))})
output$fisher_age_gender_wrapper <- renderUI({
if(nrow(non_fisher)>0){
plotlyOutput(ns("fisher_age_gender"))
}else{
tags$div(i18n("INDIVIDUAL_BREAKDOWN_LABEL_NODATA"))
}
})
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ individual_breakdown_ui <- function(id){
selectizeInput(ns("filter_fisher_category"),label = i18n("SELECT_FISHER_CATEGORY"),choices = c(i18n("INDIVIDUAL_LIST_LABEL_OWNER"),i18n("INDIVIDUAL_LIST_LABEL_CAPTAIN"),i18n("INDIVIDUAL_LIST_LABEL_HOLDER_FISHING_ID"),i18n("INDIVIDUAL_LIST_LABEL_HOLDER_FISHING_LICENSE")),multiple = FALSE, width = '40%')),
box(width = 12, height = 480, title = uiOutput(ns('title_box_gender')), status = "primary", solidHeader= TRUE, plotlyOutput(ns("fisher_gender"))),
box(width = 12, height = 480, title = uiOutput(ns('title_box_pyramid')), status = "primary", solidHeader= TRUE,
plotlyOutput(ns("fisher_age_gender"))))),
uiOutput(ns("fisher_age_gender_wrapper"))))),
shinyWidgets::verticalTabPanel(i18n("VERTICALTABPANEL_INDIVIDUAL_BREAKDOWN_EDUCATION"),box_height='70px',
div(h4(i18n("INDIVIDUAL_BREAKDOWN_TITLE_EDUCATION")),
span(checkboxInput(ns("fisher_chck_edu"), label = i18n("INDIVIDUAL_BREAKDOWN_TITLE_FISHER")),checkboxInput(ns("nonfisher_chck_edu"), label = i18n("INDIVIDUAL_BREAKDOWN_TITLE_NONFISHER"))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"INDIVIDUAL_OVERVIEW_LABEL_MALE" : "Male",
"INDIVIDUAL_OVERVIEW_LABEL_FEMALE" : "Female",
"INDIVIDUAL_OVERVIEW_LABEL_UNSPECIFIED" : "Unspecified",
"INDIVIDUAL_OVERVIEW_LABEL_NODATA" : "Nodata",
"INDIVIDUAL_OVERVIEW_LABEL_NODATA" : "No data",

/*Individual Overview infoboxes*/
"INFOBOX_TITLE_INDIVIDUAL_OVERVIEW_TOTAL_NUMBER" : "Total Number",
Expand Down
12 changes: 9 additions & 3 deletions shiny/shiny-calipseo/modules/core/individual_overview_server.R
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,17 @@ individual_overview_server <- function(id, pool) {



output$fisher_age_gender <- renderPlotly({plot_df(fisher, fill = i18n("INDIVIDUAL_OVERVIEW_LABEL_EDULEVEL"))})

output$non_fisher_age_gender <- renderPlotly({plot_df(non_fisher, fill = i18n("INDIVIDUAL_OVERVIEW_LABEL_EDULEVEL"))})
output$fisher_age_gender <- renderPlotly({plot_pyramid_data(fisher, fill = i18n("INDIVIDUAL_OVERVIEW_LABEL_EDULEVEL"))})

output$non_fisher_age_gender <- renderPlotly({(plot_pyramid_data(non_fisher, fill = i18n("INDIVIDUAL_OVERVIEW_LABEL_EDULEVEL")))})

output$non_fisher_age_gender_wrapper <- renderUI({
if(nrow(non_fisher)>0){
plotlyOutput(ns("non_fisher_age_gender"))
}else{
tags$div(i18n("INDIVIDUAL_OVERVIEW_LABEL_NODATA"))
}
})

}

Expand Down
2 changes: 1 addition & 1 deletion shiny/shiny-calipseo/modules/core/individual_overview_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ individual_overview_ui <- function(id){
div(class = 'row',div(class = 'col-md-6',box(width = 12,title = i18n("INDIVIDUAL_OVERVIEW_TITLE_FISHER"),
plotlyOutput(ns("fisher_age_gender")))),
div(class = 'col-md-6',box(width = 12,title =i18n("INDIVIDUAL_OVERVIEW_TITLE_NONFISHER"),
plotlyOutput(ns("non_fisher_age_gender")))))
uiOutput(ns("non_fisher_age_gender_wrapper")))))

)

Expand Down

0 comments on commit 3bc6d3a

Please sign in to comment.