Stretch geometry precisely to the view

I have asked the following question on stackoverflow but i didn’t get any response there.

Could you please help?

I am looking for the way of stretching a geometry (with all vertices z = 0) into visible screen (HTML Canvas Element).

For now I have worked out how to fit the geometry to the screen, like this:

geometry fitting the canvas

However I want to manipulate the vertices of the geometry at every load of new data so vertices always stretch to the available space on the screen. Now I only adjust camera so the unstretched geometry fits either to height or width leaving lots of available space.

Thanks for help.

full code and demo