Skip to content

Add htmlwidget init functions#466

Merged
jwildfire merged 2 commits intodevfrom
adam-visit-metadata
Jan 12, 2021
Merged

Add htmlwidget init functions#466
jwildfire merged 2 commits intodevfrom
adam-visit-metadata

Conversation

@jwildfire
Copy link
Contributor

@xni7 Updated the metadata as discussed in #465. Let me know if the widgets render out of the box with the update.

fix #465.

@jwildfire jwildfire requested a review from xni7 December 21, 2020 17:31
@jwildfire jwildfire self-assigned this Dec 21, 2020
Copy link
Contributor

@xni7 xni7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jwildfire , changing the meta data AVISIT and AVISITN does not seem to be sufficient. For example, safetyOutlierExplorer widget cannot render in the following function call, even if the visit_col and visitn_col are correctly mapped to AVISIT and AVISITN.

safetyGraphicsApp(  
  domainData=list(
    labs=safetyGraphics::labs %>%  select(-VISIT, -VISITNUM), 
    aes=safetyGraphics::aes, 
    dm=safetyGraphics::dm
  ),
  meta = safetyGraphics::meta, 
  charts=NULL,
  mapping=NULL,
  chartSettingsPaths = NULL)

The issue is safetyOutlierExplorer htmlwidget is expecting a list of time_cols in the settings, which is not found in the current meta data. The workaround is to use the init() function in YAML workflow. Not sure if time_cols is general enough to add to the global meta data, or we could create a safetyOutlierExplorer shiny module wrapper and add it there?

safetyOutlierExplorer_init<- function(data, settings){
    print(data)
    print(settings)
    
    settings$time_cols <- data_frame(
        value_col = c(settings[["visit_col"]], settings[["studyday_col"]]),
        type = c("ordinal", "linear"),
        order_col = c(settings[["visitn_col"]] , "null"),
        rotate_tick_labels = c(T,F),
        vertical_space = c(100,0)
    )
    
    return(list(data=data,settings=settings))
}

@jwildfire
Copy link
Contributor Author

Hmm, I think it makes sense that it's breaking. Hardcoding here was making this work in v1.0.

Still a bit confused why this is rendering in the default build. At any rate, I'll clean this up and ping you for review.

@jwildfire
Copy link
Contributor Author

jwildfire commented Jan 4, 2021

Ok, figured out why default renderer works. VISIT and VISITNUM are the defaults for time_cols in javascript, so we just got lucky. As you explained above, visit_col is just being ignored and needs to be added via an init function. Will set that up in safetyCharts now.

        time_cols: [
            {
                type: 'ordinal',
                value_col: 'VISIT',
                label: 'Visit',
                order_col: 'VISITNUM',
                order: null,
                rotate_tick_labels: true,
                vertical_space: 100
            },

@jwildfire
Copy link
Contributor Author

jwildfire commented Jan 4, 2021

OK - I think this is fixed - for real this time. Try running with this branch and the outlierinit branch of safetycharts

@jwildfire jwildfire requested a review from xni7 January 4, 2021 19:58
@jwildfire jwildfire changed the title update adam metadata. fix #465 Add htmlwidget init functions Jan 6, 2021
Copy link
Contributor

@xni7 xni7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, in reference to SafetyGraphics/safetyCharts#41

@jwildfire jwildfire merged commit 40c6837 into dev Jan 12, 2021
@jwildfire jwildfire deleted the adam-visit-metadata branch January 12, 2021 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

safetyOutlierExplorer and safetyResultsOverTime widgets initialization

2 participants