> ## Documentation Index
> Fetch the complete documentation index at: https://docs.graphext.com/llms.txt
> Use this file to discover all available pages before exploring further.

# layout_treemap

> Place nodes on the screen using a treemap layout. 

Transforms a set of columns (normally categorical) to x and y positions using a treemap layout.

The treemap will be created hierarchically according to the order of columns in the input.

At the lowest level of the treemap, points within the same category may be ordered from top to bottom
and left to right using an optional numerical column.

## Usage

The following example shows how the step can be used in a recipe.

<Accordion title="Examples" icon="code" defaultOpen="true">
  <Tabs>
    <Tab title="Example 1">
      The following configuration transforms the categories into a treemap and uses the numerical column to order the nodes in the final squares.

      ```stan theme={null}
      layout_treemap(ds.salary, ds.position, ds.average_montly_hours, {
        "numerical_col": "average_montly_hours",
        "node_size": 8
      }) -> (ds.x, ds.y)
      ```
    </Tab>

    <Tab title="Signature">
      General syntax for using the step in a recipe. Shows the inputs and outputs the step is expected to receive and will produce respectively. For futher details see sections below.

      ```stan theme={null}
      layout_treemap(*columns: category|number, {
          "param": value,
          ...
      }) -> (x: column, y: column)
      ```
    </Tab>
  </Tabs>
</Accordion>

## Inputs & Outputs

The following are the inputs expected by the step and the outputs it produces. These are generally
columns (`ds.first_name`), datasets (`ds` or `ds[["first_name", "last_name"]]`) or models (referenced
by name e.g. `"churn-clf"`).

<Accordion title="Inputs" icon="right-to-bracket">
  <ParamField path="*columns" type="column[category|number]" />
</Accordion>

<Accordion title="Outputs" icon="right-from-bracket">
  <ParamField path="x" type="column" required>
    Numerical column with the x position in the graph.
  </ParamField>

  <ParamField path="y" type="column" required>
    Numerical column with the y position in the graph.
  </ParamField>
</Accordion>

## Configuration

The following parameters can be used to configure the behaviour of the step by including them in
a json object as the last "input" to the step, i.e. `step(..., {"param": "value", ...}) -> (output)`.

<Accordion title="Parameters" defaultOpen="true" icon="sliders">
  <ParamField path="numerical_col" type="string">
    Name of the numerical column.
    Used to order the nodes consecutively in the final treemap.
  </ParamField>

  <ParamField path="node_size" type="integer" default="8">
    Size of the nodes in pixels.

    Values must be in the following range:

    ```javascript theme={null}
    1 ≤ node_size < inf
    ```
  </ParamField>

  <ParamField path="v2" type="boolean" default="false">
    Enable use of version 2 of algorithm.
  </ParamField>
</Accordion>
