Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/BarChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class BarChart extends React.Component {
}
}

componentWillReceiveProps(nextProps) {
if (nextProps.start) {
componentDidUpdate(prevProps) {
if (this.props.start && !prevProps.start) {
var intervalId = setInterval(this.update, this.props.timeout + this.props.delay);
this.setState({intervalId: intervalId});
}
Expand Down Expand Up @@ -71,7 +71,7 @@ class BarChart extends React.Component {
val: this.props.data[name][i]
};
});
toSort.sort((left, right) => descending ? left.val < right.val : left.val > right.val);
toSort.sort((left, right) => descending ? left.val < right.val ? 1: left.val > right.val ? -1 : 0 : left.val < right.val ? 1 : left.val < right.val ? -1 : 0);
toSort = toSort.slice(0, this.maxItems);
const maxVal = Math.max.apply(Math, toSort.map(item => item.val));
return [toSort.reduce((ret, item, idx) => ({
Expand Down Expand Up @@ -131,4 +131,4 @@ class BarChart extends React.Component {
}
}

export default BarChart;
export default BarChart;