@oncojs/survivalplot
Advanced tools
Comparing version 0.3.4 to 0.3.5
@@ -1,10 +0,14 @@ | ||
var _ = require('lodash'); | ||
var d3 = require('d3'); | ||
var defaultsDeep = require('lodash.defaultsdeep'); | ||
var uniqueId = require('lodash.uniqueid'); | ||
var inRange = require('lodash.inrange'); | ||
function noop() {} | ||
var linearScale = d3.scale ? d3.scale.linear : d3.scaleLinear; | ||
var defaultOptions = { | ||
onMouseEnterDonor: _.noop, | ||
onMouseLeaveDonor: _.noop, | ||
onClickDonor: _.noop, | ||
onMouseEnterDonor: noop, | ||
onMouseLeaveDonor: noop, | ||
onClickDonor: noop, | ||
palette: ['#0e6402', '#c20127', '#00005d'], | ||
@@ -22,14 +26,15 @@ xAxisLabel: 'Duration (days)', | ||
export function renderPlot(params) { | ||
var _$defaultsDeep = _.defaultsDeep({}, params, defaultOptions), | ||
container = _$defaultsDeep.container, | ||
dataSets = _$defaultsDeep.dataSets, | ||
disabledDataSets = _$defaultsDeep.disabledDataSets, | ||
onMouseEnterDonor = _$defaultsDeep.onMouseEnterDonor, | ||
onMouseLeaveDonor = _$defaultsDeep.onMouseLeaveDonor, | ||
onClickDonor = _$defaultsDeep.onClickDonor, | ||
palette = _$defaultsDeep.palette, | ||
xAxisLabel = _$defaultsDeep.xAxisLabel, | ||
yAxisLabel = _$defaultsDeep.yAxisLabel, | ||
margins = _$defaultsDeep.margins, | ||
getSetSymbol = _$defaultsDeep.getSetSymbol; | ||
var _defaultsDeep = defaultsDeep({}, params, defaultOptions), | ||
container = _defaultsDeep.container, | ||
dataSets = _defaultsDeep.dataSets, | ||
_defaultsDeep$disable = _defaultsDeep.disabledDataSets, | ||
disabledDataSets = _defaultsDeep$disable === undefined ? [] : _defaultsDeep$disable, | ||
onMouseEnterDonor = _defaultsDeep.onMouseEnterDonor, | ||
onMouseLeaveDonor = _defaultsDeep.onMouseLeaveDonor, | ||
onClickDonor = _defaultsDeep.onClickDonor, | ||
palette = _defaultsDeep.palette, | ||
xAxisLabel = _defaultsDeep.xAxisLabel, | ||
yAxisLabel = _defaultsDeep.yAxisLabel, | ||
margins = _defaultsDeep.margins, | ||
getSetSymbol = _defaultsDeep.getSetSymbol; | ||
@@ -53,4 +58,4 @@ var svg = d3.select(container).selectAll('svg'); | ||
var longestDuration = _.max(dataSets.filter(function (data) { | ||
return !_.includes(disabledDataSets, data) && data.donors.length; | ||
var longestDuration = Math.max.apply(Math, dataSets.filter(function (data) { | ||
return disabledDataSets.indexOf(data) < 0 && data.donors.length; | ||
}).map(function (data) { | ||
@@ -91,15 +96,27 @@ return data.donors.slice(-1)[0].time; | ||
var brush = d3.svg ? d3.svg.brush().x(x) : d3.brushX(); | ||
brush.on('brushend', function brushend() { | ||
var extent = brush.extent(); | ||
svg.select('.brush').call(brush.clear()); | ||
if (extent[1] - extent[0] > 1) { | ||
onDomainChange(extent); | ||
function brushed(selection) { | ||
if (selection[1] - selection[0] > 1) { | ||
onDomainChange(selection); | ||
} | ||
}); | ||
} | ||
var brush; | ||
if (d3.svg) { | ||
brush = d3.svg.brush().x(x).on('brushend', function brushend() { | ||
var extent = brush.extent(); | ||
svg.select('.brush').call(brush.clear()); | ||
brushed(extent); | ||
}); | ||
} else { | ||
brush = d3.brushX().extent([[0, 0], [axisWidth, axisHeight]]).on('end', function () { | ||
var selection = d3.event.selection; | ||
if (!selection) return; | ||
wrapper.select('.brush').call(brush.move, null); | ||
brushed(selection); | ||
}); | ||
} | ||
wrapper.append('svg:g').attr('class', 'brush').call(brush).selectAll('rect').attr('height', axisHeight); | ||
var maskName = 'mask_' + _.uniqueId(); | ||
var maskName = 'mask_' + uniqueId(); | ||
@@ -109,6 +126,9 @@ svg.append('svg:clipPath').attr('id', maskName).append('svg:rect').attr('x', 0).attr('y', -10).attr('width', axisWidth).attr('height', axisHeight + margins.top); | ||
dataSets.forEach(function (data, i) { | ||
if (_.includes(disabledDataSets, data)) { | ||
if (disabledDataSets.indexOf(data) >= 0) { | ||
return; | ||
} | ||
var line = d3.svg.area().interpolate('step-before').x(function (p) { | ||
var line = d3.svg ? d3.svg.area().interpolate('step-before') : d3.area().curve(d3.curveStepBefore); | ||
line.x(function (p) { | ||
return x(p.x); | ||
@@ -124,3 +144,3 @@ }).y(function (p) { | ||
var donorsInRange = data.donors.filter(function (donor, i, arr) { | ||
return _.inRange(donor.time, xDomain[0], xDomain[1] + 1) || arr[i - 1] && donor.time >= xDomain[1] && arr[i - 1].time <= xDomain[1] || arr[i + 1] && donor.time <= xDomain[0] && arr[i + 1].time >= xDomain[0]; | ||
return inRange(donor.time, xDomain[0], xDomain[1] + 1) || arr[i - 1] && donor.time >= xDomain[1] && arr[i - 1].time <= xDomain[1] || arr[i + 1] && donor.time <= xDomain[0] && arr[i + 1].time >= xDomain[0]; | ||
}); | ||
@@ -127,0 +147,0 @@ |
@@ -5,11 +5,15 @@ 'use strict'; | ||
exports.renderPlot = renderPlot; | ||
var _ = require('lodash'); | ||
var d3 = require('d3'); | ||
var defaultsDeep = require('lodash.defaultsdeep'); | ||
var uniqueId = require('lodash.uniqueid'); | ||
var inRange = require('lodash.inrange'); | ||
function noop() {} | ||
var linearScale = d3.scale ? d3.scale.linear : d3.scaleLinear; | ||
var defaultOptions = { | ||
onMouseEnterDonor: _.noop, | ||
onMouseLeaveDonor: _.noop, | ||
onClickDonor: _.noop, | ||
onMouseEnterDonor: noop, | ||
onMouseLeaveDonor: noop, | ||
onClickDonor: noop, | ||
palette: ['#0e6402', '#c20127', '#00005d'], | ||
@@ -27,14 +31,15 @@ xAxisLabel: 'Duration (days)', | ||
function renderPlot(params) { | ||
var _$defaultsDeep = _.defaultsDeep({}, params, defaultOptions), | ||
container = _$defaultsDeep.container, | ||
dataSets = _$defaultsDeep.dataSets, | ||
disabledDataSets = _$defaultsDeep.disabledDataSets, | ||
onMouseEnterDonor = _$defaultsDeep.onMouseEnterDonor, | ||
onMouseLeaveDonor = _$defaultsDeep.onMouseLeaveDonor, | ||
onClickDonor = _$defaultsDeep.onClickDonor, | ||
palette = _$defaultsDeep.palette, | ||
xAxisLabel = _$defaultsDeep.xAxisLabel, | ||
yAxisLabel = _$defaultsDeep.yAxisLabel, | ||
margins = _$defaultsDeep.margins, | ||
getSetSymbol = _$defaultsDeep.getSetSymbol; | ||
var _defaultsDeep = defaultsDeep({}, params, defaultOptions), | ||
container = _defaultsDeep.container, | ||
dataSets = _defaultsDeep.dataSets, | ||
_defaultsDeep$disable = _defaultsDeep.disabledDataSets, | ||
disabledDataSets = _defaultsDeep$disable === undefined ? [] : _defaultsDeep$disable, | ||
onMouseEnterDonor = _defaultsDeep.onMouseEnterDonor, | ||
onMouseLeaveDonor = _defaultsDeep.onMouseLeaveDonor, | ||
onClickDonor = _defaultsDeep.onClickDonor, | ||
palette = _defaultsDeep.palette, | ||
xAxisLabel = _defaultsDeep.xAxisLabel, | ||
yAxisLabel = _defaultsDeep.yAxisLabel, | ||
margins = _defaultsDeep.margins, | ||
getSetSymbol = _defaultsDeep.getSetSymbol; | ||
@@ -58,4 +63,4 @@ var svg = d3.select(container).selectAll('svg'); | ||
var longestDuration = _.max(dataSets.filter(function (data) { | ||
return !_.includes(disabledDataSets, data) && data.donors.length; | ||
var longestDuration = Math.max.apply(Math, dataSets.filter(function (data) { | ||
return disabledDataSets.indexOf(data) < 0 && data.donors.length; | ||
}).map(function (data) { | ||
@@ -96,15 +101,27 @@ return data.donors.slice(-1)[0].time; | ||
var brush = d3.svg ? d3.svg.brush().x(x) : d3.brushX(); | ||
brush.on('brushend', function brushend() { | ||
var extent = brush.extent(); | ||
svg.select('.brush').call(brush.clear()); | ||
if (extent[1] - extent[0] > 1) { | ||
onDomainChange(extent); | ||
function brushed(selection) { | ||
if (selection[1] - selection[0] > 1) { | ||
onDomainChange(selection); | ||
} | ||
}); | ||
} | ||
var brush; | ||
if (d3.svg) { | ||
brush = d3.svg.brush().x(x).on('brushend', function brushend() { | ||
var extent = brush.extent(); | ||
svg.select('.brush').call(brush.clear()); | ||
brushed(extent); | ||
}); | ||
} else { | ||
brush = d3.brushX().extent([[0, 0], [axisWidth, axisHeight]]).on('end', function () { | ||
var selection = d3.event.selection; | ||
if (!selection) return; | ||
wrapper.select('.brush').call(brush.move, null); | ||
brushed(selection); | ||
}); | ||
} | ||
wrapper.append('svg:g').attr('class', 'brush').call(brush).selectAll('rect').attr('height', axisHeight); | ||
var maskName = 'mask_' + _.uniqueId(); | ||
var maskName = 'mask_' + uniqueId(); | ||
@@ -114,6 +131,9 @@ svg.append('svg:clipPath').attr('id', maskName).append('svg:rect').attr('x', 0).attr('y', -10).attr('width', axisWidth).attr('height', axisHeight + margins.top); | ||
dataSets.forEach(function (data, i) { | ||
if (_.includes(disabledDataSets, data)) { | ||
if (disabledDataSets.indexOf(data) >= 0) { | ||
return; | ||
} | ||
var line = d3.svg.area().interpolate('step-before').x(function (p) { | ||
var line = d3.svg ? d3.svg.area().interpolate('step-before') : d3.area().curve(d3.curveStepBefore); | ||
line.x(function (p) { | ||
return x(p.x); | ||
@@ -129,3 +149,3 @@ }).y(function (p) { | ||
var donorsInRange = data.donors.filter(function (donor, i, arr) { | ||
return _.inRange(donor.time, xDomain[0], xDomain[1] + 1) || arr[i - 1] && donor.time >= xDomain[1] && arr[i - 1].time <= xDomain[1] || arr[i + 1] && donor.time <= xDomain[0] && arr[i + 1].time >= xDomain[0]; | ||
return inRange(donor.time, xDomain[0], xDomain[1] + 1) || arr[i - 1] && donor.time >= xDomain[1] && arr[i - 1].time <= xDomain[1] || arr[i + 1] && donor.time <= xDomain[0] && arr[i + 1].time >= xDomain[0]; | ||
}); | ||
@@ -132,0 +152,0 @@ |
74
index.js
@@ -1,10 +0,14 @@ | ||
const _ = require('lodash') | ||
const d3 = require('d3') | ||
const defaultsDeep = require('lodash.defaultsdeep') | ||
const uniqueId = require('lodash.uniqueid') | ||
const inRange = require('lodash.inrange') | ||
function noop() {} | ||
const linearScale = d3.scale ? d3.scale.linear : d3.scaleLinear | ||
const defaultOptions = { | ||
onMouseEnterDonor: _.noop, | ||
onMouseLeaveDonor: _.noop, | ||
onClickDonor: _.noop, | ||
onMouseEnterDonor: noop, | ||
onMouseLeaveDonor: noop, | ||
onClickDonor: noop, | ||
palette: ['#0e6402', '#c20127', '#00005d'], | ||
@@ -25,3 +29,3 @@ xAxisLabel: 'Duration (days)', | ||
dataSets, | ||
disabledDataSets, | ||
disabledDataSets = [], | ||
onMouseEnterDonor, | ||
@@ -35,3 +39,3 @@ onMouseLeaveDonor, | ||
getSetSymbol, | ||
} = _.defaultsDeep({}, params, defaultOptions) | ||
} = defaultsDeep({}, params, defaultOptions) | ||
@@ -57,9 +61,5 @@ let svg = d3.select(container).selectAll('svg') | ||
var longestDuration = _.max(dataSets | ||
.filter(function (data) { | ||
return !_.includes(disabledDataSets, data) && data.donors.length | ||
}) | ||
.map(function (data) { | ||
return data.donors.slice(-1)[0].time | ||
})) | ||
var longestDuration = Math.max(...dataSets | ||
.filter(data => disabledDataSets.indexOf(data) < 0 && data.donors.length) | ||
.map(data => data.donors.slice(-1)[0].time)) | ||
@@ -124,14 +124,27 @@ var xDomain = params.xDomain || [0, longestDuration] | ||
var brush = d3.svg | ||
? d3.svg.brush().x(x) | ||
: d3.brushX() | ||
brush.on('brushend', function brushend() { | ||
var extent = brush.extent() | ||
svg.select('.brush').call(brush.clear()) | ||
if (extent[1] - extent[0] > 1) { | ||
onDomainChange(extent) | ||
function brushed(selection) { | ||
if (selection[1] - selection[0] > 1) { | ||
onDomainChange(selection) | ||
} | ||
}) | ||
} | ||
var brush; | ||
if(d3.svg) { | ||
brush = d3.svg.brush().x(x) | ||
.on('brushend', function brushend() { | ||
var extent = brush.extent() | ||
svg.select('.brush').call(brush.clear()) | ||
brushed(extent); | ||
}) | ||
} else { | ||
brush = d3.brushX() | ||
.extent([[0, 0], [axisWidth, axisHeight]]) | ||
.on('end', function() { | ||
var selection = d3.event.selection; | ||
if (!selection) return; | ||
wrapper.select('.brush').call(brush.move, null) | ||
brushed(selection); | ||
}) | ||
} | ||
wrapper.append('svg:g') | ||
@@ -143,3 +156,3 @@ .attr('class', 'brush') | ||
var maskName = 'mask_' + _.uniqueId() | ||
var maskName = 'mask_' + uniqueId() | ||
@@ -155,8 +168,11 @@ svg.append('svg:clipPath') | ||
dataSets.forEach(function (data, i) { | ||
if (_.includes(disabledDataSets, data)) { | ||
if (disabledDataSets.indexOf(data) >= 0) { | ||
return | ||
} | ||
var line = d3.svg.area() | ||
.interpolate('step-before') | ||
.x(function(p) { return x(p.x) }) | ||
var line = d3.svg | ||
? d3.svg.area().interpolate('step-before') | ||
: d3.area().curve(d3.curveStepBefore) | ||
line.x(function(p) { return x(p.x) }) | ||
.y(function(p) { return y(p.y) }) | ||
@@ -173,3 +189,3 @@ | ||
var donorsInRange = data.donors.filter(function (donor, i, arr) { | ||
return _.inRange(donor.time, xDomain[0], xDomain[1] + 1) || | ||
return inRange(donor.time, xDomain[0], xDomain[1] + 1) || | ||
( arr[i - 1] && donor.time >= xDomain[1] && arr[i - 1].time <= xDomain[1] ) || | ||
@@ -176,0 +192,0 @@ ( arr[i + 1] && donor.time <= xDomain[0] && arr[i + 1].time >= xDomain[0] ) |
@@ -17,11 +17,14 @@ { | ||
"name": "@oncojs/survivalplot", | ||
"version": "0.3.4", | ||
"version": "0.3.5", | ||
"browser": "dist/umd/index.min.js", | ||
"main": "dist/lib/index.js", | ||
"dependencies": {}, | ||
"dependencies": { | ||
"lodash.defaultsdeep": "^4.6.0", | ||
"lodash.inrange": "^3.3.6", | ||
"lodash.uniqueid": "^4.0.1" | ||
}, | ||
"peerDependencies": { | ||
"d3": "3", | ||
"lodash": "4" | ||
"d3": "NaN" | ||
}, | ||
"jsnext:main": "dist/es6/index.js" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 2 instances in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
213229
3229
4
5
+ Addedlodash.defaultsdeep@^4.6.0
+ Addedlodash.inrange@^3.3.6
+ Addedlodash.uniqueid@^4.0.1
+ Addedlodash.defaultsdeep@4.6.1(transitive)
+ Addedlodash.inrange@3.3.6(transitive)
+ Addedlodash.uniqueid@4.0.1(transitive)
- Removedd3@3.5.17(transitive)
- Removedlodash@4.17.21(transitive)