Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #549 from FormidableLabs/bug/categories-for-axis
Browse files Browse the repository at this point in the history
fix warning related to categories as an object for victory axis
  • Loading branch information
boygirl authored Jan 8, 2018
2 parents f5a85d2 + f84ba90 commit 66a43ee
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/components/victory-axis/victory-axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
7 changes: 6 additions & 1 deletion src/components/victory-polar-axis/victory-polar-axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion src/helpers/axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 66a43ee

Please sign in to comment.