> ## 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.

# create_compare_insight

> Create a new insight from the Compare section. 

## Usage

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

<Accordion title="Examples" icon="code" defaultOpen="true">
  <Tabs>
    <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}
      create_compare_insight(, {
          "param": value,
          ...
      })
      ```
    </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" />

<Accordion title="Outputs" icon="right-from-bracket" />

## 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="title" type="string" required>
    Title of the insight.
  </ParamField>

  <ParamField path="columns" type="array[string]" required>
    Columns from which the insight is created.

    <Accordion title="Array items">
      <ParamField path="Item" type="string">
        Each item in array.
      </ParamField>
    </Accordion>
  </ParamField>

  <ParamField path="hiddenColumns" type="array[string]">
    Columns that will not be used to create the insight.

    <Accordion title="Array items">
      <ParamField path="Item" type="string">
        Each item in array.
      </ParamField>
    </Accordion>
  </ParamField>

  <ParamField path="insightThemeMode" type="string">
    Theme mode applied to the whole insight.

    Values must be one of the following:

    * `dark`
    * `light`
  </ParamField>

  <ParamField path="isExpanded" type="boolean">
    Sets the correlation graph as expanded.
    If true, the insight will contain an expanded chart in order to show the maximum number of categories possible.
  </ParamField>

  <ParamField path="sortingOrder" type="string">
    Useful to choose the ordering kind of the columns, by difference or by similarity.

    Values must be one of the following:

    * `differentFirst`
    * `similarFirst`
  </ParamField>

  <ParamField path="replayDisabled" type="[string, boolean]" default="false">
    Indicates if the insight can replay its original state or not.

    Values must be one of the following:

    * `drillDown`
    * `directSelectionInGraph`
    * `nonPersistedColumn`
    * `True`
    * `False`
  </ParamField>

  <ParamField path="representation" type="string" required>
    Sets the visualization type.
    In relative and absolute modes the comparing segments will be rendered as charts, but in tabular mode a table is shown.

    Values must be one of the following:

    * `relative`
    * `absolute`
    * `tabular`
  </ParamField>

  <ParamField path="elements" type="array[object]">
    Type and appearance of an insight's elements.
    A list in which each item is an object configuring the appearance of a particular insight element.

    <Accordion title="Array items">
      <ParamField path="kind" type="string">
        Specify the type of element.

        Values must be one of the following:

        `TITLE` `DESCRIPTION` `CHART` `GRAPH` `STATS` `LEGEND` `LEGEND_COLOR_SCALE` `TABLE_CHART`
      </ParamField>

      <ParamField path="text" type="string">
        The text shown for this insight element.
      </ParamField>

      <ParamField path="hidden" type="boolean">
        Element visibility.
      </ParamField>

      <ParamField path="layout" type="object">
        The element's position and size.
        The position refers to the top-left corner of the rectangle representing the insight element,
        while the size is given by its width and height. For reference, the entire insight is 12 units
        wide and 9 units high, and the origin (0, 0) of the x/y coordinates is in its top-left corner.

        <Accordion title="Properties">
          <ParamField path="x" type="integer">
            Horizontal position of the element's top-left corner.
            In increments of 1; 0 being the left-most and 8 the right-most position.

            Values must be in the following range:

            ```javascript theme={null}
            -1 ≤ x ≤ 11
            ```
          </ParamField>

          <ParamField path="y" type="integer">
            Vertical position of the element's top-left corner.
            In increments of 1; 0 being the top-most and 11 the bottom-most position.

            Values must be in the following range:

            ```javascript theme={null}
            0 ≤ y ≤ 11
            ```
          </ParamField>

          <ParamField path="w" type="integer">
            The width of the element (in increments of 1).

            Values must be in the following range:

            ```javascript theme={null}
            0 ≤ w ≤ 12
            ```
          </ParamField>

          <ParamField path="h" type="integer">
            The height of the element (in increments of 1).

            Values must be in the following range:

            ```javascript theme={null}
            0 ≤ h ≤ 9
            ```
          </ParamField>
        </Accordion>
      </ParamField>

      <ParamField path="column" type="string">
        Name of the column containing the data to be used in this insight element.
        *Required* if the element is of type CHART or STATS.
      </ParamField>
    </Accordion>
  </ParamField>

  <ParamField path="comparingSegments" type="array[object]" required>
    Array of segments to use in the insight.

    <Accordion title="Array items">
      <ParamField path="mode" type="string">
        Defines some behavior in the UI for this comparing segment.

        Values must be one of the following:

        * `VALUES`
        * `RANGE`
        * `EVERYTHING`
        * `SELECTION`
      </ParamField>

      <ParamField path="useInRelevance" type="boolean">
        Specify if the comparing segment column was used in the relevance analysis or not.
      </ParamField>

      <ParamField path="column" type="[string, null]">
        Main column from which the insight is created.
      </ParamField>

      <ParamField path="values" type="array[['number', 'string']]">
        Selection Values.
        In categorical and text columns, a selection of single values can be made and this type is useful to do that.

        <Accordion title="Array items">
          <ParamField path="Item" type="[number, string]">
            Each item in array.
          </ParamField>
        </Accordion>
      </ParamField>

      <ParamField path="range" type="array[['number', 'string']]">
        Selection Range.
        This type is useful for quantitative columns, in which a selection of values in range can be made.

        <Accordion title="Array items">
          <ParamField path="Item" type="[number, string]">
            Each item in array.
          </ParamField>
        </Accordion>
      </ParamField>
    </Accordion>
  </ParamField>
</Accordion>
