Skip to content

Participant trajectories with explicit missing visits

Read as Markdown

Participant trajectories with explicit missing visits.

Plain source. Run as a browser module after the document body exists. TSX uses jsx: "react-jsx" and jsxImportSource: "@pibbl/core".

import { } from "@pibbl/core";
import { pibblSync } from '@pibbl/core/sync';
import {
LinearScale,
TrajectorySeries,
type TrajectorySeriesProps,
type TrajectoryGroupAccessor,
type TrajectorySeriesStyle,
} from "@pibbl/core/viz";
const records = [
{ id: "P01", week: 0, change: 0 },
{ id: "P02", week: 0, change: 0 },
{ id: "P01", week: 4, change: -10 },
{ id: "P02", week: 4, change: null },
{ id: "P01", week: 12, change: -18 },
{ id: "P02", week: 12, change: -8 },
];
const group: TrajectoryGroupAccessor<(typeof records)[number]> = "id";
const style: TrajectorySeriesStyle = { stroke: "#087f8c", strokeWidth: 2 };
const props: TrajectorySeriesProps<(typeof records)[number]> = {
data: records,
group,
x: "week",
y: "change",
xScale: "visit",
yScale: "outcome",
style,
};
const canvas = document.createElement("canvas");
canvas.width = 400;
canvas.height = 300;
document.body.append(canvas);
const app = pibblSync(
canvas,
<LinearScale id="visit" domain={[0, 12]} range={[40, 360]}>
<LinearScale id="outcome" domain={[-25, 5]} range={[260, 30]}>
<TrajectorySeries {...props} />
</LinearScale>
</LinearScale>,
);
window.addEventListener("pagehide", () => app.dispose(), { once: true });

Documentation built with @pibbl/core 0.0.2, revision a1dcf8e. ALPHA — NOT FOR PRODUCTION USE.