Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vx/stats

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vx/stats - npm Package Compare versions

Comparing version 0.0.181 to 0.0.182

258

build/boxplot/BoxPlot.js

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,25 +6,24 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = BoxPlot;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _react = _interopRequireDefault(require("react"));
exports.default = BoxPlot;
var _classnames = _interopRequireDefault(require("classnames"));
var _react = require('react');
var _propTypes = _interopRequireDefault(require("prop-types"));
var _react2 = _interopRequireDefault(_react);
var _group = require("@vx/group");
var _classnames = require('classnames');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _classnames2 = _interopRequireDefault(_classnames);
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
var _propTypes = require('prop-types');
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
var _propTypes2 = _interopRequireDefault(_propTypes);
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
var _group = require('@vx/group');
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function verticalToHorizontal(_ref) {

@@ -35,3 +34,2 @@ var x1 = _ref.x1,

y2 = _ref.y2;
return {

@@ -46,28 +44,28 @@ x1: y1,

BoxPlot.propTypes = {
left: _propTypes2.default.number,
top: _propTypes2.default.number,
className: _propTypes2.default.string,
max: _propTypes2.default.number,
min: _propTypes2.default.number,
firstQuartile: _propTypes2.default.number,
thirdQuartile: _propTypes2.default.number,
median: _propTypes2.default.number,
boxWidth: _propTypes2.default.number,
fill: _propTypes2.default.string,
fillOpacity: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]),
stroke: _propTypes2.default.string,
strokeWidth: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]),
rx: _propTypes2.default.number,
ry: _propTypes2.default.number,
valueScale: _propTypes2.default.func,
outliers: _propTypes2.default.array,
horizontal: _propTypes2.default.bool,
medianProps: _propTypes2.default.object,
maxProps: _propTypes2.default.object,
minProps: _propTypes2.default.object,
boxProps: _propTypes2.default.object,
outlierProps: _propTypes2.default.object,
container: _propTypes2.default.bool,
containerProps: _propTypes2.default.object,
children: _propTypes2.default.func
left: _propTypes.default.number,
top: _propTypes.default.number,
className: _propTypes.default.string,
max: _propTypes.default.number,
min: _propTypes.default.number,
firstQuartile: _propTypes.default.number,
thirdQuartile: _propTypes.default.number,
median: _propTypes.default.number,
boxWidth: _propTypes.default.number,
fill: _propTypes.default.string,
fillOpacity: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
stroke: _propTypes.default.string,
strokeWidth: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
rx: _propTypes.default.number,
ry: _propTypes.default.number,
valueScale: _propTypes.default.func,
outliers: _propTypes.default.array,
horizontal: _propTypes.default.bool,
medianProps: _propTypes.default.object,
maxProps: _propTypes.default.object,
minProps: _propTypes.default.object,
boxProps: _propTypes.default.object,
outlierProps: _propTypes.default.object,
container: _propTypes.default.bool,
containerProps: _propTypes.default.object,
children: _propTypes.default.func
};

@@ -77,5 +75,5 @@

var _ref2$left = _ref2.left,
left = _ref2$left === undefined ? 0 : _ref2$left,
left = _ref2$left === void 0 ? 0 : _ref2$left,
_ref2$top = _ref2.top,
top = _ref2$top === undefined ? 0 : _ref2$top,
top = _ref2$top === void 0 ? 0 : _ref2$top,
className = _ref2.className,

@@ -93,29 +91,27 @@ max = _ref2.max,

