# getScatter

A Scatter model is a data model that represents bi-variable data points defined as numerical *x* and *y* values. Suitable for rendering scatter plots and other similar charts.

## **Usage**

```typescript
const formula = await dataSource.getScatter({
    xAxisColumn: 'column_A',
    xAxisJoinOperation: 'count',
    yAxisColumn: 'column_B'
    yAxisOperationColumn: 'sum'
    // + base options...
});
```

## **Options**

The `getScatter` model inherits all options from the [base options](/carto-for-developers/reference/carto-widgets-reference/models.md#model-base-options), plus:

```typescript
export interface ScatterRequestOptions extends BaseRequestOptions {
  xAxisColumn: string | string[];
  xAxisJoinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
  yAxisColumn: string | string[];
  yAxisJoinOperation?: 'count' | 'avg' | 'min' | 'max' | 'sum';
}
```

* **xAxisColumn:** the name of the column that will be used for getting the first variable (*x axis*) of each set. It also accepts a list of column names, that can be then aggregated using `xAxisJoinOperation`.
* **xAxisJoinOperation** (optional)**:** the aggregation that will be performed to aggregate an array in `xAxisColumn` into a single one. Accepted values are:
  * `count`
  * `avg`
  * `min`
  * `max`
  * `sum`
* **yAxisColumn:** the name of the column that will be used for getting the second variable (y *axis*) of each set. It also accepts a list of column names, that can be then aggregated using y`AxisJoinOperation`.
* **yAxisJoinOperation** (optional)**:** the aggregation that will be performed to aggregate an array in y`AxisColumn` into a single one. Accepted values are:
  * `count`
  * `avg`
  * `min`
  * `max`
  * `sum`

## **Response**

A two-dimensional array containing a pair of numerical values for each set of variables.

{% hint style="warning" %}
The response will be limited to the **first 500 rows** for the given combination of sources and filters.
{% endhint %}

```typescript
type CategoriesModelResponse = [number, number][];
/* example response 
    [
      [1939, 34820],
      [2374, 59231],
      [3781, 61732],
      [3200, 57689],
      [4589, 98478],
      [4873, 89573],
      [4109, 84023]
    ];
*/    
```

The response can be then freely mapped to any charting library to create data visualizations like a scatterplot chart.

<figure><img src="/files/Y1NVCmZfoS4mo2rxNo5p" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.carto.com/carto-for-developers/reference/carto-widgets-reference/models/getscatter.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
