Skip to content

Commit 00acbaa

Browse files
committed
Add support to hide ticks for an axis
1 parent c2fd126 commit 00acbaa

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/axis/axis.jsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@ export default class Axis extends Component {
2121
rangeRoundBands: null,
2222
domain: null,
2323
tickFormat: null,
24-
tickOrient: null
24+
tickOrient: null,
25+
tickExclude: []
2526
}
2627

2728
static PropTypes = {
2829
showAxis: PropTypes.bool,
2930
type: PropTypes.string,
3031
orient: PropTypes.oneOf(['top', 'bottom', 'left', 'right']),
3132
tickOrient: PropTypes.oneOf(['top', 'bottom', 'left', 'right']),
33+
tickExclude: PropTypes.array
3234
}
3335

3436
_mkTickAxis () {
@@ -94,7 +96,8 @@ export default class Axis extends Component {
9496
gridAxisClassName,
9597
axisClassName,
9698
type,
97-
style
99+
style,
100+
tickExclude
98101
} = this.props;
99102

100103
var axisGroup = ReactFauxDOM.createElement('g');
@@ -143,6 +146,10 @@ export default class Axis extends Component {
143146
axisDom.selectAll('.axis path')
144147
.style('display', 'none')
145148

149+
// Hide the specified ticks
150+
axisDom.selectAll('.axis .tick')
151+
.style('display', d => tickExclude.indexOf(d) > -1 ? 'none' : 'auto');
152+
146153
var axisText = axisDom.selectAll('.axis text')
147154

148155
if(style) {

0 commit comments

Comments
 (0)