doGraph[a_]:=Module[{},
queueCoord[{t_,Q_},Qi_]:={t,Total[Take[Q,Qi]]};
fluidSolution = {     {0,{8,1,15}},
				{4,{8,0,12}},
				{a,{8,0,16-a}},
				{a+(16-a)2,{8-(16-a)*2*(1/4),0,0}},
{Min[40,a+32],{Max[8-(16-a)*2*(1/4)-(((40-(a+(16-a)2)))/4),0],0,0}},
{40,{0,0,0}}
};
holdTrapzoid[x_,y_]:=Abs[y[[1]]-x[[1]]]*((Total[x[[2]]]+Total[y[[2]]])/2);
holdCost = holdTrapzoid[fluidSolution[[1]],fluidSolution[[2]]]+
holdTrapzoid[fluidSolution[[2]],fluidSolution[[3]]]+
	holdTrapzoid[fluidSolution[[3]],fluidSolution[[4]]]+
		holdTrapzoid[fluidSolution[[4]],fluidSolution[[5]]];
fluidGraph =Join[Flatten[Reverse[Table[{RGBColor[.2*i,.2*i,.2*i],Polygon[Join[{{0,0}},Map[queueCoord[#,i]&,fluidSolution]]]},{i,3}]],1],{RGBColor[0,0,0],Text[Style[Round[holdCost,.1],Large],{35,23}]}];
Show[Graphics[fluidGraph,{Frame->True,PlotRange->{0,25}}]]
];
Manipulate[doGraph[a],{a,4,16}]