victory-chart
Advanced tools
Comparing version 24.6.0 to 24.6.1
# VictoryChart Changelog | ||
## 24.6.1 (2018-01-08) | ||
- [550](https://github.com/FormidableLabs/victory-chart/pull/550) Fixes a bug related to voronoi tooltip positioning | ||
- [549](https://github.com/FormidableLabs/victory-chart/pull/549) Fixes a prop type warning for `categories` supplied to `VictoryAxis` | ||
- [548](https://github.com/FormidableLabs/victory-chart/pull/548) Adds a `voronoiBlacklist` prop to `VictoryVoronoiContainer` | ||
- [547](https://github.com/FormidableLabs/victory-chart/pull/547) Fixes downsampling in `VictoryZoomContainer` with function plotting | ||
- [545](https://github.com/FormidableLabs/victory-chart/pull/545) Fixes a bug related to panning in `VictoryZoomContainer` | ||
## 24.6.0 (2018-01-02) | ||
@@ -4,0 +12,0 @@ |
@@ -191,3 +191,3 @@ import _defaults from "lodash/defaults"; | ||
var labelPosition = this.getLabelPosition(props, points, labelProps); | ||
return _extends({}, labelPosition, labelProps); | ||
return _defaults({}, labelPosition, labelProps); | ||
} | ||
@@ -230,2 +230,3 @@ }, { | ||
radius: PropTypes.number, | ||
voronoiBlacklist: PropTypes.arrayOf(PropTypes.string), | ||
voronoiDimension: PropTypes.oneOf(["x", "y"]), | ||
@@ -232,0 +233,0 @@ voronoiPadding: PropTypes.number |
@@ -1,2 +0,2 @@ | ||
import _get from "lodash/get"; | ||
import _isFunction from "lodash/isFunction"; | ||
import _defaults from "lodash/defaults"; | ||
@@ -82,13 +82,25 @@ | ||
key: "downsampleZoomData", | ||
value: function downsampleZoomData(props, childProps, domain) { | ||
value: function downsampleZoomData(props, child, domain) { | ||
var downsample = props.downsample; | ||
var rawData = _get(childProps, "data"); | ||
var getData = function (childProps) { | ||
var data = childProps.data, | ||
x = childProps.x, | ||
y = childProps.y; | ||
var defaultGetData = child.type && _isFunction(child.type.getData) ? child.type.getData : function () { | ||
return undefined; | ||
}; | ||
// skip costly data formatting if x and y accessors are not present | ||
return Array.isArray(data) && !x && !y ? data : defaultGetData(childProps); | ||
}; | ||
var data = getData(child.props); | ||
// return undefined if downsample is not run, then default() will replace with child.props.data | ||
if (!downsample || !rawData || !domain) { | ||
if (!downsample || !domain || !data) { | ||
return undefined; | ||
} | ||
// if data accessors are not used, skip calling expensive Data.formatData | ||
var data = childProps.x || childProps.y ? Data.formatData(rawData, childProps) : rawData; | ||
var maxPoints = downsample === true ? DEFAULT_DOWNSAMPLE : downsample; | ||
@@ -154,3 +166,3 @@ var dimension = props.zoomDimension || "x"; | ||
domain: newDomain, | ||
data: role === "legend" ? undefined : _this2.downsampleZoomData(props, currentChild.props, newDomain) | ||
data: role === "legend" ? undefined : _this2.downsampleZoomData(props, currentChild, newDomain) | ||
}, currentChild.props)); | ||
@@ -157,0 +169,0 @@ }); |
@@ -0,1 +1,2 @@ | ||
import _includes from "lodash/includes"; | ||
import _isEqual from "lodash/isEqual"; | ||
@@ -67,10 +68,15 @@ import _keys from "lodash/keys"; | ||
var role = child.type && child.type.role; | ||
var childProps = child.props || {}; | ||
var blacklist = props.voronoiBlacklist || []; | ||
if (role === "axis" || role === "legend" || role === "label") { | ||
return null; | ||
} else if (_includes(blacklist, childName)) { | ||
// ignore any children with names that match the blacklist | ||
return null; | ||
} else if (child.type && _isFunction(child.type.getData)) { | ||
child = parent ? React.cloneElement(child, parent.props) : child; | ||
var childData = child.props && child.type.getData(_extends({}, child.props, { domain: props.domain })); | ||
var childData = childProps && child.type.getData(_extends({}, childProps, { domain: props.domain })); | ||
return childData ? addMeta(childData, childName, child) : null; | ||
} else { | ||
var _childData = getData(_extends({}, child.props, { domain: props.domain })); | ||
var _childData = getData(_extends({}, childProps, { domain: props.domain })); | ||
return _childData ? addMeta(_childData, childName, child) : null; | ||
@@ -77,0 +83,0 @@ } |
@@ -169,3 +169,5 @@ import _partialRight from "lodash/partialRight"; | ||
axisLabelComponent: PropTypes.element, | ||
categories: PropTypes.arrayOf(PropTypes.string), | ||
categories: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.shape({ | ||
x: PropTypes.arrayOf(PropTypes.string), y: PropTypes.arrayOf(PropTypes.string) | ||
})]), | ||
crossAxis: PropTypes.bool, | ||
@@ -172,0 +174,0 @@ dependentAxis: PropTypes.bool, |
@@ -143,3 +143,5 @@ import _partialRight from "lodash/partialRight"; | ||
axisValue: PropTypes.number, | ||
categories: PropTypes.arrayOf(PropTypes.string), | ||
categories: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.string), PropTypes.shape({ | ||
x: PropTypes.arrayOf(PropTypes.string), y: PropTypes.arrayOf(PropTypes.string) | ||
})]), | ||
circularAxisComponent: PropTypes.element, | ||
@@ -146,0 +148,0 @@ circularGridComponent: PropTypes.element, |
@@ -229,5 +229,6 @@ import _without from "lodash/without"; | ||
getStringTicks: function (props) { | ||
var stringMap = props.stringMap, | ||
categories = props.categories; | ||
var stringMap = props.stringMap; | ||
var axis = this.getAxis(props); | ||
var categories = Array.isArray(props.categories) ? props.categories : props.categories && props.categories[axis]; | ||
var ticksFromCategories = categories && Collection.containsOnlyStrings(categories) ? categories.map(function (tick) { | ||
@@ -234,0 +235,0 @@ return stringMap[tick]; |
@@ -211,3 +211,3 @@ Object.defineProperty(exports, "__esModule", { | ||
var labelPosition = this.getLabelPosition(props, points, labelProps); | ||
return _extends({}, labelPosition, labelProps); | ||
return (0, _defaults3.default)({}, labelPosition, labelProps); | ||
} | ||
@@ -250,2 +250,3 @@ }, { | ||
radius: _propTypes2.default.number, | ||
voronoiBlacklist: _propTypes2.default.arrayOf(_propTypes2.default.string), | ||
voronoiDimension: _propTypes2.default.oneOf(["x", "y"]), | ||
@@ -252,0 +253,0 @@ voronoiPadding: _propTypes2.default.number |
@@ -6,5 +6,5 @@ Object.defineProperty(exports, "__esModule", { | ||
var _get2 = require("lodash/get"); | ||
var _isFunction2 = require("lodash/isFunction"); | ||
var _get3 = _interopRequireDefault(_get2); | ||
var _isFunction3 = _interopRequireDefault(_isFunction2); | ||
@@ -103,13 +103,25 @@ var _defaults2 = require("lodash/defaults"); | ||
key: "downsampleZoomData", | ||
value: function downsampleZoomData(props, childProps, domain) { | ||
value: function downsampleZoomData(props, child, domain) { | ||
var downsample = props.downsample; | ||
var rawData = (0, _get3.default)(childProps, "data"); | ||
var getData = function (childProps) { | ||
var data = childProps.data, | ||
x = childProps.x, | ||
y = childProps.y; | ||
var defaultGetData = child.type && (0, _isFunction3.default)(child.type.getData) ? child.type.getData : function () { | ||
return undefined; | ||
}; | ||
// skip costly data formatting if x and y accessors are not present | ||
return Array.isArray(data) && !x && !y ? data : defaultGetData(childProps); | ||
}; | ||
var data = getData(child.props); | ||
// return undefined if downsample is not run, then default() will replace with child.props.data | ||
if (!downsample || !rawData || !domain) { | ||
if (!downsample || !domain || !data) { | ||
return undefined; | ||
} | ||
// if data accessors are not used, skip calling expensive Data.formatData | ||
var data = childProps.x || childProps.y ? _victoryCore.Data.formatData(rawData, childProps) : rawData; | ||
var maxPoints = downsample === true ? DEFAULT_DOWNSAMPLE : downsample; | ||
@@ -175,3 +187,3 @@ var dimension = props.zoomDimension || "x"; | ||
domain: newDomain, | ||
data: role === "legend" ? undefined : _this2.downsampleZoomData(props, currentChild.props, newDomain) | ||
data: role === "legend" ? undefined : _this2.downsampleZoomData(props, currentChild, newDomain) | ||
}, currentChild.props)); | ||
@@ -178,0 +190,0 @@ }); |
@@ -5,2 +5,6 @@ Object.defineProperty(exports, "__esModule", { | ||
var _includes2 = require("lodash/includes"); | ||
var _includes3 = _interopRequireDefault(_includes2); | ||
var _isEqual2 = require("lodash/isEqual"); | ||
@@ -95,10 +99,15 @@ | ||
var role = child.type && child.type.role; | ||
var childProps = child.props || {}; | ||
var blacklist = props.voronoiBlacklist || []; | ||
if (role === "axis" || role === "legend" || role === "label") { | ||
return null; | ||
} else if ((0, _includes3.default)(blacklist, childName)) { | ||
// ignore any children with names that match the blacklist | ||
return null; | ||
} else if (child.type && (0, _isFunction3.default)(child.type.getData)) { | ||
child = parent ? _react2.default.cloneElement(child, parent.props) : child; | ||
var childData = child.props && child.type.getData(_extends({}, child.props, { domain: props.domain })); | ||
var childData = childProps && child.type.getData(_extends({}, childProps, { domain: props.domain })); | ||
return childData ? addMeta(childData, childName, child) : null; | ||
} else { | ||
var _childData = getData(_extends({}, child.props, { domain: props.domain })); | ||
var _childData = getData(_extends({}, childProps, { domain: props.domain })); | ||
return _childData ? addMeta(_childData, childName, child) : null; | ||
@@ -105,0 +114,0 @@ } |
@@ -192,3 +192,5 @@ Object.defineProperty(exports, "__esModule", { | ||
axisLabelComponent: _propTypes2.default.element, | ||
categories: _propTypes2.default.arrayOf(_propTypes2.default.string), | ||
categories: _propTypes2.default.oneOfType([_propTypes2.default.arrayOf(_propTypes2.default.string), _propTypes2.default.shape({ | ||
x: _propTypes2.default.arrayOf(_propTypes2.default.string), y: _propTypes2.default.arrayOf(_propTypes2.default.string) | ||
})]), | ||
crossAxis: _propTypes2.default.bool, | ||
@@ -195,0 +197,0 @@ dependentAxis: _propTypes2.default.bool, |
@@ -163,3 +163,5 @@ Object.defineProperty(exports, "__esModule", { | ||
axisValue: _propTypes2.default.number, | ||
categories: _propTypes2.default.arrayOf(_propTypes2.default.string), | ||
categories: _propTypes2.default.oneOfType([_propTypes2.default.arrayOf(_propTypes2.default.string), _propTypes2.default.shape({ | ||
x: _propTypes2.default.arrayOf(_propTypes2.default.string), y: _propTypes2.default.arrayOf(_propTypes2.default.string) | ||
})]), | ||
circularAxisComponent: _propTypes2.default.element, | ||
@@ -166,0 +168,0 @@ circularGridComponent: _propTypes2.default.element, |
@@ -263,5 +263,6 @@ Object.defineProperty(exports, "__esModule", { | ||
getStringTicks: function (props) { | ||
var stringMap = props.stringMap, | ||
categories = props.categories; | ||
var stringMap = props.stringMap; | ||
var axis = this.getAxis(props); | ||
var categories = Array.isArray(props.categories) ? props.categories : props.categories && props.categories[axis]; | ||
var ticksFromCategories = categories && _victoryCore.Collection.containsOnlyStrings(categories) ? categories.map(function (tick) { | ||
@@ -268,0 +269,0 @@ return stringMap[tick]; |
{ | ||
"name": "victory-chart", | ||
"version": "24.6.0", | ||
"version": "24.6.1", | ||
"description": "Chart Component for Victory", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -16,2 +16,3 @@ import PropTypes from "prop-types"; | ||
radius: PropTypes.number, | ||
voronoiBlacklist: PropTypes.arrayOf(PropTypes.string), | ||
voronoiDimension: PropTypes.oneOf(["x", "y"]), | ||
@@ -205,3 +206,3 @@ voronoiPadding: PropTypes.number | ||
const labelPosition = this.getLabelPosition(props, points, labelProps); | ||
return { ...labelPosition, ...labelProps }; | ||
return defaults({}, labelPosition, labelProps); | ||
} | ||
@@ -208,0 +209,0 @@ |
import PropTypes from "prop-types"; | ||
import React from "react"; | ||
import { defaults, get } from "lodash"; | ||
import { defaults, isFunction } from "lodash"; | ||
import ZoomHelpers from "./zoom-helpers"; | ||
@@ -138,10 +138,18 @@ import { | ||
downsampleZoomData(props, childProps, domain) { | ||
downsampleZoomData(props, child, domain) { | ||
const { downsample } = props; | ||
const rawData = get(childProps, "data"); | ||
const getData = (childProps) => { | ||
const { data, x, y } = childProps; | ||
const defaultGetData = child.type && isFunction(child.type.getData) ? | ||
child.type.getData : () => undefined; | ||
// skip costly data formatting if x and y accessors are not present | ||
return Array.isArray(data) && !x && !y ? data : defaultGetData(childProps); | ||
}; | ||
const data = getData(child.props); | ||
// return undefined if downsample is not run, then default() will replace with child.props.data | ||
if (!downsample || !rawData || !domain) { return undefined; } | ||
if (!downsample || !domain || !data) { return undefined; } | ||
// if data accessors are not used, skip calling expensive Data.formatData | ||
const data = (childProps.x || childProps.y) ? Data.formatData(rawData, childProps) : rawData; | ||
const maxPoints = (downsample === true) ? DEFAULT_DOWNSAMPLE : downsample; | ||
@@ -199,3 +207,3 @@ const dimension = props.zoomDimension || "x"; | ||
data: role === "legend" ? | ||
undefined : this.downsampleZoomData(props, currentChild.props, newDomain) | ||
undefined : this.downsampleZoomData(props, currentChild, newDomain) | ||
}, currentChild.props) | ||
@@ -202,0 +210,0 @@ ); |
import { Selection, Data, Helpers } from "victory-core"; | ||
import { assign, throttle, isFunction, groupBy, keys, isEqual } from "lodash"; | ||
import { assign, throttle, isFunction, groupBy, keys, isEqual, includes } from "lodash"; | ||
import { voronoi as d3Voronoi } from "d3-voronoi"; | ||
@@ -46,11 +46,16 @@ import React from "react"; | ||
const role = child.type && child.type.role; | ||
const childProps = child.props || {}; | ||
const blacklist = props.voronoiBlacklist || []; | ||
if (role === "axis" || role === "legend" || role === "label") { | ||
return null; | ||
} else if (includes(blacklist, childName)) { | ||
// ignore any children with names that match the blacklist | ||
return null; | ||
} else if (child.type && isFunction(child.type.getData)) { | ||
child = parent ? React.cloneElement(child, parent.props) : child; | ||
const childData = child.props | ||
&& child.type.getData({ ...child.props, domain: props.domain }); | ||
const childData = childProps | ||
&& child.type.getData({ ...childProps, domain: props.domain }); | ||
return childData ? addMeta(childData, childName, child) : null; | ||
} else { | ||
const childData = getData({ ...child.props, domain: props.domain }); | ||
const childData = getData({ ...childProps, domain: props.domain }); | ||
return childData ? addMeta(childData, childName, child) : null; | ||
@@ -57,0 +62,0 @@ } |
@@ -53,3 +53,8 @@ import PropTypes from "prop-types"; | ||
axisLabelComponent: PropTypes.element, | ||
categories: PropTypes.arrayOf(PropTypes.string), | ||
categories: PropTypes.oneOfType([ | ||
PropTypes.arrayOf(PropTypes.string), | ||
PropTypes.shape({ | ||
x: PropTypes.arrayOf(PropTypes.string), y: PropTypes.arrayOf(PropTypes.string) | ||
}) | ||
]), | ||
crossAxis: PropTypes.bool, | ||
@@ -56,0 +61,0 @@ dependentAxis: PropTypes.bool, |
@@ -52,3 +52,8 @@ import React from "react"; | ||
axisValue: PropTypes.number, | ||
categories: PropTypes.arrayOf(PropTypes.string), | ||
categories: PropTypes.oneOfType([ | ||
PropTypes.arrayOf(PropTypes.string), | ||
PropTypes.shape({ | ||
x: PropTypes.arrayOf(PropTypes.string), y: PropTypes.arrayOf(PropTypes.string) | ||
}) | ||
]), | ||
circularAxisComponent: PropTypes.element, | ||
@@ -55,0 +60,0 @@ circularGridComponent: PropTypes.element, |
@@ -200,3 +200,6 @@ import { Collection } from "victory-core"; | ||
getStringTicks(props) { | ||
const { stringMap, categories } = props; | ||
const { stringMap } = props; | ||
const axis = this.getAxis(props); | ||
const categories = Array.isArray(props.categories) ? | ||
props.categories : props.categories && props.categories[axis]; | ||
const ticksFromCategories = categories && Collection.containsOnlyStrings(categories) ? | ||
@@ -203,0 +206,0 @@ categories.map((tick) => stringMap[tick]) : undefined; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
2862915
51641