Skip to content

Commit

Permalink
empty data error message
Browse files Browse the repository at this point in the history
  • Loading branch information
arajajyothibabu committed Jul 3, 2017
1 parent d3bf5b0 commit 175e54b
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 80 deletions.
101 changes: 58 additions & 43 deletions lib/reactcohortgraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -2716,64 +2716,38 @@ var ReactCohortGraph = function (_React$Component) {
value: function render() {
var _this2 = this;

var _props = this.props,
_props$showEmptyDataM = _props.showEmptyDataMessage,
showEmptyDataMessage = _props$showEmptyDataM === undefined ? true : _props$showEmptyDataM,
customEmptyDataMessage = _props.customEmptyDataMessage;
var _state = this.state,
dataStore = _state.dataStore,
currentType = _state.currentType,
valueType = _state.valueType;

var header = dataStore.getHeader(currentType);
var rows = dataStore.getRows(currentType);
return _react2.default.createElement(
'div',
{ style: _styles.Table },
_react2.default.createElement(
if (header && header.length > 0) {
return _react2.default.createElement(
'div',
{ style: _styles.TableBody },
{ style: _styles.Table },
_react2.default.createElement(
'div',
{ style: _styles.TableRow },
{ style: _styles.TableBody },
_react2.default.createElement(
'div',
{ style: _styles.FixedTablePart },
{ style: _styles.TableRow },
_react2.default.createElement(
'div',
{ style: _styles.Table },
_react2.default.createElement(
'div',
{ style: _styles.TableHeading },
header.map(function (headerCell, i) {
return _this2.isFixed(i) && _react2.default.createElement(_components.HeaderCell, _extends({ key: "header" + i }, headerCell, { valueType: valueType }));
})
),
_react2.default.createElement(
'div',
{ style: _styles.TableBody },
rows.map(function (row, j) {
return _react2.default.createElement(
'div',
{ style: _styles.TableRow, key: "row" + j },
row.map(function (cell, k) {
return _this2.isFixed(k) && _react2.default.createElement(_components.BodyCell, _extends({ key: "cell" + k }, cell, { valueType: valueType }));
})
);
})
)
)
),
_react2.default.createElement(
'div',
{ style: _styles.ScrollableTablePart },
_react2.default.createElement(
_components.ScrollableContent,
null,
{ style: _styles.FixedTablePart },
_react2.default.createElement(
'div',
{ style: _styles.Table },
_react2.default.createElement(
'div',
{ style: _styles.TableHeading },
header.map(function (headerCell, i) {
return !_this2.isFixed(i) && _react2.default.createElement(_components.HeaderCell, _extends({ key: "header" + i }, headerCell, { valueType: valueType }));
return _this2.isFixed(i) && _react2.default.createElement(_components.HeaderCell, _extends({ key: "header" + i }, headerCell, { valueType: valueType }));
})
),
_react2.default.createElement(
Expand All @@ -2784,17 +2758,56 @@ var ReactCohortGraph = function (_React$Component) {
'div',
{ style: _styles.TableRow, key: "row" + j },
row.map(function (cell, k) {
return !_this2.isFixed(k) && _react2.default.createElement(_components.BodyCell, _extends({ key: "cell" + k }, cell, { valueType: valueType }));
return _this2.isFixed(k) && _react2.default.createElement(_components.BodyCell, _extends({ key: "cell" + k }, cell, { valueType: valueType }));
})
);
})
)
)
),
_react2.default.createElement(
'div',
{ style: _styles.ScrollableTablePart },
_react2.default.createElement(
_components.ScrollableContent,
null,
_react2.default.createElement(
'div',
{ style: _styles.Table },
_react2.default.createElement(
'div',
{ style: _styles.TableHeading },
header.map(function (headerCell, i) {
return !_this2.isFixed(i) && _react2.default.createElement(_components.HeaderCell, _extends({ key: "header" + i }, headerCell, { valueType: valueType }));
})
),
_react2.default.createElement(
'div',
{ style: _styles.TableBody },
rows.map(function (row, j) {
return _react2.default.createElement(
'div',
{ style: _styles.TableRow, key: "row" + j },
row.map(function (cell, k) {
return !_this2.isFixed(k) && _react2.default.createElement(_components.BodyCell, _extends({ key: "cell" + k }, cell, { valueType: valueType }));
})
);
})
)
)
)
)
)
)
)
);
);
}
if (showEmptyDataMessage) {
return customEmptyDataMessage || _react2.default.createElement(
'h3',
null,
'No Data..!'
);
}
}
}]);

