forked from RhoInc/safety-shift-plot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
14 changed files
with
412 additions
and
639 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
export default function addVariables() { | ||
this.initial_data.forEach(d => { | ||
d[this.config.measure_col] = d[this.config.measure_col].trim(); | ||
d.ssp_measure = d.hasOwnProperty(this.config.unit_col) | ||
? `${d[this.config.measure_col]} (${d[this.config.unit_col]})` | ||
: d[this.config.measure_col]; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,30 @@ | ||
import { set } from 'd3'; | ||
import { dataOps } from 'webcharts'; | ||
|
||
export default function getMeasures() { | ||
this.measures = set(this.initial_data.map(d => d[this.config.measure_col])) | ||
.values() | ||
.sort(); | ||
// Define set of measure values as they appear in the data. | ||
this.measures = this.initial_data[0].hasOwnProperty(this.config.measure_order_col) | ||
? [...new Set(this.initial_data.map(d => +d[this.config.measure_order_col])).values()] | ||
.sort((a, b) => a - b) | ||
.map( | ||
value => | ||
this.initial_data.find(d => +d[this.config.measure_order_col] === value)[ | ||
this.config.measure_col | ||
] | ||
) | ||
: [...new Set(this.initial_data.map(d => d[this.config.measure_col])).values()].sort( | ||
dataOps.naturalSorter | ||
); | ||
|
||
// Define set of measure values with units (in ADaM units are already attached; in SDTM units are captured in a separate variable). | ||
this.ssp_measures = this.initial_data[0].hasOwnProperty(this.config.measure_order_col) | ||
? [...new Set(this.initial_data.map(d => +d[this.config.measure_order_col])).values()] | ||
.sort((a, b) => a - b) | ||
.map( | ||
value => | ||
this.initial_data.find(d => +d[this.config.measure_order_col] === value) | ||
.ssp_measure | ||
) // sort measures by measure order | ||
: [...new Set(this.initial_data.map(d => d.ssp_measure)).values()].sort( | ||
dataOps.naturalSorter | ||
); // sort measures alphabetically | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export default function syncSettings(settings) { | ||
settings.measure = settings.start_value; | ||
return settings; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,28 @@ | ||
d3.csv( | ||
'https://raw.githubusercontent.com/RhoInc/data-library/master/data/clinical-trials/renderer-specific/adbds.csv', | ||
function(d) { | ||
function(d,i) { | ||
return d; | ||
}, | ||
function(data) { | ||
const ssp = safetyShiftPlot( | ||
const measures = [...new Set(data.map(d => d.TEST)).values()] | ||
.sort(webCharts.dataOps.naturalSorter) | ||
.sort(() => .5 - Math.random()); | ||
data.forEach(d => { | ||
d.TESTN = measures.findIndex(measure => measure === d.TEST); | ||
}); | ||
|
||
const instance = safetyShiftPlot( | ||
'#container', // element | ||
{ | ||
filters: [ | ||
{value_col: 'SITEID', label: 'Site ID'}, | ||
{value_col: 'SEX', label: 'Sex'}, | ||
{value_col: 'RACE', label: 'Race'}, | ||
{value_col: 'ARM', label: 'Treatment Group'}, | ||
{value_col: 'USUBJID', label: 'Participant ID'}, | ||
], | ||
} // settings | ||
); | ||
ssp.init(data); | ||
instance.init(data); | ||
} | ||
); |