dataN : [106.2, -5.1, -1.4, -.8, -8.7, 2]$ dataL : ["Original model Jan 05", "Revised revenue forecasts", "Change to marketing costs", "Correct error in interest calculation", "Change to long-term growth assumptions", "Results of head-count estimates", "Current model Sep 05" ]; lengthN : length(dataN)$ if (lengthN+1) > length(dataL) then print("Labels are missing")$ labelSpace : 2.5$ pointSpacer : .2$ rectSpacer : .2$ currentY : dataN[1]$ rectLabel : [[string(ev(round(currentY*100)/100, numer)), 2*pointSpacer, currentY+labelSpace]]$ termBox : [rectangle([0, 0], [1-rectSpacer, currentY])]$ sumBoxUp : []$ sumBoxDn : []$ pointUp : []$ pointDn : []$ /* return a list of items, which are also lists */ tempFunc(a, b) := [append(a, [[X-1+pointSpacer, labelY]]), append(b, [rectangle([X-1, currentY], [X-rectSpacer, newY])])]$ for X : 2 thru lengthN do ( currentD : dataN[X], newY : currentY + currentD, labelY : newY + signum(currentD) * labelSpace, if currentD < 0 then /* underneath rectangle */ /* break returned list into items */ [pointDn, sumBoxDn] : tempFunc(pointDn, sumBoxDn) else /* above rectangle */ /* break returned list into items */ [pointUp, sumBoxUp] : tempFunc(pointUp, sumBoxUp), rectLabel : append(rectLabel, [[string(ev(round(abs(dataN[X])*100)/100, numer)), X-1+3*pointSpacer, labelY]]), currentY : newY )$ kill(tempFunc)$ /* not needed */ rectLabel : append(rectLabel, [[string(ev(round(currentY*100)/100, numer)), lengthN+2*pointSpacer, currentY+labelSpace]])$ termBox : append(termBox, [rectangle([lengthN, 0], [lengthN+1-rectSpacer, currentY])])$ axisLabel : []$ for X : 1 thru length(dataL) do axisLabel : append(axisLabel, [[dataL[X], X-.5-rectSpacer/2, -1]])$ load('draw)$ draw2d(yrange=[-70, lreduce(max, dataN)*1.1], xtics=none, dimensions=[768, 1024], title="revenue - allocation chart", axis_left=false, axis_right=false, axis_bottom=false, map(label, rectLabel), /* number for amounts */ color=red, point_type=filled_down_triangle, /* 11 */ points(pointDn), /* allocation decrease */ color=black, point_type=filled_up_triangle, /* 9 */ points(pointUp), /* allocation increase */ label_orientation='vertical, label_alignment='right, map(label, axisLabel), /* vertical labels for x-axis */ fill_color=yellow, termBox, /* start & finish amounts */ fill_color=pink, sumBoxDn, /* intermediate decrease */ fill_color=gray, sumBoxUp /* intermediate increase */ );