Using a Python script to generate Cumulative Flow Diagrams

Cumulative Flow Diagram is a graphical tool used extensively in Lean and Agile projects. It is used to track project progress, visualize work in progress (WIP) and obtain understanding of issues with the project including bottlenecks & scope changes.

CFD generated using Spyder 2 IDE with matplotlib and numpy modules
CFD generated using Spyder 2 IDE with matplotlib and numpy modules

Burn Up and Burn Down charts are much more commonly used by Agile teams than Cumulative Flow Diagrams (CFD) because they can be easily plotted on a white board using a marker pen. In the case of CFDs, it is not easy to plot it manually on a white board  and so many teams therefore, have to procure software, even when the team is co-located just for the sake of generating plots.

There is a way to plot CFDs using excel described here, but to automate it we need to script it. This article describes a very simple way to generate CFDs using a python script.

The input to this script is hard-coded in the form of arrays for each status, but these can be easily replaced by variables input from a web form.

The Kanban flow for this specific case has Requirements, Development, Testing, Verification and Done indicated by the arrays features_req, features_dev, features_tst, features_vfy and features_dne which contain the values from Week 1 (W1) to Week 12 (W12). The arrays are as below which forms a matrix.

 #Weeks ->     W1,W2,W3,W4,W5,W6,W7,W8,W9,W10,W11, W12
features_req = [1, 1, 4, 3, 1, 1, 0, 0, 0, 0,  0,   0]
features_dev = [0, 1, 2, 2, 3, 2, 2, 1, 1, 0,  0,   0]
features_tst = [0, 0, 0, 1, 1, 2, 2, 2, 1, 2,  0,   0]
features_vfy = [0, 0, 0, 0, 1, 1, 2, 2, 3, 1,  2,   0]
features_dne = [0, 0, 0, 0, 0, 0, 0, 1, 1, 3,  4,   6]

I will describe in detail the data (above) giving examples of the Kanban board for that week.

The Board has just one feature request in the first week.
Kanban Board – Week 1

The status of the board for a week should be read in vertical for that week. e.g. For week 1, there is just one feature request as indicated by the values in the column for W1 (Week 1) -> 1,0,0,0,0.

Kanban Board - Week 2
Kanban Board – Week 2

For Week 2, a new feature request has been made which arrives in the first column (Requirements). The first feature request has now been pulled into the development stage and is been worked on. So the column for W2 (Week 2) has the values -> 1,1,0,0,0

Kanban Board - Week 3
Kanban Board – Week 3

In the third week (Week 3), four feature requests have come into the first column (Requirements), the one request which had come in the last week is moved to Development so that you now have a total of two features in development. So the column W3 has the values -> 4,2,0,0,0.

Kanban Board - Week 12
Kanban Board – Week 12

The last column in the matrix has the values for Week 12 (W12), which is 0,0,0,0,6 and the corresponding Kanban board shows all the items (6) in the Done column.

This basically means that there is one-to-one correspondence between the column for that week and the Kanban board columns. It is straight forward to construct this matrix for your specific use case even to have a similar web form constructed to feed in the data representing the Kanban board.

The script uses python with matplotlib and numpy. The plot was generated using iPython in Spyder2 IDE. The script is as below.

import numpy as np
from matplotlib import pyplot as plt

weeks = np.arange(1,13,1)
#Weeks -> W1,W2,W3,W4,W5,W6,W7,W8,W9,W10,W11, W12
features_req = [1, 1, 4, 3, 1, 1, 0, 0, 0, 0, 0, 0]
features_dev = [0, 1, 2, 2, 3, 2, 2, 1, 1, 0, 0, 0]
features_tst = [0, 0, 0, 1, 1, 2, 2, 2, 1, 2, 0, 0]
features_vfy = [0, 0, 0, 0, 1, 1, 2, 2, 3, 1, 2, 0]
features_dne = [0, 0, 0, 0, 0, 0, 0, 1, 1, 3, 4, 6]
features = np.row_stack((features_dne, features_vfy, features_tst,
features_dev, features_req))

fig, ax = plt.subplots()
ax.stackplot(weeks, features)

# Add relevant y and x labels and text to the plot
plt.title('Cumulative Flow Diagram')
ax.set_xlim(1, 12)
ax.set_ylim(0, 6)

You can download it from here.

Leadership Behavior and Employee Attrition – Why are your employees leaving you ?

The article investigates the relationship between attrition and leadership behavior.

As a Manager, your people are the source of your greatest joys and also the source of your greatest sorrows. When they leave, all the investment that you made on them goes out of the door. But the eternal truth in people management is  “People don’t leave companies, they leave their bosses”. The work environment and your leadership behavior that creates it, plays a profound role in your relationship with your employee and therefore, employee retention.  Please read on to find out about few of the extremely damaging leadership behaviors which cause employees to leave.

An Environment of Fear  

There are managers among us that believe that the best way to get results is by using fear and intimidation. There are many forms –  public humiliation, sarcasm and the like. These managers do not trust their employees to do good work and this, for them, becomes a way of guaranteeing that the work will be done with the level of quality that they expect.  On the fear scale, fear of job loss creates the maximum fear – this goes by many names resource actions, work force reduction/re-balancing etc and the threats thereof. You may have noticed, you decide when some of them leave; they decide when more of them leave.

