safety.viz · gsm.safety · design · approved 11 November 2026

One x-axis toggle: Visit or Study day

The demo data and the charts will carry both visit and study day. Every chart that shows change over time gets the same control to switch between them, as the original safetyGraphics outlier explorer did. Clinicians then only need to choose which view each chart opens on.

Bottom line
  • Data model: every lab, vital-sign and ECG record carries its visit (name and number) and its study day, plus the baseline flag.
  • Seven charts get the toggle: the participant profile (on its own and as the side panel in eight charts), the outlier explorer, hep-explorer's time slider and the profile drill-downs in the QT and nep explorers. The rest are visit-only or day-only by design, and say so.
  • The axis title and tooltips always name what is plotted. A missing column greys out its option and says why.
  • A study with neither a visit nor a study day: the participant profile and the outlier explorer show a message instead of a chart.
  • The six questions for the group become one table of defaults, plus two small questions. The charts are built with the defaults below; the group's answers can change any default without new code.
The four requirements this design covers
  1. Both visit and study day in the demo data, with the baseline flag and one visit numbering (safety.viz v1.12.0)
  2. One x-axis toggle between Visit and Study day (safety.viz v1.12.0)
  3. hep-explorer's time slider takes the toggle, and its 30-day timing test uses study days (safety.viz v1.12.0)
  4. gsm.safety's widgets take the toggle (gsm.safety v1.3.0, after safety.viz v1.12.0)

How it works: one participant's ALT

1 Measure ALT (×ULN)
2 X-axis
Hover or tap a point.
Illustrative values for one made-up participant, not study data.
  1. 1The chart's existing controls stay where they are.
  2. 2The toggle sits beside them, labelled "X-axis". The default comes from the chart's settings, so clinicians choose it per chart.
  3. 3The axis title changes with the toggle. Visit view spaces visits evenly in visit order; Study day view puts each record at its real day.
  4. 4The unscheduled visit sits right after Week 8 in Visit view, and at its actual day (66) in Study day view.
  5. 5Adverse events are drawn as a track only on the Study day axis. In Visit view they are listed under the chart with their own study days.
  6. 6Switch Data to "No study day": the Study day option greys out and says why. Switch to "Neither column": the participant profile and the outlier explorer show a message instead of a chart (decided 11 November).

Where the toggle goes

The proposed default is our starting point. The clinicians' one question is whether each default is right.

ChartToggleProposed defaultWhat switches
Participant profile, on its ownYesVisitThe labs, vitals and ECG lines, the axis title and the tooltips. The adverse-event track shows only in Study day view.
Participant profile as the side panel, in the histogram, outlier explorer, shift plot, delta-delta, hep-explorer, QT explorer, AE explorer and AE timelinesYesOpens on the host chart's current view. For hosts with no toggle, Visit, except Study day beside the AE explorer and AE timelines, whose panels show adverse events onlyAs above. The panel has its own toggle, so switching it doesn't change the host chart.
Outlier explorerYesVisitThe main x-axis. The toggle is already built (time_cols, as in the original chart); the gallery and demo app don't turn it on yet, so it shows a measurement sequence today. That sequence axis goes: with neither column the chart shows a message.
hep-explorerYesStudy dayThe time slider and animation step by visit or by day. The listing shows both columns. The 30-day timing test always uses study days and says "not evaluated" when there are none.
QT explorer (its profile drill-down)YesVisitSeveral ECGs on one day separate in Visit view and stack in Study day view.
nep-explorer (the Phase 2 profile drill-down)LaterVisitThe drill-down isn't built yet; it takes the toggle when it is. The scatter's tooltip shows both now.
Results over timeVisit only–Box plots need groups, so it stays by visit. Its tooltip gains the median study day for each visit.
Shift plot, delta-deltaVisit only–No time axis: they compare two chosen visits. Their listings show both columns.
hep-waterfall, histogramNone–No time axis. The waterfall listing shows both columns; the histogram reaches time only through its side panel.
AE timelines, time to event, Patient JourneyStudy day only–Adverse events and time to event have no visits. The Patient Journey lines everything up on one day axis, and its lab tooltips show the visit.

How the toggle behaves everywhere

Visit view

Visits are evenly spaced in visit-number order, with tick labels from the visit name. Unscheduled visits sit right after the visit they follow.

Study day view

A linear axis in days. Pre-dose records have negative days, day 1 is the first dose, and there is no day 0 (CDISC). Baseline records are marked.

Honest labels

The axis title is "Visit" or "Study day", never one over the other's data. Tooltips show both: Week 8 · Day 57.

Missing columns

With no study day, the Study day option greys out and says "No study day in this data". With no visit, the Visit option does the same. With neither, the participant profile and the outlier explorer show a message instead of a chart.

Side panels

The profile opens on the host chart's current view and keeps its own toggle after that.

Day-based tests