_ref2$rx = _ref2.rx,
rx = _ref2$rx === undefined ? 2 : _ref2$rx,
rx = _ref2$rx === void 0 ? 2 : _ref2$rx,
_ref2$ry = _ref2.ry,
ry = _ref2$ry === undefined ? 2 : _ref2$ry,
ry = _ref2$ry === void 0 ? 2 : _ref2$ry,
valueScale = _ref2.valueScale,
_ref2$outliers = _ref2.outliers,
outliers = _ref2$outliers === undefined ? [] : _ref2$outliers,
outliers = _ref2$outliers === void 0 ? [] : _ref2$outliers,
horizontal = _ref2.horizontal,
_ref2$medianProps = _ref2.medianProps,
medianProps = _ref2$medianProps === undefined ? {} : _ref2$medianProps,
medianProps = _ref2$medianProps === void 0 ? {} : _ref2$medianProps,
_ref2$maxProps = _ref2.maxProps,
maxProps = _ref2$maxProps === undefined ? {} : _ref2$maxProps,
maxProps = _ref2$maxProps === void 0 ? {} : _ref2$maxProps,
_ref2$minProps = _ref2.minProps,
minProps = _ref2$minProps === undefined ? {} : _ref2$minProps,
minProps = _ref2$minProps === void 0 ? {} : _ref2$minProps,
_ref2$boxProps = _ref2.boxProps,
boxProps = _ref2$boxProps === undefined ? {} : _ref2$boxProps,
boxProps = _ref2$boxProps === void 0 ? {} : _ref2$boxProps,
_ref2$outlierProps = _ref2.outlierProps,
outlierProps = _ref2$outlierProps === undefined ? {} : _ref2$outlierProps,
outlierProps = _ref2$outlierProps === void 0 ? {} : _ref2$outlierProps,
_ref2$container = _ref2.container,
container = _ref2$container === undefined ? false : _ref2$container,
container = _ref2$container === void 0 ? false : _ref2$container,
_ref2$containerProps = _ref2.containerProps,
containerProps = _ref2$containerProps === undefined ? {} : _ref2$containerProps,
containerProps = _ref2$containerProps === void 0 ? {} : _ref2$containerProps,
children = _ref2.children;
var offset = horizontal ? top : left;
var center = offset + boxWidth / 2;
var valueRange = valueScale.range();
var boxplot = {

@@ -183,87 +179,77 @@ valueRange: valueRange,

if (children) return children(boxplot);
return _react2.default.createElement(
_group.Group,
{ className: (0, _classnames2.default)('vx-boxplot', className) },
outliers.map(function (d, i) {
var cx = horizontal ? valueScale(d) : center;
var cy = horizontal ? center : valueScale(d);
return _react2.default.createElement('circle', _extends({
key: 'vx-boxplot-outlier-' + i,
className: 'vx-boxplot-outlier',
cx: cx,
cy: cy,
r: 4,
stroke: stroke,
strokeWidth: strokeWidth,
fill: fill,
fillOpacity: fillOpacity
}, outlierProps));
}),
_react2.default.createElement('line', _extends({
className: 'vx-boxplot-max',
x1: boxplot.max.x1,
y1: boxplot.max.y1,
x2: boxplot.max.x2,
y2: boxplot.max.y2,
return _react.default.createElement(_group.Group, {
className: (0, _classnames.default)('vx-boxplot', className)
}, outliers.map(function (d, i) {
var cx = horizontal ? valueScale(d) : center;
var cy = horizontal ? center : valueScale(d);
return _react.default.createElement("circle", _extends({
key: "vx-boxplot-outlier-".concat(i),
className: "vx-boxplot-outlier",
cx: cx,
cy: cy,
r: 4,
stroke: stroke,
strokeWidth: strokeWidth
}, maxProps)),
_react2.default.createElement('line', {
className: 'vx-boxplot-max-to-third',
x1: boxplot.maxToThird.x1,
y1: boxplot.maxToThird.y1,
x2: boxplot.maxToThird.x2,
y2: boxplot.maxToThird.y2,
stroke: stroke,
strokeWidth: strokeWidth
}),
_react2.default.createElement('rect', _extends({
className: 'vx-boxplot-box',
x: boxplot.box.x1,
y: boxplot.box.y1,
width: boxplot.box.x2,
height: boxplot.box.y2,
stroke: stroke,
strokeWidth: strokeWidth,
fill: fill,
fillOpacity: fillOpacity,
rx: rx,
ry: ry
}, boxProps)),
_react2.default.createElement('line', _extends({
className: 'vx-boxplot-median',
x1: boxplot.median.x1,
y1: boxplot.median.y1,
x2: boxplot.median.x2,
y2: boxplot.median.y2,
stroke: stroke,
strokeWidth: strokeWidth
}, medianProps)),
_react2.default.createElement('line', {
className: 'vx-boxplot-min-to-first',
x1: boxplot.minToFirst.x1,
y1: boxplot.minToFirst.y1,
x2: boxplot.minToFirst.x2,
y2: boxplot.minToFirst.y2,
stroke: stroke,
strokeWidth: strokeWidth
}),
_react2.default.createElement('line', _extends({
className: 'vx-boxplot-min',
x1: boxplot.min.x1,
y1: boxplot.min.y1,
x2: boxplot.min.x2,
y2: boxplot.min.y2,
stroke: stroke,
strokeWidth: strokeWidth
}, minProps)),
container && _react2.default.createElement('rect', _extends({
x: boxplot.container.x1,
y: boxplot.container.y1,
width: boxplot.container.x2,
height: boxplot.container.y2,
fillOpacity: '0'
}, containerProps))
);
fillOpacity: fillOpacity
}, outlierProps));
}), _react.default.createElement("line", _extends({
className: "vx-boxplot-max",
x1: boxplot.max.x1,
y1: boxplot.max.y1,
x2: boxplot.max.x2,
y2: boxplot.max.y2,
stroke: stroke,
strokeWidth: strokeWidth
}, maxProps)), _react.default.createElement("line", {
className: "vx-boxplot-max-to-third",
x1: boxplot.maxToThird.x1,
y1: boxplot.maxToThird.y1,
x2: boxplot.maxToThird.x2,
y2: boxplot.maxToThird.y2,
stroke: stroke,
strokeWidth: strokeWidth
}), _react.default.createElement("rect", _extends({
className: "vx-boxplot-box",
x: boxplot.box.x1,
y: boxplot.box.y1,
width: boxplot.box.x2,
height: boxplot.box.y2,
stroke: stroke,
strokeWidth: strokeWidth,
fill: fill,
fillOpacity: fillOpacity,
rx: rx,
ry: ry
}, boxProps)), _react.default.createElement("line", _extends({
className: "vx-boxplot-median",
x1: boxplot.median.x1,
y1: boxplot.median.y1,
x2: boxplot.median.x2,
y2: boxplot.median.y2,
stroke: stroke,
strokeWidth: strokeWidth
}, medianProps)), _react.default.createElement("line", {
className: "vx-boxplot-min-to-first",
x1: boxplot.minToFirst.x1,
y1: boxplot.minToFirst.y1,
x2: boxplot.minToFirst.x2,
y2: boxplot.minToFirst.y2,
stroke: stroke,
strokeWidth: strokeWidth
}), _react.default.createElement("line", _extends({
className: "vx-boxplot-min",
x1: boxplot.min.x1,
y1: boxplot.min.y1,
x2: boxplot.min.x2,
y2: boxplot.min.y2,
stroke: stroke,
strokeWidth: strokeWidth
}, minProps)), container && _react.default.createElement("rect", _extends({
x: boxplot.container.x1,
y: boxplot.container.y1,
width: boxplot.container.x2,
height: boxplot.container.y2,
fillOpacity: "0"
}, containerProps)));
}

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,30 +6,27 @@ Object.defineProperty(exports, "__esModule", {

});
var _BoxPlot = require('./boxplot/BoxPlot');
Object.defineProperty(exports, 'BoxPlot', {
Object.defineProperty(exports, "BoxPlot", {
enumerable: true,
get: function get() {
return _interopRequireDefault(_BoxPlot).default;
return _BoxPlot.default;
}
});
var _ViolinPlot = require('./violinplot/ViolinPlot');
Object.defineProperty(exports, 'ViolinPlot', {
Object.defineProperty(exports, "ViolinPlot", {
enumerable: true,
get: function get() {
return _interopRequireDefault(_ViolinPlot).default;
return _ViolinPlot.default;
}
});
var _computeStats = require('./util/computeStats');
Object.defineProperty(exports, 'computeStats', {
Object.defineProperty(exports, "computeStats", {
enumerable: true,
get: function get() {
return _interopRequireDefault(_computeStats).default;
return _computeStats.default;
}
});
var _BoxPlot = _interopRequireDefault(require("./boxplot/BoxPlot"));
var _ViolinPlot = _interopRequireDefault(require("./violinplot/ViolinPlot"));
var _computeStats = _interopRequireDefault(require("./util/computeStats"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -8,8 +8,15 @@ "use strict";

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function computeStats(numericalArray) {
var points = [].concat(_toConsumableArray(numericalArray)).sort(function (a, b) {
var points = _toConsumableArray(numericalArray).sort(function (a, b) {
return a - b;
});
var sampleSize = points.length;

@@ -19,6 +26,4 @@ var firstQuartile = points[Math.round(sampleSize / 4)];

var IQR = thirdQuartile - firstQuartile;
var min = firstQuartile - 1.5 * IQR;
var max = thirdQuartile + 1.5 * IQR;
var outliers = points.filter(function (p) {

@@ -30,3 +35,2 @@ return p < min || p > max;

var actualBinWidth = (max - min) / binNum;
var bins = Array(binNum + 2).fill(0);

@@ -40,3 +44,2 @@ var values = Array(binNum + 2).fill(min);

values[values.length - 1] = max;
points.filter(function (p) {

@@ -47,3 +50,2 @@ return p >= min && p <= max;

});
var binData = values.map(function (v, i) {

@@ -55,3 +57,2 @@ return {

});
var boxPlot = {

@@ -65,3 +66,2 @@ min: min,

};
return {

@@ -68,0 +68,0 @@ boxPlot: boxPlot,

@@ -1,2 +0,2 @@

'use strict';
"use strict";

@@ -6,40 +6,41 @@ Object.defineProperty(exports, "__esModule", {

});
exports.default = ViolinPlot;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _react = _interopRequireDefault(require("react"));
exports.default = ViolinPlot;
var _classnames = _interopRequireDefault(require("classnames"));
var _react = require('react');
var _propTypes = _interopRequireDefault(require("prop-types"));
var _react2 = _interopRequireDefault(_react);
var _scale = require("@vx/scale");
var _classnames = require('classnames');
var _d3Shape = require("d3-shape");
var _classnames2 = _interopRequireDefault(_classnames);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _propTypes = require('prop-types');
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
var _propTypes2 = _interopRequireDefault(_propTypes);
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
var _scale = require('@vx/scale');
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
var _d3Shape = require('d3-shape');
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
ViolinPlot.propTypes = {
left: _propTypes2.default.number,
top: _propTypes2.default.number,
className: _propTypes2.default.string,
data: _propTypes2.default.array.isRequired,
width: _propTypes2.default.number,
count: _propTypes2.default.func,
value: _propTypes2.default.func,
valueScale: _propTypes2.default.func,
horizontal: _propTypes2.default.bool,
children: _propTypes2.default.func
left: _propTypes.default.number,
top: _propTypes.default.number,
className: _propTypes.default.string,
data: _propTypes.default.array.isRequired,
width: _propTypes.default.number,
count: _propTypes.default.func,
value: _propTypes.default.func,
valueScale: _propTypes.default.func,
horizontal: _propTypes.default.bool,
children: _propTypes.default.func
};

@@ -49,5 +50,5 @@

var _ref$left = _ref.left,
left = _ref$left === undefined ? 0 : _ref$left,
left = _ref$left === void 0 ? 0 : _ref$left,
_ref$top = _ref.top,
top = _ref$top === undefined ? 0 : _ref$top,
top = _ref$top === void 0 ? 0 : _ref$top,
className = _ref.className,

@@ -57,7 +58,7 @@ data = _ref.data,

_ref$count = _ref.count,
count = _ref$count === undefined ? function (d) {
count = _ref$count === void 0 ? function (d) {
return d.count;
} : _ref$count,
_ref$value = _ref.value,
value = _ref$value === undefined ? function (d) {
value = _ref$value === void 0 ? function (d) {
return d.value;

@@ -68,3 +69,3 @@ } : _ref$value,

children = _ref.children,
restProps = _objectWithoutProperties(_ref, ['left', 'top', 'className', 'data', 'width', 'count', 'value', 'valueScale', 'horizontal', 'children']);
restProps = _objectWithoutProperties(_ref, ["left", "top", "className", "data", "width", "count", "value", "valueScale", "horizontal", "children"]);

@@ -79,3 +80,2 @@ var center = (horizontal ? top : left) + width / 2;

});
var path = '';

@@ -89,3 +89,2 @@

}).curve(_d3Shape.curveCardinal);
var bottomCurve = (0, _d3Shape.line)().x(function (d) {

@@ -96,6 +95,5 @@ return valueScale(value(d));

}).curve(_d3Shape.curveCardinal);
var topCurvePath = topCurve(data);
var bottomCurvePath = bottomCurve([].concat(_toConsumableArray(data)).reverse());
path = topCurvePath + ' ' + bottomCurvePath.replace('M', 'L') + ' Z';
var bottomCurvePath = bottomCurve(_toConsumableArray(data).reverse());
path = "".concat(topCurvePath, " ").concat(bottomCurvePath.replace('M', 'L'), " Z");
} else {

@@ -107,3 +105,2 @@ var rightCurve = (0, _d3Shape.line)().x(function (d) {

}).curve(_d3Shape.curveCardinal);
var leftCurve = (0, _d3Shape.line)().x(function (d) {

@@ -114,9 +111,14 @@ return center - widthScale(count(d));

}).curve(_d3Shape.curveCardinal);
var rightCurvePath = rightCurve(data);
var leftCurvePath = leftCurve([].concat(_toConsumableArray(data)).reverse());
path = rightCurvePath + ' ' + leftCurvePath.replace('M', 'L') + ' Z';
var leftCurvePath = leftCurve(_toConsumableArray(data).reverse());
path = "".concat(rightCurvePath, " ").concat(leftCurvePath.replace('M', 'L'), " Z");
}
if (children) return children({ path: path });
return _react2.default.createElement('path', _extends({ className: (0, _classnames2.default)('vx-violin', className), d: path }, restProps));
if (children) return children({
path: path
});
return _react.default.createElement("path", _extends({
className: (0, _classnames.default)('vx-violin', className),
d: path
}, restProps));
}

@@ -0,44 +1,82 @@

import { Group } from '@vx/group';
import React from 'react';
import classnames from 'classnames';
import PropTypes from 'prop-types';
import { Group } from '@vx/group';
import { scaleLinear } from '@vx/scale';
import { line, curveCardinal } from 'd3-shape';
var _extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
};
}
var objectWithoutProperties = function (obj, keys) {
var target = {};
function _objectWithoutProperties(source, excluded) {
if (source == null) return {};
for (var i in obj) {
if (keys.indexOf(i) >= 0) continue;
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
target[i] = obj[i];
var target = _objectWithoutPropertiesLoose(source, excluded);
var key, i;
if (Object.getOwnPropertySymbols) {
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
for (i = 0; i < sourceSymbolKeys.length; i++) {
key = sourceSymbolKeys[i];
if (excluded.indexOf(key) >= 0) continue;
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
target[key] = source[key];
}
}
return target;
};
}
var toConsumableArray = function (arr) {
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
} else {
return Array.from(arr);
}
};
}
function _iterableToArray(iter) {
if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance");
}
function verticalToHorizontal(_ref) {

@@ -49,3 +87,2 @@ var x1 = _ref.x1,

y2 = _ref.y2;
return {

@@ -87,8 +124,7 @@ x1: y1,

};
function BoxPlot(_ref2) {
var _ref2$left = _ref2.left,
left = _ref2$left === undefined ? 0 : _ref2$left,
left = _ref2$left === void 0 ? 0 : _ref2$left,
_ref2$top = _ref2.top,
top = _ref2$top === undefined ? 0 : _ref2$top,
top = _ref2$top === void 0 ? 0 : _ref2$top,
className = _ref2.className,

@@ -106,29 +142,27 @@ max = _ref2.max,

_ref2$rx = _ref2.rx,
rx = _ref2$rx === undefined ? 2 : _ref2$rx,
rx = _ref2$rx === void 0 ? 2 : _ref2$rx,
_ref2$ry = _ref2.ry,
ry = _ref2$ry === undefined ? 2 : _ref2$ry,
ry = _ref2$ry === void 0 ? 2 : _ref2$ry,
valueScale = _ref2.valueScale,
_ref2$outliers = _ref2.outliers,
outliers = _ref2$outliers === undefined ? [] : _ref2$outliers,
outliers = _ref2$outliers === void 0 ? [] : _ref2$outliers,
horizontal = _ref2.horizontal,
_ref2$medianProps = _ref2.medianProps,
medianProps = _ref2$medianProps === undefined ? {} : _ref2$medianProps,
medianProps = _ref2$medianProps === void 0 ? {} : _ref2$medianProps,
_ref2$maxProps = _ref2.maxProps,
maxProps = _ref2$maxProps === undefined ? {} : _ref2$maxProps,
maxProps = _ref2$maxProps === void 0 ? {} : _ref2$maxProps,
_ref2$minProps = _ref2.minProps,
minProps = _ref2$minProps === undefined ? {} : _ref2$minProps,
minProps = _ref2$minProps === void 0 ? {} : _ref2$minProps,
_ref2$boxProps = _ref2.boxProps,
boxProps = _ref2$boxProps === undefined ? {} : _ref2$boxProps,
boxProps = _ref2$boxProps === void 0 ? {} : _ref2$boxProps,
_ref2$outlierProps = _ref2.outlierProps,
outlierProps = _ref2$outlierProps === undefined ? {} : _ref2$outlierProps,
outlierProps = _ref2$outlierProps === void 0 ? {} : _ref2$outlierProps,
_ref2$container = _ref2.container,
container = _ref2$container === undefined ? false : _ref2$container,
container = _ref2$container === void 0 ? false : _ref2$container,
_ref2$containerProps = _ref2.containerProps,
containerProps = _ref2$containerProps === undefined ? {} : _ref2$containerProps,
containerProps = _ref2$containerProps === void 0 ? {} : _ref2$containerProps,
children = _ref2.children;
var offset = horizontal ? top : left;
var center = offset + boxWidth / 2;
var valueRange = valueScale.range();
var boxplot = {

@@ -178,3 +212,3 @@ valueRange: valueRange,

x2: boxWidth,
y1: Math.min.apply(Math, toConsumableArray(valueRange)),
y1: Math.min.apply(Math, _toConsumableArray(valueRange)),
y2: Math.abs(valueRange[0] - valueRange[1])

@@ -193,91 +227,81 @@ }

boxplot.container = verticalToHorizontal(boxplot.container);
boxplot.container.y1 = Math.min.apply(Math, toConsumableArray(valueRange));
boxplot.container.y1 = Math.min.apply(Math, _toConsumableArray(valueRange));
}
if (children) return children(boxplot);
return React.createElement(
Group,
{ className: classnames('vx-boxplot', className) },
outliers.map(function (d, i) {
var cx = horizontal ? valueScale(d) : center;
var cy = horizontal ? center : valueScale(d);
return React.createElement('circle', _extends({
key: 'vx-boxplot-outlier-' + i,
className: 'vx-boxplot-outlier',
cx: cx,
cy: cy,
r: 4,
stroke: stroke,
strokeWidth: strokeWidth,
fill: fill,
fillOpacity: fillOpacity
}, outlierProps));
}),
React.createElement('line', _extends({
className: 'vx-boxplot-max',
x1: boxplot.max.x1,
y1: boxplot.max.y1,
x2: boxplot.max.x2,
y2: boxplot.max.y2,
return React.createElement(Group, {
className: classnames('vx-boxplot', className)
}, outliers.map(function (d, i) {
var cx = horizontal ? valueScale(d) : center;
var cy = horizontal ? center : valueScale(d);
return React.createElement("circle", _extends({
key: "vx-boxplot-outlier-".concat(i),
className: "vx-boxplot-outlier",
cx: cx,
cy: cy,
r: 4,
stroke: stroke,
strokeWidth: strokeWidth
}, maxProps)),
React.createElement('line', {
className: 'vx-boxplot-max-to-third',
x1: boxplot.maxToThird.x1,
y1: boxplot.maxToThird.y1,
x2: boxplot.maxToThird.x2,
y2: boxplot.maxToThird.y2,
stroke: stroke,
strokeWidth: strokeWidth
}),
React.createElement('rect', _extends({
className: 'vx-boxplot-box',
x: boxplot.box.x1,
y: boxplot.box.y1,
width: boxplot.box.x2,
height: boxplot.box.y2,
stroke: stroke,
strokeWidth: strokeWidth,
fill: fill,
fillOpacity: fillOpacity,
rx: rx,
ry: ry
}, boxProps)),
React.createElement('line', _extends({
className: 'vx-boxplot-median',
x1: boxplot.median.x1,
y1: boxplot.median.y1,
x2: boxplot.median.x2,
y2: boxplot.median.y2,
stroke: stroke,
strokeWidth: strokeWidth
}, medianProps)),
React.createElement('line', {
className: 'vx-boxplot-min-to-first',
x1: boxplot.minToFirst.x1,
y1: boxplot.minToFirst.y1,
x2: boxplot.minToFirst.x2,
y2: boxplot.minToFirst.y2,
stroke: stroke,
strokeWidth: strokeWidth
}),
React.createElement('line', _extends({
className: 'vx-boxplot-min',
x1: boxplot.min.x1,
y1: boxplot.min.y1,
x2: boxplot.min.x2,
y2: boxplot.min.y2,
stroke: stroke,
strokeWidth: strokeWidth
}, minProps)),
container && React.createElement('rect', _extends({
x: boxplot.container.x1,
y: boxplot.container.y1,
width: boxplot.container.x2,
height: boxplot.container.y2,
fillOpacity: '0'
}, containerProps))
);
fillOpacity: fillOpacity
}, outlierProps));
}), React.createElement("line", _extends({
className: "vx-boxplot-max",
x1: boxplot.max.x1,
y1: boxplot.max.y1,
x2: boxplot.max.x2,
y2: boxplot.max.y2,
stroke: stroke,
strokeWidth: strokeWidth
}, maxProps)), React.createElement("line", {
className: "vx-boxplot-max-to-third",
x1: boxplot.maxToThird.x1,
y1: boxplot.maxToThird.y1,
x2: boxplot.maxToThird.x2,
y2: boxplot.maxToThird.y2,
stroke: stroke,
strokeWidth: strokeWidth
}), React.createElement("rect", _extends({
className: "vx-boxplot-box",
x: boxplot.box.x1,
y: boxplot.box.y1,
width: boxplot.box.x2,
height: boxplot.box.y2,
stroke: stroke,
strokeWidth: strokeWidth,
fill: fill,
fillOpacity: fillOpacity,
rx: rx,
ry: ry
}, boxProps)), React.createElement("line", _extends({
className: "vx-boxplot-median",
x1: boxplot.median.x1,
y1: boxplot.median.y1,
x2: boxplot.median.x2,
y2: boxplot.median.y2,
stroke: stroke,
strokeWidth: strokeWidth
}, medianProps)), React.createElement("line", {
className: "vx-boxplot-min-to-first",
x1: boxplot.minToFirst.x1,
y1: boxplot.minToFirst.y1,
x2: boxplot.minToFirst.x2,
y2: boxplot.minToFirst.y2,
stroke: stroke,
strokeWidth: strokeWidth
}), React.createElement("line", _extends({
className: "vx-boxplot-min",
x1: boxplot.min.x1,
y1: boxplot.min.y1,
x2: boxplot.min.x2,
y2: boxplot.min.y2,
stroke: stroke,
strokeWidth: strokeWidth
}, minProps)), container && React.createElement("rect", _extends({
x: boxplot.container.x1,
y: boxplot.container.y1,
width: boxplot.container.x2,
height: boxplot.container.y2,
fillOpacity: "0"
}, containerProps)));
}

@@ -297,8 +321,7 @@

};
function ViolinPlot(_ref) {
var _ref$left = _ref.left,
left = _ref$left === undefined ? 0 : _ref$left,
left = _ref$left === void 0 ? 0 : _ref$left,
_ref$top = _ref.top,
top = _ref$top === undefined ? 0 : _ref$top,
top = _ref$top === void 0 ? 0 : _ref$top,
className = _ref.className,

@@ -308,7 +331,7 @@ data = _ref.data,

_ref$count = _ref.count,
count = _ref$count === undefined ? function (d) {
count = _ref$count === void 0 ? function (d) {
return d.count;
} : _ref$count,
_ref$value = _ref.value,
value = _ref$value === undefined ? function (d) {
value = _ref$value === void 0 ? function (d) {
return d.value;

@@ -319,3 +342,3 @@ } : _ref$value,

children = _ref.children,
restProps = objectWithoutProperties(_ref, ['left', 'top', 'className', 'data', 'width', 'count', 'value', 'valueScale', 'horizontal', 'children']);
restProps = _objectWithoutProperties(_ref, ["left", "top", "className", "data", "width", "count", "value", "valueScale", "horizontal", "children"]);

@@ -328,5 +351,4 @@ var center = (horizontal ? top : left) + width / 2;

rangeRound: [0, width / 2],
domain: [0, Math.max.apply(Math, toConsumableArray(binCounts))]
domain: [0, Math.max.apply(Math, _toConsumableArray(binCounts))]
});
var path = '';

@@ -340,3 +362,2 @@

}).curve(curveCardinal);
var bottomCurve = line().x(function (d) {

@@ -347,6 +368,5 @@ return valueScale(value(d));

}).curve(curveCardinal);
var topCurvePath = topCurve(data);
var bottomCurvePath = bottomCurve([].concat(toConsumableArray(data)).reverse());
path = topCurvePath + ' ' + bottomCurvePath.replace('M', 'L') + ' Z';
var bottomCurvePath = bottomCurve(_toConsumableArray(data).reverse());
path = "".concat(topCurvePath, " ").concat(bottomCurvePath.replace('M', 'L'), " Z");
} else {

@@ -358,3 +378,2 @@ var rightCurve = line().x(function (d) {

}).curve(curveCardinal);
var leftCurve = line().x(function (d) {

@@ -365,15 +384,21 @@ return center - widthScale(count(d));

}).curve(curveCardinal);
var rightCurvePath = rightCurve(data);
var leftCurvePath = leftCurve([].concat(toConsumableArray(data)).reverse());
path = rightCurvePath + ' ' + leftCurvePath.replace('M', 'L') + ' Z';
var leftCurvePath = leftCurve(_toConsumableArray(data).reverse());
path = "".concat(rightCurvePath, " ").concat(leftCurvePath.replace('M', 'L'), " Z");
}
if (children) return children({ path: path });
return React.createElement('path', _extends({ className: classnames('vx-violin', className), d: path }, restProps));
if (children) return children({
path: path
});
return React.createElement("path", _extends({
className: classnames('vx-violin', className),
d: path
}, restProps));
}
function computeStats(numericalArray) {
var points = [].concat(toConsumableArray(numericalArray)).sort(function (a, b) {
var points = _toConsumableArray(numericalArray).sort(function (a, b) {
return a - b;
});
var sampleSize = points.length;

@@ -383,6 +408,4 @@ var firstQuartile = points[Math.round(sampleSize / 4)];

var IQR = thirdQuartile - firstQuartile;
var min = firstQuartile - 1.5 * IQR;
var max = thirdQuartile + 1.5 * IQR;
var outliers = points.filter(function (p) {

@@ -394,3 +417,2 @@ return p < min || p > max;

var actualBinWidth = (max - min) / binNum;
var bins = Array(binNum + 2).fill(0);

@@ -404,3 +426,2 @@ var values = Array(binNum + 2).fill(min);

values[values.length - 1] = max;
points.filter(function (p) {

@@ -411,3 +432,2 @@ return p >= min && p <= max;

});
var binData = values.map(function (v, i) {

@@ -419,3 +439,2 @@ return {

});
var boxPlot = {

@@ -429,3 +448,2 @@ min: min,

};
return {

@@ -432,0 +450,0 @@ boxPlot: boxPlot,

@@ -1,1 +0,1 @@

!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react"),require("classnames"),require("prop-types"),require("@vx/group"),require("@vx/scale"),require("d3-shape")):"function"==typeof define&&define.amd?define(["exports","react","classnames","prop-types","@vx/group","@vx/scale","d3-shape"],r):r(e.vx=e.vx||{},e.React,e.classNames,e.PropTypes,e.vx,e.vx,e.d3)}(this,function(e,D,G,r,V,M,O){"use strict";D=D&&D.hasOwnProperty("default")?D.default:D,G=G&&G.hasOwnProperty("default")?G.default:G,r=r&&r.hasOwnProperty("default")?r.default:r;var H=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},I=function(e){if(Array.isArray(e)){for(var r=0,t=Array(e.length);r<e.length;r++)t[r]=e[r];return t}return Array.from(e)};function J(e){var r=e.x1,t=e.x2;return{x1:e.y1,x2:e.y2,y1:r,y2:t}}function t(e){var r=e.left,t=void 0===r?0:r,n=e.top,o=void 0===n?0:n,a=e.className,i=e.max,l=e.min,c=e.firstQuartile,u=e.thirdQuartile,s=e.median,x=e.boxWidth,m=e.fill,d=e.fillOpacity,y=e.stroke,f=e.strokeWidth,p=e.rx,h=void 0===p?2:p,v=e.ry,b=void 0===v?2:v,T=e.valueScale,P=e.outliers,g=void 0===P?[]:P,k=e.horizontal,M=e.medianProps,O=void 0===M?{}:M,N=e.maxProps,W=void 0===N?{}:N,j=e.minProps,w=void 0===j?{}:j,E=e.boxProps,q=void 0===E?{}:E,F=e.outlierProps,A=void 0===F?{}:F,Q=e.container,S=void 0!==Q&&Q,z=e.containerProps,C=void 0===z?{}:z,R=e.children,L=k?o:t,Z=L+x/2,_=T.range(),B={valueRange:_,center:Z,offset:L,boxWidth:x,max:{x1:Z-x/4,x2:Z+x/4,y1:T(i),y2:T(i)},maxToThird:{x1:Z,x2:Z,y1:T(i),y2:T(u)},median:{x1:L,x2:L+x,y1:T(s),y2:T(s)},minToFirst:{x1:Z,x2:Z,y1:T(c),y2:T(l)},min:{x1:Z-x/4,x2:Z+x/4,y1:T(l),y2:T(l)},box:{x1:L,x2:x,y1:T(u),y2:Math.abs(T(u)-T(c))},container:{x1:L,x2:x,y1:Math.min.apply(Math,I(_)),y2:Math.abs(_[0]-_[1])}};return k&&(B.max=J(B.max),B.maxToThird=J(B.maxToThird),B.box=J(B.box),B.box.y1=T(c),B.median=J(B.median),B.minToFirst=J(B.minToFirst),B.min=J(B.min),B.container=J(B.container),B.container.y1=Math.min.apply(Math,I(_))),R?R(B):D.createElement(V.Group,{className:G("vx-boxplot",a)},g.map(function(e,r){var t=k?T(e):Z,n=k?Z:T(e);return D.createElement("circle",H({key:"vx-boxplot-outlier-"+r,className:"vx-boxplot-outlier",cx:t,cy:n,r:4,stroke:y,strokeWidth:f,fill:m,fillOpacity:d},A))}),D.createElement("line",H({className:"vx-boxplot-max",x1:B.max.x1,y1:B.max.y1,x2:B.max.x2,y2:B.max.y2,stroke:y,strokeWidth:f},W)),D.createElement("line",{className:"vx-boxplot-max-to-third",x1:B.maxToThird.x1,y1:B.maxToThird.y1,x2:B.maxToThird.x2,y2:B.maxToThird.y2,stroke:y,strokeWidth:f}),D.createElement("rect",H({className:"vx-boxplot-box",x:B.box.x1,y:B.box.y1,width:B.box.x2,height:B.box.y2,stroke:y,strokeWidth:f,fill:m,fillOpacity:d,rx:h,ry:b},q)),D.createElement("line",H({className:"vx-boxplot-median",x1:B.median.x1,y1:B.median.y1,x2:B.median.x2,y2:B.median.y2,stroke:y,strokeWidth:f},O)),D.createElement("line",{className:"vx-boxplot-min-to-first",x1:B.minToFirst.x1,y1:B.minToFirst.y1,x2:B.minToFirst.x2,y2:B.minToFirst.y2,stroke:y,strokeWidth:f}),D.createElement("line",H({className:"vx-boxplot-min",x1:B.min.x1,y1:B.min.y1,x2:B.min.x2,y2:B.min.y2,stroke:y,strokeWidth:f},w)),S&&D.createElement("rect",H({x:B.container.x1,y:B.container.y1,width:B.container.x2,height:B.container.y2,fillOpacity:"0"},C)))}function n(e){var r=e.left,t=void 0===r?0:r,n=e.top,o=void 0===n?0:n,a=e.className,i=e.data,l=e.width,c=e.count,u=void 0===c?function(e){return e.count}:c,s=e.value,x=void 0===s?function(e){return e.value}:s,m=e.valueScale,d=e.horizontal,y=e.children,f=function(e,r){var t={};for(var n in e)0<=r.indexOf(n)||Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t}(e,["left","top","className","data","width","count","value","valueScale","horizontal","children"]),p=(d?o:t)+l/2,h=i.map(function(e){return e.count}),v=M.scaleLinear({rangeRound:[0,l/2],domain:[0,Math.max.apply(Math,I(h))]}),b="";if(d){var T=O.line().x(function(e){return m(x(e))}).y(function(e){return p-v(u(e))}).curve(O.curveCardinal),P=O.line().x(function(e){return m(x(e))}).y(function(e){return p+v(u(e))}).curve(O.curveCardinal);b=T(i)+" "+P([].concat(I(i)).reverse()).replace("M","L")+" Z"}else{var g=O.line().x(function(e){return p+v(u(e))}).y(function(e){return m(x(e))}).curve(O.curveCardinal),k=O.line().x(function(e){return p-v(u(e))}).y(function(e){return m(x(e))}).curve(O.curveCardinal);b=g(i)+" "+k([].concat(I(i)).reverse()).replace("M","L")+" Z"}return y?y({path:b}):D.createElement("path",H({className:G("vx-violin",a),d:b},f))}t.propTypes={left:r.number,top:r.number,className:r.string,max:r.number,min:r.number,firstQuartile:r.number,thirdQuartile:r.number,median:r.number,boxWidth:r.number,fill:r.string,fillOpacity:r.oneOfType([r.number,r.string]),stroke:r.string,strokeWidth:r.oneOfType([r.number,r.string]),rx:r.number,ry:r.number,valueScale:r.func,outliers:r.array,horizontal:r.bool,medianProps:r.object,maxProps:r.object,minProps:r.object,boxProps:r.object,outlierProps:r.object,container:r.bool,containerProps:r.object,children:r.func},n.propTypes={left:r.number,top:r.number,className:r.string,data:r.array.isRequired,width:r.number,count:r.func,value:r.func,valueScale:r.func,horizontal:r.bool,children:r.func},e.BoxPlot=t,e.ViolinPlot=n,e.computeStats=function(e){for(var r=[].concat(I(e)).sort(function(e,r){return e-r}),t=r.length,n=r[Math.round(t/4)],o=r[Math.round(3*t/4)],a=o-n,i=n-1.5*a,l=o+1.5*a,c=r.filter(function(e){return e<i||l<e}),u=2*a*Math.pow(t-c.length,-1/3),s=Math.round((l-i)/u),x=(l-i)/s,m=Array(s+2).fill(0),d=Array(s+2).fill(i),y=1;y<=s;y+=1)d[y]+=x*(y-.5);d[d.length-1]=l,r.filter(function(e){return i<=e&&e<=l}).forEach(function(e){m[Math.floor((e-i)/x)+1]+=1});var f=d.map(function(e,r){return{value:e,count:m[r]}});return{boxPlot:{min:i,firstQuartile:n,median:r[Math.round(t/2)],thirdQuartile:o,max:l,outliers:c},binData:f}},Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@vx/group"),require("react"),require("classnames"),require("prop-types"),require("@vx/scale"),require("d3-shape")):"function"==typeof define&&define.amd?define(["exports","@vx/group","react","classnames","prop-types","@vx/scale","d3-shape"],t):t(e.vx=e.vx||{},e.vx,e.React,e.classNames,e.PropTypes,e.vx,e.d3)}(this,function(e,B,D,G,t,N,E){"use strict";function V(){return(V=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function W(e,t){if(null==e)return{};var r,n,o=function(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)r=i[n],0<=t.indexOf(r)||(o[r]=e[r]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],0<=t.indexOf(r)||Object.prototype.propertyIsEnumerable.call(e,r)&&(o[r]=e[r])}return o}function H(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function J(e){var t=e.x1,r=e.x2;return{x1:e.y1,x2:e.y2,y1:t,y2:r}}function r(e){var t=e.left,r=void 0===t?0:t,n=e.top,o=void 0===n?0:n,i=e.className,a=e.max,l=e.min,c=e.firstQuartile,u=e.thirdQuartile,s=e.median,x=e.boxWidth,m=e.fill,d=e.fillOpacity,y=e.stroke,f=e.strokeWidth,p=e.rx,h=void 0===p?2:p,v=e.ry,b=void 0===v?2:v,T=e.valueScale,g=e.outliers,O=void 0===g?[]:g,P=e.horizontal,k=e.medianProps,j=void 0===k?{}:k,M=e.maxProps,w=void 0===M?{}:M,N=e.minProps,E=void 0===N?{}:N,W=e.boxProps,S=void 0===W?{}:W,q=e.outlierProps,A=void 0===q?{}:q,F=e.container,Q=void 0!==F&&F,z=e.containerProps,C=void 0===z?{}:z,R=e.children,L=P?o:r,I=L+x/2,Z=T.range(),_={valueRange:Z,center:I,offset:L,boxWidth:x,max:{x1:I-x/4,x2:I+x/4,y1:T(a),y2:T(a)},maxToThird:{x1:I,x2:I,y1:T(a),y2:T(u)},median:{x1:L,x2:L+x,y1:T(s),y2:T(s)},minToFirst:{x1:I,x2:I,y1:T(c),y2:T(l)},min:{x1:I-x/4,x2:I+x/4,y1:T(l),y2:T(l)},box:{x1:L,x2:x,y1:T(u),y2:Math.abs(T(u)-T(c))},container:{x1:L,x2:x,y1:Math.min.apply(Math,H(Z)),y2:Math.abs(Z[0]-Z[1])}};return P&&(_.max=J(_.max),_.maxToThird=J(_.maxToThird),_.box=J(_.box),_.box.y1=T(c),_.median=J(_.median),_.minToFirst=J(_.minToFirst),_.min=J(_.min),_.container=J(_.container),_.container.y1=Math.min.apply(Math,H(Z))),R?R(_):D.createElement(B.Group,{className:G("vx-boxplot",i)},O.map(function(e,t){var r=P?T(e):I,n=P?I:T(e);return D.createElement("circle",V({key:"vx-boxplot-outlier-".concat(t),className:"vx-boxplot-outlier",cx:r,cy:n,r:4,stroke:y,strokeWidth:f,fill:m,fillOpacity:d},A))}),D.createElement("line",V({className:"vx-boxplot-max",x1:_.max.x1,y1:_.max.y1,x2:_.max.x2,y2:_.max.y2,stroke:y,strokeWidth:f},w)),D.createElement("line",{className:"vx-boxplot-max-to-third",x1:_.maxToThird.x1,y1:_.maxToThird.y1,x2:_.maxToThird.x2,y2:_.maxToThird.y2,stroke:y,strokeWidth:f}),D.createElement("rect",V({className:"vx-boxplot-box",x:_.box.x1,y:_.box.y1,width:_.box.x2,height:_.box.y2,stroke:y,strokeWidth:f,fill:m,fillOpacity:d,rx:h,ry:b},S)),D.createElement("line",V({className:"vx-boxplot-median",x1:_.median.x1,y1:_.median.y1,x2:_.median.x2,y2:_.median.y2,stroke:y,strokeWidth:f},j)),D.createElement("line",{className:"vx-boxplot-min-to-first",x1:_.minToFirst.x1,y1:_.minToFirst.y1,x2:_.minToFirst.x2,y2:_.minToFirst.y2,stroke:y,strokeWidth:f}),D.createElement("line",V({className:"vx-boxplot-min",x1:_.min.x1,y1:_.min.y1,x2:_.min.x2,y2:_.min.y2,stroke:y,strokeWidth:f},E)),Q&&D.createElement("rect",V({x:_.container.x1,y:_.container.y1,width:_.container.x2,height:_.container.y2,fillOpacity:"0"},C)))}function n(e){var t=e.left,r=void 0===t?0:t,n=e.top,o=void 0===n?0:n,i=e.className,a=e.data,l=e.width,c=e.count,u=void 0===c?function(e){return e.count}:c,s=e.value,x=void 0===s?function(e){return e.value}:s,m=e.valueScale,d=e.horizontal,y=e.children,f=W(e,["left","top","className","data","width","count","value","valueScale","horizontal","children"]),p=(d?o:r)+l/2,h=a.map(function(e){return e.count}),v=N.scaleLinear({rangeRound:[0,l/2],domain:[0,Math.max.apply(Math,H(h))]}),b="";if(d){var T=E.line().x(function(e){return m(x(e))}).y(function(e){return p-v(u(e))}).curve(E.curveCardinal),g=E.line().x(function(e){return m(x(e))}).y(function(e){return p+v(u(e))}).curve(E.curveCardinal),O=T(a),P=g(H(a).reverse());b="".concat(O," ").concat(P.replace("M","L")," Z")}else{var k=E.line().x(function(e){return p+v(u(e))}).y(function(e){return m(x(e))}).curve(E.curveCardinal),j=E.line().x(function(e){return p-v(u(e))}).y(function(e){return m(x(e))}).curve(E.curveCardinal),M=k(a),w=j(H(a).reverse());b="".concat(M," ").concat(w.replace("M","L")," Z")}return y?y({path:b}):D.createElement("path",V({className:G("vx-violin",i),d:b},f))}D=D&&D.hasOwnProperty("default")?D.default:D,G=G&&G.hasOwnProperty("default")?G.default:G,t=t&&t.hasOwnProperty("default")?t.default:t,r.propTypes={left:t.number,top:t.number,className:t.string,max:t.number,min:t.number,firstQuartile:t.number,thirdQuartile:t.number,median:t.number,boxWidth:t.number,fill:t.string,fillOpacity:t.oneOfType([t.number,t.string]),stroke:t.string,strokeWidth:t.oneOfType([t.number,t.string]),rx:t.number,ry:t.number,valueScale:t.func,outliers:t.array,horizontal:t.bool,medianProps:t.object,maxProps:t.object,minProps:t.object,boxProps:t.object,outlierProps:t.object,container:t.bool,containerProps:t.object,children:t.func},n.propTypes={left:t.number,top:t.number,className:t.string,data:t.array.isRequired,width:t.number,count:t.func,value:t.func,valueScale:t.func,horizontal:t.bool,children:t.func},e.BoxPlot=r,e.ViolinPlot=n,e.computeStats=function(e){for(var t=H(e).sort(function(e,t){return e-t}),r=t.length,n=t[Math.round(r/4)],o=t[Math.round(3*r/4)],i=o-n,a=n-1.5*i,l=o+1.5*i,c=t.filter(function(e){return e<a||l<e}),u=2*i*Math.pow(r-c.length,-1/3),s=Math.round((l-a)/u),x=(l-a)/s,m=Array(s+2).fill(0),d=Array(s+2).fill(a),y=1;y<=s;y+=1)d[y]+=x*(y-.5);d[d.length-1]=l,t.filter(function(e){return a<=e&&e<=l}).forEach(function(e){m[Math.floor((e-a)/x)+1]+=1});var f=d.map(function(e,t){return{value:e,count:m[t]}});return{boxPlot:{min:a,firstQuartile:n,median:t[Math.round(r/2)],thirdQuartile:o,max:l,outliers:c},binData:f}},Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "@vx/stats",
"version": "0.0.181",
"version": "0.0.182",
"description": "vx stats box violin",

@@ -15,3 +15,3 @@ "sideEffects": false,

"build:dist": "rm -rf dist && mkdir dist && rollup -c",
"build:babel": "rm -rf build && mkdir build && babel src --out-dir build --ignore node_modules/ --presets stage-0,react,env",
"build:babel": "rm -rf build && mkdir build && babel src --out-dir build --ignore node_modules/ --presets @babel/preset-react,@babel/preset-env",
"prepublish": "npm run build",

@@ -38,4 +38,4 @@ "test": "jest"

"dependencies": {
"@vx/group": "0.0.170",
"@vx/scale": "0.0.179",
"@vx/group": "0.0.182",
"@vx/scale": "0.0.182",
"classnames": "^2.2.5",

@@ -46,9 +46,25 @@ "d3-shape": "^1.2.0",

"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-jest": "^21.2.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/plugin-external-helpers": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-proposal-decorators": "^7.0.0",
"@babel/plugin-proposal-do-expressions": "^7.0.0",
"@babel/plugin-proposal-export-default-from": "^7.0.0",
"@babel/plugin-proposal-export-namespace-from": "^7.0.0",
"@babel/plugin-proposal-function-bind": "^7.0.0",
"@babel/plugin-proposal-function-sent": "^7.0.0",
"@babel/plugin-proposal-json-strings": "^7.0.0",
"@babel/plugin-proposal-logical-assignment-operators": "^7.0.0",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.0.0",
"@babel/plugin-proposal-numeric-separator": "^7.0.0",
"@babel/plugin-proposal-optional-chaining": "^7.0.0",
"@babel/plugin-proposal-pipeline-operator": "^7.0.0",
"@babel/plugin-proposal-throw-expressions": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-syntax-import-meta": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^23.4.2",
"enzyme": "^3.1.0",

@@ -62,4 +78,4 @@ "enzyme-adapter-react-16": "^1.0.2",

"react-test-renderer": "^16.0.0",
"rollup": "^0.59.4",
"rollup-plugin-babel": "^3.0.4",
"rollup": "^0.67.4",
"rollup-plugin-babel": "^4.0.1",
"rollup-plugin-commonjs": "^9.1.3",

@@ -66,0 +82,0 @@ "rollup-plugin-node-resolve": "^3.3.0",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc