/** @format */ /** * External dependencies */ import classNames from 'classnames'; import { Component } from '@wordpress/element'; import PropTypes from 'prop-types'; /** * WooCommerce dependencies */ import { formatCurrency } from '@woocommerce/currency'; /** * Internal dependencies */ import './style.scss'; import { getColor } from './utils'; function getFormatedTotal( total, valueType ) { let rowTotal = total; switch ( valueType ) { case 'average': rowTotal = Math.round( total ); break; case 'currency': rowTotal = formatCurrency( total ); break; case 'number': break; } return rowTotal; } /** * A legend specifically designed for the WooCommerce admin charts. */ class Legend extends Component { render() { const { colorScheme, data, handleLegendHover, handleLegendToggle, legendDirection, valueType, } = this.props; const colorParams = { orderedKeys: data, colorScheme, }; const numberOfRowsVisible = data.filter( row => row.visible ).length; return (