results-over-time API reference

Generated from the module's JSDoc and JSON-Schema data contract — npm run docs:api fails on undocumented surface.

Overview

Every safety.viz renderer is one factory call. resultsOverTime(element, settings) empties the container, renders the shared control shell, and returns a chart instance; pass data to setData (or init) and the module validates it against its data contract, structures it, and draws. Settings are merged onto the module's defaults, so callers supply only overrides — column mappings follow ADaM naming out of the box. The same lifecycle (init, setData, setSettings, render, resize, destroy) is shared by every module and consumed unchanged by the gsm.safety R bindings. See Architecture for how the pieces fit together.

Factory

resultsOverTime([element], [settings])

Create a safety results-over-time chart inside a container element. The control shell renders immediately; pass long-format result records to setData (or init) on the returned instance to validate the data and draw the chart.

ParamTypeDefaultDescription
element (optional)string | HTMLElement'body'Container node, or a CSS selector for it.
settings (optional)ResultsOverTimeSettings{}Setting overrides, merged onto DEFAULT_SETTINGS and normalized.

Returns: SafetyResultsOverTime — The live results-over-time instance.

Methods

init(data)

Load data and render: an alias for setData that keeps the two-step create-then-init call shape working.

ParamTypeDefaultDescription
dataArray.<Object>Long-format result records matching the results-over-time data contract.

Returns: SafetyResultsOverTime — The instance, for chaining.

setData(data)

Replace the bound data and re-render. The data is validated against the settings mapping (throwing, and rendering the message into the target element, when required columns are missing), rows with missing or non-numeric results are removed with a console warning, and the controls are rebuilt from the new data's measures and filter values.

ParamTypeDefaultDescription
dataArray.<Object>Long-format result records matching the results-over-time data contract.

Returns: SafetyResultsOverTime — The instance, for chaining.

setSettings(settings)

Merge setting overrides onto the current settings, re-normalize them (same rules as the factory), rebuild the controls, and re-render.

ParamTypeDefaultDescription
settingsResultsOverTimeSettingsSetting overrides to merge.

Returns: SafetyResultsOverTime — The instance, for chaining.

render()

Redraw everything from the current data, settings, and control state: destroys the live chart, recomputes the per-visit-group statistics and box specs, and draws the box-and-whisker plot with its outlier overlay.

Returns: void

resize()

Resize the live chart to its container. For host layouts that change the container size without a window resize — e.g. the R htmlwidget bindings.

Returns: void

destroy()

Tear the chart down: destroy the Chart.js instance and empty the target element. The instance cannot be reused afterwards — create a new one via the factory instead.

Returns: void

Settings

SettingTypeDefaultDescription
id_colstring'USUBJID'Participant identifier column; drives the participant counts shown above the chart.
measure_colstring'TEST'Column holding the measure name; required in the data. Each distinct measure (with its unit) becomes an option in the Measure control.
value_colstring'STRESN'Column holding the numeric result; required in the data. Rows with missing or non-numeric values are removed with a console warning.
unit_colstring'STRESU'Unit column, appended to the measure name in labels and the y-axis title when present.
time_colstring'VISIT'Column holding the visit name; required in the data. Distinct visits become the x-axis categories.
time_order_colstring'VISITNUM'Optional numeric column ordering the visits along the x-axis; falls back to alphanumeric visit order when absent.
time_labelstring'Visit'Axis label for the time (visit) dimension.
filtersArray.<(string|Object)>[]Filter controls: column names or { value_col, label } specs. Filters whose column is absent from the data are dropped with a console warning.
groupsArray.<(string|Object)>[]Group-by options; a "None" option is always offered first. The selected group splits each visit into side-by-side box plots.
start_valuestring | nullnullMeasure selected on first render; falls back to the first measure (with a console warning) when absent from the data.
group_bystring'srot_none'Column the box plots are grouped by on first render; 'srot_none' disables grouping. Unknown columns are added to the group options as-is.
boxplotsbooleantrueDraw the box-and-whisker marks on first render.
outliersbooleantrueOverlay the results outside the 5th/95th percentiles as outlier points on first render.
visits_without_databooleanfalseShow x-axis timepoints for visits with no data for the current measure/filters.
unscheduled_visitsbooleanfalseShow unscheduled visits (matched by unscheduled_visit_values or unscheduled_visit_pattern).
unscheduled_visit_patternstring'/unscheduled|early termination/i'Regular expression (in /source/flags string form) identifying unscheduled visits.
unscheduled_visit_valuesArray.<string> | nullnullExplicit list of unscheduled visit names; takes precedence over unscheduled_visit_pattern when set.
y_scalestring'linear'Initial y-axis scale, one of the Y_SCALES options ('linear' or 'log').
widthstring'100%'Widget width, carried over for the R widget bindings; the current shell always spans its container.
heightnumber460Chart-area height in pixels, carried over for the R widget bindings; the current shell fixes the chart area at 460px.

Data contract

safety.viz results-over-time data contract

Long-format results data with a visit dimension: one record per participant per visit per measure (SROT-DATA-001/002). Column names are supplied by the settings mapping; the renderer removes missing/non-numeric results with a reported count and degrades gracefully when optional columns are absent.

FieldTypeRequiredDefaultDescription
dataarrayyesd3.csv()-style records; every row carries the measure, result, and visit columns named in settings.
settingsobjectyesColumn mappings and rendering options; merged onto the module's DEFAULT_SETTINGS, so only overrides need to be supplied.
settings.measure_colstringyesTESTColumn holding the measure name; required in data.
settings.value_colstringyesSTRESNColumn holding the numeric result; required in data.
settings.time_colstringyesVISITColumn holding the visit name; required in data. Distinct visits become the x-axis categories.
settings.time_order_colstringnoVISITNUMOptional numeric column ordering the visits; falls back to alphanumeric order when absent.
settings.id_colstringnoUSUBJIDOptional participant identifier column driving the participant counts.
settings.unit_colstringnoSTRESUOptional unit column, appended to measure labels and the y-axis title.
settings.filtersarraynoOptional filter columns rendered as controls.
settings.groupsarraynoOptional group-by columns that split each visit into side-by-side box plots.