$\begingroup$you can create keyframes on the objects visibility in the Outliner panel. But you could also transform your initial cube to a bar with a second shapekey...$\endgroup$
– moonbootsApr 29 '19 at 16:06

$\begingroup$You could also animate the array modifier of simply the scale in stepped keys.$\endgroup$
– LeanderApr 29 '19 at 21:13