I am trying to draw a Burndowm chart form a data API.
I have successfully retrieved the data etc.
I now need to draw an ideal Burndown line. This will be from the full sprint estimate number, down to zero. I am using Chart.js to draw the line graph.
I have tried to calculate each day's ideal total using the following code:
var totalSprintEstimate = 148.5;
var totalDays = 10;
var idealIncrement = totalSprintEstimate / totalDays;
var ideal = [];
for (i = 0; i <= totalDays-1; i++) {
ideal.push(idealIncrement * i);
}
ideal.reverse();
With this logic, I always end up one day short of a full total (133 point something) against totalDays = 10-1
or I reach the full 148.5 but with too many days to plot on the graph.
I have tried to look this up on t'internet but have come to a halt as I don't really know what to search for.
Well, of course you end up one increment short, because you shift to a zero based index and multiply with that.
Your first iteration is
robbing you of your first increment.
change
to
and you should be able to go on with your current strategy. Or, which is better to read, start your for loop at
i=1
and go all the way up tototaldays
, that works fine too. No need to start at0
since you don't access the array index anywhere in that loop.