Skip to content

Commit 5add689

Browse files
committed
Add ability to exclude ticks for x axis
1 parent ea978d4 commit 5add689

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
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) {

src/axis/xaxis.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default class Xaxis extends Component {
2525
xTickPadding: 3,
2626
xInnerTickSize: 6,
2727
xOuterTickSize: 6,
28+
xTickExclude: [],
2829
...CommonProps
2930
}
3031

@@ -47,6 +48,7 @@ export default class Xaxis extends Component {
4748
xTickPadding: PropTypes.number,
4849
xTickFormat: PropTypes.func,
4950
xTicks: PropTypes.array,
51+
xTickExclude: PropTypes.array,
5052
style: PropTypes.object
5153
}
5254

@@ -73,7 +75,8 @@ export default class Xaxis extends Component {
7375
xLabel,
7476
xLabelPosition,
7577
labelOffset,
76-
style
78+
style,
79+
xTickExclude
7780
} = this.props;
7881

7982
var t;
@@ -127,6 +130,7 @@ export default class Xaxis extends Component {
127130
tickSizeOuter = {xTickSizeOuter}
128131
ticks = {xTicks}
129132
style = {style}
133+
tickExclude = {xTickExclude}
130134
/>
131135
{axisLabel}
132136
</g>

0 commit comments

Comments
 (0)