fix check on this.props.data
This commit is contained in:
parent
427d0ac7dd
commit
2ac101f1c2
|
@ -7,7 +7,7 @@ import classNames from 'classnames';
|
|||
import { Component, createRef, Fragment } from '@wordpress/element';
|
||||
import { decodeEntities } from '@wordpress/html-entities';
|
||||
import { formatDefaultLocale as d3FormatDefaultLocale } from 'd3-format';
|
||||
import { get, isEmpty, isEqual, partial } from 'lodash';
|
||||
import { get, isEqual, partial } from 'lodash';
|
||||
import Gridicon from 'gridicons';
|
||||
import { IconButton, NavigableMenu, SelectControl } from '@wordpress/components';
|
||||
import { interpolateViridis as d3InterpolateViridis } from 'd3-scale-chromatic';
|
||||
|
@ -263,7 +263,6 @@ class Chart extends Component {
|
|||
yFormat = '.0f';
|
||||
break;
|
||||
}
|
||||
const showChart = ! isRequesting && ! isEmpty( visibleData );
|
||||
return (
|
||||
<div className="woocommerce-chart">
|
||||
<div className="woocommerce-chart__header">
|
||||
|
@ -308,7 +307,7 @@ class Chart extends Component {
|
|||
ref={ this.chartBodyRef }
|
||||
>
|
||||
{ isViewportWide && legendDirection === 'column' && legend }
|
||||
{ ! showChart && (
|
||||
{ isRequesting && (
|
||||
<Fragment>
|
||||
<span className="screen-reader-text">
|
||||
{ __( 'Your requested data is loading', 'wc-admin' ) }
|
||||
|
@ -316,7 +315,7 @@ class Chart extends Component {
|
|||
<ChartPlaceholder />
|
||||
</Fragment>
|
||||
) }
|
||||
{ showChart &&
|
||||
{ ! isRequesting &&
|
||||
width > 0 && (
|
||||
<D3Chart
|
||||
colorScheme={ d3InterpolateViridis }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { isEqual } from 'lodash';
|
||||
import { isEmpty, isEqual } from 'lodash';
|
||||
import { Component, createRef } from '@wordpress/element';
|
||||
import PropTypes from 'prop-types';
|
||||
import classNames from 'classnames';
|
||||
|
@ -162,7 +162,7 @@ class D3Chart extends Component {
|
|||
}
|
||||
|
||||
render() {
|
||||
if ( ! this.props.data ) {
|
||||
if ( isEmpty( this.props.data ) ) {
|
||||
return null; // TODO: improve messaging
|
||||
}
|
||||
return (
|
||||
|
|
Loading…
Reference in New Issue