inst/abcdmetrics/www/R/outputs/plot_evolution.R

output$plot_evolution <- renderHighchart({
  dta <- dta_abcd_visit() |> 
    filter(! site == "_ALL SITES_")
  
  if(input$aggregation_selection) {
    return(
      dta |> 
        group_by(timepoint, category) |> summarise(n = sum(n), .groups = "drop") |> 
        hchart(type = "column", hcaes(x = "timepoint", y = "n", group = "category")) |> 
        hc_yAxis(title = list(text = "%"), max = 115, endOnTick = FALSE, stackLabels = list(enabled = TRUE)) |> 
        hc_xAxis(title = "") |> 
        hc_colors(color_category) |> 
        hc_plotOptions(series = list(stacking = "percent"))
    )
  }
  if(! input$aggregation_selection) {
    return(
      dta |> 
        group_by(timepoint, status) |> summarise(n = sum(n), .groups = "drop") |> 
        hchart(type = "column", hcaes(x = "timepoint", y = "n", group = "status")) |> 
        hc_yAxis(title = list(text = "%"), max = 115, endOnTick = FALSE, stackLabels = list(enabled = TRUE)) |> 
        hc_xAxis(title = "") |> 
        hc_colors(visit_status$color_status) |> 
        hc_plotOptions(series = list(stacking = "percent"))
    )
  }
})
ucsd-dsm/abcd-metrics documentation built on April 27, 2022, 12:06 a.m.