# squarify

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-livecharts/treemap_chart_engine/function-squarify/

**function** · [`ferroui-livecharts`](/docs/0.5.0/api/ferroui-livecharts/) · v0.5.0

```rust
fn squarify<T: Clone>(items: &[(f64, T)], rect: ferroui_base::Rect) -> Vec<(T, ferroui_base::Rect)>
```

Partitions `rect` into rectangles of areas proportional to the weights
(`TreemapLayout.Squarify`), row by row along the shorter side, keeping each row while its worst
aspect ratio does not get worse. Non-positive and non-finite weights are skipped; the result is in descending weight
order (a stable sort, so equal weights keep their order).

The weights are normalised by the largest before they are summed, which keeps the areas of the
source without its overflow for weights near `f64::MAX`; a rectangle that collapses to no
shorter side places the rest of the items at zero size instead of dividing by zero.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.LiveCharts/treemap_chart_engine.rs#L101)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
