Any decent bubble is barrel shaped
I think you mean ‘vial’, the container in which the bubble is housed, not the bubble itself.
A barrel-shaped interior to the vial is expensive to produce, especially in (ground) glass.
I think there is an old ME article on making a precision level which used a cylindrical glass tube, restrained at the two ends, with a jacking screw under its centre. That would put a very slight curve in the tube.
—
Thanks for all the replies: it is a difficult question.
I am not sure an ellipse works: if you look at pictures of a level in plan view, the shape of the bubble is not elliptical. It is difficult to describe, but the ends are not pointed enough. With an ellipse, you can only specify the ratio between the major and minor axes.
It is easy enough to malke an ellipse of varying eccentricity in Desmos or Geogebra but they do not look correct. To me, the shape looks closer to an olympic running track where the straights are not straight, but bowed slightly outwards.
—
If we changed from a ‘linear’ level to a ‘bullseye’ level, I do not know if that makes it easier to answer. I guess the inside of a bullseye vial is spherical, but the shape the bubble in one of those makes is not like slicing the top off an orange. The bubble retains some other shape.