Calculate Ideal Burndown

1k Views Asked by At

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.

2

There are 2 best solutions below

0
On BEST ANSWER

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

ideal.push(idealIncrement * 0);

robbing you of your first increment.

change

ideal.push(idealIncrement * i);

to

ideal.push(idealIncrement * (i+1));

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 to totaldays, that works fine too. No need to start at 0 since you don't access the array index anywhere in that loop.

0
On

I think the logic in your code is solid. A burndown chart plots the work you should have at the end of the day for each day in a sprint, right? So if you set the first day to the full 148.5 you rob yourself of a days work. It should really start at 133.65 as that would be where you should be at the end of day 1.