ae-timelines 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. aeTimelines(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, showParticipantDetail, backToTimelines, 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
aeTimelines([element], [settings])
Create an adverse-event timelines chart inside a container element. The control shell renders immediately; pass one-record-per-adverse-event data to setData (or init) on the returned instance to validate the data and draw the timelines.
| Param | Type | Default | Description |
|---|---|---|---|
element (optional) | string | HTMLElement | 'body' | Container node, or a CSS selector for it. |
settings (optional) | AETimelinesSettings | {} | Setting overrides, merged onto DEFAULT_SETTINGS and normalized. |
Returns: AETimelines — The live timelines instance.
Methods
init(data)
Load data and render: an alias for setData that keeps the original renderer's create-then-init call shape working (AET-DATA-004).
| Param | Type | Default | Description |
|---|---|---|---|
data | Array.<Object> | — | Adverse-event records matching the ae-timelines data contract. |
Returns: AETimelines — 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); records with blank terms or non-integer start days are removed with console warnings while AE-free placeholder rows still count toward the population; and the filter controls are rebuilt from the new data's values.
| Param | Type | Default | Description |
|---|---|---|---|
data | Array.<Object> | — | Adverse-event records matching the ae-timelines data contract. |
Returns: AETimelines — 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.
| Param | Type | Default | Description |
|---|---|---|---|
settings | AETimelinesSettings | — | Setting overrides to merge. |
Returns: AETimelines — The instance, for chaining.
render()
Redraw everything from the current data, settings, and control state: closes any open participant detail view, destroys the live charts, and draws the timeline chart and the participant-count note. Called automatically by the controls and the data/settings setters; call it directly only after mutating state by hand.
Returns: void —
showParticipantDetail(participant)
Open the detail view for one participant: their per-event timeline on the main chart's study-day domain (one row per sequence number), the raw-record listing with search/sort/CSV export, and the Back button — hiding the timelines and controls, and dispatching the participantsSelected event with the selected ID.
| Param | Type | Default | Description |
|---|---|---|---|
participant | string | — | Participant ID to detail. |
Returns: void —
backToTimelines()
Return from the participant detail view to the timelines (AET-FUNC-010): clears the selection, dispatches participantsSelected with an empty array, and re-renders the timeline chart.
Returns: void —
resize()
Resize every live chart (the timeline and any open detail 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 timelines down: destroy every 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
| Setting | Type | Default | Description |
|---|---|---|---|
id_col | string | 'USUBJID' | Participant identifier column; required in the data. One timeline row per participant; clicking the ID opens the detail view. |
seq_col | string | 'AESEQ' | Adverse-event sequence number column; required in the data. Blank in placeholder rows for participants without adverse events. |
stdy_col | string | 'ASTDY' | Study day of onset; required in the data. Records with non-integer values are removed with a console warning. |
endy_col | string | 'AENDY' | Study day of resolution; required in the data. Events with unusable stop days render as zero-length events at the start day. |
term_col | string | 'AETERM' | Verbatim adverse-event term column; required in the data (AET-CFG-004). Records with blank terms are removed with a console warning. |
color | Object | — | Event color stratification (AET-CFG-005): value_col (default 'AESEV'; required in the data, but remappable), label ('Severity/Intensity'), values (expected levels in legend order: MILD, MODERATE, SEVERE), and colors (assigned by domain position; N/A always renders gray). |
highlight | Object | null | — | Distinct marking for notable events (AET-CFG-007) — serious events by default: value_col ('AESER'), label ('Serious Event'), value ('Y', AET-CFG-008), detail_col (optional tooltip/listing detail, AET-CFG-009), and attributes ({ stroke, 'stroke-width' } mark style, AET-CFG-010). Pass null to disable highlighting. |
filters | Array.<(string|Object)> | null | null | Filter controls (AET-CFG-011): column names or { value_col, label } specs. When null, defaults to serious event, severity, and participant identifier; filters whose column is absent or single-valued are dropped with a console warning. |
details | Array.<(string|Object)> | null | null | Columns for the participant detail listing (AET-CFG-012). Custom columns append after the defaults (sequence, start/stop day, term, severity, seriousness), deduplicated by column. |
sort_participants | string | 'earliest' | Initial participant order: 'earliest' (first adverse-event onset, earliest at the top) or 'alphabetical-descending' (the original's label for its alphabetical order). |
row_height | number | 15 | Vertical pixels per participant row; the chart area grows with the participant count like the original's range band. |
page_size | number | 10 | Rows per page in the participant detail listing. |
Data contract
safety.viz ae-timelines data contract
Adverse-event data: one record per adverse event, with placeholder rows (blank term and start day) keeping AE-free participants in the population denominator (AET-DATA-001). Column names default to the ADaM ADAE standard and are supplied by the settings mapping; records with blank reported terms or non-integer start days are removed with reported counts, and a coloring variable — severity by default — is required but remappable (AET-DATA-003).
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
data | array | yes | — | d3.csv()-style records; every row carries the participant, sequence, study-day, term, and coloring columns named in settings. |
settings | object | yes | — | Column mappings and rendering options; merged onto the module's DEFAULT_SETTINGS, so only overrides need to be supplied. |
settings.id_col | string | yes | USUBJID | Participant identifier column; required in data. Drives the timeline rows, the participant counts, and the detail-view click-through. |
settings.seq_col | string | yes | AESEQ | Adverse-event sequence number column; required in data. Blank in placeholder rows for participants without adverse events. |
settings.stdy_col | string | yes | ASTDY | Study day of adverse-event onset; required in data. Records with non-integer values are removed with a reported count. |
settings.endy_col | string | yes | AENDY | Study day of adverse-event resolution; required in data. Events with unusable stop days render as zero-length events at the start day. |
settings.term_col | string | yes | AETERM | Verbatim adverse-event term column; required in data (AET-CFG-004). Records with blank terms are removed with a reported count. |
settings.color | object | yes | — | Event color stratification: the variable, its label, its expected levels, and their colors (AET-CFG-005). A coloring variable is required but does not have to be severity (AET-DATA-003). |
settings.color.value_col | string | yes | AESEV | Color stratification variable name, usually event severity (AET-CFG-006); required in data. Blank values normalize to N/A. |
settings.color.label | string | no | Severity/Intensity | |
settings.color.values | array | no | — | Expected levels in legend order; unexpected levels found in the data append alphabetically, with N/A last. |
settings.color.colors | array | no | — | Colors assigned by domain position; N/A always renders gray. |
settings.highlight | object,null | no | — | What events to mark distinctly and how — serious events by default (AET-CFG-007). Pass null to disable highlighting. |
settings.highlight.value_col | string | no | AESER | |
settings.highlight.label | string | no | Serious Event | |
settings.highlight.value | string | no | Y | Value of highlight.value_col that identifies events to highlight (AET-CFG-008). |
settings.highlight.detail_col | string,null | no | — | Optional column with highlight detail text for tooltips and the detail listing (AET-CFG-009). |
settings.highlight.attributes | object | no | — | Mark style for highlighted events (AET-CFG-010): stroke (color) and stroke-width map onto the highlight outline and overlay line. |
settings.filters | array,null | no | — | Filter columns rendered as controls (AET-CFG-011); defaults to serious event, severity, and participant identifier. |
settings.details | array,null | no | — | Columns for the participant detail listing (AET-CFG-012); custom columns append to the defaults. |
settings.sort_participants | string | no | earliest | Initial participant sort: by earliest adverse-event onset, or alphabetically. |