Given array of positive numbers, I would like to draw this diagram and be able to put descriptions inside: 
There should be no empty space left, consider that these numbers represent % of total.
Do you know name or description of such algorithm or library with implementation of it ?
Also I want this algorithm to work for nested numbers - when a rectangle has components inside with proper optimization of sizes and locations of outer and inner rectangles.
Visualization is considered optimal if descriptions are easily readable and areas are easily comparable between each other and also with enclosing rectangle. I believe these goals are achieved when these rectangles are closer to squares.
Does this algorithm needs to be iterative or it's possible to have a target formula for position and size of each rectangle ?
The algoritm you are looking for is called Squarified Treemap Algorithm.
Its description and discussion of related issues can be found in this paper by Mark Bruls, Kees Huizing, and Jarke J. van Wijk. The proposed algorithm is recursive in nature.
Key portion of the paper goes like this:
There is also this relevant question on SO:
https://stackoverflow.com/questions/9880635/implementing-a-squarified-treemap-in-javascript
Also, implementation in TypeScript is here. Its demo is here. Screenshot of the demo:
There is also an open source utility for disk space visualization called WinDirStat. It contains C++ implementation of the algorithm above. Its screenshot: