safety-results-over-time
Version:
Chart showing population averages for lab measures, vital signs and other related measures during the course of a clinical trial.
33 lines (31 loc) • 1.47 kB
JavaScript
import { format } from 'd3';
export default function addSummaryStatistics(subgroup) {
const format0 = format(`.${this.config.y.precision + 0}f`);
const format1 = format(`.${this.config.y.precision + 1}f`);
const format2 = format(`.${this.config.y.precision + 2}f`);
subgroup.svg
.selectAll('g')
.append('title')
.html(
d =>
`${subgroup.key} at ${subgroup.group.x.key}:\n N = ${
subgroup.results.n
}\n Min = ${format0(
subgroup.results.min
)}\n 5th % = ${format1(
subgroup.results.q5
)}\n Q1 = ${format1(
subgroup.results.q25
)}\n Median = ${format1(
subgroup.results.median
)}\n Q3 = ${format1(
subgroup.results.q75
)}\n 95th % = ${format1(
subgroup.results.q95
)}\n Max = ${format0(
subgroup.results.max
)}\n Mean = ${format1(
subgroup.results.mean
)}\n StDev = ${format2(subgroup.results.deviation)}`
);
}