Checks measured in days, like hep-explorer's 30-day timing, always use study days, whatever the view. Without study days they say "not evaluated" and why.

Remembered choice

In the demo app, each chart remembers the last view while the page is open. In R, the widget takes the same default.

One setting shape

Every chart takes the same settings, so the gsm.safety widgets and the demo app pass the same thing. The host names each column and gives its label beside it.

x_axis: {
  options: [
    { key: "visit", col: "VISITNUM", label_col: "VISIT", type: "ordinal", title: "Visit" },
    { key: "day",   col: "DY",                           type: "linear",  title: "Study day" }
  ],
  default: "visit"   // per chart; the one thing clinicians choose
}

What the data model needs

Both, on every record

Labs, vitals and ECGs carry VISIT, VISITNUM and DY (from ADY), plus ABLFL. Adverse events keep ASTDY and AENDY.

One visit numbering

Today labs number Week 26 as 13 while vitals use 26, and Screening sorts after Baseline. The demo data, the synthetic cohorts and gsm.safety's bundled data move to one numbering.

Where it comes from

The source ADaM data already has ADY, and the Patient Journey extract already maps it. The demo build keeps it for every domain.

What this does to the questions for the clinicians

Before: six questions

  1. Visits evenly spaced, or at planned days?
  2. hep-explorer's 30-day check without study days?
  3. Show pre-dose records, and mark day 1?
  4. Baseline flag, or last value before first dose?
  5. Where do unscheduled visits go?
  6. QT profile by visit or by day?

After: one table and two questions

  • Is each chart's default view right? (The table above.)
  • In Study day view, show pre-dose records and mark day 1?
  • For baseline, use the dataset's flag, or the last value before the first dose?

Questions 1, 5 and 6 are answered by having both views. Question 2 is a rule: day-based checks need days.

Decided, 8 to 11 November

Four requirements

The data, the toggle, hep-explorer's timing, gsm.safety. The toggle stays one requirement, about five days of work.

Both in the data model

Visit and study day on every record, and a toggle between them on charts that show change over time.

Neither column

The participant profile and the outlier explorer show a message instead of a chart. No "Measurement" axis.

Baseline

The shared baseline rule reads the dataset's baseline flag, as a third task in the data requirement.

Today's settings

studyday_col, visit_col, visitn_col and time_cols keep working as shorthand when x_axis is not given.

Host defaults

The histogram, outlier explorer, shift plot and delta-delta default the day option to DY; noted in the release notes.

How the pieces fit

Data (safety.viz build scripts)

scripts/build-demo-data.mjs keeps ADY as DY and ABLFL on labs, vital signs and ECGs; the three synthetic cohorts get DY from their schedule; one visit numbering (Baseline 0, Week N = N, Screening negative, unscheduled 0.1 after the visit it follows); pje-lb.csv gains the visit. deriveBaseline in src/hep-core/rows.js reads baseline_col.

Shared

src/x-axis.js, beside src/axis-limits.js: normalises x_axis, resolves each option against the data, gives an unavailable option its reason, picks the default, and builds x_axis from the old settings. The control renders through the shell's controls, labelled "X-axis".

Participant profile

structureData.js gives each point an x for each view; spaghetti.js, inset.js and measureTable.js read the active view; aeTracks.js draws the track in Study day view only and lists the events otherwise; a day-1 line in Study day view.

Hosts

The eight hosts forward x_axis and their current view through profileSettings(). The QT drill-down stops passing the visit number as a study day. The outlier explorer's "Plot by" control becomes the shared control.

hep-explorer

animation.js and views/scatter.js step the slider by visit or by day; structureData.js runs the timing test on study days only and marks it not evaluated otherwise.

Demo app and gsm.safety

The app's chart recipes pass x_axis and drop the "visit order" fallback. The gsm.safety widgets pass lSettings through unchanged, so x_axis needs no R code; examples, report workflows and tests follow the vendored v1.12.0.

Order and change list

OrderRequirementFilesSize
1Both visit and study day in the demo datascripts/build-demo-data.mjs, scripts/demo-data-lib.mjs, the three cohort scripts, site/demo/*.js, site/data/*.csv, scripts/check-demo-data.mjs, src/hep-core/rows.js2 to 3 days
2One x-axis togglesrc/x-axis.js (new), src/participant-profile/*, src/profile-host.js, the eight hosts and their configure.js and schemas, src/outlier-explorer/*, src/qt-explorer.js, src/results-over-time/getPlugins.js, src/app/charts.js, requirements/*.mdabout 5 days
3hep-explorer's slider and timingsrc/hep-explorer/{animation,structureData,getPlugins}.js, views/scatter.js, src/hep-explorer.js, src/hep-waterfall.js2 days
4gsm.safety takes the togglethe vendored bundle and inst/extdata/, R/Widget_*.R docs and examples, five 4_modules/*.yaml, their tests1 day