check if second x axis tick required

This commit is contained in:
Robert Elliott 2018-09-14 13:36:53 +02:00
parent b5b84fe72c
commit 0b4ff7454d
1 changed files with 7 additions and 1 deletions

View File

@ -242,7 +242,13 @@ export const drawAxis = ( node, params ) => {
.tickValues( params.uniqueDates.map( d => ( params.type === 'line' ? new Date( d ) : d ) ) )
.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() );