victory-core
Advanced tools
Comparing version 35.5.1 to 35.6.0
@@ -73,30 +73,41 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
}, { | ||
key: "shouldComponentUpdate", | ||
value: function shouldComponentUpdate(nextProps, nextState) { | ||
var equalProps = isEqual(this.props, nextProps); | ||
key: "componentDidUpdate", | ||
value: function componentDidUpdate(prevProps) { | ||
var equalProps = isEqual(this.props, prevProps); | ||
if (!equalProps) { | ||
/* cancel existing loop if it exists */ | ||
this.timer.unsubscribe(this.loopID); | ||
/* If an object was supplied */ | ||
if (!Array.isArray(nextProps.data)) { | ||
// Replace the tween queue. Could set `this.queue = [nextProps.data]`, | ||
// but let's reuse the same array. | ||
this.queue.length = 0; | ||
this.queue.push(nextProps.data); | ||
/* If an array was supplied */ | ||
/* If the previous animation didn't finish, force it to complete before starting a new one */ | ||
if (this.interpolator && this.state.animationInfo && this.state.animationInfo.progress < 1) { | ||
// eslint-disable-next-line react/no-did-update-set-state | ||
this.setState({ | ||
data: this.interpolator(1), | ||
animationInfo: { | ||
progress: 1, | ||
animating: false, | ||
terminating: true | ||
} | ||
}); | ||
} else { | ||
var _queue; | ||
/* cancel existing loop if it exists */ | ||
this.timer.unsubscribe(this.loopID); | ||
/* If an object was supplied */ | ||
/* Extend the tween queue */ | ||
(_queue = this.queue).push.apply(_queue, _toConsumableArray(nextProps.data)); | ||
} | ||
/* Start traversing the tween queue */ | ||
if (!Array.isArray(this.props.data)) { | ||
// Replace the tween queue. Could set `this.queue = [nextProps.data]`, | ||
// but let's reuse the same array. | ||
this.queue.length = 0; | ||
this.queue.push(this.props.data); | ||
/* If an array was supplied */ | ||
} else { | ||
var _queue; | ||
/* Extend the tween queue */ | ||
(_queue = this.queue).push.apply(_queue, _toConsumableArray(this.props.data)); | ||
} | ||
/* Start traversing the tween queue */ | ||
this.traverseQueue(); | ||
this.traverseQueue(); | ||
} | ||
} | ||
return nextState.animationInfo.animating || nextState.animationInfo.terminating || !equalProps; | ||
} | ||
@@ -103,0 +114,0 @@ }, { |
@@ -0,1 +1,3 @@ | ||
import _omitBy from "lodash/omitBy"; | ||
import _isUndefined from "lodash/isUndefined"; | ||
import _includes from "lodash/includes"; | ||
@@ -13,2 +15,10 @@ import _isEqual from "lodash/isEqual"; | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } | ||
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
@@ -111,2 +121,60 @@ | ||
}); | ||
} // This method will remove data points that fall outside of the desired domain (non-continuous charts only) | ||
function formatDataFromDomain(dataset, domain, defaultBaseline) { | ||
var exists = function (val) { | ||
return val !== undefined; | ||
}; | ||
var _domain$x = _slicedToArray(domain.x, 2), | ||
minDomainX = _domain$x[0], | ||
maxDomainX = _domain$x[1]; | ||
var _domain$y = _slicedToArray(domain.y, 2), | ||
minDomainY = _domain$y[0], | ||
maxDomainY = _domain$y[1]; | ||
var underMin = function (min) { | ||
return function (val) { | ||
return exists(val) && val < min; | ||
}; | ||
}; | ||
var overMax = function (max) { | ||
return function (val) { | ||
return exists(val) && val > max; | ||
}; | ||
}; | ||
var isUnderMinX = underMin(minDomainX); | ||
var isUnderMinY = underMin(minDomainY); | ||
var isOverMaxX = overMax(maxDomainX); | ||
var isOverMaxY = overMax(maxDomainY); // eslint-disable-next-line complexity | ||
return dataset.map(function (datum) { | ||
var _x = datum._x, | ||
_y = datum._y, | ||
_y0 = datum._y0, | ||
_y1 = datum._y1; // single x point less than min domain | ||
if (isUnderMinX(_x) || isOverMaxX(_x)) _x = null; | ||
var baseline = exists(_y0) ? _y0 : defaultBaseline; | ||
var value = exists(_y) ? _y : _y1; | ||
if (!exists(value)) return datum; // value only and less than min domain or greater than max domain | ||
if (!exists(baseline) && (isUnderMinY(value) || isOverMaxY(value))) _y = null; // baseline and value are both less than min domain or both greater than max domain | ||
if (isUnderMinY(baseline) && isUnderMinY(value) || isOverMaxY(baseline) && isOverMaxY(value)) _y = _y0 = _y1 = null; // baseline and value with only baseline below min, set baseline to minDomainY | ||
if (isUnderMinY(baseline) && !isUnderMinY(value)) _y0 = minDomainY; // baseline and value with only baseline above max, set baseline to maxDomainY | ||
if (isOverMaxY(baseline) && !isOverMaxY(value)) _y0 = maxDomainY; | ||
return _assign({}, datum, _omitBy({ | ||
_x: _x, | ||
_y: _y, | ||
_y0: _y0, | ||
_y1: _y1 | ||
}, _isUndefined)); | ||
}); | ||
} // Returns a data accessor given an eventKey prop | ||
@@ -416,2 +484,3 @@ | ||
formatData: formatData, | ||
formatDataFromDomain: formatDataFromDomain, | ||
generateData: generateData, | ||
@@ -418,0 +487,0 @@ getCategories: getCategories, |
@@ -88,30 +88,41 @@ "use strict"; | ||
}, { | ||
key: "shouldComponentUpdate", | ||
value: function shouldComponentUpdate(nextProps, nextState) { | ||
var equalProps = (0, _reactFastCompare.default)(this.props, nextProps); | ||
key: "componentDidUpdate", | ||
value: function componentDidUpdate(prevProps) { | ||
var equalProps = (0, _reactFastCompare.default)(this.props, prevProps); | ||
if (!equalProps) { | ||
/* cancel existing loop if it exists */ | ||
this.timer.unsubscribe(this.loopID); | ||
/* If an object was supplied */ | ||
if (!Array.isArray(nextProps.data)) { | ||
// Replace the tween queue. Could set `this.queue = [nextProps.data]`, | ||
// but let's reuse the same array. | ||
this.queue.length = 0; | ||
this.queue.push(nextProps.data); | ||
/* If an array was supplied */ | ||
/* If the previous animation didn't finish, force it to complete before starting a new one */ | ||
if (this.interpolator && this.state.animationInfo && this.state.animationInfo.progress < 1) { | ||
// eslint-disable-next-line react/no-did-update-set-state | ||
this.setState({ | ||
data: this.interpolator(1), | ||
animationInfo: { | ||
progress: 1, | ||
animating: false, | ||
terminating: true | ||
} | ||
}); | ||
} else { | ||
var _queue; | ||
/* cancel existing loop if it exists */ | ||
this.timer.unsubscribe(this.loopID); | ||
/* If an object was supplied */ | ||
/* Extend the tween queue */ | ||
(_queue = this.queue).push.apply(_queue, _toConsumableArray(nextProps.data)); | ||
} | ||
/* Start traversing the tween queue */ | ||
if (!Array.isArray(this.props.data)) { | ||
// Replace the tween queue. Could set `this.queue = [nextProps.data]`, | ||
// but let's reuse the same array. | ||
this.queue.length = 0; | ||
this.queue.push(this.props.data); | ||
/* If an array was supplied */ | ||
} else { | ||
var _queue; | ||
/* Extend the tween queue */ | ||
(_queue = this.queue).push.apply(_queue, _toConsumableArray(this.props.data)); | ||
} | ||
/* Start traversing the tween queue */ | ||
this.traverseQueue(); | ||
this.traverseQueue(); | ||
} | ||
} | ||
return nextState.animationInfo.animating || nextState.animationInfo.terminating || !equalProps; | ||
} | ||
@@ -118,0 +129,0 @@ }, { |
@@ -8,2 +8,6 @@ "use strict"; | ||
var _omitBy2 = _interopRequireDefault(require("lodash/omitBy")); | ||
var _isUndefined2 = _interopRequireDefault(require("lodash/isUndefined")); | ||
var _includes2 = _interopRequireDefault(require("lodash/includes")); | ||
@@ -43,2 +47,10 @@ | ||
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } | ||
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } | ||
function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } | ||
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } | ||
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } | ||
@@ -133,2 +145,60 @@ | ||
}); | ||
} // This method will remove data points that fall outside of the desired domain (non-continuous charts only) | ||
function formatDataFromDomain(dataset, domain, defaultBaseline) { | ||
var exists = function (val) { | ||
return val !== undefined; | ||
}; | ||
var _domain$x = _slicedToArray(domain.x, 2), | ||
minDomainX = _domain$x[0], | ||
maxDomainX = _domain$x[1]; | ||
var _domain$y = _slicedToArray(domain.y, 2), | ||
minDomainY = _domain$y[0], | ||
maxDomainY = _domain$y[1]; | ||
var underMin = function (min) { | ||
return function (val) { | ||
return exists(val) && val < min; | ||
}; | ||
}; | ||
var overMax = function (max) { | ||
return function (val) { | ||
return exists(val) && val > max; | ||
}; | ||
}; | ||
var isUnderMinX = underMin(minDomainX); | ||
var isUnderMinY = underMin(minDomainY); | ||
var isOverMaxX = overMax(maxDomainX); | ||
var isOverMaxY = overMax(maxDomainY); // eslint-disable-next-line complexity | ||
return dataset.map(function (datum) { | ||
var _x = datum._x, | ||
_y = datum._y, | ||
_y0 = datum._y0, | ||
_y1 = datum._y1; // single x point less than min domain | ||
if (isUnderMinX(_x) || isOverMaxX(_x)) _x = null; | ||
var baseline = exists(_y0) ? _y0 : defaultBaseline; | ||
var value = exists(_y) ? _y : _y1; | ||
if (!exists(value)) return datum; // value only and less than min domain or greater than max domain | ||
if (!exists(baseline) && (isUnderMinY(value) || isOverMaxY(value))) _y = null; // baseline and value are both less than min domain or both greater than max domain | ||
if (isUnderMinY(baseline) && isUnderMinY(value) || isOverMaxY(baseline) && isOverMaxY(value)) _y = _y0 = _y1 = null; // baseline and value with only baseline below min, set baseline to minDomainY | ||
if (isUnderMinY(baseline) && !isUnderMinY(value)) _y0 = minDomainY; // baseline and value with only baseline above max, set baseline to maxDomainY | ||
if (isOverMaxY(baseline) && !isOverMaxY(value)) _y0 = maxDomainY; | ||
return (0, _assign2.default)({}, datum, (0, _omitBy2.default)({ | ||
_x: _x, | ||
_y: _y, | ||
_y0: _y0, | ||
_y1: _y1 | ||
}, _isUndefined2.default)); | ||
}); | ||
} // Returns a data accessor given an eventKey prop | ||
@@ -438,2 +508,3 @@ | ||
formatData: formatData, | ||
formatDataFromDomain: formatDataFromDomain, | ||
generateData: generateData, | ||
@@ -440,0 +511,0 @@ getCategories: getCategories, |
{ | ||
"name": "victory-core", | ||
"version": "35.5.1", | ||
"version": "35.6.0", | ||
"description": "Victory Core", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -100,23 +100,34 @@ /*global setTimeout:false */ | ||
shouldComponentUpdate(nextProps, nextState) { | ||
const equalProps = isEqual(this.props, nextProps); | ||
componentDidUpdate(prevProps) { | ||
const equalProps = isEqual(this.props, prevProps); | ||
if (!equalProps) { | ||
/* cancel existing loop if it exists */ | ||
this.timer.unsubscribe(this.loopID); | ||
/* If an object was supplied */ | ||
if (!Array.isArray(nextProps.data)) { | ||
// Replace the tween queue. Could set `this.queue = [nextProps.data]`, | ||
// but let's reuse the same array. | ||
this.queue.length = 0; | ||
this.queue.push(nextProps.data); | ||
/* If an array was supplied */ | ||
/* If the previous animation didn't finish, force it to complete before starting a new one */ | ||
if (this.interpolator && this.state.animationInfo && this.state.animationInfo.progress < 1) { | ||
// eslint-disable-next-line react/no-did-update-set-state | ||
this.setState({ | ||
data: this.interpolator(1), | ||
animationInfo: { | ||
progress: 1, | ||
animating: false, | ||
terminating: true | ||
} | ||
}); | ||
} else { | ||
/* Extend the tween queue */ | ||
this.queue.push(...nextProps.data); | ||
/* cancel existing loop if it exists */ | ||
this.timer.unsubscribe(this.loopID); | ||
/* If an object was supplied */ | ||
if (!Array.isArray(this.props.data)) { | ||
// Replace the tween queue. Could set `this.queue = [nextProps.data]`, | ||
// but let's reuse the same array. | ||
this.queue.length = 0; | ||
this.queue.push(this.props.data); | ||
/* If an array was supplied */ | ||
} else { | ||
/* Extend the tween queue */ | ||
this.queue.push(...this.props.data); | ||
} | ||
/* Start traversing the tween queue */ | ||
this.traverseQueue(); | ||
} | ||
/* Start traversing the tween queue */ | ||
this.traverseQueue(); | ||
} | ||
return nextState.animationInfo.animating || nextState.animationInfo.terminating || !equalProps; | ||
} | ||
@@ -123,0 +134,0 @@ |
@@ -15,3 +15,5 @@ /* eslint-disable func-style */ | ||
isEqual, | ||
includes | ||
includes, | ||
isUndefined, | ||
omitBy | ||
} from "lodash"; | ||
@@ -95,2 +97,48 @@ import Helpers from "./helpers"; | ||
// This method will remove data points that fall outside of the desired domain (non-continuous charts only) | ||
function formatDataFromDomain(dataset, domain, defaultBaseline) { | ||
const exists = (val) => val !== undefined; | ||
const [minDomainX, maxDomainX] = domain.x; | ||
const [minDomainY, maxDomainY] = domain.y; | ||
const underMin = (min) => (val) => exists(val) && val < min; | ||
const overMax = (max) => (val) => exists(val) && val > max; | ||
const isUnderMinX = underMin(minDomainX); | ||
const isUnderMinY = underMin(minDomainY); | ||
const isOverMaxX = overMax(maxDomainX); | ||
const isOverMaxY = overMax(maxDomainY); | ||
// eslint-disable-next-line complexity | ||
return dataset.map((datum) => { | ||
let { _x, _y, _y0, _y1 } = datum; | ||
// single x point less than min domain | ||
if (isUnderMinX(_x) || isOverMaxX(_x)) _x = null; | ||
const baseline = exists(_y0) ? _y0 : defaultBaseline; | ||
const value = exists(_y) ? _y : _y1; | ||
if (!exists(value)) return datum; | ||
// value only and less than min domain or greater than max domain | ||
if (!exists(baseline) && (isUnderMinY(value) || isOverMaxY(value))) _y = null; | ||
// baseline and value are both less than min domain or both greater than max domain | ||
if ( | ||
(isUnderMinY(baseline) && isUnderMinY(value)) || | ||
(isOverMaxY(baseline) && isOverMaxY(value)) | ||
) | ||
_y = _y0 = _y1 = null; | ||
// baseline and value with only baseline below min, set baseline to minDomainY | ||
if (isUnderMinY(baseline) && !isUnderMinY(value)) _y0 = minDomainY; | ||
// baseline and value with only baseline above max, set baseline to maxDomainY | ||
if (isOverMaxY(baseline) && !isOverMaxY(value)) _y0 = maxDomainY; | ||
return assign({}, datum, omitBy({ _x, _y, _y0, _y1 }, isUndefined)); | ||
}); | ||
} | ||
// Returns a data accessor given an eventKey prop | ||
@@ -385,2 +433,3 @@ function getEventKey(key) { | ||
formatData, | ||
formatDataFromDomain, | ||
generateData, | ||
@@ -387,0 +436,0 @@ getCategories, |
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
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
2243817
45468