From f84ba9074d2d75edad0670f1a50e17c2ea02a875 Mon Sep 17 00:00:00 2001 From: boygirl Date: Mon, 8 Jan 2018 15:11:53 -0800 Subject: [PATCH] fix warning related to categories as an object for victory axis --- src/components/victory-axis/victory-axis.js | 7 ++++++- src/components/victory-polar-axis/victory-polar-axis.js | 7 ++++++- src/helpers/axis.js | 5 ++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/components/victory-axis/victory-axis.js b/src/components/victory-axis/victory-axis.js index 0ea8decb..5d44dbc1 100644 --- a/src/components/victory-axis/victory-axis.js +++ b/src/components/victory-axis/victory-axis.js @@ -50,7 +50,12 @@ class VictoryAxis extends React.Component { ...BaseProps, axisComponent: PropTypes.element, 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, dependentAxis: PropTypes.bool, events: PropTypes.arrayOf(PropTypes.shape({ diff --git a/src/components/victory-polar-axis/victory-polar-axis.js b/src/components/victory-polar-axis/victory-polar-axis.js index 61283c91..a6d24c95 100644 --- a/src/components/victory-polar-axis/victory-polar-axis.js +++ b/src/components/victory-polar-axis/victory-polar-axis.js @@ -49,7 +49,12 @@ class VictoryPolarAxis extends React.Component { axisComponent: PropTypes.element, axisLabelComponent: PropTypes.element, 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, circularGridComponent: PropTypes.element, containerComponent: PropTypes.element, diff --git a/src/helpers/axis.js b/src/helpers/axis.js index 8c0bc4d0..409ff687 100644 --- a/src/helpers/axis.js +++ b/src/helpers/axis.js @@ -197,7 +197,10 @@ export default { }, 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) ? categories.map((tick) => stringMap[tick]) : undefined; const ticksFromStringMap = stringMap && values(stringMap);