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 )
.tickValues( ticks )
.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 ];
prevMonth = prevMonth instanceof Date ? prevMonth : new Date( prevMonth );
monthDate =
i !== 0
? compareStrings(
params.x2Format( prevMonth ),
params.x2Format( monthDate ),
params
).join( ' ' )
: params.x2Format( monthDate );
return i === 0 || monthDate !== params.x2Format( prevMonth ) ? monthDate : '';
return i === 0
? params.x2Format( monthDate )
: compareStrings( params.x2Format( prevMonth ), params.x2Format( monthDate ) ).join(
' '
);
} )
)
.call( g => g.select( '.domain' ).remove() );