victory-scatter
Advanced tools
Comparing version 36.9.2 to 37.0.0
# victory-scatter | ||
## 37.0.0 | ||
### Major Changes | ||
- Upgrade babel dependencies and build target to modern browsers ([#2804](https://github.com/FormidableLabs/victory/pull/2804)) | ||
## 36.9.2 | ||
@@ -4,0 +10,0 @@ |
@@ -1,55 +0,39 @@ | ||
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; } | ||
import { Helpers, LabelHelpers, Data, Domain, Scale } from "victory-core"; | ||
export var getSymbol = function (data, props) { | ||
export const getSymbol = (data, props) => { | ||
if (props.bubbleProperty) { | ||
return "circle"; | ||
} | ||
return data.symbol || props.symbol; | ||
}; | ||
export var getBubbleSize = function (datum, props) { | ||
var data = props.data, | ||
z = props.z, | ||
maxBubbleSize = props.maxBubbleSize, | ||
minBubbleSize = props.minBubbleSize; | ||
var zData = data.map(function (point) { | ||
return point[z]; | ||
}); | ||
var zMin = Math.min.apply(Math, _toConsumableArray(zData)); | ||
var zMax = Math.max.apply(Math, _toConsumableArray(zData)); | ||
var getMaxRadius = function () { | ||
var minPadding = Math.min.apply(Math, _toConsumableArray(Object.values(Helpers.getPadding(props)))); | ||
export const getBubbleSize = (datum, props) => { | ||
const { | ||
data, | ||
z, | ||
maxBubbleSize, | ||
minBubbleSize | ||
} = props; | ||
const zData = data.map(point => point[z]); | ||
const zMin = Math.min(...zData); | ||
const zMax = Math.max(...zData); | ||
const getMaxRadius = () => { | ||
const minPadding = Math.min(...Object.values(Helpers.getPadding(props))); | ||
return Math.max(minPadding, 5); // eslint-disable-line no-magic-numbers | ||
}; | ||
var maxRadius = maxBubbleSize || getMaxRadius(); | ||
var minRadius = minBubbleSize || maxRadius * 0.1; // eslint-disable-line no-magic-numbers | ||
const maxRadius = maxBubbleSize || getMaxRadius(); | ||
const minRadius = minBubbleSize || maxRadius * 0.1; // eslint-disable-line no-magic-numbers | ||
if (zMax === zMin) { | ||
return Math.max(minRadius, 1); | ||
} | ||
var maxArea = Math.PI * Math.pow(maxRadius, 2); | ||
var minArea = Math.PI * Math.pow(minRadius, 2); | ||
var pointArea = (datum[z] - zMin) / (zMax - zMin) * maxArea; | ||
var area = Math.max(pointArea, minArea); | ||
var radius = Math.sqrt(area / Math.PI); | ||
const maxArea = Math.PI * Math.pow(maxRadius, 2); | ||
const minArea = Math.PI * Math.pow(minRadius, 2); | ||
const pointArea = (datum[z] - zMin) / (zMax - zMin) * maxArea; | ||
const area = Math.max(pointArea, minArea); | ||
const radius = Math.sqrt(area / Math.PI); | ||
return Math.max(radius, 1); | ||
}; | ||
export var getSize = function (datum, props) { | ||
var size = props.size, | ||
z = props.z; | ||
export const getSize = (datum, props) => { | ||
const { | ||
size, | ||
z | ||
} = props; | ||
if (datum.size) { | ||
@@ -62,93 +46,91 @@ return typeof datum.size === "function" ? datum.size : Math.max(datum.size, 1); | ||
} | ||
return Math.max(size || 0, 1); | ||
}; | ||
var getCalculatedValues = function (props) { | ||
var defaultStyles = Helpers.getDefaultStyles(props, "scatter"); | ||
var style = Helpers.getStyles(props.style, defaultStyles); | ||
var range = { | ||
const getCalculatedValues = props => { | ||
const defaultStyles = Helpers.getDefaultStyles(props, "scatter"); | ||
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 origin = props.polar ? props.origin || Helpers.getPolarOrigin(props) : undefined; | ||
var z = props.bubbleProperty || "z"; | ||
var data = Data.getData(props); | ||
const origin = props.polar ? props.origin || Helpers.getPolarOrigin(props) : undefined; | ||
const z = props.bubbleProperty || "z"; | ||
let data = Data.getData(props); | ||
data = Data.formatDataFromDomain(data, domain); | ||
return { | ||
domain: domain, | ||
data: data, | ||
scale: scale, | ||
style: style, | ||
origin: origin, | ||
z: z | ||
domain, | ||
data, | ||
scale, | ||
style, | ||
origin, | ||
z | ||
}; | ||
}; | ||
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, | ||
scale = props.scale, | ||
name = props.name, | ||
sharedEvents = props.sharedEvents, | ||
standalone = props.standalone, | ||
style = props.style, | ||
theme = props.theme, | ||
width = props.width, | ||
labels = props.labels, | ||
horizontal = props.horizontal, | ||
disableInlineStyles = props.disableInlineStyles; | ||
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, | ||
scale, | ||
name, | ||
sharedEvents, | ||
standalone, | ||
style, | ||
theme, | ||
width, | ||
labels, | ||
horizontal, | ||
disableInlineStyles | ||
} = props; | ||
const initialChildProps = { | ||
parent: { | ||
style: style.parent, | ||
scale: scale, | ||
domain: domain, | ||
data: data, | ||
height: height, | ||
width: width, | ||
standalone: standalone, | ||
theme: theme, | ||
origin: origin, | ||
polar: polar, | ||
padding: padding, | ||
name: name, | ||
horizontal: horizontal | ||
scale, | ||
domain, | ||
data, | ||
height, | ||
width, | ||
standalone, | ||
theme, | ||
origin, | ||
polar, | ||
padding, | ||
name, | ||
horizontal | ||
} | ||
}; | ||
return data.reduce(function (childProps, datum, index) { | ||
var eventKey = !Helpers.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, | ||
polar: polar, | ||
origin: origin, | ||
horizontal: horizontal, | ||
return data.reduce((childProps, datum, index) => { | ||
const eventKey = !Helpers.isNil(datum.eventKey) ? datum.eventKey : index; | ||
const { | ||
x, | ||
y | ||
} = Helpers.scalePoint(props, datum); | ||
const dataProps = { | ||
x, | ||
y, | ||
datum, | ||
data, | ||
index, | ||
scale, | ||
polar, | ||
origin, | ||
horizontal, | ||
size: getSize(datum, props), | ||
symbol: getSymbol(datum, props), | ||
style: disableInlineStyles ? {} : style.data, | ||
disableInlineStyles: disableInlineStyles | ||
disableInlineStyles | ||
}; | ||
@@ -158,10 +140,8 @@ childProps[eventKey] = { | ||
}; | ||
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); | ||
}; |
@@ -1,25 +0,5 @@ | ||
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"; | ||
import { Helpers, VictoryLabel, addEvents, VictoryContainer, VictoryTheme, DefaultTransitions, Data, Domain, Point, UserProps } from "victory-core"; | ||
import { getBaseProps } from "./helper-methods"; | ||
var fallbackProps = { | ||
const fallbackProps = { | ||
width: 450, | ||
@@ -32,2 +12,4 @@ height: 300, | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
/** | ||
@@ -37,61 +19,40 @@ * Draw area charts with React. VictoryArea is a composable component, so it doesn't include axes. | ||
*/ | ||
var VictoryScatterBase = /*#__PURE__*/function (_React$Component) { | ||
_inherits(VictoryScatterBase, _React$Component); | ||
class VictoryScatterBase extends React.Component { | ||
static animationWhitelist = ["data", "domain", "height", "maxBubbleSize", "padding", "samples", "size", "style", "width"]; | ||
static displayName = "VictoryScatter"; | ||
static role = "scatter"; | ||
static defaultTransitions = DefaultTransitions.discreteTransitions(); | ||
static defaultProps = { | ||
containerComponent: /*#__PURE__*/React.createElement(VictoryContainer, null), | ||
dataComponent: /*#__PURE__*/React.createElement(Point, null), | ||
labelComponent: /*#__PURE__*/React.createElement(VictoryLabel, null), | ||
groupComponent: /*#__PURE__*/React.createElement("g", null), | ||
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"]; | ||
var _super = _createSuper(VictoryScatterBase); | ||
function VictoryScatterBase() { | ||
_classCallCheck(this, VictoryScatterBase); | ||
return _super.apply(this, arguments); | ||
// Overridden in native versions | ||
shouldAnimate() { | ||
return !!this.props.animate; | ||
} | ||
_createClass(VictoryScatterBase, [{ | ||
key: "shouldAnimate", | ||
value: // Overridden in native versions | ||
function shouldAnimate() { | ||
return !!this.props.animate; | ||
render() { | ||
const { | ||
animationWhitelist, | ||
role | ||
} = VictoryScatter; | ||
const props = Helpers.modifyProps(this.props, fallbackProps, role); | ||
if (this.shouldAnimate()) { | ||
return this.animateComponent(props, animationWhitelist); | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var animationWhitelist = VictoryScatter.animationWhitelist, | ||
role = VictoryScatter.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 VictoryScatterBase; | ||
}(React.Component); | ||
VictoryScatterBase.animationWhitelist = ["data", "domain", "height", "maxBubbleSize", "padding", "samples", "size", "style", "width"]; | ||
VictoryScatterBase.displayName = "VictoryScatter"; | ||
VictoryScatterBase.role = "scatter"; | ||
VictoryScatterBase.defaultTransitions = DefaultTransitions.discreteTransitions(); | ||
VictoryScatterBase.defaultProps = { | ||
containerComponent: /*#__PURE__*/React.createElement(VictoryContainer, null), | ||
dataComponent: /*#__PURE__*/React.createElement(Point, null), | ||
labelComponent: /*#__PURE__*/React.createElement(VictoryLabel, null), | ||
groupComponent: /*#__PURE__*/React.createElement("g", null), | ||
samples: 50, | ||
sortOrder: "ascending", | ||
standalone: true, | ||
theme: VictoryTheme.grayscale | ||
}; | ||
VictoryScatterBase.getDomain = Domain.getDomain; | ||
VictoryScatterBase.getData = Data.getData; | ||
VictoryScatterBase.getBaseProps = function (props) { | ||
return getBaseProps(props, fallbackProps); | ||
}; | ||
VictoryScatterBase.expectedComponents = ["dataComponent", "labelComponent", "groupComponent", "containerComponent"]; | ||
export var VictoryScatter = addEvents(VictoryScatterBase); | ||
const children = this.renderData(props); | ||
const component = props.standalone ? this.renderContainer(props.containerComponent, children) : children; | ||
return UserProps.withSafeUserProps(component, props); | ||
} | ||
} | ||
export const VictoryScatter = addEvents(VictoryScatterBase); |
@@ -7,64 +7,42 @@ "use strict"; | ||
exports.getSymbol = exports.getSize = exports.getBubbleSize = exports.getBaseProps = void 0; | ||
var _victoryCore = require("victory-core"); | ||
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; } | ||
var getSymbol = function (data, props) { | ||
const getSymbol = (data, props) => { | ||
if (props.bubbleProperty) { | ||
return "circle"; | ||
} | ||
return data.symbol || props.symbol; | ||
}; | ||
exports.getSymbol = getSymbol; | ||
var getBubbleSize = function (datum, props) { | ||
var data = props.data, | ||
z = props.z, | ||
maxBubbleSize = props.maxBubbleSize, | ||
minBubbleSize = props.minBubbleSize; | ||
var zData = data.map(function (point) { | ||
return point[z]; | ||
}); | ||
var zMin = Math.min.apply(Math, _toConsumableArray(zData)); | ||
var zMax = Math.max.apply(Math, _toConsumableArray(zData)); | ||
var getMaxRadius = function () { | ||
var minPadding = Math.min.apply(Math, _toConsumableArray(Object.values(_victoryCore.Helpers.getPadding(props)))); | ||
const getBubbleSize = (datum, props) => { | ||
const { | ||
data, | ||
z, | ||
maxBubbleSize, | ||
minBubbleSize | ||
} = props; | ||
const zData = data.map(point => point[z]); | ||
const zMin = Math.min(...zData); | ||
const zMax = Math.max(...zData); | ||
const getMaxRadius = () => { | ||
const minPadding = Math.min(...Object.values(_victoryCore.Helpers.getPadding(props))); | ||
return Math.max(minPadding, 5); // eslint-disable-line no-magic-numbers | ||
}; | ||
var maxRadius = maxBubbleSize || getMaxRadius(); | ||
var minRadius = minBubbleSize || maxRadius * 0.1; // eslint-disable-line no-magic-numbers | ||
const maxRadius = maxBubbleSize || getMaxRadius(); | ||
const minRadius = minBubbleSize || maxRadius * 0.1; // eslint-disable-line no-magic-numbers | ||
if (zMax === zMin) { | ||
return Math.max(minRadius, 1); | ||
} | ||
var maxArea = Math.PI * Math.pow(maxRadius, 2); | ||
var minArea = Math.PI * Math.pow(minRadius, 2); | ||
var pointArea = (datum[z] - zMin) / (zMax - zMin) * maxArea; | ||
var area = Math.max(pointArea, minArea); | ||
var radius = Math.sqrt(area / Math.PI); | ||
const maxArea = Math.PI * Math.pow(maxRadius, 2); | ||
const minArea = Math.PI * Math.pow(minRadius, 2); | ||
const pointArea = (datum[z] - zMin) / (zMax - zMin) * maxArea; | ||
const area = Math.max(pointArea, minArea); | ||
const radius = Math.sqrt(area / Math.PI); | ||
return Math.max(radius, 1); | ||
}; | ||
exports.getBubbleSize = getBubbleSize; | ||
var getSize = function (datum, props) { | ||
var size = props.size, | ||
z = props.z; | ||
const getSize = (datum, props) => { | ||
const { | ||
size, | ||
z | ||
} = props; | ||
if (datum.size) { | ||
@@ -77,100 +55,92 @@ return typeof datum.size === "function" ? datum.size : Math.max(datum.size, 1); | ||
} | ||
return Math.max(size || 0, 1); | ||
}; | ||
exports.getSize = getSize; | ||
var getCalculatedValues = function (props) { | ||
var defaultStyles = _victoryCore.Helpers.getDefaultStyles(props, "scatter"); | ||
var style = _victoryCore.Helpers.getStyles(props.style, defaultStyles); | ||
var range = { | ||
const getCalculatedValues = props => { | ||
const defaultStyles = _victoryCore.Helpers.getDefaultStyles(props, "scatter"); | ||
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 origin = props.polar ? props.origin || _victoryCore.Helpers.getPolarOrigin(props) : undefined; | ||
var z = props.bubbleProperty || "z"; | ||
var data = _victoryCore.Data.getData(props); | ||
const origin = props.polar ? props.origin || _victoryCore.Helpers.getPolarOrigin(props) : undefined; | ||
const z = props.bubbleProperty || "z"; | ||
let data = _victoryCore.Data.getData(props); | ||
data = _victoryCore.Data.formatDataFromDomain(data, domain); | ||
return { | ||
domain: domain, | ||
data: data, | ||
scale: scale, | ||
style: style, | ||
origin: origin, | ||
z: z | ||
domain, | ||
data, | ||
scale, | ||
style, | ||
origin, | ||
z | ||
}; | ||
}; | ||
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, | ||
scale = props.scale, | ||
name = props.name, | ||
sharedEvents = props.sharedEvents, | ||
standalone = props.standalone, | ||
style = props.style, | ||
theme = props.theme, | ||
width = props.width, | ||
labels = props.labels, | ||
horizontal = props.horizontal, | ||
disableInlineStyles = props.disableInlineStyles; | ||
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, | ||
scale, | ||
name, | ||
sharedEvents, | ||
standalone, | ||
style, | ||
theme, | ||
width, | ||
labels, | ||
horizontal, | ||
disableInlineStyles | ||
} = props; | ||
const initialChildProps = { | ||
parent: { | ||
style: style.parent, | ||
scale: scale, | ||
domain: domain, | ||
data: data, | ||
height: height, | ||
width: width, | ||
standalone: standalone, | ||
theme: theme, | ||
origin: origin, | ||
polar: polar, | ||
padding: padding, | ||
name: name, | ||
horizontal: horizontal | ||
scale, | ||
domain, | ||
data, | ||
height, | ||
width, | ||
standalone, | ||
theme, | ||
origin, | ||
polar, | ||
padding, | ||
name, | ||
horizontal | ||
} | ||
}; | ||
return data.reduce(function (childProps, datum, index) { | ||
var eventKey = !_victoryCore.Helpers.isNil(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, | ||
polar: polar, | ||
origin: origin, | ||
horizontal: horizontal, | ||
return data.reduce((childProps, datum, index) => { | ||
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, | ||
polar, | ||
origin, | ||
horizontal, | ||
size: getSize(datum, props), | ||
symbol: getSymbol(datum, props), | ||
style: disableInlineStyles ? {} : style.data, | ||
disableInlineStyles: disableInlineStyles | ||
disableInlineStyles | ||
}; | ||
@@ -180,13 +150,9 @@ childProps[eventKey] = { | ||
}; | ||
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; |
@@ -6,5 +6,3 @@ "use strict"; | ||
}); | ||
var _victoryScatter = require("./victory-scatter"); | ||
Object.keys(_victoryScatter).forEach(function (key) { | ||
@@ -11,0 +9,0 @@ if (key === "default" || key === "__esModule") return; |
@@ -7,32 +7,7 @@ "use strict"; | ||
exports.VictoryScatter = void 0; | ||
var _react = _interopRequireDefault(require("react")); | ||
var _victoryCore = require("victory-core"); | ||
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, | ||
@@ -45,2 +20,4 @@ height: 300, | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
/** | ||
@@ -50,63 +27,40 @@ * Draw area charts with React. VictoryArea is a composable component, so it doesn't include axes. | ||
*/ | ||
var VictoryScatterBase = /*#__PURE__*/function (_React$Component) { | ||
_inherits(VictoryScatterBase, _React$Component); | ||
class VictoryScatterBase extends _react.default.Component { | ||
static animationWhitelist = ["data", "domain", "height", "maxBubbleSize", "padding", "samples", "size", "style", "width"]; | ||
static displayName = "VictoryScatter"; | ||
static role = "scatter"; | ||
static defaultTransitions = _victoryCore.DefaultTransitions.discreteTransitions(); | ||
static defaultProps = { | ||
containerComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryContainer, null), | ||
dataComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.Point, null), | ||
labelComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryLabel, null), | ||
groupComponent: /*#__PURE__*/_react.default.createElement("g", null), | ||
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"]; | ||
var _super = _createSuper(VictoryScatterBase); | ||
function VictoryScatterBase() { | ||
_classCallCheck(this, VictoryScatterBase); | ||
return _super.apply(this, arguments); | ||
// Overridden in native versions | ||
shouldAnimate() { | ||
return !!this.props.animate; | ||
} | ||
_createClass(VictoryScatterBase, [{ | ||
key: "shouldAnimate", | ||
value: // Overridden in native versions | ||
function shouldAnimate() { | ||
return !!this.props.animate; | ||
render() { | ||
const { | ||
animationWhitelist, | ||
role | ||
} = VictoryScatter; | ||
const props = _victoryCore.Helpers.modifyProps(this.props, fallbackProps, role); | ||
if (this.shouldAnimate()) { | ||
return this.animateComponent(props, animationWhitelist); | ||
} | ||
}, { | ||
key: "render", | ||
value: function render() { | ||
var animationWhitelist = VictoryScatter.animationWhitelist, | ||
role = VictoryScatter.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 VictoryScatterBase; | ||
}(_react.default.Component); | ||
VictoryScatterBase.animationWhitelist = ["data", "domain", "height", "maxBubbleSize", "padding", "samples", "size", "style", "width"]; | ||
VictoryScatterBase.displayName = "VictoryScatter"; | ||
VictoryScatterBase.role = "scatter"; | ||
VictoryScatterBase.defaultTransitions = _victoryCore.DefaultTransitions.discreteTransitions(); | ||
VictoryScatterBase.defaultProps = { | ||
containerComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryContainer, null), | ||
dataComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.Point, null), | ||
labelComponent: /*#__PURE__*/_react.default.createElement(_victoryCore.VictoryLabel, null), | ||
groupComponent: /*#__PURE__*/_react.default.createElement("g", null), | ||
samples: 50, | ||
sortOrder: "ascending", | ||
standalone: true, | ||
theme: _victoryCore.VictoryTheme.grayscale | ||
}; | ||
VictoryScatterBase.getDomain = _victoryCore.Domain.getDomain; | ||
VictoryScatterBase.getData = _victoryCore.Data.getData; | ||
VictoryScatterBase.getBaseProps = function (props) { | ||
return (0, _helperMethods.getBaseProps)(props, fallbackProps); | ||
}; | ||
VictoryScatterBase.expectedComponents = ["dataComponent", "labelComponent", "groupComponent", "containerComponent"]; | ||
var VictoryScatter = (0, _victoryCore.addEvents)(VictoryScatterBase); | ||
exports.VictoryScatter = VictoryScatter; | ||
const children = this.renderData(props); | ||
const component = props.standalone ? this.renderContainer(props.containerComponent, children) : children; | ||
return _victoryCore.UserProps.withSafeUserProps(component, props); | ||
} | ||
} | ||
const VictoryScatter = exports.VictoryScatter = (0, _victoryCore.addEvents)(VictoryScatterBase); |
{ | ||
"name": "victory-scatter", | ||
"version": "36.9.2", | ||
"version": "37.0.0", | ||
"description": "Scatter Component for Victory", | ||
@@ -24,3 +24,3 @@ "keywords": [ | ||
"lodash": "^4.17.19", | ||
"victory-core": "^36.9.2" | ||
"victory-core": "^37.0.0" | ||
}, | ||
@@ -27,0 +27,0 @@ "peerDependencies": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 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
959773
16945
4
+ Addedvictory-core@37.1.1(transitive)
+ Addedvictory-vendor@37.1.1(transitive)
- Removedvictory-core@36.9.2(transitive)
- Removedvictory-vendor@36.9.2(transitive)
Updatedvictory-core@^37.0.0