Skip to content

Commit

Permalink
Merge pull request #12 from EVS-GIS/fix_unit_area
Browse files Browse the repository at this point in the history
Fix unit area
  • Loading branch information
LouisManiere authored Nov 2, 2023
2 parents 6f16f58 + 8921e6f commit 8852ca8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 31 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ jobs:
R_KEEP_PKG_SOURCE: yes

steps:
- name: Create and populate .Renviron file
run: |
echo DBMAPDO_HOST="DBMAPDO_HOST" >> ~/.Renviron
echo DBMAPDO_PORT="DBMAPDO_PORT" >> ~/.Renviron
shell: bash
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v2
Expand Down
64 changes: 33 additions & 31 deletions R/mod_explore.R
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ mod_explore_server <- function(id){

}
### axis clicked ####

if (input$exploremap_shape_click$group == params_map_group()$axis) {
# save the clicked axis values
r_val$axis_click = input$exploremap_shape_click
Expand Down Expand Up @@ -357,7 +358,7 @@ mod_explore_server <- function(id){

observeEvent(c(input$metric, input$unit_area), ignoreInit = TRUE, {
# change field if unit_area in percentage
if (!is.null(input$unit_area) && input$unit_area == "% du fond de vallée"
if (!is.null(input$metric) && input$unit_area == "% du fond de vallée"
&& (input$metric_type %in% c("Occupation du sol", "Continuité latérale"))){
r_val$selected_metric = paste0(input$metric,"_pc")
r_val$selected_metric_name = utile_get_metric_name(selected_metric = input$metric)
Expand All @@ -368,50 +369,51 @@ mod_explore_server <- function(id){
r_val$select_metric_category = utile_get_category_name(selected_metric = input$metric)
}

# build metric filter slider
r_val$min_max_metric <- data_get_min_max_metric(selected_region_id = r_val$region_click$id, selected_metric = r_val$selected_metric)

r_val$ui_metric_filter = sliderInput(ns("metricfilter"),
label = r_val$selected_metric_name,
min = isolate(r_val$min_max_metric[["min"]]),
max = isolate(r_val$min_max_metric[["max"]]),
value = c(
isolate(r_val$min_max_metric[["min"]]),
isolate(r_val$min_max_metric[["max"]])
)
)
if (!is.null(input$metric)){
# build metric filter slider
r_val$min_max_metric <- data_get_min_max_metric(selected_region_id = r_val$region_click$id, selected_metric = r_val$selected_metric)

r_val$ui_metric_filter = sliderInput(ns("metricfilter"),
label = r_val$selected_metric_name,
min = isolate(r_val$min_max_metric[["min"]]),
max = isolate(r_val$min_max_metric[["max"]]),
value = c(
isolate(r_val$min_max_metric[["min"]]),
isolate(r_val$min_max_metric[["max"]])
)
)

# update profile with new metric selected
if (r_val$profile_display == TRUE){
proxy_main_axe <-
lg_profile_update_main(
data = r_val$selected_axis_df,
y = r_val$selected_axis_df[[r_val$selected_metric]],
y_label = r_val$selected_metric_name,
y_label_category = r_val$select_metric_category
)
# update profile with new metric selected
if (r_val$profile_display == TRUE){
proxy_main_axe <-
lg_profile_update_main(
data = r_val$selected_axis_df,
y = r_val$selected_axis_df[[r_val$selected_metric]],
y_label = r_val$selected_metric_name,
y_label_category = r_val$select_metric_category
)

plotlyProxy("long_profile") %>%
plotlyProxyInvoke("deleteTraces", 0) %>%
plotlyProxyInvoke("addTraces", proxy_main_axe$trace, 0) %>%
plotlyProxyInvoke("relayout", proxy_main_axe$layout)
plotlyProxy("long_profile") %>%
plotlyProxyInvoke("deleteTraces", 0) %>%
plotlyProxyInvoke("addTraces", proxy_main_axe$trace, 0) %>%
plotlyProxyInvoke("relayout", proxy_main_axe$layout)
}
}
})

### EVENT METRIC & AXIS ####
### EVENT METRIC & AXIS RESULTS ####

observeEvent(c(input$metric, input$exploremap_shape_click), {
observeEvent(c(r_val$selected_metric, r_val$axis_click), {
if (r_val$profile_display == FALSE){
if (is.null(input$metric)==FALSE && input$exploremap_shape_click$group == params_map_group()$axis){
if (!is.null(r_val$selected_metric) && !is.null(r_val$axis_click)){

r_val$profile_display = TRUE
r_val$profile_display = TRUE # this event run only one time controlled with profile_display

# build input for profile metric type
r_val$ui_profile_metric_type = selectInput(ns("profile_metric_type"), "Ajoutez une métrique :",
choices = names(params_metrics_choice()),
selected = names(params_metrics_choice())[1])


# plot single axe with metric selected
r_val$plot = lg_profile_main(data = r_val$selected_axis_df,
y = r_val$selected_axis_df[[r_val$selected_metric]],
Expand Down

0 comments on commit 8852ca8

Please sign in to comment.