BarChart: Print message if data is empty

This commit is contained in:
Aaron Lindsay 2017-01-10 20:41:08 -05:00
parent 007e122a4a
commit dcb921c5f5

View File

@ -11,9 +11,9 @@ module.exports = React.createClass({
* {'Label': 'bar', 'Value': 8} * {'Label': 'bar', 'Value': 8}
* ]; * ];
*/ */
if (this.props.data.length < 1)
return (<div />);
var rows = [];
if (this.props.data.length >= 1) {
var max = parseFloat(this.props.data[0].Value); var max = parseFloat(this.props.data[0].Value);
var min = parseFloat(this.props.data[0].Value); var min = parseFloat(this.props.data[0].Value);
for (var i = 0; i < this.props.data.length; i++) { for (var i = 0; i < this.props.data.length; i++) {
@ -24,7 +24,6 @@ module.exports = React.createClass({
min = cur; min = cur;
} }
var rows = [];
for (var i = 0; i < this.props.data.length; i++) { for (var i = 0; i < this.props.data.length; i++) {
var rowData = this.props.data[i]; var rowData = this.props.data[i];
if ((max - min) == 0.0) if ((max - min) == 0.0)
@ -40,6 +39,11 @@ module.exports = React.createClass({
</tr> </tr>
)); ));
} }
} else {
rows.push((
<tr><td>No data</td></tr>
));
}
return ( return (
<Panel header={this.props.title}> <Panel header={this.props.title}>