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

fix warning related to categories as an object for victory axis #549

Merged
merged 1 commit into from
Jan 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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