diff --git a/plugins/woocommerce-admin/packages/components/src/chart/d3chart/utils/bar-chart.js b/plugins/woocommerce-admin/packages/components/src/chart/d3chart/utils/bar-chart.js index 3757fe51208..de5ecc727b0 100644 --- a/plugins/woocommerce-admin/packages/components/src/chart/d3chart/utils/bar-chart.js +++ b/plugins/woocommerce-admin/packages/components/src/chart/d3chart/utils/bar-chart.js @@ -46,7 +46,16 @@ export const drawBars = ( node, data, params ) => { .attr( 'y', 0 ) .attr( 'width', params.xGroupScale.range()[ 1 ] ) .attr( 'height', params.height ) - .attr( 'opacity', '0' ); + .attr( 'opacity', '0' ) + .on( 'mouseover', ( d, i, nodes ) => { + const position = calculateTooltipPosition( + d3Event.target, + node.node(), + params.tooltipPosition + ); + handleMouseOverBarChart( d.date, nodes[ i ].parentNode, node, data, params, position ); + } ) + .on( 'mouseout', ( d, i, nodes ) => hideTooltip( nodes[ i ].parentNode, params.tooltip ) ); barGroup .selectAll( '.bar' ) @@ -68,6 +77,7 @@ export const drawBars = ( node, data, params ) => { .attr( 'width', params.xGroupScale.bandwidth() ) .attr( 'height', d => params.height - params.yScale( d.value ) ) .attr( 'fill', d => getColor( d.key, params.orderedKeys, params.colorScheme ) ) + .attr( 'pointer-events', 'none' ) .attr( 'tabindex', '0' ) .attr( 'aria-label', d => { const label = params.mode === 'time-comparison' && d.label ? d.label : d.key; @@ -83,22 +93,4 @@ export const drawBars = ( node, data, params ) => { handleMouseOverBarChart( d.date, nodes[ i ].parentNode, node, data, params, position ); } ) .on( 'blur', ( d, i, nodes ) => hideTooltip( nodes[ i ].parentNode, params.tooltip ) ); - - barGroup - .append( 'rect' ) - .attr( 'class', 'barmouse' ) - .attr( 'x', 0 ) - .attr( 'y', 0 ) - .attr( 'width', params.xGroupScale.range()[ 1 ] ) - .attr( 'height', params.height ) - .attr( 'opacity', '0' ) - .on( 'mouseover', ( d, i, nodes ) => { - const position = calculateTooltipPosition( - d3Event.target, - node.node(), - params.tooltipPosition - ); - handleMouseOverBarChart( d.date, nodes[ i ].parentNode, node, data, params, position ); - } ) - .on( 'mouseout', ( d, i, nodes ) => hideTooltip( nodes[ i ].parentNode, params.tooltip ) ); };