victory-core
Advanced tools
Comparing version 16.0.0 to 16.0.1
VictoryCore Changelog | ||
===================== | ||
## 16.0.1 (2017-06-06) | ||
-[251](https://github.com/FormidableLabs/victory-core/pull/251) Adds an optional `clipId` prop to `VictoryClipContainer` | ||
-[252](https://github.com/FormidableLabs/victory-core/pull/252) Changes domain calculation for single data point components so that domains aren't forced to include zero | ||
## 16.0.0 (2017-06-06) | ||
@@ -5,0 +10,0 @@ |
@@ -36,5 +36,8 @@ Object.defineProperty(exports,"__esModule",{value:true});var _isFunction2=require("lodash/isFunction");var _isFunction3=_interopRequireDefault(_isFunction2);var _defaults2=require("lodash/defaults");var _defaults3=_interopRequireDefault(_defaults2);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 _jsxFileName="src/victory-clip-container/victory-clip-container.js";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); | ||
function VictoryClipContainer(props){_classCallCheck(this,VictoryClipContainer);var _this=_possibleConstructorReturn(this,(VictoryClipContainer.__proto__||Object.getPrototypeOf(VictoryClipContainer)).call(this, | ||
props)); | ||
_this.clipId=Math.round(Math.random()*10000);return _this; | ||
_this.clipId=props.clipId!==undefined? | ||
props.clipId: | ||
Math.round(Math.random()*10000);return _this; | ||
}_createClass(VictoryClipContainer,[{key:"renderClippedGroup",value:function renderClippedGroup( | ||
@@ -51,6 +54,6 @@ | ||
events,{ | ||
transform:transform,__source:{fileName:_jsxFileName,lineNumber:46}}), | ||
transform:transform,__source:{fileName:_jsxFileName,lineNumber:49}}), | ||
clipComponent, | ||
_react2.default.createElement("g",{clipPath:"url(#"+clipId+")",__source:{fileName:_jsxFileName,lineNumber:53}}, | ||
_react2.default.createElement("g",{clipPath:"url(#"+clipId+")",__source:{fileName:_jsxFileName,lineNumber:56}}, | ||
children))); | ||
@@ -70,3 +73,3 @@ | ||
events,{ | ||
transform:transform,__source:{fileName:_jsxFileName,lineNumber:64}}), | ||
transform:transform,__source:{fileName:_jsxFileName,lineNumber:67}}), | ||
@@ -122,2 +125,2 @@ children)); | ||
return this.renderClippedGroup(clipProps,this.clipId); | ||
}}]);return VictoryClipContainer;}(_react2.default.Component);VictoryClipContainer.displayName="VictoryClipContainer";VictoryClipContainer.role="container";VictoryClipContainer.propTypes={children:_propTypes2.default.oneOfType([_propTypes2.default.arrayOf(_propTypes2.default.node),_propTypes2.default.node]),className:_propTypes2.default.string,clipHeight:_propTypes2.default.number,clipPadding:_propTypes2.default.shape({top:_propTypes2.default.number,bottom:_propTypes2.default.number,left:_propTypes2.default.number,right:_propTypes2.default.number}),clipPathComponent:_propTypes2.default.element,clipWidth:_propTypes2.default.number,events:_propTypes2.default.object,origin:_propTypes2.default.shape({x:_propTypes2.default.number,y:_propTypes2.default.number}),polar:_propTypes2.default.bool,radius:_propTypes2.default.bool,style:_propTypes2.default.object,transform:_propTypes2.default.string,translateX:_propTypes2.default.number,translateY:_propTypes2.default.number};VictoryClipContainer.defaultProps={clipPathComponent:_react2.default.createElement(_clipPath2.default,{__source:{fileName:_jsxFileName,lineNumber:33}})};exports.default=VictoryClipContainer; | ||
}}]);return VictoryClipContainer;}(_react2.default.Component);VictoryClipContainer.displayName="VictoryClipContainer";VictoryClipContainer.role="container";VictoryClipContainer.propTypes={children:_propTypes2.default.oneOfType([_propTypes2.default.arrayOf(_propTypes2.default.node),_propTypes2.default.node]),className:_propTypes2.default.string,clipHeight:_propTypes2.default.number,clipId:_propTypes2.default.number,clipPadding:_propTypes2.default.shape({top:_propTypes2.default.number,bottom:_propTypes2.default.number,left:_propTypes2.default.number,right:_propTypes2.default.number}),clipPathComponent:_propTypes2.default.element,clipWidth:_propTypes2.default.number,events:_propTypes2.default.object,origin:_propTypes2.default.shape({x:_propTypes2.default.number,y:_propTypes2.default.number}),polar:_propTypes2.default.bool,radius:_propTypes2.default.number,style:_propTypes2.default.object,transform:_propTypes2.default.string,translateX:_propTypes2.default.number,translateY:_propTypes2.default.number};VictoryClipContainer.defaultProps={clipPathComponent:_react2.default.createElement(_clipPath2.default,{__source:{fileName:_jsxFileName,lineNumber:34}})};exports.default=VictoryClipContainer; |
@@ -117,9 +117,7 @@ Object.defineProperty(exports,"__esModule",{value:true});var _sortedUniq2=require("lodash/sortedUniq");var _sortedUniq3=_interopRequireDefault(_sortedUniq2);var _isPlainObject2=require("lodash/isPlainObject");var _isPlainObject3=_interopRequireDefault(_isPlainObject2);var _includes2=require("lodash/includes");var _includes3=_interopRequireDefault(_includes2);var _flatten2=require("lodash/flatten");var _flatten3=_interopRequireDefault(_flatten2); | ||
var max=_collection2.default.getMaxValue(allData); | ||
var domain=void 0; | ||
if(min===max){ | ||
var adjustedMax=max===0?1:max; | ||
return[0,adjustedMax]; | ||
domain=this.getSinglePointDomain(max); | ||
} | ||
var domain=[min,max]; | ||
domain=[min,max]; | ||
var angularRange=Math.abs((props.startAngle||0)-(props.endAngle||360)); | ||
@@ -130,2 +128,9 @@ return props.polar&&axis==="x"&&angularRange===360? | ||
getSinglePointDomain:function getSinglePointDomain(val){ | ||
var verySmallNumber=1/Number.MAX_SAFE_INTEGER; | ||
var adjustedMin=val instanceof Date?new Date(val-1):val-verySmallNumber; | ||
var adjustedMax=val instanceof Date?new Date(val+1):val+verySmallNumber; | ||
return[adjustedMin,adjustedMax]; | ||
}, | ||
getSymmetricDomain:function getSymmetricDomain(domain,data){ | ||
@@ -219,7 +224,4 @@ var processedData=(0,_sortedUniq3.default)(data.sort(function(a,b){return a-b;})); | ||
var domainMax=_collection2.default.getMaxValue.apply(_collection2.default,[globalDomain].concat(_toConsumableArray(cumulativeMaxArray))); | ||
if(domainMin===domainMax){ | ||
var adjustedMax=domainMax===0?1:domainMax; | ||
return[0,adjustedMax]; | ||
return this.getSinglePointDomain(domainMax); | ||
} | ||
@@ -226,0 +228,0 @@ return[domainMin,domainMax]; |
{ | ||
"name": "victory-core", | ||
"version": "16.0.0", | ||
"version": "16.0.1", | ||
"description": "Victory Core", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -16,2 +16,3 @@ import React from "react"; | ||
clipHeight: PropTypes.number, | ||
clipId: PropTypes.number, | ||
clipPadding: PropTypes.shape({ | ||
@@ -26,3 +27,3 @@ top: PropTypes.number, bottom: PropTypes.number, | ||
polar: PropTypes.bool, | ||
radius: PropTypes.bool, | ||
radius: PropTypes.number, | ||
style: PropTypes.object, | ||
@@ -40,3 +41,5 @@ transform: PropTypes.string, | ||
super(props); | ||
this.clipId = Math.round(Math.random() * 10000); // eslint-disable-line no-magic-numbers | ||
this.clipId = props.clipId !== undefined ? | ||
props.clipId : | ||
Math.round(Math.random() * 10000); // eslint-disable-line no-magic-numbers | ||
} | ||
@@ -43,0 +46,0 @@ |
@@ -117,9 +117,7 @@ import { flatten, includes, isPlainObject, sortedUniq } from "lodash"; | ||
const max = Collection.getMaxValue(allData); | ||
// TODO: is this the correct behavior, or should we just error. How do we | ||
// handle charts with just one data point? | ||
let domain; | ||
if (min === max) { | ||
const adjustedMax = max === 0 ? 1 : max; | ||
return [0, adjustedMax]; | ||
domain = this.getSinglePointDomain(max); | ||
} | ||
const domain = [min, max]; | ||
domain = [min, max]; | ||
const angularRange = Math.abs((props.startAngle || 0) - (props.endAngle || 360)); | ||
@@ -130,2 +128,9 @@ return props.polar && axis === "x" && angularRange === 360 ? | ||
getSinglePointDomain(val) { | ||
const verySmallNumber = 1 / Number.MAX_SAFE_INTEGER; | ||
const adjustedMin = val instanceof Date ? new Date(val - 1) : val - verySmallNumber; | ||
const adjustedMax = val instanceof Date ? new Date(val + 1) : val + verySmallNumber; | ||
return [adjustedMin, adjustedMax]; | ||
}, | ||
getSymmetricDomain(domain, data) { | ||
@@ -219,7 +224,4 @@ const processedData = sortedUniq(data.sort((a, b) => a - b)); | ||
const domainMax = Collection.getMaxValue(globalDomain, ...cumulativeMaxArray); | ||
// TODO: is this the correct behavior, or should we just error. How do we | ||
// handle charts with just one data point? | ||
if (domainMin === domainMax) { | ||
const adjustedMax = domainMax === 0 ? 1 : domainMax; | ||
return [0, adjustedMax]; | ||
return this.getSinglePointDomain(domainMax); | ||
} | ||
@@ -226,0 +228,0 @@ return [domainMin, domainMax]; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1435773
28549