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

victory-voronoi

Package Overview
Dependencies
Maintainers
17
Versions
146
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

victory-voronoi - npm Package Compare versions

Comparing version 36.9.1 to 36.9.2-next.0

12

CHANGELOG.md
# victory-voronoi
## 36.9.2-next.0
### Patch Changes
- f6f7cc515: Replace lodash isNil and isNan with native code
- 6e34169a5: Replace lodash isFunction with native code
- Updated dependencies [3f2da66e3]
- Updated dependencies [c13308624]
- Updated dependencies [f6f7cc515]
- Updated dependencies [6e34169a5]
- victory-core@36.9.2-next.0
## 36.9.1

@@ -4,0 +16,0 @@

0

es/helper-methods.d.ts

@@ -0,0 +0,0 @@ import { voronoi as d3Voronoi } from "d3-voronoi";

186

es/helper-methods.js

@@ -1,142 +0,116 @@

import _isNil from "lodash/isNil";
import _without from "lodash/without";
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
// victory-vendor note: This module is still CommonJS, so not part of victory-vendor.
import { voronoi as d3Voronoi } from "d3-voronoi";
import { Helpers, LabelHelpers, Scale, Domain, Data } from "victory-core"; // Re-export for tests
import { Helpers, LabelHelpers, Scale, Domain, Data } from "victory-core";
// Re-export for tests
export { d3Voronoi as _internalD3Voronoi };
var getVoronoi = function (props, range, scale) {
var minRange = [Math.min.apply(Math, _toConsumableArray(range.x)), Math.min.apply(Math, _toConsumableArray(range.y))];
var maxRange = [Math.max.apply(Math, _toConsumableArray(range.x)), Math.max.apply(Math, _toConsumableArray(range.y))];
var angleAccessor = function (d) {
var x = scale.x(d._x1 !== undefined ? d._x1 : d._x);
const getVoronoi = (props, range, scale) => {
const minRange = [Math.min(...range.x), Math.min(...range.y)];
const maxRange = [Math.max(...range.x), Math.max(...range.y)];
const angleAccessor = d => {
const x = scale.x(d._x1 !== undefined ? d._x1 : d._x);
return -1 * x + Math.PI / 2;
};
var xAccessor = function (d) {
const xAccessor = d => {
return props.horizontal ? scale.y(d._y1 !== undefined ? d._y1 : d._y) : scale.x(d._x1 !== undefined ? d._x1 : d._x);
};
var yAccessor = function (d) {
const yAccessor = d => {
return props.horizontal ? scale.x(d._x1 !== undefined ? d._x1 : d._x) : scale.y(d._y1 !== undefined ? d._y1 : d._y);
};
return d3Voronoi().x(function (d) {
return props.polar ? angleAccessor(d) : xAccessor(d);
}).y(function (d) {
return yAccessor(d);
}).extent([minRange, maxRange]);
return d3Voronoi().x(d => props.polar ? angleAccessor(d) : xAccessor(d)).y(d => yAccessor(d)).extent([minRange, maxRange]);
};
var getCalculatedValues = function (props) {
var defaultStyles = props.theme && props.theme.voronoi && props.theme.voronoi.style ? props.theme.voronoi.style : {};
var style = Helpers.getStyles(props.style, defaultStyles);
var range = {
const getCalculatedValues = props => {
const defaultStyles = props.theme && props.theme.voronoi && props.theme.voronoi.style ? props.theme.voronoi.style : {};
const style = Helpers.getStyles(props.style, defaultStyles);
const range = {
x: Helpers.getRange(props, "x"),
y: Helpers.getRange(props, "y")
};
var domain = {
const domain = {
x: Domain.getDomain(props, "x"),
y: Domain.getDomain(props, "y")
};
var scale = {
const scale = {
x: Scale.getBaseScale(props, "x").domain(domain.x).range(props.horizontal ? range.y : range.x),
y: Scale.getBaseScale(props, "y").domain(domain.y).range(props.horizontal ? range.x : range.y)
};
var data = Data.getData(props);
data = Data.formatDataFromDomain(data, domain); // Manually remove data with null _x or _y values.
let data = Data.getData(props);
data = Data.formatDataFromDomain(data, domain);
// Manually remove data with null _x or _y values.
// Otherwise, we hit null error in: d3-voronoi/src/Cell.js
data = data.filter(function (datum) {
data = data.filter(datum => {
if (datum._x === null) {
return false;
}
if (datum._y === null) {
return false;
}
return true;
});
var voronoi = getVoronoi(props, range, scale);
var polygons = voronoi.polygons(data);
var origin = props.polar ? props.origin || Helpers.getPolarOrigin(props) : undefined;
const voronoi = getVoronoi(props, range, scale);
const polygons = voronoi.polygons(data);
const origin = props.polar ? props.origin || Helpers.getPolarOrigin(props) : undefined;
return {
domain: domain,
data: data,
scale: scale,
style: style,
polygons: polygons,
origin: origin
domain,
data,
scale,
style,
polygons,
origin
};
};
export var getBaseProps = function (initialProps, fallbackProps) {
var modifiedProps = Helpers.modifyProps(initialProps, fallbackProps, "scatter");
var props = Object.assign({}, modifiedProps, getCalculatedValues(modifiedProps));
var data = props.data,
domain = props.domain,
events = props.events,
height = props.height,
origin = props.origin,
padding = props.padding,
polar = props.polar,
polygons = props.polygons,
scale = props.scale,
sharedEvents = props.sharedEvents,
standalone = props.standalone,
style = props.style,
theme = props.theme,
width = props.width,
labels = props.labels,
name = props.name;
var initialChildProps = {
export const getBaseProps = (initialProps, fallbackProps) => {
const modifiedProps = Helpers.modifyProps(initialProps, fallbackProps, "scatter");
const props = Object.assign({}, modifiedProps, getCalculatedValues(modifiedProps));
const {
data,
domain,
events,
height,
origin,
padding,
polar,
polygons,
scale,
sharedEvents,
standalone,
style,
theme,
width,
labels,
name
} = props;
const initialChildProps = {
parent: {
style: style.parent,
scale: scale,
domain: domain,
data: data,
standalone: standalone,
height: height,
width: width,
theme: theme,
origin: origin,
polar: polar,
padding: padding,
name: name
scale,
domain,
data,
standalone,
height,
width,
theme,
origin,
polar,
padding,
name
}
};
return data.reduce(function (childProps, datum, index) {
var polygon = _without(polygons[index], "data");
var eventKey = !_isNil(datum.eventKey) ? datum.eventKey : index;
var _Helpers$scalePoint = Helpers.scalePoint(props, datum),
x = _Helpers$scalePoint.x,
y = _Helpers$scalePoint.y;
var dataProps = {
x: x,
y: y,
datum: datum,
data: data,
index: index,
scale: scale,
polygon: polygon,
origin: origin,
return data.reduce((childProps, datum, index) => {
const polygon = _without(polygons[index], "data");
const eventKey = !Helpers.isNil(datum.eventKey) ? datum.eventKey : index;
const {
x,
y
} = Helpers.scalePoint(props, datum);
const dataProps = {
x,
y,
datum,
data,
index,
scale,
polygon,
origin,
size: props.size,

@@ -148,10 +122,8 @@ style: style.data

};
var text = LabelHelpers.getText(props, datum, index);
const text = LabelHelpers.getText(props, datum, index);
if (text !== undefined && text !== null || labels && (events || sharedEvents)) {
childProps[eventKey].labels = LabelHelpers.getProps(props, index);
}
return childProps;
}, initialChildProps);
};
export * from "./victory-voronoi";
export * from "./voronoi";
//# sourceMappingURL=index.d.ts.map

@@ -0,0 +0,0 @@ import React from "react";

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

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
import React from "react";

@@ -25,69 +5,50 @@ import { Helpers, VictoryLabel, addEvents, VictoryContainer, VictoryTheme, DefaultTransitions, Data, Domain, UserProps } from "victory-core";

import { getBaseProps } from "./helper-methods";
var fallbackProps = {
const fallbackProps = {
width: 450,
height: 300,
padding: 50
}; // eslint-disable-next-line @typescript-eslint/no-empty-interface
};
var VictoryVoronoiBase = /*#__PURE__*/function (_React$Component) {
_inherits(VictoryVoronoiBase, _React$Component);
// eslint-disable-next-line @typescript-eslint/no-empty-interface
var _super = _createSuper(VictoryVoronoiBase);
class VictoryVoronoiBase extends React.Component {
static animationWhitelist = ["data", "domain", "height", "padding", "samples", "size", "style", "width"];
static displayName = "VictoryVoronoi";
static role = "voronoi";
static defaultTransitions = DefaultTransitions.discreteTransitions();
static defaultProps = {
containerComponent: /*#__PURE__*/React.createElement(VictoryContainer, null),
dataComponent: /*#__PURE__*/React.createElement(Voronoi, null),
labelComponent: /*#__PURE__*/React.createElement(VictoryLabel, null),
groupComponent: /*#__PURE__*/React.createElement("g", {
role: "presentation"
}),
samples: 50,
sortOrder: "ascending",
standalone: true,
theme: VictoryTheme.grayscale
};
static getDomain = Domain.getDomain;
static getData = Data.getData;
static getBaseProps = props => getBaseProps(props, fallbackProps);
static expectedComponents = ["dataComponent", "labelComponent", "groupComponent", "containerComponent"];
function VictoryVoronoiBase() {
_classCallCheck(this, VictoryVoronoiBase);
return _super.apply(this, arguments);
// Overridden in native versions
shouldAnimate() {
return !!this.props.animate;
}
_createClass(VictoryVoronoiBase, [{
key: "shouldAnimate",
value: // Overridden in native versions
function shouldAnimate() {
return !!this.props.animate;
render() {
const {
animationWhitelist,
role
} = VictoryVoronoi;
const props = Helpers.modifyProps(this.props, fallbackProps, role);
if (this.shouldAnimate()) {
return this.animateComponent(props, animationWhitelist);
}
}, {
key: "render",
value: function render() {
var animationWhitelist = VictoryVoronoi.animationWhitelist,
role = VictoryVoronoi.role;
var props = Helpers.modifyProps(this.props, fallbackProps, role);
if (this.shouldAnimate()) {
return this.animateComponent(props, animationWhitelist);
}
var children = this.renderData(props);
var component = props.standalone ? this.renderContainer(props.containerComponent, children) : children;
return UserProps.withSafeUserProps(component, props);
}
}]);
return VictoryVoronoiBase;
}(React.Component);
VictoryVoronoiBase.animationWhitelist = ["data", "domain", "height", "padding", "samples", "size", "style", "width"];
VictoryVoronoiBase.displayName = "VictoryVoronoi";
VictoryVoronoiBase.role = "voronoi";
VictoryVoronoiBase.defaultTransitions = DefaultTransitions.discreteTransitions();
VictoryVoronoiBase.defaultProps = {
containerComponent: /*#__PURE__*/React.createElement(VictoryContainer, null),
dataComponent: /*#__PURE__*/React.createElement(Voronoi, null),
labelComponent: /*#__PURE__*/React.createElement(VictoryLabel, null),
groupComponent: /*#__PURE__*/React.createElement("g", {
role: "presentation"
}),
samples: 50,
sortOrder: "ascending",
standalone: true,
theme: VictoryTheme.grayscale
};
VictoryVoronoiBase.getDomain = Domain.getDomain;
VictoryVoronoiBase.getData = Data.getData;
VictoryVoronoiBase.getBaseProps = function (props) {
return getBaseProps(props, fallbackProps);
};
VictoryVoronoiBase.expectedComponents = ["dataComponent", "labelComponent", "groupComponent", "containerComponent"];
export var VictoryVoronoi = addEvents(VictoryVoronoiBase);
const children = this.renderData(props);
const component = props.standalone ? this.renderContainer(props.containerComponent, children) : children;
return UserProps.withSafeUserProps(component, props);
}
}
export const VictoryVoronoi = addEvents(VictoryVoronoiBase);

@@ -0,0 +0,0 @@ import React from "react";

@@ -1,17 +0,9 @@

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import React from "react";
import { Helpers, ClipPath, Path, Circle, UserProps } from "victory-core";
var getVoronoiPath = function (props) {
var _props$polygon;
var polygon = props.polygon;
return Array.isArray(polygon) && polygon.length ? "M ".concat((_props$polygon = props.polygon) === null || _props$polygon === void 0 ? void 0 : _props$polygon.join("L"), " Z") : "";
const getVoronoiPath = props => {
const {
polygon
} = props;
return Array.isArray(polygon) && polygon.length ? `M ${props.polygon?.join("L")} Z` : "";
};
function evaluateProps(props) {

@@ -26,17 +18,16 @@ /**

*/
var ariaLabel = Helpers.evaluateProp(props.ariaLabel, props);
var id = Helpers.evaluateProp(props.id, props);
var size = Helpers.evaluateProp(props.size, props);
var style = Helpers.evaluateStyle(props.style, props);
var tabIndex = Helpers.evaluateProp(props.tabIndex, props);
const ariaLabel = Helpers.evaluateProp(props.ariaLabel, props);
const id = Helpers.evaluateProp(props.id, props);
const size = Helpers.evaluateProp(props.size, props);
const style = Helpers.evaluateStyle(props.style, props);
const tabIndex = Helpers.evaluateProp(props.tabIndex, props);
return Object.assign({}, props, {
ariaLabel: ariaLabel,
id: id,
size: size,
style: style,
tabIndex: tabIndex
ariaLabel,
id,
size,
style,
tabIndex
});
}
var defaultProps = {
const defaultProps = {
pathComponent: /*#__PURE__*/React.createElement(Path, null),

@@ -49,48 +40,53 @@ circleComponent: /*#__PURE__*/React.createElement(Circle, null),

};
export var Voronoi = function (initialProps) {
var props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), initialProps));
var ariaLabel = props.ariaLabel,
role = props.role,
shapeRendering = props.shapeRendering,
className = props.className,
events = props.events,
transform = props.transform,
style = props.style,
size = props.size,
tabIndex = props.tabIndex;
var voronoiPath = getVoronoiPath(props);
var sharedProps = _objectSpread({
export const Voronoi = initialProps => {
const props = evaluateProps({
...defaultProps,
...initialProps
});
const {
ariaLabel,
role,
shapeRendering,
className,
events,
transform,
style,
size,
tabIndex
} = props;
const voronoiPath = getVoronoiPath(props);
const sharedProps = {
"aria-label": ariaLabel,
className: className,
role: role,
shapeRendering: shapeRendering,
style: style,
tabIndex: tabIndex,
transform: transform
}, events);
var userProps = UserProps.getSafeUserProps(props);
className,
role,
shapeRendering,
style,
tabIndex,
transform,
...events
};
const userProps = UserProps.getSafeUserProps(props);
if (size) {
var circle = /*#__PURE__*/React.cloneElement(props.circleComponent, _objectSpread(_objectSpread({}, sharedProps), {}, {
key: "".concat(props.id, "-circle-clip"),
clipPath: "url(#".concat(props.clipId, ")"),
const circle = /*#__PURE__*/React.cloneElement(props.circleComponent, {
...sharedProps,
key: `${props.id}-circle-clip`,
clipPath: `url(#${props.clipId})`,
cx: props.x,
cy: props.y,
r: size
}));
var voronoiClipPath = /*#__PURE__*/React.cloneElement(props.clipPathComponent, {
key: "".concat(props.id, "-voronoi-clip"),
});
const voronoiClipPath = /*#__PURE__*/React.cloneElement(props.clipPathComponent, {
key: `${props.id}-voronoi-clip`,
clipId: props.clipId
}, /*#__PURE__*/React.cloneElement(props.pathComponent, {
d: voronoiPath,
className: className
className
}));
return /*#__PURE__*/React.cloneElement(props.groupComponent, {}, [voronoiClipPath, circle]);
}
return /*#__PURE__*/React.cloneElement(props.pathComponent, _objectSpread(_objectSpread(_objectSpread({}, sharedProps), userProps), {}, {
return /*#__PURE__*/React.cloneElement(props.pathComponent, {
...sharedProps,
...userProps,
d: voronoiPath
}));
});
};

@@ -0,0 +0,0 @@ import { voronoi as d3Voronoi } from "d3-voronoi";

@@ -13,149 +13,118 @@ "use strict";

exports.getBaseProps = void 0;
var _isNil2 = _interopRequireDefault(require("lodash/isNil"));
var _without2 = _interopRequireDefault(require("lodash/without"));
var _d3Voronoi = require("d3-voronoi");
var _victoryCore = require("victory-core");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// victory-vendor note: This module is still CommonJS, so not part of victory-vendor.
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
// Re-export for tests
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
var getVoronoi = function (props, range, scale) {
var minRange = [Math.min.apply(Math, _toConsumableArray(range.x)), Math.min.apply(Math, _toConsumableArray(range.y))];
var maxRange = [Math.max.apply(Math, _toConsumableArray(range.x)), Math.max.apply(Math, _toConsumableArray(range.y))];
var angleAccessor = function (d) {
var x = scale.x(d._x1 !== undefined ? d._x1 : d._x);
const getVoronoi = (props, range, scale) => {
const minRange = [Math.min(...range.x), Math.min(...range.y)];
const maxRange = [Math.max(...range.x), Math.max(...range.y)];
const angleAccessor = d => {
const x = scale.x(d._x1 !== undefined ? d._x1 : d._x);
return -1 * x + Math.PI / 2;
};
var xAccessor = function (d) {
const xAccessor = d => {
return props.horizontal ? scale.y(d._y1 !== undefined ? d._y1 : d._y) : scale.x(d._x1 !== undefined ? d._x1 : d._x);
};
var yAccessor = function (d) {
const yAccessor = d => {
return props.horizontal ? scale.x(d._x1 !== undefined ? d._x1 : d._x) : scale.y(d._y1 !== undefined ? d._y1 : d._y);
};
return (0, _d3Voronoi.voronoi)().x(function (d) {
return props.polar ? angleAccessor(d) : xAccessor(d);
}).y(function (d) {
return yAccessor(d);
}).extent([minRange, maxRange]);
return (0, _d3Voronoi.voronoi)().x(d => props.polar ? angleAccessor(d) : xAccessor(d)).y(d => yAccessor(d)).extent([minRange, maxRange]);
};
var getCalculatedValues = function (props) {
var defaultStyles = props.theme && props.theme.voronoi && props.theme.voronoi.style ? props.theme.voronoi.style : {};
var style = _victoryCore.Helpers.getStyles(props.style, defaultStyles);
var range = {
const getCalculatedValues = props => {
const defaultStyles = props.theme && props.theme.voronoi && props.theme.voronoi.style ? props.theme.voronoi.style : {};
const style = _victoryCore.Helpers.getStyles(props.style, defaultStyles);
const range = {
x: _victoryCore.Helpers.getRange(props, "x"),
y: _victoryCore.Helpers.getRange(props, "y")
};
var domain = {
const domain = {
x: _victoryCore.Domain.getDomain(props, "x"),
y: _victoryCore.Domain.getDomain(props, "y")
};
var scale = {
const scale = {
x: _victoryCore.Scale.getBaseScale(props, "x").domain(domain.x).range(props.horizontal ? range.y : range.x),
y: _victoryCore.Scale.getBaseScale(props, "y").domain(domain.y).range(props.horizontal ? range.x : range.y)
};
var data = _victoryCore.Data.getData(props);
data = _victoryCore.Data.formatDataFromDomain(data, domain); // Manually remove data with null _x or _y values.
let data = _victoryCore.Data.getData(props);
data = _victoryCore.Data.formatDataFromDomain(data, domain);
// Manually remove data with null _x or _y values.
// Otherwise, we hit null error in: d3-voronoi/src/Cell.js
data = data.filter(function (datum) {
data = data.filter(datum => {
if (datum._x === null) {
return false;
}
if (datum._y === null) {
return false;
}
return true;
});
var voronoi = getVoronoi(props, range, scale);
var polygons = voronoi.polygons(data);
var origin = props.polar ? props.origin || _victoryCore.Helpers.getPolarOrigin(props) : undefined;
const voronoi = getVoronoi(props, range, scale);
const polygons = voronoi.polygons(data);
const origin = props.polar ? props.origin || _victoryCore.Helpers.getPolarOrigin(props) : undefined;
return {
domain: domain,
data: data,
scale: scale,
style: style,
polygons: polygons,
origin: origin
domain,
data,
scale,
style,
polygons,
origin
};
};
var getBaseProps = function (initialProps, fallbackProps) {
var modifiedProps = _victoryCore.Helpers.modifyProps(initialProps, fallbackProps, "scatter");
var props = Object.assign({}, modifiedProps, getCalculatedValues(modifiedProps));
var data = props.data,
domain = props.domain,
events = props.events,
height = props.height,
origin = props.origin,
padding = props.padding,
polar = props.polar,
polygons = props.polygons,
scale = props.scale,
sharedEvents = props.sharedEvents,
standalone = props.standalone,
style = props.style,
theme = props.theme,
width = props.width,
labels = props.labels,
name = props.name;
var initialChildProps = {
const getBaseProps = (initialProps, fallbackProps) => {
const modifiedProps = _victoryCore.Helpers.modifyProps(initialProps, fallbackProps, "scatter");
const props = Object.assign({}, modifiedProps, getCalculatedValues(modifiedProps));
const {
data,
domain,
events,
height,
origin,
padding,
polar,
polygons,
scale,
sharedEvents,
standalone,
style,
theme,
width,
labels,
name
} = props;
const initialChildProps = {
parent: {
style: style.parent,
scale: scale,
domain: domain,
data: data,
standalone: standalone,
height: height,
width: width,
theme: theme,
origin: origin,
polar: polar,
padding: padding,
name: name
scale,
domain,
data,
standalone,
height,
width,
theme,
origin,
polar,
padding,
name
}
};
return data.reduce(function (childProps, datum, index) {
var polygon = (0, _without2.default)(polygons[index], "data");
var eventKey = !(0, _isNil2.default)(datum.eventKey) ? datum.eventKey : index;
var _Helpers$scalePoint = _victoryCore.Helpers.scalePoint(props, datum),
x = _Helpers$scalePoint.x,
y = _Helpers$scalePoint.y;
var dataProps = {
x: x,
y: y,
datum: datum,
data: data,
index: index,
scale: scale,
polygon: polygon,
origin: origin,
return data.reduce((childProps, datum, index) => {
const polygon = (0, _without2.default)(polygons[index], "data");
const eventKey = !_victoryCore.Helpers.isNil(datum.eventKey) ? datum.eventKey : index;
const {
x,
y
} = _victoryCore.Helpers.scalePoint(props, datum);
const dataProps = {
x,
y,
datum,
data,
index,
scale,
polygon,
origin,
size: props.size,

@@ -167,13 +136,9 @@ style: style.data

};
var text = _victoryCore.LabelHelpers.getText(props, datum, index);
const text = _victoryCore.LabelHelpers.getText(props, datum, index);
if (text !== undefined && text !== null || labels && (events || sharedEvents)) {
childProps[eventKey].labels = _victoryCore.LabelHelpers.getProps(props, index);
}
return childProps;
}, initialChildProps);
};
exports.getBaseProps = getBaseProps;
export * from "./victory-voronoi";
export * from "./voronoi";
//# sourceMappingURL=index.d.ts.map

@@ -6,5 +6,3 @@ "use strict";

});
var _victoryVoronoi = require("./victory-voronoi");
Object.keys(_victoryVoronoi).forEach(function (key) {

@@ -20,5 +18,3 @@ if (key === "default" || key === "__esModule") return;

});
var _voronoi = require("./voronoi");
Object.keys(_voronoi).forEach(function (key) {

@@ -25,0 +21,0 @@ if (key === "default" || key === "__esModule") return;

@@ -0,0 +0,0 @@ import React from "react";

@@ -7,102 +7,55 @@ "use strict";

exports.VictoryVoronoi = void 0;
var _react = _interopRequireDefault(require("react"));
var _victoryCore = require("victory-core");
var _voronoi = require("./voronoi");
var _helperMethods = require("./helper-methods");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
var fallbackProps = {
const fallbackProps = {
width: 450,
height: 300,
padding: 50
}; // eslint-disable-next-line @typescript-eslint/no-empty-interface
};
var VictoryVoronoiBase = /*#__PURE__*/function (_React$Component) {
_inherits(VictoryVoronoiBase, _React$Component);
// eslint-disable-next-line @typescript-eslint/no-empty-interface
var _super = _createSuper(VictoryVoronoiBase);
class VictoryVoronoiBase extends _react.default.Component {
static animationWhitelist = ["data", "domain", "height", "padding", "samples", "size", "style", "width"];
static displayName = "VictoryVoronoi";
static role = "voronoi";
static defaultTransitions = _victoryCore.DefaultTransitions.discreteTransitions();
static defaultProps = {
containerComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryContainer, null),
dataComponent: /*#__PURE__*/_react.default.createElement(_voronoi.Voronoi, null),
labelComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryLabel, null),
groupComponent: /*#__PURE__*/_react.default.createElement("g", {
role: "presentation"
}),
samples: 50,
sortOrder: "ascending",
standalone: true,
theme: _victoryCore.VictoryTheme.grayscale
};
static getDomain = _victoryCore.Domain.getDomain;
static getData = _victoryCore.Data.getData;
static getBaseProps = props => (0, _helperMethods.getBaseProps)(props, fallbackProps);
static expectedComponents = ["dataComponent", "labelComponent", "groupComponent", "containerComponent"];
function VictoryVoronoiBase() {
_classCallCheck(this, VictoryVoronoiBase);
return _super.apply(this, arguments);
// Overridden in native versions
shouldAnimate() {
return !!this.props.animate;
}
_createClass(VictoryVoronoiBase, [{
key: "shouldAnimate",
value: // Overridden in native versions
function shouldAnimate() {
return !!this.props.animate;
render() {
const {
animationWhitelist,
role
} = VictoryVoronoi;
const props = _victoryCore.Helpers.modifyProps(this.props, fallbackProps, role);
if (this.shouldAnimate()) {
return this.animateComponent(props, animationWhitelist);
}
}, {
key: "render",
value: function render() {
var animationWhitelist = VictoryVoronoi.animationWhitelist,
role = VictoryVoronoi.role;
var props = _victoryCore.Helpers.modifyProps(this.props, fallbackProps, role);
if (this.shouldAnimate()) {
return this.animateComponent(props, animationWhitelist);
}
var children = this.renderData(props);
var component = props.standalone ? this.renderContainer(props.containerComponent, children) : children;
return _victoryCore.UserProps.withSafeUserProps(component, props);
}
}]);
return VictoryVoronoiBase;
}(_react.default.Component);
VictoryVoronoiBase.animationWhitelist = ["data", "domain", "height", "padding", "samples", "size", "style", "width"];
VictoryVoronoiBase.displayName = "VictoryVoronoi";
VictoryVoronoiBase.role = "voronoi";
VictoryVoronoiBase.defaultTransitions = _victoryCore.DefaultTransitions.discreteTransitions();
VictoryVoronoiBase.defaultProps = {
containerComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryContainer, null),
dataComponent: /*#__PURE__*/_react.default.createElement(_voronoi.Voronoi, null),
labelComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryLabel, null),
groupComponent: /*#__PURE__*/_react.default.createElement("g", {
role: "presentation"
}),
samples: 50,
sortOrder: "ascending",
standalone: true,
theme: _victoryCore.VictoryTheme.grayscale
};
VictoryVoronoiBase.getDomain = _victoryCore.Domain.getDomain;
VictoryVoronoiBase.getData = _victoryCore.Data.getData;
VictoryVoronoiBase.getBaseProps = function (props) {
return (0, _helperMethods.getBaseProps)(props, fallbackProps);
};
VictoryVoronoiBase.expectedComponents = ["dataComponent", "labelComponent", "groupComponent", "containerComponent"];
var VictoryVoronoi = (0, _victoryCore.addEvents)(VictoryVoronoiBase);
exports.VictoryVoronoi = VictoryVoronoi;
const children = this.renderData(props);
const component = props.standalone ? this.renderContainer(props.containerComponent, children) : children;
return _victoryCore.UserProps.withSafeUserProps(component, props);
}
}
const VictoryVoronoi = exports.VictoryVoronoi = (0, _victoryCore.addEvents)(VictoryVoronoiBase);

@@ -0,0 +0,0 @@ import React from "react";

@@ -7,22 +7,11 @@ "use strict";

exports.Voronoi = void 0;
var _react = _interopRequireDefault(require("react"));
var _victoryCore = require("victory-core");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var getVoronoiPath = function (props) {
var _props$polygon;
var polygon = props.polygon;
return Array.isArray(polygon) && polygon.length ? "M ".concat((_props$polygon = props.polygon) === null || _props$polygon === void 0 ? void 0 : _props$polygon.join("L"), " Z") : "";
const getVoronoiPath = props => {
const {
polygon
} = props;
return Array.isArray(polygon) && polygon.length ? `M ${props.polygon?.join("L")} Z` : "";
};
function evaluateProps(props) {

@@ -37,22 +26,16 @@ /**

*/
var ariaLabel = _victoryCore.Helpers.evaluateProp(props.ariaLabel, props);
var id = _victoryCore.Helpers.evaluateProp(props.id, props);
var size = _victoryCore.Helpers.evaluateProp(props.size, props);
var style = _victoryCore.Helpers.evaluateStyle(props.style, props);
var tabIndex = _victoryCore.Helpers.evaluateProp(props.tabIndex, props);
const ariaLabel = _victoryCore.Helpers.evaluateProp(props.ariaLabel, props);
const id = _victoryCore.Helpers.evaluateProp(props.id, props);
const size = _victoryCore.Helpers.evaluateProp(props.size, props);
const style = _victoryCore.Helpers.evaluateStyle(props.style, props);
const tabIndex = _victoryCore.Helpers.evaluateProp(props.tabIndex, props);
return Object.assign({}, props, {
ariaLabel: ariaLabel,
id: id,
size: size,
style: style,
tabIndex: tabIndex
ariaLabel,
id,
size,
style,
tabIndex
});
}
var defaultProps = {
const defaultProps = {
pathComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.Path, null),

@@ -65,53 +48,54 @@ circleComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.Circle, null),

};
var Voronoi = function (initialProps) {
var props = evaluateProps(_objectSpread(_objectSpread({}, defaultProps), initialProps));
var ariaLabel = props.ariaLabel,
role = props.role,
shapeRendering = props.shapeRendering,
className = props.className,
events = props.events,
transform = props.transform,
style = props.style,
size = props.size,
tabIndex = props.tabIndex;
var voronoiPath = getVoronoiPath(props);
var sharedProps = _objectSpread({
const Voronoi = initialProps => {
const props = evaluateProps({
...defaultProps,
...initialProps
});
const {
ariaLabel,
role,
shapeRendering,
className,
events,
transform,
style,
size,
tabIndex
} = props;
const voronoiPath = getVoronoiPath(props);
const sharedProps = {
"aria-label": ariaLabel,
className: className,
role: role,
shapeRendering: shapeRendering,
style: style,
tabIndex: tabIndex,
transform: transform
}, events);
var userProps = _victoryCore.UserProps.getSafeUserProps(props);
className,
role,
shapeRendering,
style,
tabIndex,
transform,
...events
};
const userProps = _victoryCore.UserProps.getSafeUserProps(props);
if (size) {
var circle = /*#__PURE__*/_react.default.cloneElement(props.circleComponent, _objectSpread(_objectSpread({}, sharedProps), {}, {
key: "".concat(props.id, "-circle-clip"),
clipPath: "url(#".concat(props.clipId, ")"),
const circle = /*#__PURE__*/_react.default.cloneElement(props.circleComponent, {
...sharedProps,
key: `${props.id}-circle-clip`,
clipPath: `url(#${props.clipId})`,
cx: props.x,
cy: props.y,
r: size
}));
var voronoiClipPath = /*#__PURE__*/_react.default.cloneElement(props.clipPathComponent, {
key: "".concat(props.id, "-voronoi-clip"),
});
const voronoiClipPath = /*#__PURE__*/_react.default.cloneElement(props.clipPathComponent, {
key: `${props.id}-voronoi-clip`,
clipId: props.clipId
}, /*#__PURE__*/_react.default.cloneElement(props.pathComponent, {
d: voronoiPath,
className: className
className
}));
return /*#__PURE__*/_react.default.cloneElement(props.groupComponent, {}, [voronoiClipPath, circle]);
}
return /*#__PURE__*/_react.default.cloneElement(props.pathComponent, _objectSpread(_objectSpread(_objectSpread({}, sharedProps), userProps), {}, {
return /*#__PURE__*/_react.default.cloneElement(props.pathComponent, {
...sharedProps,
...userProps,
d: voronoiPath
}));
});
};
exports.Voronoi = Voronoi;
{
"name": "victory-voronoi",
"version": "36.9.1",
"version": "36.9.2-next.0",
"description": "Voronoi Component for Victory",

@@ -25,3 +25,3 @@ "keywords": [

"lodash": "^4.17.19",
"victory-core": "^36.9.1"
"victory-core": "^36.9.2-next.0"
},

@@ -31,5 +31,2 @@ "peerDependencies": {

},
"publishConfig": {
"provenance": true
},
"wireit": {

@@ -244,3 +241,3 @@ "### THESE WIREIT CONFIGS ARE GENERATED ####": {},

"jest": {
"command": "nps jest:pkg",
"command": "jest --passWithNoTests",
"files": [

@@ -254,4 +251,4 @@ "src/**/*.test.*",

"dependencies": [
"build:lib:cjs",
"../victory-vendor:build:lib:cjs"
"../victory-core:build",
"../victory-vendor:build"
],

@@ -258,0 +255,0 @@ "packageLocks": [

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

import { without, isNil } from "lodash";
import { without } from "lodash";
// victory-vendor note: This module is still CommonJS, so not part of victory-vendor.

@@ -126,3 +126,3 @@ import { voronoi as d3Voronoi } from "d3-voronoi";

const polygon = without(polygons[index], "data");
const eventKey = !isNil(datum.eventKey) ? datum.eventKey : index;
const eventKey = !Helpers.isNil(datum.eventKey) ? datum.eventKey : index;
const { x, y } = Helpers.scalePoint(props, datum);

@@ -129,0 +129,0 @@ const dataProps = {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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