@oncojs/react-lolliplot
Advanced tools
Comparing version 0.11.8 to 0.11.9
@@ -47,11 +47,8 @@ import invariant from 'invariant'; | ||
min = Math.floor(min); | ||
max = Math.round(max); | ||
var xTickInt = (max - min) / numXTicks; | ||
var length = (max - min) / numXTicks; | ||
var uniqueXTicks = uniq(range(numXTicks - 1).map(function (x) { | ||
return x + 1; | ||
}).map(function (i) { | ||
return Math.round(length * i + min); | ||
return Math.round(xTickInt * i + min); | ||
})); | ||
@@ -61,6 +58,6 @@ | ||
var xTickInt = numUniqueXTicks.length === 1 ? 1 : uniqueXTicks[1] - uniqueXTicks[0]; | ||
var xTickDistance = numUniqueXTicks.length === 1 ? 1 : uniqueXTicks[1] - uniqueXTicks[0]; | ||
// min & max are invisible ticks on the far left and right | ||
min = uniqueXTicks[0] - xTickInt; | ||
min = uniqueXTicks[0] - xTickDistance; | ||
max = uniqueXTicks[numUniqueXTicks - 1]; | ||
@@ -84,3 +81,3 @@ | ||
var visibleData = data.filter(function (d) { | ||
return d.x > min && d.x < max; | ||
return d.x >= min && d.x <= max; | ||
}); | ||
@@ -152,7 +149,9 @@ | ||
x1: function x1(d) { | ||
return scaleLinear(d.x); | ||
var x1 = scaleLinear(d.x); | ||
return x1; | ||
}, | ||
y1: height - xAxisOffset, | ||
x2: function x2(d) { | ||
return scaleLinear(d.x); | ||
var x2 = scaleLinear(d.x); | ||
return x2; | ||
}, | ||
@@ -294,2 +293,4 @@ y2: function y2(d) { | ||
var tickXPositions = {}; | ||
d3Root.select('.xTicks').append('g').selectAll('text').data(range(numUniqueXTicks - 1).map(function (x) { | ||
@@ -304,3 +305,5 @@ return x + 1; | ||
x: function x(i) { | ||
return olength * i * scale + yAxisOffset; | ||
var tickX = olength * i * scale + yAxisOffset; | ||
tickXPositions[uniqueXTicks[i - 1]] = tickX; | ||
return tickX; | ||
}, | ||
@@ -314,9 +317,8 @@ y: height - xAxisOffset + 20, | ||
for (var i = 1; i < numUniqueXTicks; i++) { | ||
var _length = domainWidth / numUniqueXTicks; | ||
var x = olength * i * scale + yAxisOffset; | ||
d3Root.select('.xTicks').append('line').attrs({ | ||
class: 'xTick-line-' + i, | ||
x1: _length * i * scale + yAxisOffset, | ||
x1: x, | ||
y1: height - xAxisOffset, | ||
x2: _length * i * scale + yAxisOffset, | ||
x2: x, | ||
y2: height - xAxisOffset + 10, | ||
@@ -323,0 +325,0 @@ stroke: theme.black, |
var uuid = function uuid(a) { | ||
return a ? (a ^ Math.random() * 16 >> a / 4).toString(16) : ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, uuid); | ||
}; | ||
export default uuid; |
@@ -74,11 +74,8 @@ 'use strict'; | ||
min = Math.floor(min); | ||
max = Math.round(max); | ||
var xTickInt = (max - min) / numXTicks; | ||
var length = (max - min) / numXTicks; | ||
var uniqueXTicks = (0, _lodash4.default)((0, _lodash2.default)(numXTicks - 1).map(function (x) { | ||
return x + 1; | ||
}).map(function (i) { | ||
return Math.round(length * i + min); | ||
return Math.round(xTickInt * i + min); | ||
})); | ||
@@ -88,6 +85,6 @@ | ||
var xTickInt = numUniqueXTicks.length === 1 ? 1 : uniqueXTicks[1] - uniqueXTicks[0]; | ||
var xTickDistance = numUniqueXTicks.length === 1 ? 1 : uniqueXTicks[1] - uniqueXTicks[0]; | ||
// min & max are invisible ticks on the far left and right | ||
min = uniqueXTicks[0] - xTickInt; | ||
min = uniqueXTicks[0] - xTickDistance; | ||
max = uniqueXTicks[numUniqueXTicks - 1]; | ||
@@ -111,3 +108,3 @@ | ||
var visibleData = data.filter(function (d) { | ||
return d.x > min && d.x < max; | ||
return d.x >= min && d.x <= max; | ||
}); | ||
@@ -179,7 +176,9 @@ | ||
x1: function x1(d) { | ||
return scaleLinear(d.x); | ||
var x1 = scaleLinear(d.x); | ||
return x1; | ||
}, | ||
y1: height - xAxisOffset, | ||
x2: function x2(d) { | ||
return scaleLinear(d.x); | ||
var x2 = scaleLinear(d.x); | ||
return x2; | ||
}, | ||
@@ -321,2 +320,4 @@ y2: function y2(d) { | ||
var tickXPositions = {}; | ||
d3Root.select('.xTicks').append('g').selectAll('text').data((0, _lodash2.default)(numUniqueXTicks - 1).map(function (x) { | ||
@@ -331,3 +332,5 @@ return x + 1; | ||
x: function x(i) { | ||
return olength * i * scale + yAxisOffset; | ||
var tickX = olength * i * scale + yAxisOffset; | ||
tickXPositions[uniqueXTicks[i - 1]] = tickX; | ||
return tickX; | ||
}, | ||
@@ -341,9 +344,8 @@ y: height - xAxisOffset + 20, | ||
for (var i = 1; i < numUniqueXTicks; i++) { | ||
var _length = domainWidth / numUniqueXTicks; | ||
var x = olength * i * scale + yAxisOffset; | ||
d3Root.select('.xTicks').append('line').attrs({ | ||
class: 'xTick-line-' + i, | ||
x1: _length * i * scale + yAxisOffset, | ||
x1: x, | ||
y1: height - xAxisOffset, | ||
x2: _length * i * scale + yAxisOffset, | ||
x2: x, | ||
y2: height - xAxisOffset + 10, | ||
@@ -350,0 +352,0 @@ stroke: _theme2.default.black, |
@@ -7,3 +7,2 @@ "use strict"; | ||
}; | ||
exports.default = uuid; |
@@ -37,11 +37,8 @@ // @flow | ||
min = Math.floor(min) | ||
max = Math.round(max) | ||
const xTickInt = (max - min) / numXTicks | ||
let length = (max - min) / numXTicks | ||
const uniqueXTicks = uniq( | ||
range(numXTicks - 1) | ||
.map(x => x + 1) | ||
.map(i => Math.round(length * i + min)) | ||
.map(i => Math.round(xTickInt * i + min)) | ||
) | ||
@@ -51,3 +48,3 @@ | ||
const xTickInt = numUniqueXTicks.length === 1 | ||
const xTickDistance = numUniqueXTicks.length === 1 | ||
? 1 | ||
@@ -57,3 +54,3 @@ : uniqueXTicks[1] - uniqueXTicks[0] | ||
// min & max are invisible ticks on the far left and right | ||
min = uniqueXTicks[0] - xTickInt | ||
min = uniqueXTicks[0] - xTickDistance | ||
max = uniqueXTicks[numUniqueXTicks - 1] | ||
@@ -65,3 +62,3 @@ | ||
let root = ReactFauxDOM.createElement(`div`) | ||
const root = ReactFauxDOM.createElement(`div`) | ||
@@ -73,9 +70,9 @@ invariant(root, `Must provide an element or selector!`) | ||
let uniqueSelector = uuid() | ||
let xAxisLength = width - yAxisOffset | ||
let scale = xAxisLength / domainWidth | ||
const uniqueSelector = uuid() | ||
const xAxisLength = width - yAxisOffset | ||
const scale = xAxisLength / domainWidth | ||
let visibleData = data.filter(d => d.x > min && d.x < max) | ||
const visibleData = data.filter(d => d.x >= min && d.x <= max) | ||
let scaleLinear = d3 | ||
const scaleLinear = d3 | ||
.scaleLinear() | ||
@@ -89,3 +86,3 @@ .domain([min, max]) | ||
let scaleLinearY = d3 | ||
const scaleLinearY = d3 | ||
.scaleLinear() | ||
@@ -170,5 +167,11 @@ .domain([-highestValue / numXTicks, highestValue]) | ||
'clip-path': `url(#${uniqueSelector}-chart-clip)`, | ||
x1: d => scaleLinear(d.x), | ||
x1: d => { | ||
let x1 = scaleLinear(d.x) | ||
return x1 | ||
}, | ||
y1: height - xAxisOffset, | ||
x2: d => scaleLinear(d.x), | ||
x2: d => { | ||
let x2 = scaleLinear(d.x) | ||
return x2 | ||
}, | ||
y2: d => scaleLinearY(d.y), | ||
@@ -302,2 +305,4 @@ stroke: `rgba(0, 0, 0, 0.2)`, | ||
let tickXPositions = {} | ||
d3Root | ||
@@ -313,3 +318,7 @@ .select(`.xTicks`) | ||
class: i => `xTick-text-${i}`, | ||
x: i => olength * i * scale + yAxisOffset, | ||
x: i => { | ||
let tickX = olength * i * scale + yAxisOffset | ||
tickXPositions[uniqueXTicks[i - 1]] = tickX | ||
return tickX | ||
}, | ||
y: height - xAxisOffset + 20, | ||
@@ -322,4 +331,3 @@ 'font-size': `11px`, | ||
for (let i = 1; i < numUniqueXTicks; i++) { | ||
let length = domainWidth / numUniqueXTicks | ||
const x = olength * i * scale + yAxisOffset | ||
d3Root | ||
@@ -330,5 +338,5 @@ .select(`.xTicks`) | ||
class: `xTick-line-${i}`, | ||
x1: length * i * scale + yAxisOffset, | ||
x1: x, | ||
y1: height - xAxisOffset, | ||
x2: length * i * scale + yAxisOffset, | ||
x2: x, | ||
y2: height - xAxisOffset + 10, | ||
@@ -335,0 +343,0 @@ stroke: theme.black, |
@@ -29,3 +29,3 @@ { | ||
"name": "@oncojs/react-lolliplot", | ||
"version": "0.11.8", | ||
"version": "0.11.9", | ||
"description": "A protein viewer built with d3 (React Component)", | ||
@@ -32,0 +32,0 @@ "browser": "dist/umd/index.min.js", |
let uuid = a => a | ||
? (a ^ Math.random() * 16 >> a / 4).toString(16) | ||
: ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, uuid) | ||
export default uuid |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1359269
9727