Expand All @@ -2807,10 +2820,10 @@ ReactCohortGraph.propTypes = {
valueType: _propTypes2.default.string.isRequired, //["value", "percent"]
cellClickEvent: _propTypes2.default.func,
showEmptyDataMessage: _propTypes2.default.bool,
customEmptyDataMessage: _propTypes2.default.string,
customEmptyDataMessage: _propTypes2.default.any,
columnClickEvent: _propTypes2.default.func,
maxDays: _propTypes2.default.number,
/*maxWeeks : PropTypes.number, //TODO:
/*maxDays : PropTypes.number,
maxWeeks : PropTypes.number, //TODO:
maxMonths : PropTypes.number,*/
//enableTooltip : PropTypes.bool, TODO
showAbsolute: _propTypes2.default.bool,
Expand Down Expand Up @@ -3171,6 +3184,7 @@ var _initialiseProps = function _initialiseProps() {
return _this.headers[type]; //returns [][]
} else {
console.error('No Headers Found for type => ' + type);
return [];
}
};

Expand All @@ -3179,6 +3193,7 @@ var _initialiseProps = function _initialiseProps() {
return _this.store[type]; //returns [][]
} else {
console.error('No Headers Found for type => ' + type);
return [];
}
};

Expand Down
2 changes: 1 addition & 1 deletion lib/reactcohortgraph.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-cohort-graph",
"version": "0.5.8",
"version": "0.5.9",
"description": "Cohort Analysis Graph with ReactJS",
"main": "lib/reactcohortgraph.js",
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions src/DataStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ export default class DataStore {
return this.headers[type]; //returns [][]
}else{
console.error(`No Headers Found for type => ${type}`);
return [];
}
};

Expand All @@ -274,6 +275,7 @@ export default class DataStore {
return this.store[type]; //returns [][]
}else{
console.error(`No Headers Found for type => ${type}`);
return [];
}
};

Expand Down
78 changes: 43 additions & 35 deletions src/ReactCohortGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,40 +61,42 @@ class ReactCohortGraph extends React.Component {
isFixed = (index) => index < 2;

render(){
const {showEmptyDataMessage = true, customEmptyDataMessage} = this.props;
const { dataStore, currentType, valueType } = this.state;
const header = dataStore.getHeader(currentType);
const rows = dataStore.getRows(currentType);
return(
<div style={Table}>
<div style={TableBody}>
<div style={TableRow}>
<div style={FixedTablePart}>
<div style={Table}>
<div style={TableHeading}>
{
header.map((headerCell, i) =>
this.isFixed(i) && <HeaderCell key={"header" + i} {...headerCell} valueType={valueType} />
)
}
</div>
<div style={TableBody}>
{
rows.map((row, j) =>
<div style={TableRow} key={"row" + j}>
{
row.map((cell, k) =>
this.isFixed(k) && <BodyCell key={"cell" + k} {...cell} valueType={valueType} />
)
}
</div>
)
}
if(header && header.length > 0){
return(
<div style={Table}>
<div style={TableBody}>
<div style={TableRow}>
<div style={FixedTablePart}>
<div style={Table}>
<div style={TableHeading}>
{
header.map((headerCell, i) =>
this.isFixed(i) && <HeaderCell key={"header" + i} {...headerCell} valueType={valueType} />
)
}
</div>
<div style={TableBody}>
{
rows.map((row, j) =>
<div style={TableRow} key={"row" + j}>
{
row.map((cell, k) =>
this.isFixed(k) && <BodyCell key={"cell" + k} {...cell} valueType={valueType} />
)
}
</div>
)
}
</div>
</div>
</div>
</div>
<div style={ScrollableTablePart}>
<ScrollableContent>
<div style={Table}>
<div style={ScrollableTablePart}>
<ScrollableContent>
<div style={Table}>
<div style={TableHeading}>
{
header.map((headerCell, i) =>
Expand All @@ -116,12 +118,18 @@ class ReactCohortGraph extends React.Component {
}
</div>
</div>
</ScrollableContent>
</ScrollableContent>
</div>
</div>
</div>
</div>
</div>
)
)
}
if(showEmptyDataMessage){
return(
customEmptyDataMessage || <h3>No Data..!</h3>
);
}
}

}
Expand All @@ -132,10 +140,10 @@ ReactCohortGraph.propTypes = {
valueType: PropTypes.string.isRequired, //["value", "percent"]
cellClickEvent : PropTypes.func,
showEmptyDataMessage : PropTypes.bool,
customEmptyDataMessage : PropTypes.string,
customEmptyDataMessage : PropTypes.any,
columnClickEvent : PropTypes.func,
maxDays : PropTypes.number,
/*maxWeeks : PropTypes.number, //TODO:
/*maxDays : PropTypes.number,
maxWeeks : PropTypes.number, //TODO:
maxMonths : PropTypes.number,*/
//enableTooltip : PropTypes.bool, TODO
showAbsolute : PropTypes.bool,
Expand Down

0 comments on commit 175e54b

Please sign in to comment.