The equation is simple – fear creates resentment. Mostly, this resentment is private and as your behavior impacts more people the resentment becomes public. Resentment makes people want to get back at you – one of the most common ways is to just leave you.

Managers who rule by fear fail to understand the fundamental nature of knowledge work – Fear arrests innovation, employees want to play safe and innovation by definition requires a certain amount of risk taking. Work stays as hard as it has always been, efficiency does not improve, company doesn’t save money and in fact loses money due to the rapidly departing employees.

Annoying the Employee

As an organization increases in size, they want to put in processes for efficiency. Very soon, you have an environment where there are processes for everything and everyone. These first becomes rules of thumb and then very soon becomes the law (called the policy). In may big companies, you can see company veterans going around quoting these policies whenever an appropriate situation props up – if any examples of this comes to mind, I can almost guarantee you, your organization has straight jacketed itself and you will be, almost 100% be facing a serious attrition issue.

In these companies, when an employee approaches you (the manager) for a solution to his/her problem and when you show them the rule book, preferring not to stand up against the defunct processes/procedures, you are setting the stage for the departure of the employee from the organization. If processes/procedures do not permit you to have satisfied employees, then they should be scrapped without compunction – this is not optional but an obligation for you as a manager to your employee and to the organization.


“Knowledge is Power” absolutely! But, in the knowledge worker industry, if knowledge is held back for you to feel powerful, execution and decision-making suffers. Bad decisions get made, effort wasted to deliver the wrong work items  and your employees will resent you for not sharing when them information which could have helped them make the right decisions.

Your employees have a right to know what affects their work, career and life. This is critical information for them and if you hold this back or worse, they hear it from someone else, they are not going to trust you. And, without trust, don’t expect them to stick around.

Remember, transparency & trust are the cornerstones of good management.

The Bait

Lets face it, you know good people want to do good work and you have created a Job Description document which attracts the best in the market but which is a spruced up version of the real job. Now the employee has joined expecting to find what was mentioned in the job description and then faces the reality of the current job not being anywhere near what was advertised.

This however, is a recipe for disaster. You will hold the employee, only till he/she can find another job. In the knowledge worker industry, absolutely no one wants to work below his skill level or capability. Also, in the era of social networks, the image of the organization will take a beating, you will struggle to find talent in the future. People are more connected today than ever before and they are more connected than you think.

The solution is, of course, to adopt a policy of complete honesty. Describe what the job is about in sufficient detail so that the person applying for the position has a very good understanding about the position. Conduct the interview to evaluate the skills which are necessary to do the job – do not hire the “best person”, hire the “right person” for the job. Also, during the interview, ensure that the candidate understands the job requirement, the work timing and anything else which he/she may want to know.

The Bias

When your people work hard for you and they  see you pushing in your relatives/friends into important positions in your organization, they see you rewarding someone in your team for reasons other than professional, they feel crushed. You may have established a coterie system and culture of favoritism to make you feel secure, but these hardly work in the long-term. When your employees see what is happening, they take the shortest way out because working for such an organization is just a waste of time.

For you, the manager, everyone in the team should be equal irrespective of region, religion, color, gender or anything else. When you reward a professional achievement, it should be because of that achievement and nothing else. To be unbiased is such an important criteria for a manager that even the remotest perception of bias quickly kills productivity and damages the team irreparably.

The Support

Ask yourself, How good am I in creating & finding opportunities for my team members ? How passionate am I to push them to take higher responsibilities, to help them grow, to encourage them to learn ? If you struggle to find answers to the above questions, then you will, for sure have an attrition problem.

Most top employers provide development support ranging from career planning, formal mentoring, tuition assistance with study leave that help employees prepare for more advanced positions. They have clear career paths, goals and tons of encouragement for employees to learn.

Employees want to see a future for them. As they work with you, they need mentoring, guidance and developmental support (training, opportunities, certifications etc.) for career advancement. If you are not going to provide then with these opportunities or support they are going to find someone who can.

Divisive Behavior/Negative Competition

Some managers adopt a divisive strategy and pit one employee against the other, one department against the other. They do it with the expectation that competition encourages performance. Healthy competition is good, but this approach creates a very negative atmosphere with huge amounts of stress. Most people are not comfortable facing stressful situations day after day, they will leave you and the company if stress is making them feel unwell.

There is a quantifiable cost associated with bad leadership behavior. The simple metric of the number of people  citing “relationship with manager” as the reason for leaving can serve as a starting point if your organization wants to quantify this cost. This is usually much higher than the budgets for “Learning and Development” and “Employee Engagement” budgets put together. Organizations often  pump up their employee engagement funds  and development budgets  to prevent attrition and leadership behavior is an often ignored and under-investigated area but which has huge impact on employee retention. 

So if you want to know Why are my employees leaving me ? Reflect on your own behavior and others in your management chain, make sure it is not what is driving your people away.