check if second x axis tick required

This commit is contained in:
Robert Elliott 2018-09-14 13:36:53 +02:00 committed by Timmy Crawford
parent ac8952d7ec
commit ddc2645bef
1 changed files with 7 additions and 1 deletions

View File

@ -329,7 +329,13 @@ export const drawAxis = ( node, params ) => {
.tickValues( ticks )
.tickFormat( ( d, i ) => {
const monthDate = d instanceof Date ? d : new Date( d );
return monthDate.getDate() === 1 || i === 0 ? params.x2Format( monthDate ) : '';
let prevMonth = i !== 0 ? params.uniqueDates[ i - 1 ] : params.uniqueDates[ i ];
prevMonth = prevMonth instanceof Date ? prevMonth : new Date( prevMonth );
return monthDate.getDate() === 1 ||
i === 0 ||
params.x2Format( monthDate ) !== params.x2Format( prevMonth )
? params.x2Format( monthDate )
: '';
} )
)
.call( g => g.select( '.domain' ).remove() );