victory-zoom-container
Advanced tools
Comparing version 31.2.0 to 32.0.0
@@ -53,5 +53,6 @@ import _isFunction from "lodash/isFunction"; | ||
polar = props.polar, | ||
origin = props.origin; | ||
var rangeX = scale.x.range(); | ||
var rangeY = scale.y.range(); | ||
origin = props.origin, | ||
horizontal = props.horizontal; | ||
var rangeX = horizontal ? scale.y.range() : scale.x.range(); | ||
var rangeY = horizontal ? scale.x.range() : scale.y.range(); | ||
var plottableWidth = Math.abs(rangeX[0] - rangeX[1]); | ||
@@ -58,0 +59,0 @@ var plottableHeight = Math.abs(rangeY[0] - rangeY[1]); |
@@ -177,3 +177,4 @@ import _defaults from "lodash/defaults"; | ||
}, | ||
getDomainScale: function (domain, scale, axis) { | ||
// eslint-disable-next-line max-params | ||
getDomainScale: function (domain, scale, axis, horizontal) { | ||
var axisDomain = Array.isArray(domain) ? domain : domain[axis]; | ||
@@ -185,3 +186,4 @@ | ||
var range = scale[axis].range(); | ||
var otherAxis = axis === "x" ? "y" : "x"; | ||
var range = horizontal ? scale[otherAxis].range() : scale[axis].range(); | ||
var plottableWidth = Math.abs(range[0] - range[1]); | ||
@@ -218,20 +220,3 @@ return plottableWidth / (to - from); | ||
children = props.children, | ||
zoomDimension = props.zoomDimension, | ||
horizontal = props.horizontal; | ||
var xAxis = "x"; | ||
var yAxis = "y"; | ||
var zoomAxis = zoomDimension; | ||
if (horizontal) { | ||
xAxis = "y"; | ||
yAxis = "x"; | ||
if (zoomDimension) { | ||
zoomAxis = { | ||
x: xAxis, | ||
y: yAxis | ||
}[zoomDimension]; | ||
} | ||
} | ||
zoomDimension = props.zoomDimension; | ||
var childComponents = Children.toArray(children); | ||
@@ -241,5 +226,5 @@ var childrenDomain = {}; | ||
if (childComponents.length) { | ||
childrenDomain = zoomDimension ? _defineProperty({}, zoomDimension, Wrapper.getDomainFromChildren(props, zoomAxis, childComponents)) : { | ||
x: Wrapper.getDomainFromChildren(props, xAxis, childComponents), | ||
y: Wrapper.getDomainFromChildren(props, yAxis, childComponents) | ||
childrenDomain = zoomDimension ? _defineProperty({}, zoomDimension, Wrapper.getDomainFromChildren(props, zoomDimension, childComponents)) : { | ||
x: Wrapper.getDomainFromChildren(props, "x", childComponents), | ||
y: Wrapper.getDomainFromChildren(props, "y", childComponents) | ||
}; | ||
@@ -311,4 +296,5 @@ } | ||
onZoomDomainChange = targetProps.onZoomDomainChange, | ||
zoomDomain = targetProps.zoomDomain, | ||
zoomDimension = targetProps.zoomDimension, | ||
zoomDomain = targetProps.zoomDomain; | ||
horizontal = targetProps.horizontal; | ||
var parentSVG = targetProps.parentSVG || Selection.getParentSVG(evt); | ||
@@ -322,4 +308,6 @@ | ||
var lastDomain = this.getLastDomain(targetProps, originalDomain); | ||
var dx = (startX - x) / this.getDomainScale(lastDomain, scale, "x"); | ||
var dy = (y - startY) / this.getDomainScale(lastDomain, scale, "y"); | ||
var deltaX = horizontal ? y - startY : startX - x; | ||
var deltaY = horizontal ? startX - x : y - startY; | ||
var dx = deltaX / this.getDomainScale(lastDomain, scale, "x", horizontal); | ||
var dy = deltaY / this.getDomainScale(lastDomain, scale, "y", horizontal); | ||
var currentDomain = { | ||
@@ -326,0 +314,0 @@ x: zoomDimension === "y" ? originalDomain.x : this.pan(lastDomain.x, originalDomain.x, dx), |
@@ -68,5 +68,6 @@ "use strict"; | ||
polar = props.polar, | ||
origin = props.origin; | ||
var rangeX = scale.x.range(); | ||
var rangeY = scale.y.range(); | ||
origin = props.origin, | ||
horizontal = props.horizontal; | ||
var rangeX = horizontal ? scale.y.range() : scale.x.range(); | ||
var rangeY = horizontal ? scale.x.range() : scale.y.range(); | ||
var plottableWidth = Math.abs(rangeX[0] - rangeX[1]); | ||
@@ -73,0 +74,0 @@ var plottableHeight = Math.abs(rangeY[0] - rangeY[1]); |
@@ -189,3 +189,4 @@ "use strict"; | ||
}, | ||
getDomainScale: function (domain, scale, axis) { | ||
// eslint-disable-next-line max-params | ||
getDomainScale: function (domain, scale, axis, horizontal) { | ||
var axisDomain = Array.isArray(domain) ? domain : domain[axis]; | ||
@@ -197,3 +198,4 @@ | ||
var range = scale[axis].range(); | ||
var otherAxis = axis === "x" ? "y" : "x"; | ||
var range = horizontal ? scale[otherAxis].range() : scale[axis].range(); | ||
var plottableWidth = Math.abs(range[0] - range[1]); | ||
@@ -230,20 +232,4 @@ return plottableWidth / (to - from); | ||
children = props.children, | ||
zoomDimension = props.zoomDimension, | ||
horizontal = props.horizontal; | ||
var xAxis = "x"; | ||
var yAxis = "y"; | ||
var zoomAxis = zoomDimension; | ||
zoomDimension = props.zoomDimension; | ||
if (horizontal) { | ||
xAxis = "y"; | ||
yAxis = "x"; | ||
if (zoomDimension) { | ||
zoomAxis = { | ||
x: xAxis, | ||
y: yAxis | ||
}[zoomDimension]; | ||
} | ||
} | ||
var childComponents = _react.Children.toArray(children); | ||
@@ -254,5 +240,5 @@ | ||
if (childComponents.length) { | ||
childrenDomain = zoomDimension ? _defineProperty({}, zoomDimension, _victoryCore.Wrapper.getDomainFromChildren(props, zoomAxis, childComponents)) : { | ||
x: _victoryCore.Wrapper.getDomainFromChildren(props, xAxis, childComponents), | ||
y: _victoryCore.Wrapper.getDomainFromChildren(props, yAxis, childComponents) | ||
childrenDomain = zoomDimension ? _defineProperty({}, zoomDimension, _victoryCore.Wrapper.getDomainFromChildren(props, zoomDimension, childComponents)) : { | ||
x: _victoryCore.Wrapper.getDomainFromChildren(props, "x", childComponents), | ||
y: _victoryCore.Wrapper.getDomainFromChildren(props, "y", childComponents) | ||
}; | ||
@@ -324,4 +310,5 @@ } | ||
onZoomDomainChange = targetProps.onZoomDomainChange, | ||
zoomDomain = targetProps.zoomDomain, | ||
zoomDimension = targetProps.zoomDimension, | ||
zoomDomain = targetProps.zoomDomain; | ||
horizontal = targetProps.horizontal; | ||
@@ -336,4 +323,6 @@ var parentSVG = targetProps.parentSVG || _victoryCore.Selection.getParentSVG(evt); | ||
var lastDomain = this.getLastDomain(targetProps, originalDomain); | ||
var dx = (startX - x) / this.getDomainScale(lastDomain, scale, "x"); | ||
var dy = (y - startY) / this.getDomainScale(lastDomain, scale, "y"); | ||
var deltaX = horizontal ? y - startY : startX - x; | ||
var deltaY = horizontal ? startX - x : y - startY; | ||
var dx = deltaX / this.getDomainScale(lastDomain, scale, "x", horizontal); | ||
var dy = deltaY / this.getDomainScale(lastDomain, scale, "y", horizontal); | ||
var currentDomain = { | ||
@@ -340,0 +329,0 @@ x: zoomDimension === "y" ? originalDomain.x : this.pan(lastDomain.x, originalDomain.x, dx), |
{ | ||
"name": "victory-zoom-container", | ||
"version": "31.2.0", | ||
"version": "32.0.0", | ||
"description": "Interactive Zoom Component for Victory", | ||
@@ -24,3 +24,3 @@ "keywords": [ | ||
"prop-types": "^15.5.8", | ||
"victory-core": "^31.2.0" | ||
"victory-core": "^32.0.0" | ||
}, | ||
@@ -27,0 +27,0 @@ "scripts": { |
@@ -96,5 +96,5 @@ import PropTypes from "prop-types"; | ||
clipDataComponents(children, props) { | ||
const { scale, clipContainerComponent, polar, origin } = props; | ||
const rangeX = scale.x.range(); | ||
const rangeY = scale.y.range(); | ||
const { scale, clipContainerComponent, polar, origin, horizontal } = props; | ||
const rangeX = horizontal ? scale.y.range() : scale.x.range(); | ||
const rangeY = horizontal ? scale.x.range() : scale.y.range(); | ||
const plottableWidth = Math.abs(rangeX[0] - rangeX[1]); | ||
@@ -101,0 +101,0 @@ const plottableHeight = Math.abs(rangeY[0] - rangeY[1]); |
@@ -135,7 +135,8 @@ /*eslint no-magic-numbers: ["error", { "ignore": [-1, 0, 1, 2, 1000] }]*/ | ||
}, | ||
getDomainScale(domain, scale, axis) { | ||
// eslint-disable-next-line max-params | ||
getDomainScale(domain, scale, axis, horizontal) { | ||
const axisDomain = Array.isArray(domain) ? domain : domain[axis]; | ||
const [from, to] = axisDomain; | ||
const range = scale[axis].range(); | ||
const otherAxis = axis === "x" ? "y" : "x"; | ||
const range = horizontal ? scale[otherAxis].range() : scale[axis].range(); | ||
const plottableWidth = Math.abs(range[0] - range[1]); | ||
@@ -165,13 +166,3 @@ return plottableWidth / (to - from); | ||
getDomain(props) { | ||
const { originalDomain, domain, children, zoomDimension, horizontal } = props; | ||
let xAxis = "x"; | ||
let yAxis = "y"; | ||
let zoomAxis = zoomDimension; | ||
if (horizontal) { | ||
xAxis = "y"; | ||
yAxis = "x"; | ||
if (zoomDimension) { | ||
zoomAxis = { x: xAxis, y: yAxis }[zoomDimension]; | ||
} | ||
} | ||
const { originalDomain, domain, children, zoomDimension } = props; | ||
const childComponents = Children.toArray(children); | ||
@@ -182,7 +173,7 @@ let childrenDomain = {}; | ||
? { | ||
[zoomDimension]: Wrapper.getDomainFromChildren(props, zoomAxis, childComponents) | ||
[zoomDimension]: Wrapper.getDomainFromChildren(props, zoomDimension, childComponents) | ||
} | ||
: { | ||
x: Wrapper.getDomainFromChildren(props, xAxis, childComponents), | ||
y: Wrapper.getDomainFromChildren(props, yAxis, childComponents) | ||
x: Wrapper.getDomainFromChildren(props, "x", childComponents), | ||
y: Wrapper.getDomainFromChildren(props, "y", childComponents) | ||
}; | ||
@@ -247,3 +238,11 @@ } | ||
if (targetProps.panning && targetProps.allowPan) { | ||
const { scale, startX, startY, onZoomDomainChange, zoomDimension, zoomDomain } = targetProps; | ||
const { | ||
scale, | ||
startX, | ||
startY, | ||
onZoomDomainChange, | ||
zoomDomain, | ||
zoomDimension, | ||
horizontal | ||
} = targetProps; | ||
const parentSVG = targetProps.parentSVG || Selection.getParentSVG(evt); | ||
@@ -253,4 +252,6 @@ const { x, y } = Selection.getSVGEventCoordinates(evt, parentSVG); | ||
const lastDomain = this.getLastDomain(targetProps, originalDomain); | ||
const dx = (startX - x) / this.getDomainScale(lastDomain, scale, "x"); | ||
const dy = (y - startY) / this.getDomainScale(lastDomain, scale, "y"); | ||
const deltaX = horizontal ? y - startY : startX - x; | ||
const deltaY = horizontal ? startX - x : y - startY; | ||
const dx = deltaX / this.getDomainScale(lastDomain, scale, "x", horizontal); | ||
const dy = deltaY / this.getDomainScale(lastDomain, scale, "y", horizontal); | ||
const currentDomain = { | ||
@@ -257,0 +258,0 @@ x: zoomDimension === "y" ? originalDomain.x : this.pan(lastDomain.x, originalDomain.x, dx), |
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
1240836
22649
+ Addedvictory-core@32.3.7(transitive)
- Removedvictory-core@31.2.0(transitive)
Updatedvictory-core@^32.0.0