fix compareStrings issue

This commit is contained in:
Robert Elliott 2018-10-25 13:47:31 +02:00
parent 54ffd1bd0a
commit e6a609ae7a
1 changed files with 6 additions and 10 deletions

View File

@ -402,18 +402,14 @@ export const drawAxis = ( node, params ) => {
d3AxisBottom( xScale ) d3AxisBottom( xScale )
.tickValues( ticks ) .tickValues( ticks )
.tickFormat( ( d, i ) => { .tickFormat( ( d, i ) => {
let monthDate = d instanceof Date ? d : new Date( d ); const monthDate = d instanceof Date ? d : new Date( d );
let prevMonth = i !== 0 ? ticks[ i - 1 ] : ticks[ i ]; let prevMonth = i !== 0 ? ticks[ i - 1 ] : ticks[ i ];
prevMonth = prevMonth instanceof Date ? prevMonth : new Date( prevMonth ); prevMonth = prevMonth instanceof Date ? prevMonth : new Date( prevMonth );
monthDate = return i === 0
i !== 0 ? params.x2Format( monthDate )
? compareStrings( : compareStrings( params.x2Format( prevMonth ), params.x2Format( monthDate ) ).join(
params.x2Format( prevMonth ), ' '
params.x2Format( monthDate ), );
params
).join( ' ' )
: params.x2Format( monthDate );
return i === 0 || monthDate !== params.x2Format( prevMonth ) ? monthDate : '';
} ) } )
) )
.call( g => g.select( '.domain' ).remove() ); .call( g => g.select( '.domain' ).remove() );