From 0b4ff7454d7b451861e88ccd7f25da51316a292f Mon Sep 17 00:00:00 2001 From: Robert Elliott Date: Fri, 14 Sep 2018 13:36:53 +0200 Subject: [PATCH] check if second x axis tick required --- .../woocommerce-admin/client/components/chart/utils.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/woocommerce-admin/client/components/chart/utils.js b/plugins/woocommerce-admin/client/components/chart/utils.js index 91ed5a43c69..bde074cca9c 100644 --- a/plugins/woocommerce-admin/client/components/chart/utils.js +++ b/plugins/woocommerce-admin/client/components/chart/utils.js @@ -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() );