Skip to content

Commit

Permalink
Merge pull request jiahuang#33 from wenzul/master
Browse files Browse the repository at this point in the history
Set either beginning or ending
  • Loading branch information
jiahuang committed Nov 17, 2014
2 parents 982f214 + add5100 commit 5d36291
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/d3-timeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@

// check how many stacks we're gonna need
// do this here so that we can draw the axis before the graph
if (stacked || (ending === 0 && beginning === 0)) {
if (stacked || ending === 0 || beginning === 0) {
g.each(function (d, i) {
d.forEach(function (datum, index) {

Expand All @@ -79,21 +79,23 @@
}

// figure out beginning and ending times if they are unspecified
if (ending === 0 && beginning === 0){
datum.times.forEach(function (time, i) {
datum.times.forEach(function (time, i) {
if(beginning === 0)
if (time.starting_time < minTime || (minTime === 0 && timeIsRelative === false))
minTime = time.starting_time;
if(ending === 0)
if (time.ending_time > maxTime)
maxTime = time.ending_time;
});
}
});
});
});

if (ending === 0 && beginning === 0) {
beginning = minTime;
if (ending === 0) {
ending = maxTime;
}
if (beginning === 0) {
beginning = minTime;
}
}

var scaleFactor = (1/(ending - beginning)) * (width - margin.left - margin.right);
Expand Down

0 comments on commit 5d36291

Please sign in to comment.