diff --git a/src/axis/axis.jsx b/src/axis/axis.jsx index 818c503..62cd0da 100644 --- a/src/axis/axis.jsx +++ b/src/axis/axis.jsx @@ -21,7 +21,8 @@ export default class Axis extends Component { rangeRoundBands: null, domain: null, tickFormat: null, - tickOrient: null + tickOrient: null, + tickExclude: [] } static PropTypes = { @@ -29,6 +30,7 @@ export default class Axis extends Component { type: PropTypes.string, orient: PropTypes.oneOf(['top', 'bottom', 'left', 'right']), tickOrient: PropTypes.oneOf(['top', 'bottom', 'left', 'right']), + tickExclude: PropTypes.array } _mkTickAxis () { @@ -94,7 +96,8 @@ export default class Axis extends Component { gridAxisClassName, axisClassName, type, - style + style, + tickExclude } = this.props; var axisGroup = ReactFauxDOM.createElement('g'); @@ -143,6 +146,10 @@ export default class Axis extends Component { axisDom.selectAll('.axis path') .style('display', 'none') + // Hide the specified ticks + axisDom.selectAll('.axis .tick') + .style('display', d => tickExclude.indexOf(d) > -1 ? 'none' : 'auto'); + var axisText = axisDom.selectAll('.axis text') if(style) { diff --git a/src/axis/xaxis.jsx b/src/axis/xaxis.jsx index 67d9322..10230cf 100644 --- a/src/axis/xaxis.jsx +++ b/src/axis/xaxis.jsx @@ -25,6 +25,7 @@ export default class Xaxis extends Component { xTickPadding: 3, xInnerTickSize: 6, xOuterTickSize: 6, + xTickExclude: [], ...CommonProps } @@ -47,6 +48,7 @@ export default class Xaxis extends Component { xTickPadding: PropTypes.number, xTickFormat: PropTypes.func, xTicks: PropTypes.array, + xTickExclude: PropTypes.array, style: PropTypes.object } @@ -73,7 +75,8 @@ export default class Xaxis extends Component { xLabel, xLabelPosition, labelOffset, - style + style, + xTickExclude } = this.props; var t; @@ -127,6 +130,7 @@ export default class Xaxis extends Component { tickSizeOuter = {xTickSizeOuter} ticks = {xTicks} style = {style} + tickExclude = {xTickExclude} /> {axisLabel}