Skip to content

Commit

Permalink
Merge pull request speced#234 from NamPNQ/patch-1
Browse files Browse the repository at this point in the history
Update process.js
  • Loading branch information
almossawi committed Nov 26, 2014
2 parents d50910d + 4b423a5 commit 125ea77
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/misc/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ function process_line(args) {
var processed_data = [];

//we'll be starting from the day after our first date
var start_date = clone(first['date']).setDate(first['date'].getDate() + 1);
var start_date = clone(first[args.x_accessor]).setDate(first[args.x_accessor].getDate() + 1);

//if we've set a max_x, add data points up to there
var from = (args.min_x) ? args.min_x : start_date;
var upto = (args.max_x) ? args.max_x : last['date'];
var upto = (args.max_x) ? args.max_x : last[args.x_accessor];
for (var d = new Date(from); d <= upto; d.setDate(d.getDate() + 1)) {
var o = {};
d.setHours(0, 0, 0, 0);
Expand All @@ -81,7 +81,7 @@ function process_line(args) {

//if we don't have this date in our data object, add it and set it to zero
if(!existing_o) {
o['date'] = new Date(d);
o[args.x_accessor] = new Date(d);
o[args.y_accessor] = 0;
processed_data.push(o);
}
Expand All @@ -91,7 +91,7 @@ function process_line(args) {
}

//add the last data item
if(Date.parse(d) == Date.parse(new Date(last['date']))) {
if(Date.parse(d) == Date.parse(new Date(last[args.x_accessor]))) {
processed_data.push(last);
}
}
Expand Down

0 comments on commit 125ea77

Please sign in to comment.