Skip to content

Commit

Permalink
Merge pull request #30 from janfromberlin/master
Browse files Browse the repository at this point in the history
bugfix for timeline widget
  • Loading branch information
jogibear9988 authored Jun 13, 2019
2 parents 8791373 + d381850 commit 023be06
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/app/widgets/timeline/timeline.widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,29 +155,29 @@
var partitionData = function (raw) {
var partitions = [];
if (!raw.data) return; //was raw.datapoints, bt this seems a bug datapoints is used in charts

var currentState = raw.data[0].state;
var currentStartTime = raw.data[0].time;

for (var i = 1; i < raw.data.length; i++) {
if (raw.data[i].state !== currentState) {
partitions.push({
state: currentState,
starting_time: currentStartTime,
ending_time: raw.data[i].time
});
currentState = raw.data[i].state;
currentStartTime = raw.data[i].time;
if (raw.data.length > 0) {
var currentState = raw.data[0].state;
var currentStartTime = raw.data[0].time;

for (var i = 1; i < raw.data.length; i++) {
if (raw.data[i].state !== currentState) {
partitions.push({
state: currentState,
starting_time: currentStartTime,
ending_time: raw.data[i].time
});
currentState = raw.data[i].state;
currentStartTime = raw.data[i].time;
}
}
}

// push the last partition
partitions.push({
state: currentState,
starting_time: currentStartTime,
ending_time: Date.now()
});

// push the last partition
partitions.push({
state: currentState,
starting_time: currentStartTime,
ending_time: Date.now()
});
}
return partitions;
};

Expand Down

0 comments on commit 023be06

Please sign in to comment.