victory-chart
Advanced tools
Comparing version 16.0.1 to 16.1.0
# VictoryChart Changelog | ||
## 16.1.0 (2017-02-03) | ||
- [429](https://github.com/FormidableLabs/victory-chart/pull/429) | ||
- Throttles `onWheel` and `onMouseMove` events on Victory container components | ||
- Exports container event helpers | ||
## 16.0.1 (2017-02-01) | ||
@@ -4,0 +10,0 @@ |
@@ -1,4 +0,4 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});var _isFunction2=require("lodash/isFunction");var _isFunction3=_interopRequireDefault(_isFunction2);var _isEqual2=require("lodash/isEqual");var _isEqual3=_interopRequireDefault(_isEqual2);var _assign2=require("lodash/assign");var _assign3=_interopRequireDefault(_assign2);var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};var _createClass=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);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};}();var _react=require("react");var _react2=_interopRequireDefault(_react); | ||
Object.defineProperty(exports,"__esModule",{value:true});var _isEqual2=require("lodash/isEqual");var _isEqual3=_interopRequireDefault(_isEqual2);var _assign2=require("lodash/assign");var _assign3=_interopRequireDefault(_assign2);var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};var _createClass=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);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};}();var _react=require("react");var _react2=_interopRequireDefault(_react); | ||
var _victoryCore=require("victory-core"); | ||
var _helperMethods=require("./helper-methods");var _helperMethods2=_interopRequireDefault(_helperMethods);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i];}return arr2;}else{return Array.from(arr);}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call&&(typeof call==="object"||typeof call==="function")?call:self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass;}var | ||
var _brushHelpers=require("./brush-helpers");var _brushHelpers2=_interopRequireDefault(_brushHelpers);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i];}return arr2;}else{return Array.from(arr);}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call&&(typeof call==="object"||typeof call==="function")?call:self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass;}var | ||
@@ -62,126 +62,2 @@ | ||
props,coordinates){var | ||
@@ -248,2 +124,2 @@ x=coordinates.x,y=coordinates.y;var | ||
}); | ||
}}]);return VictoryBrushContainer;}(_victoryCore.VictoryContainer);VictoryBrushContainer.displayName="VictoryBrushContainer";VictoryBrushContainer.propTypes=_extends({},_victoryCore.VictoryContainer.propTypes,{selectionStyle:_react2.default.PropTypes.object,handleStyle:_react2.default.PropTypes.object,dimension:_react2.default.PropTypes.oneOf(["x","y"]),selectedDomain:_react2.default.PropTypes.shape({x:_react2.default.PropTypes.array,y:_react2.default.PropTypes.array}),onDomainChange:_react2.default.PropTypes.func,handleWidth:_react2.default.PropTypes.number,selectionComponent:_react2.default.PropTypes.element,handleComponent:_react2.default.PropTypes.element});VictoryBrushContainer.defaultProps=_extends({},_victoryCore.VictoryContainer.defaultProps,{selectionStyle:{stroke:"transparent",fill:"black",fillOpacity:0.1},handleStyle:{stroke:"transparent",fill:"transparent"},dimension:"x",handleWidth:8,selectionComponent:_react2.default.createElement("rect",null),handleComponent:_react2.default.createElement("rect",null)});VictoryBrushContainer.defaultEvents=[{target:"parent",eventHandlers:{onMouseDown:function onMouseDown(evt,targetProps){evt.preventDefault();var dimension=targetProps.dimension,selectedDomain=targetProps.selectedDomain,domain=targetProps.domain,handleWidth=targetProps.handleWidth,onDomainChange=targetProps.onDomainChange,cachedSelectedDomain=targetProps.cachedSelectedDomain;var fullDomainBox=targetProps.fullDomainBox||_helperMethods2.default.getDomainBox(targetProps,domain);var currentDomain=(0,_isEqual3.default)(selectedDomain,cachedSelectedDomain)?targetProps.currentDomain||selectedDomain||domain:selectedDomain||domain;var _Selection$getSVGEven=_victoryCore.Selection.getSVGEventCoordinates(evt),x=_Selection$getSVGEven.x,y=_Selection$getSVGEven.y;if(!_helperMethods2.default.withinBounds({x:x,y:y},fullDomainBox,handleWidth)){return{};}var domainBox=_helperMethods2.default.getDomainBox(targetProps,domain,currentDomain);var activeHandles=_helperMethods2.default.getActiveHandles({x:x,y:y},targetProps,domainBox);if(activeHandles){return[{target:"parent",mutation:function mutation(){return _extends({isSelecting:true,domainBox:domainBox,fullDomainBox:fullDomainBox,cachedSelectedDomain:selectedDomain,currentDomain:currentDomain},_helperMethods2.default.getResizeMutation(domainBox,activeHandles));}}];}else if(_helperMethods2.default.withinBounds({x:x,y:y},domainBox)&&!(0,_isEqual3.default)(domain,currentDomain)){return[{target:"parent",mutation:function mutation(){return{isPanning:true,startX:x,startY:y,domainBox:domainBox,fullDomainBox:fullDomainBox,currentDomain:currentDomain,cachedSelectedDomain:selectedDomain};}}];}else{var minimumDomain=_helperMethods2.default.getMinimumDomain();if((0,_isFunction3.default)(onDomainChange)){onDomainChange(minimumDomain);}return[{target:"parent",mutation:function mutation(){return _extends({isSelecting:true,domainBox:domainBox,fullDomainBox:fullDomainBox,cachedSelectedDomain:selectedDomain,currentDomain:_helperMethods2.default.getMinimumDomain()},_helperMethods2.default.getSelectionMutation({x:x,y:y},domainBox,dimension));}}];}},onMouseMove:function onMouseMove(evt,targetProps){if(!targetProps.isPanning&&!targetProps.isSelecting){return{};}var dimension=targetProps.dimension,scale=targetProps.scale,isPanning=targetProps.isPanning,isSelecting=targetProps.isSelecting,fullDomainBox=targetProps.fullDomainBox,onDomainChange=targetProps.onDomainChange;var _Selection$getSVGEven2=_victoryCore.Selection.getSVGEventCoordinates(evt),x=_Selection$getSVGEven2.x,y=_Selection$getSVGEven2.y;if(!_helperMethods2.default.withinBounds({x:x,y:y},fullDomainBox)){return{};}if(isPanning){var _ret=function(){var startX=targetProps.startX,startY=targetProps.startY;var pannedBox=_helperMethods2.default.panBox(targetProps,{x:x,y:y});var constrainedBox=_helperMethods2.default.constrainBox(pannedBox,fullDomainBox);var currentDomain=_victoryCore.Selection.getBounds(_extends({},constrainedBox,{scale:scale}));if((0,_isFunction3.default)(onDomainChange)){onDomainChange(currentDomain);}return{v:[{target:"parent",mutation:function mutation(){return _extends({currentDomain:currentDomain,startX:pannedBox.x2>=fullDomainBox.x2||pannedBox.x1<=fullDomainBox.x1?startX:x,startY:pannedBox.y2>=fullDomainBox.y2||pannedBox.y1<=fullDomainBox.y1?startY:y},constrainedBox);}}]};}();if(typeof _ret==="object")return _ret.v;}else if(isSelecting){var _ret2=function(){var x2=dimension!=="y"?x:targetProps.x2;var y2=dimension!=="x"?y:targetProps.y2;var currentDomain=_victoryCore.Selection.getBounds({x2:x2,y2:y2,x1:targetProps.x1,y1:targetProps.y1,scale:scale});if((0,_isFunction3.default)(onDomainChange)){onDomainChange(currentDomain);}return{v:[{target:"parent",mutation:function mutation(){return{x2:x2,y2:y2,currentDomain:currentDomain};}}]};}();if(typeof _ret2==="object")return _ret2.v;}},onMouseUp:function onMouseUp(evt,targetProps){var x1=targetProps.x1,y1=targetProps.y1,x2=targetProps.x2,y2=targetProps.y2,domain=targetProps.domain,onDomainChange=targetProps.onDomainChange;if(x1===x2||y1===y2){if((0,_isFunction3.default)(onDomainChange)){onDomainChange(domain);}return[{target:"parent",mutation:function mutation(){return{isPanning:false,isSelecting:false,currentDomain:domain};}}];}return[{target:"parent",mutation:function mutation(){return{isPanning:false,isSelecting:false};}}];},onMouseLeave:function onMouseLeave(){return[{target:"parent",mutation:function mutation(){return{isPanning:false,isSelecting:false};}}];}}}];exports.default=VictoryBrushContainer; | ||
}}]);return VictoryBrushContainer;}(_victoryCore.VictoryContainer);VictoryBrushContainer.displayName="VictoryBrushContainer";VictoryBrushContainer.propTypes=_extends({},_victoryCore.VictoryContainer.propTypes,{selectionStyle:_react2.default.PropTypes.object,handleStyle:_react2.default.PropTypes.object,dimension:_react2.default.PropTypes.oneOf(["x","y"]),selectedDomain:_react2.default.PropTypes.shape({x:_react2.default.PropTypes.array,y:_react2.default.PropTypes.array}),onDomainChange:_react2.default.PropTypes.func,handleWidth:_react2.default.PropTypes.number,selectionComponent:_react2.default.PropTypes.element,handleComponent:_react2.default.PropTypes.element});VictoryBrushContainer.defaultProps=_extends({},_victoryCore.VictoryContainer.defaultProps,{selectionStyle:{stroke:"transparent",fill:"black",fillOpacity:0.1},handleStyle:{stroke:"transparent",fill:"transparent"},dimension:"x",handleWidth:8,selectionComponent:_react2.default.createElement("rect",null),handleComponent:_react2.default.createElement("rect",null)});VictoryBrushContainer.defaultEvents=[{target:"parent",eventHandlers:{onMouseDown:function onMouseDown(evt,targetProps){_brushHelpers2.default.onMouseMove.cancel();return _brushHelpers2.default.onMouseDown(evt,targetProps);},onMouseMove:function onMouseMove(evt,targetProps){evt.persist();return _brushHelpers2.default.onMouseMove(evt,targetProps);},onMouseUp:function onMouseUp(evt,targetProps){_brushHelpers2.default.onMouseMove.cancel();return _brushHelpers2.default.onMouseUp(evt,targetProps);},onMouseLeave:function onMouseLeave(evt,targetProps){_brushHelpers2.default.onMouseMove.cancel();return _brushHelpers2.default.onMouseLeave(evt,targetProps);}}}];exports.default=VictoryBrushContainer; |
@@ -1,6 +0,6 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});var _assign2=require("lodash/assign");var _assign3=_interopRequireDefault(_assign2);var _isFunction2=require("lodash/isFunction");var _isFunction3=_interopRequireDefault(_isFunction2);var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};var _createClass=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);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};}();var _react=require("react");var _react2=_interopRequireDefault(_react); | ||
var _victoryCore=require("victory-core");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i];}return arr2;}else{return Array.from(arr);}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call&&(typeof call==="object"||typeof call==="function")?call:self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass;}var | ||
Object.defineProperty(exports,"__esModule",{value:true});var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};var _createClass=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);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};}();var _react=require("react");var _react2=_interopRequireDefault(_react); | ||
var _victoryCore=require("victory-core"); | ||
var _selectionHelpers=require("./selection-helpers");var _selectionHelpers2=_interopRequireDefault(_selectionHelpers);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _toConsumableArray(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++){arr2[i]=arr[i];}return arr2;}else{return Array.from(arr);}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call&&(typeof call==="object"||typeof call==="function")?call:self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass;}var | ||
VictorySelectionContainer=function(_VictoryContainer){_inherits(VictorySelectionContainer,_VictoryContainer);function VictorySelectionContainer(){_classCallCheck(this,VictorySelectionContainer);return _possibleConstructorReturn(this,(VictorySelectionContainer.__proto__||Object.getPrototypeOf(VictorySelectionContainer)).apply(this,arguments));}_createClass(VictorySelectionContainer,[{key:"getRect",value:function getRect( | ||
@@ -46,58 +46,2 @@ | ||
props){var | ||
@@ -120,2 +64,2 @@ x1=props.x1,x2=props.x2,y1=props.y1,y2=props.y2,selectionStyle=props.selectionStyle,selectionComponent=props.selectionComponent; | ||
}); | ||
}}]);return VictorySelectionContainer;}(_victoryCore.VictoryContainer);VictorySelectionContainer.displayName="VictorySelectionContainer";VictorySelectionContainer.propTypes=_extends({},_victoryCore.VictoryContainer.propTypes,{selectionStyle:_react2.default.PropTypes.object,onSelection:_react2.default.PropTypes.func,onSelectionCleared:_react2.default.PropTypes.func,dimension:_react2.default.PropTypes.oneOf(["x","y"]),standalone:_react2.default.PropTypes.bool,selectionComponent:_react2.default.PropTypes.element});VictorySelectionContainer.defaultProps=_extends({},_victoryCore.VictoryContainer.defaultProps,{selectionStyle:{stroke:"transparent",fill:"black",fillOpacity:0.1},standalone:true,selectionComponent:_react2.default.createElement("rect",null)});VictorySelectionContainer.defaultEvents=[{target:"parent",eventHandlers:{onMouseDown:function onMouseDown(evt,targetProps){evt.preventDefault();var dimension=targetProps.dimension,scale=targetProps.scale;var _Selection$getSVGEven=_victoryCore.Selection.getSVGEventCoordinates(evt),x=_Selection$getSVGEven.x,y=_Selection$getSVGEven.y;var x1=dimension!=="y"?x:_victoryCore.Selection.getDomainCoordinates(scale).x[0];var y1=dimension!=="x"?y:_victoryCore.Selection.getDomainCoordinates(scale).y[0];var x2=dimension!=="y"?x:_victoryCore.Selection.getDomainCoordinates(scale).x[1];var y2=dimension!=="x"?y:_victoryCore.Selection.getDomainCoordinates(scale).y[1];if((0,_isFunction3.default)(targetProps.onSelectionCleared)){targetProps.onSelectionCleared();}return[{target:"parent",mutation:function mutation(){return{x1:x1,y1:y1,select:true,x2:x2,y2:y2};}},{target:"data",childName:targetProps.children?"all":undefined,eventKey:"all",mutation:function mutation(){return null;}}];},onMouseMove:function onMouseMove(evt,targetProps){var dimension=targetProps.dimension,scale=targetProps.scale,select=targetProps.select;if(!select){return{};}else{var _ret=function(){var _Selection$getSVGEven2=_victoryCore.Selection.getSVGEventCoordinates(evt),x=_Selection$getSVGEven2.x,y=_Selection$getSVGEven2.y;var x2=dimension!=="y"?x:_victoryCore.Selection.getDomainCoordinates(scale).x[1];var y2=dimension!=="x"?y:_victoryCore.Selection.getDomainCoordinates(scale).y[1];return{v:{target:"parent",mutation:function mutation(){return{x2:x2,y2:y2};}}};}();if(typeof _ret==="object")return _ret.v;}},onMouseUp:function onMouseUp(evt,targetProps){var x2=targetProps.x2,y2=targetProps.y2;var parentMutation=[{target:"parent",mutation:function mutation(){return{select:false,x1:null,x2:null,y1:null,y2:null};}}];if(!x2||!y2){return parentMutation;}var bounds=_victoryCore.Selection.getBounds(targetProps);var datasets=_victoryCore.Selection.getDatasets(targetProps);var selectedData=_victoryCore.Selection.filterDatasets(datasets,bounds);var callbackMutation=selectedData&&(0,_isFunction3.default)(targetProps.onSelection)?targetProps.onSelection(selectedData,bounds):{};var dataMutation=selectedData?selectedData.map(function(d){return{childName:d.childName,eventKey:d.eventKey,target:"data",mutation:function mutation(){return(0,_assign3.default)({active:true},callbackMutation);}};}):[];return parentMutation.concat(dataMutation);}}}];exports.default=VictorySelectionContainer; | ||
}}]);return VictorySelectionContainer;}(_victoryCore.VictoryContainer);VictorySelectionContainer.displayName="VictorySelectionContainer";VictorySelectionContainer.propTypes=_extends({},_victoryCore.VictoryContainer.propTypes,{selectionStyle:_react2.default.PropTypes.object,onSelection:_react2.default.PropTypes.func,onSelectionCleared:_react2.default.PropTypes.func,dimension:_react2.default.PropTypes.oneOf(["x","y"]),standalone:_react2.default.PropTypes.bool,selectionComponent:_react2.default.PropTypes.element});VictorySelectionContainer.defaultProps=_extends({},_victoryCore.VictoryContainer.defaultProps,{selectionStyle:{stroke:"transparent",fill:"black",fillOpacity:0.1},standalone:true,selectionComponent:_react2.default.createElement("rect",null)});VictorySelectionContainer.defaultEvents=[{target:"parent",eventHandlers:{onMouseDown:function onMouseDown(evt,targetProps){_selectionHelpers2.default.onMouseMove.cancel();return _selectionHelpers2.default.onMouseDown(evt,targetProps);},onMouseMove:function onMouseMove(evt,targetProps){evt.persist();return _selectionHelpers2.default.onMouseMove(evt,targetProps);},onMouseUp:function onMouseUp(evt,targetProps){_selectionHelpers2.default.onMouseMove.cancel();return _selectionHelpers2.default.onMouseUp(evt,targetProps);}}}];exports.default=VictorySelectionContainer; |
@@ -1,8 +0,6 @@ | ||
Object.defineProperty(exports,"__esModule",{value:true});var _isEqual2=require("lodash/isEqual");var _isEqual3=_interopRequireDefault(_isEqual2);var _isFunction2=require("lodash/isFunction");var _isFunction3=_interopRequireDefault(_isFunction2);var _defaults2=require("lodash/defaults");var _defaults3=_interopRequireDefault(_defaults2);var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};var _createClass=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);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};}();var _react=require("react");var _react2=_interopRequireDefault(_react); | ||
Object.defineProperty(exports,"__esModule",{value:true});var _isEqual2=require("lodash/isEqual");var _isEqual3=_interopRequireDefault(_isEqual2);var _defaults2=require("lodash/defaults");var _defaults3=_interopRequireDefault(_defaults2);var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};var _createClass=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);}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor;};}();var _react=require("react");var _react2=_interopRequireDefault(_react); | ||
var _helperMethods=require("./helper-methods");var _helperMethods2=_interopRequireDefault(_helperMethods); | ||
var _zoomHelpers=require("./zoom-helpers");var _zoomHelpers2=_interopRequireDefault(_zoomHelpers); | ||
var _victoryCore=require("victory-core");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 _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call&&(typeof call==="object"||typeof call==="function")?call:self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass;}var | ||
VictoryZoomContainer=function(_VictoryContainer){_inherits(VictoryZoomContainer,_VictoryContainer);function VictoryZoomContainer(){_classCallCheck(this,VictoryZoomContainer);return _possibleConstructorReturn(this,(VictoryZoomContainer.__proto__||Object.getPrototypeOf(VictoryZoomContainer)).apply(this,arguments));}_createClass(VictoryZoomContainer,[{key:"clipDataComponents",value:function clipDataComponents( | ||
@@ -59,73 +57,2 @@ | ||
children,props){var | ||
@@ -191,2 +118,2 @@ scale=props.scale,height=props.height,clipContainerComponent=props.clipContainerComponent; | ||
return this.clipDataComponents(children,props); | ||
}}]);return VictoryZoomContainer;}(_victoryCore.VictoryContainer);VictoryZoomContainer.displayName="VictoryZoomContainer";VictoryZoomContainer.propTypes=_extends({},_victoryCore.VictoryContainer.propTypes,{zoomDomain:_react.PropTypes.shape({x:_victoryCore.PropTypes.domain,y:_victoryCore.PropTypes.domain}),onDomainChange:_react.PropTypes.func,clipContainerComponent:_react.PropTypes.element.isRequired,allowZoom:_react.PropTypes.bool});VictoryZoomContainer.defaultProps=_extends({},_victoryCore.VictoryContainer.defaultProps,{clipContainerComponent:_react2.default.createElement(_victoryCore.VictoryClipContainer,null),allowZoom:true});VictoryZoomContainer.defaultEvents=[{target:"parent",eventHandlers:{onMouseDown:function onMouseDown(evt,targetProps,eventKey,ctx){evt.preventDefault();var getTimer=targetProps.getTimer||ctx.context&&ctx.context.getTimer||new _victoryCore.Timer();var originalDomain=targetProps.originalDomain||targetProps.domain;var currentDomain=targetProps.currentDomain||targetProps.zoomDomain||originalDomain;var _Selection$getSVGEven=_victoryCore.Selection.getSVGEventCoordinates(evt),x=_Selection$getSVGEven.x;return[{target:"parent",mutation:function mutation(){return{startX:x,domain:currentDomain,cachedZoomDomain:targetProps.zoomDomain,originalDomain:originalDomain,currentDomain:currentDomain,getTimer:getTimer,isPanning:true,parentControlledProps:["domain"]};}}];},onMouseUp:function onMouseUp(){return[{target:"parent",mutation:function mutation(){return{isPanning:false};}}];},onMouseLeave:function onMouseLeave(){return[{target:"parent",mutation:function mutation(){return{isPanning:false};}}];},onMouseMove:function onMouseMove(evt,targetProps,eventKey,ctx){if(targetProps.isPanning){var _ret=function(){var scale=targetProps.scale,startX=targetProps.startX,onDomainChange=targetProps.onDomainChange,domain=targetProps.domain,zoomDomain=targetProps.zoomDomain;var _Selection$getSVGEven2=_victoryCore.Selection.getSVGEventCoordinates(evt),x=_Selection$getSVGEven2.x;var originalDomain=targetProps.originalDomain||domain;var lastDomain=targetProps.currentDomain||targetProps.zoomDomain||originalDomain;var calculatedDx=(startX-x)/_helperMethods2.default.getDomainScale(lastDomain,scale);var nextXDomain=_helperMethods2.default.pan(lastDomain.x,originalDomain.x,calculatedDx);var currentDomain={x:nextXDomain,y:originalDomain.y};var getTimer=(0,_isFunction3.default)(ctx.getTimer)&&ctx.getTimer.bind(ctx);var resumeAnimation=void 0;if(getTimer&&(0,_isFunction3.default)(getTimer().bypassAnimation)){getTimer().bypassAnimation();resumeAnimation=(0,_isFunction3.default)(getTimer().resumeAnimation)?function(){return getTimer().resumeAnimation();}:undefined;}if((0,_isFunction3.default)(onDomainChange)){onDomainChange(currentDomain);}return{v:[{target:"parent",callback:resumeAnimation,mutation:function mutation(){return{domain:currentDomain,currentDomain:currentDomain,originalDomain:originalDomain,cachedZoomDomain:zoomDomain};}}]};}();if(typeof _ret==="object")return _ret.v;}},onWheel:function onWheel(evt,targetProps,eventKey,ctx){if(!targetProps.allowZoom){return{};}evt.preventDefault();var deltaY=evt.deltaY;var onDomainChange=targetProps.onDomainChange,domain=targetProps.domain,zoomDomain=targetProps.zoomDomain;var originalDomain=targetProps.originalDomain||domain;var lastDomain=targetProps.currentDomain||zoomDomain||originalDomain;var x=lastDomain.x;var xBounds=originalDomain.x;var nextXDomain=_helperMethods2.default.scale(x,xBounds,1+deltaY/300);var currentDomain={x:nextXDomain,y:originalDomain.y};var getTimer=(0,_isFunction3.default)(ctx.getTimer)&&ctx.getTimer.bind(ctx);var resumeAnimation=void 0;if(getTimer&&(0,_isFunction3.default)(getTimer().bypassAnimation)){getTimer().bypassAnimation();resumeAnimation=(0,_isFunction3.default)(getTimer().resumeAnimation)?function(){return getTimer().resumeAnimation();}:undefined;}if((0,_isFunction3.default)(onDomainChange)){onDomainChange(currentDomain);}return[{target:"parent",callback:resumeAnimation,mutation:function mutation(){return{domain:currentDomain,currentDomain:currentDomain,originalDomain:originalDomain,cachedZoomDomain:zoomDomain,parentControlledProps:["domain"]};}}];}}}];exports.default=VictoryZoomContainer; | ||
}}]);return VictoryZoomContainer;}(_victoryCore.VictoryContainer);VictoryZoomContainer.displayName="VictoryZoomContainer";VictoryZoomContainer.propTypes=_extends({},_victoryCore.VictoryContainer.propTypes,{zoomDomain:_react.PropTypes.shape({x:_victoryCore.PropTypes.domain,y:_victoryCore.PropTypes.domain}),onDomainChange:_react.PropTypes.func,clipContainerComponent:_react.PropTypes.element.isRequired,allowZoom:_react.PropTypes.bool});VictoryZoomContainer.defaultProps=_extends({},_victoryCore.VictoryContainer.defaultProps,{clipContainerComponent:_react2.default.createElement(_victoryCore.VictoryClipContainer,null),allowZoom:true});VictoryZoomContainer.defaultEvents=[{target:"parent",eventHandlers:{onMouseDown:function onMouseDown(evt,targetProps){_zoomHelpers2.default.onMouseMove.cancel();_zoomHelpers2.default.onWheel.cancel();return _zoomHelpers2.default.onMouseDown(evt,targetProps);},onMouseUp:function onMouseUp(evt,targetProps){_zoomHelpers2.default.onMouseMove.cancel();_zoomHelpers2.default.onWheel.cancel();return _zoomHelpers2.default.onMouseUp(evt,targetProps);},onMouseLeave:function onMouseLeave(evt,targetProps){_zoomHelpers2.default.onMouseMove.cancel();_zoomHelpers2.default.onWheel.cancel();return _zoomHelpers2.default.onMouseLeave(evt,targetProps);},onMouseMove:function onMouseMove(evt,targetProps,eventKey,ctx){evt.preventDefault();evt.persist();_zoomHelpers2.default.onWheel.cancel();return _zoomHelpers2.default.onMouseMove(evt,targetProps,eventKey,ctx);},onWheel:function onWheel(evt,targetProps,eventKey,ctx){evt.preventDefault();evt.persist();_zoomHelpers2.default.onMouseMove.cancel();return _zoomHelpers2.default.onWheel(evt,targetProps,eventKey,ctx);}}}];exports.default=VictoryZoomContainer; |
@@ -22,2 +22,5 @@ Object.defineProperty(exports,"__esModule",{value:true});var _victoryChart=require("./components/victory-chart/victory-chart");Object.defineProperty(exports,"VictoryChart",{enumerable:true,get:function get(){return _interopRequireDefault(_victoryChart).default;}});var _victoryLine=require("./components/victory-line/victory-line");Object.defineProperty(exports,"VictoryLine",{enumerable:true,get:function get(){return _interopRequireDefault(_victoryLine). | ||
default;}});var _victoryZoom=require("./components/victory-zoom/victory-zoom");Object.defineProperty(exports,"VictoryZoom",{enumerable:true,get:function get(){return _interopRequireDefault(_victoryZoom). | ||
default;}});var _brushHelpers=require("./components/containers/brush-helpers");Object.defineProperty(exports,"BrushHelpers",{enumerable:true,get:function get(){return _interopRequireDefault(_brushHelpers). | ||
default;}});var _selectionHelpers=require("./components/containers/selection-helpers");Object.defineProperty(exports,"Selectionelpers",{enumerable:true,get:function get(){return _interopRequireDefault(_selectionHelpers). | ||
default;}});var _zoomHelpers=require("./components/containers/zoom-helpers");Object.defineProperty(exports,"ZoomHelpers",{enumerable:true,get:function get(){return _interopRequireDefault(_zoomHelpers). | ||
default;}});function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};} |
{ | ||
"name": "victory-chart", | ||
"version": "16.0.1", | ||
"version": "16.1.0", | ||
"description": "Chart Component for Victory", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
import React from "react"; | ||
import { VictoryContainer, Selection } from "victory-core"; | ||
import Helpers from "./helper-methods"; | ||
import { assign, isEqual, isFunction } from "lodash"; | ||
import BrushHelpers from "./brush-helpers"; | ||
import { assign, isEqual } from "lodash"; | ||
@@ -43,141 +43,17 @@ | ||
eventHandlers: { | ||
onMouseDown: (evt, targetProps) => { // eslint-disable-line max-statements | ||
evt.preventDefault(); | ||
const { | ||
dimension, selectedDomain, domain, handleWidth, onDomainChange, cachedSelectedDomain | ||
} = targetProps; | ||
const fullDomainBox = targetProps.fullDomainBox || | ||
Helpers.getDomainBox(targetProps, domain); | ||
const currentDomain = isEqual(selectedDomain, cachedSelectedDomain) ? | ||
targetProps.currentDomain || selectedDomain || domain : selectedDomain || domain; | ||
const {x, y} = Selection.getSVGEventCoordinates(evt); | ||
// Ignore events that occur outside of the maximum domain region | ||
if (!Helpers.withinBounds({x, y}, fullDomainBox, handleWidth)) { | ||
return {}; | ||
} | ||
const domainBox = Helpers.getDomainBox(targetProps, domain, currentDomain); | ||
const activeHandles = Helpers.getActiveHandles({x, y}, targetProps, domainBox); | ||
// If the event occurs in any of the handle regions, start a resize | ||
if (activeHandles) { | ||
return [{ | ||
target: "parent", | ||
mutation: () => { | ||
return { | ||
isSelecting: true, domainBox, fullDomainBox, | ||
cachedSelectedDomain: selectedDomain, currentDomain, | ||
...Helpers.getResizeMutation(domainBox, activeHandles) | ||
}; | ||
} | ||
}]; | ||
} else if ( | ||
Helpers.withinBounds({x, y}, domainBox) && | ||
!isEqual(domain, currentDomain) | ||
) { | ||
// if the event occurs within a selected region start a panning event, unless the whole | ||
// domain is selected | ||
return [{ | ||
target: "parent", | ||
mutation: () => ({ | ||
isPanning: true, startX: x, startY: y, domainBox, fullDomainBox, currentDomain, | ||
cachedSelectedDomain: selectedDomain | ||
}) | ||
}]; | ||
} else { | ||
// if the event occurs outside the region, or if the whole domain is selected, | ||
// start a new selection | ||
const minimumDomain = Helpers.getMinimumDomain(); | ||
if (isFunction(onDomainChange)) { | ||
onDomainChange(minimumDomain); | ||
} | ||
return [{ | ||
target: "parent", | ||
mutation: () => { | ||
return { | ||
isSelecting: true, domainBox, fullDomainBox, | ||
cachedSelectedDomain: selectedDomain, | ||
currentDomain: Helpers.getMinimumDomain(), | ||
...Helpers.getSelectionMutation({x, y}, domainBox, dimension) | ||
}; | ||
} | ||
}]; | ||
} | ||
onMouseDown: (evt, targetProps) => { | ||
BrushHelpers.onMouseMove.cancel(); | ||
return BrushHelpers.onMouseDown(evt, targetProps); | ||
}, | ||
onMouseMove: (evt, targetProps) => { // eslint-disable-line max-statements | ||
// if a panning or selection has not been started, ignore the event | ||
if (!targetProps.isPanning && !targetProps.isSelecting) { | ||
return {}; | ||
} | ||
const { | ||
dimension, scale, isPanning, isSelecting, fullDomainBox, onDomainChange | ||
} = targetProps; | ||
const {x, y} = Selection.getSVGEventCoordinates(evt); | ||
// Ignore events that occur outside of the maximum domain region | ||
if (!Helpers.withinBounds({x, y}, fullDomainBox)) { | ||
return {}; | ||
} | ||
if (isPanning) { | ||
const {startX, startY} = targetProps; | ||
const pannedBox = Helpers.panBox(targetProps, {x, y}); | ||
const constrainedBox = Helpers.constrainBox(pannedBox, fullDomainBox); | ||
const currentDomain = Selection.getBounds({...constrainedBox, scale}); | ||
if (isFunction(onDomainChange)) { | ||
onDomainChange(currentDomain); | ||
} | ||
return [{ | ||
target: "parent", | ||
mutation: () => { | ||
return { | ||
currentDomain, | ||
startX: pannedBox.x2 >= fullDomainBox.x2 || pannedBox.x1 <= fullDomainBox.x1 ? | ||
startX : x, | ||
startY: pannedBox.y2 >= fullDomainBox.y2 || pannedBox.y1 <= fullDomainBox.y1 ? | ||
startY : y, | ||
...constrainedBox | ||
}; | ||
} | ||
}]; | ||
} else if (isSelecting) { | ||
const x2 = dimension !== "y" ? x : targetProps.x2; | ||
const y2 = dimension !== "x" ? y : targetProps.y2; | ||
const currentDomain = | ||
Selection.getBounds({x2, y2, x1: targetProps.x1, y1: targetProps.y1, scale}); | ||
if (isFunction(onDomainChange)) { | ||
onDomainChange(currentDomain); | ||
} | ||
return [{ | ||
target: "parent", | ||
mutation: () => { | ||
return { | ||
x2, y2, currentDomain | ||
}; | ||
} | ||
}]; | ||
} | ||
onMouseMove: (evt, targetProps) => { | ||
evt.persist(); | ||
return BrushHelpers.onMouseMove(evt, targetProps); | ||
}, | ||
onMouseUp: (evt, targetProps) => { | ||
const {x1, y1, x2, y2, domain, onDomainChange} = targetProps; | ||
// if the mouse hasn't moved since a mouseDown event, select the whole domain region | ||
if (x1 === x2 || y1 === y2) { | ||
if (isFunction(onDomainChange)) { | ||
onDomainChange(domain); | ||
} | ||
return [{ | ||
target: "parent", | ||
mutation: () => { | ||
return { | ||
isPanning: false, isSelecting: false, currentDomain: domain | ||
}; | ||
} | ||
}]; | ||
} | ||
return [{ | ||
target: "parent", | ||
mutation: () => ({ isPanning: false, isSelecting: false }) | ||
}]; | ||
BrushHelpers.onMouseMove.cancel(); | ||
return BrushHelpers.onMouseUp(evt, targetProps); | ||
}, | ||
onMouseLeave: () => { | ||
return [{ | ||
target: "parent", | ||
mutation: () => ({ isPanning: false, isSelecting: false }) | ||
}]; | ||
onMouseLeave: (evt, targetProps) => { | ||
BrushHelpers.onMouseMove.cancel(); | ||
return BrushHelpers.onMouseLeave(evt, targetProps); | ||
} | ||
@@ -184,0 +60,0 @@ } |
import React from "react"; | ||
import { VictoryContainer, Selection } from "victory-core"; | ||
import { isFunction, assign } from "lodash"; | ||
import { VictoryContainer } from "victory-core"; | ||
import SelectionHelpers from "./selection-helpers"; | ||
@@ -32,68 +32,12 @@ | ||
onMouseDown: (evt, targetProps) => { | ||
evt.preventDefault(); | ||
const { dimension, scale } = targetProps; | ||
const {x, y} = Selection.getSVGEventCoordinates(evt); | ||
const x1 = dimension !== "y" ? x : Selection.getDomainCoordinates(scale).x[0]; | ||
const y1 = dimension !== "x" ? y : Selection.getDomainCoordinates(scale).y[0]; | ||
const x2 = dimension !== "y" ? x : Selection.getDomainCoordinates(scale).x[1]; | ||
const y2 = dimension !== "x" ? y : Selection.getDomainCoordinates(scale).y[1]; | ||
if (isFunction(targetProps.onSelectionCleared)) { | ||
targetProps.onSelectionCleared(); | ||
} | ||
return [ | ||
{ | ||
target: "parent", | ||
mutation: () => { | ||
return {x1, y1, select: true, x2, y2}; | ||
} | ||
}, { | ||
target: "data", | ||
childName: targetProps.children ? "all" : undefined, | ||
eventKey: "all", | ||
mutation: () => null | ||
} | ||
]; | ||
SelectionHelpers.onMouseMove.cancel(); | ||
return SelectionHelpers.onMouseDown(evt, targetProps); | ||
}, | ||
onMouseMove: (evt, targetProps) => { | ||
const {dimension, scale, select} = targetProps; | ||
if (!select) { | ||
return {}; | ||
} else { | ||
const {x, y} = Selection.getSVGEventCoordinates(evt); | ||
const x2 = dimension !== "y" ? x : Selection.getDomainCoordinates(scale).x[1]; | ||
const y2 = dimension !== "x" ? y : Selection.getDomainCoordinates(scale).y[1]; | ||
return { | ||
target: "parent", | ||
mutation: () => { | ||
return { x2, y2 }; | ||
} | ||
}; | ||
} | ||
evt.persist(); | ||
return SelectionHelpers.onMouseMove(evt, targetProps); | ||
}, | ||
onMouseUp: (evt, targetProps) => { | ||
const {x2, y2} = targetProps; | ||
const parentMutation = [{ | ||
target: "parent", | ||
mutation: () => { | ||
return { select: false, x1: null, x2: null, y1: null, y2: null }; | ||
} | ||
}]; | ||
if (!x2 || !y2) { | ||
return parentMutation; | ||
} | ||
const bounds = Selection.getBounds(targetProps); | ||
const datasets = Selection.getDatasets(targetProps); | ||
const selectedData = Selection.filterDatasets(datasets, bounds); | ||
const callbackMutation = selectedData && isFunction(targetProps.onSelection) ? | ||
targetProps.onSelection(selectedData, bounds) : {}; | ||
const dataMutation = selectedData ? | ||
selectedData.map((d) => { | ||
return { | ||
childName: d.childName, eventKey: d.eventKey, target: "data", | ||
mutation: () => { | ||
return assign({active: true}, callbackMutation); | ||
} | ||
}; | ||
}) : []; | ||
return parentMutation.concat(dataMutation); | ||
SelectionHelpers.onMouseMove.cancel(); | ||
return SelectionHelpers.onMouseUp(evt, targetProps); | ||
} | ||
@@ -100,0 +44,0 @@ } |
import React, {PropTypes} from "react"; | ||
import { defaults, isFunction, isEqual } from "lodash"; | ||
import Helpers from "./helper-methods"; | ||
import { | ||
VictoryContainer, VictoryClipContainer, PropTypes as CustomPropTypes, Selection, Timer | ||
} from "victory-core"; | ||
import { defaults, isEqual } from "lodash"; | ||
import ZoomHelpers from "./zoom-helpers"; | ||
import { VictoryContainer, VictoryClipContainer, PropTypes as CustomPropTypes } from "victory-core"; | ||
@@ -29,99 +27,28 @@ export default class VictoryZoomContainer extends VictoryContainer { | ||
eventHandlers: { | ||
onMouseDown: (evt, targetProps, eventKey, ctx) => { // eslint-disable-line max-params | ||
evt.preventDefault(); | ||
const getTimer = targetProps.getTimer || ctx.context && ctx.context.getTimer || new Timer(); | ||
const originalDomain = targetProps.originalDomain || targetProps.domain; | ||
const currentDomain = targetProps.currentDomain || targetProps.zoomDomain || originalDomain; | ||
const {x} = Selection.getSVGEventCoordinates(evt); | ||
return [{ | ||
target: "parent", | ||
mutation: () => { | ||
return { | ||
startX: x, domain: currentDomain, cachedZoomDomain: targetProps.zoomDomain, | ||
originalDomain, currentDomain, getTimer, isPanning: true, | ||
parentControlledProps: ["domain"] | ||
}; | ||
} | ||
}]; | ||
onMouseDown: (evt, targetProps) => { | ||
ZoomHelpers.onMouseMove.cancel(); | ||
ZoomHelpers.onWheel.cancel(); | ||
return ZoomHelpers.onMouseDown(evt, targetProps); | ||
}, | ||
onMouseUp: () => { | ||
return [{ | ||
target: "parent", | ||
mutation: () => { | ||
return {isPanning: false}; | ||
} | ||
}]; | ||
onMouseUp: (evt, targetProps) => { | ||
ZoomHelpers.onMouseMove.cancel(); | ||
ZoomHelpers.onWheel.cancel(); | ||
return ZoomHelpers.onMouseUp(evt, targetProps); | ||
}, | ||
onMouseLeave: () => { | ||
return [{ | ||
target: "parent", | ||
mutation: () => { | ||
return {isPanning: false}; | ||
} | ||
}]; | ||
onMouseLeave: (evt, targetProps) => { | ||
ZoomHelpers.onMouseMove.cancel(); | ||
ZoomHelpers.onWheel.cancel(); | ||
return ZoomHelpers.onMouseLeave(evt, targetProps); | ||
}, | ||
onMouseMove: (evt, targetProps, eventKey, ctx) => { // eslint-disable-line max-params, max-statements, max-len | ||
if (targetProps.isPanning) { | ||
const { scale, startX, onDomainChange, domain, zoomDomain } = targetProps; | ||
const {x} = Selection.getSVGEventCoordinates(evt); | ||
const originalDomain = targetProps.originalDomain || domain; | ||
const lastDomain = targetProps.currentDomain || targetProps.zoomDomain || originalDomain; | ||
const calculatedDx = (startX - x) / Helpers.getDomainScale(lastDomain, scale); | ||
const nextXDomain = Helpers.pan(lastDomain.x, originalDomain.x, calculatedDx); | ||
const currentDomain = { x: nextXDomain, y: originalDomain.y }; | ||
const getTimer = isFunction(ctx.getTimer) && ctx.getTimer.bind(ctx); | ||
let resumeAnimation; | ||
if (getTimer && isFunction(getTimer().bypassAnimation)) { | ||
getTimer().bypassAnimation(); | ||
resumeAnimation = isFunction(getTimer().resumeAnimation) ? | ||
() => getTimer().resumeAnimation() : undefined; | ||
} | ||
if (isFunction(onDomainChange)) { | ||
onDomainChange(currentDomain); | ||
} | ||
return [{ | ||
target: "parent", | ||
callback: resumeAnimation, | ||
mutation: () => { | ||
return { | ||
domain: currentDomain, currentDomain, originalDomain, cachedZoomDomain: zoomDomain | ||
}; | ||
} | ||
}]; | ||
} | ||
onMouseMove: (evt, targetProps, eventKey, ctx) => { // eslint-disable-line max-params | ||
evt.preventDefault(); | ||
evt.persist(); | ||
ZoomHelpers.onWheel.cancel(); | ||
return ZoomHelpers.onMouseMove(evt, targetProps, eventKey, ctx); | ||
}, | ||
onWheel: (evt, targetProps, eventKey, ctx) => { // eslint-disable-line max-params, max-statements, max-len | ||
if (!targetProps.allowZoom) { | ||
return {}; | ||
} | ||
onWheel: (evt, targetProps, eventKey, ctx) => { // eslint-disable-line max-params | ||
evt.preventDefault(); | ||
const deltaY = evt.deltaY; | ||
const { onDomainChange, domain, zoomDomain } = targetProps; | ||
const originalDomain = targetProps.originalDomain || domain; | ||
const lastDomain = targetProps.currentDomain || zoomDomain || originalDomain; | ||
const {x} = lastDomain; | ||
const xBounds = originalDomain.x; | ||
// TODO: Check scale factor | ||
const nextXDomain = Helpers.scale(x, xBounds, 1 + (deltaY / 300)); | ||
const currentDomain = { x: nextXDomain, y: originalDomain.y }; | ||
const getTimer = isFunction(ctx.getTimer) && ctx.getTimer.bind(ctx); | ||
let resumeAnimation; | ||
if (getTimer && isFunction(getTimer().bypassAnimation)) { | ||
getTimer().bypassAnimation(); | ||
resumeAnimation = isFunction(getTimer().resumeAnimation) ? | ||
() => getTimer().resumeAnimation() : undefined; | ||
} | ||
if (isFunction(onDomainChange)) { | ||
onDomainChange(currentDomain); | ||
} | ||
return [{ | ||
target: "parent", | ||
callback: resumeAnimation, | ||
mutation: () => { | ||
return { | ||
domain: currentDomain, currentDomain, originalDomain, cachedZoomDomain: zoomDomain, | ||
parentControlledProps: ["domain"] | ||
}; | ||
} | ||
}]; | ||
evt.persist(); | ||
ZoomHelpers.onMouseMove.cancel(); | ||
return ZoomHelpers.onWheel(evt, targetProps, eventKey, ctx); | ||
} | ||
@@ -128,0 +55,0 @@ } |
@@ -23,2 +23,6 @@ export { default as VictoryChart } from "./components/victory-chart/victory-chart"; | ||
export { default as VictoryZoom } from "./components/victory-zoom/victory-zoom"; | ||
export { default as BrushHelpers } from "./components/containers/brush-helpers"; | ||
export { default as Selectionelpers } from "./components/containers/selection-helpers"; | ||
export { default as ZoomHelpers } from "./components/containers/zoom-helpers"; | ||
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1742104
70
30805