# Hello, dotAtlas!

This is the developer's manual for dotAtlas version 1.1.0.

dotAtlas is a JavaScript library for interactive exploration of 2d point collections.

dotAtlas can produce zoomable visualizations similar to the one shown below. They combine various types of layers, such as elevations, markers or labels, to produce an attractive map-like presentation of your data.

![dotAtlas map with labeled islands, elevation contours, colored markers and a highlighted group of selected points.](/assets/apidocs/img/dTphPtWdBe-1306.jpeg)

---

To get started with dotAtlas, have a look at:

-   [Quick start](/quick-start/): setting up your first simple dotAtlas visualization with a minimal amount of code.
    
-   Guides: in-depth articles covering various aspects of dotAtlas, such as [requirements](/requirements/), [installation](/installation/), [API overview](/api-overview/), [defining layers](/defining-layers/), [listening to events](/listening-to-events/) and more.
    

Finally, the [API](/api-common/) [references](/api-dotatlas/) contain details on all the available options and methods.

---

# Quick start

This article shows how to build your first simple dotAtlas visualization. See the ES6 + NPM + React or plain old JavaScript options below.

## ES6 + NPM + React

To add dotAtlas to your React-based application, follow these steps.

1.  Add dotAtlas dependency to your project:
    
    ```bash
    npm install @carrotsearch/dotatlas
    ```
    
    or
    
    ```bash
    yarn add @carrotsearch/dotatlas
    ```
    
2.  Create a React component that will embed dotAtlas into your application.
    
    ```jsx
    import { DotAtlas as DotAtlasImpl } from "@carrotsearch/dotatlas";
    import React, { useEffect, useRef } from "react";
    
    export const DotAtlas = () => {
      const element = useRef(null);
      useEffect(() => {
        const points = [
          { x: 0, y: 0, elevation: 1.0, label: "Central peak" },
          { x: -1, y: 0, elevation: 0.6, label: "West peak" },
          { x: 1, y: 0, elevation: 0.6, label: "East peak" },
          { x: 0, y: -1, elevation: 0.4, label: "North peak" },
          { x: 0, y: 1, elevation: 0.4, label: "South peak" }
        ];
    
        const dotatlas = DotAtlasImpl.embed({
    
          element: element.current,
          layers: [
            { points: points, type: "elevation" },
            { points: points, type: "marker" },
            { points: points, type: "label" }
          ]
        });
    
        return () => dotatlas.dispose();
      }, []);
    
      return <div ref={element} style={{ width: 400, height: 300 }} />;
    };
    ```
    
3.  Use the component in your application. See the [dotAtlas quick start CodeSandbox](https://codesandbox.io/s/dotatlas-rect-quick-start-clrzj) for a complete working example.

## Plain old JavaScript

To get your first dotAtlas visualization, follow these three steps:

1.  Include `dotatlas.min.js` in the code of your page. You can get it from the dotAtlas [distribution package](/installation/#distribution-package) or from the UNPKG CDN:
    
    ```http
    https://unpkg.com/@carrotsearch/dotatlas@1.1.0/dotatlas.min.js
    ```
    
2.  Define an HTML element into which dotAtlas should be embedded. The element must have non-zero dimensions.
    
3.  Initialize dotAtlas by calling the `DotAtlas.embed()` method. In the options object passed to the method, provide a reference to the HTML element and some data to visualize.
    

The code below is a complete working example. Please note you may need to correct the path to `dotatlas.min.js` depending on the structure of your project.

```html
<!doctype html>
<html>
  <head>
    <title>dotAtlas Hello World</title>
    <meta charset="utf-8" />
  </head>

  <body>
    <div id="dotatlas" style="width: 600px; height: 400px"></div>  <!-- highlight-line -->
    <script src="dotatlas.min.js"></script>  <!-- highlight-line -->
    <script>

      window.addEventListener("load", () => {
        const points = [
          { x:  0, y: 0,  elevation: 1.0, label: "Central peak" },
          { x: -1, y: 0,  elevation: 0.6, label: "West peak" },
          { x:  1, y: 0,  elevation: 0.6, label: "East peak" },
          { x:  0, y: -1, elevation: 0.4, label: "North peak" },
          { x:  0, y: 1,  elevation: 0.4, label: "South peak" },
        ];

        const dotatlas = DotAtlas.embed({
          element: document.getElementById("dotatlas"),
          layers: [
            { points: points, type: "elevation" },
            { points: points, type: "marker" },
            { points: points, type: "label" }
          ]
        });
      });
    </script>
  </body>
</html>
```

A ~30-line working dotAtlas example with elevations, marker and label layers.

Notice that dotAtlas is initialized in the `load` event listener to ensure that the provided HTML element has non-zero dimensions.

---

If everything worked correctly, you should see the following visualization:

![Result of the quick start simple dotAtlas visualization.](/assets/apidocs/img/avv2HYaAiR-1200.jpeg)

Visualization produced by the ~30-line dotAtlas example.

---

# Requirements

dotAtlas will work in any modern desktop browser, but make sure you know what the specific requirements are.

## Supported browsers

dotAtlas supports modern browsers based on the Blink, Gecko and WebKit engines. These include, for example, Chrome, Edge, Opera, Firefox, Safari.

> [!WARNING]
> **Mobile browsers not yet supported.**
>
> dotAtlas does not currently support mobile devices. Based on user interest, dotAtlas may support mobile browsers in the future, possibly with a limited set of available layer types or slightly degraded rendering quality.

## Technological requirements

dotAtlas relies on the following web technologies:

-   **JavaScript.** The minimum required version is ECMAScript 2022. dotAtlas comes both as an ECMAScript module and as a classic script.
    
-   **HTML5 canvas.**
    
-   **WebGL 2.** In addition to the base WebGL 2 specification, dotAtlas requires the following WebGL extensions:
    
    -   `OES_texture_float_linear`
    -   `EXT_color_buffer_float`
    -   `EXT_float_blend`
    -   `WEBGL_lose_context`
    
    Note that support for WebGL extensions depends on specific graphics hardware, not the browser. The vast majority of current hardware does support the above WebGL extensions.

---

# Installation

dotAtlas comes as an NPM dependency, UNPKG CDN download and also as a traditional ZIP distribution package. Choose the one that best suits your workflow.

## NPM dependency

dotAtlas is available as an NPM dependency for modern web application development workflows. To add it to your project, run:

```bash
npm install @carrotsearch/dotatlas
```

or

```bash
yarn add @carrotsearch/dotatlas
```

Once the dotAtlas dependency is installed, you can import the `DotAtlas` class and plugin classes as follows:

```js
import { DotAtlas, Theme, Effects } from "@carrotsearch/dotatlas";

const dotAtlas = DotAtlas.with(Theme, Effects).embed({ ... });
```

If you hold a dotAtlas license, see the [license key](#license-key) section.

## Distribution package

For traditional plain old JavaScript workflows, use the dotAtlas ZIP distribution archive. The contents of the archive are the following:

### Contents

dotAtlas distribution archive contains the following files:

<table><thead><tr><th>Path</th><th>Description</th></tr></thead><tbody><tr><td><code>doc/</code></td><td><p>This documentation.</p></td></tr><tr><td><code>demos/</code></td><td><p>Self-contained code examples demonstrating specific aspects of dotAtlas.</p></td></tr><tr><td><code>dotatlas.js</code><br></td><td><p>dotAtlas implementation in the ES6 modules format, minified.</p></td></tr><tr><td><code>dotatlas.min.js</code></td><td><p>dotAtlas implementation as a classic script (the <code>DotAtlas</code> global), minified.</p></td></tr><tr><td><code>index.js</code></td><td><p>The ES module entry point that exports <code>DotAtlas</code> and all plugin classes by name.</p></td></tr><tr><td><code>plugin.*.js</code>, <code>plugin.*.min.js</code></td><td><p>dotAtlas plugins as ES modules and as classic scripts (globals), respectively. The plugins come as source code under the Apache Software License 2.0, so feel free to copy and modify them as desired.</p></td></tr><tr><td><code>plugin.legend.css</code></td><td><p>The default stylesheet of the <a href="/using-plugins/#legend">Legend plugin</a>.</p></td></tr></tbody></table>

### Installation

The way you reference dotAtlas in your page depends on whether you choose the ES modules or the classic scripts.

#### Classic scripts

To use the classic scripts, include the desired `*.min.js` scripts in your page and use the global symbols they provide. The following example uses the `DotAtlas` class along with the `Theme` plugin:

```markup
<body>
  <script src="dotatlas.min.js"></script>
  <script src="plugin.theme.min.js"></script>

  <script>
    var dotAtlas = DotAtlas.with(Theme).embed({ ... });
  </script>
</body>
```

#### ES6 modules

The support for [ES6 modules in modern browsers](https://caniuse.com/#feat=es6-module) is very good and you can use this format with dotAtlas too. The following example uses the main `DotAtlas` class and the `Theme` plugin. Note the `type="module"` attribute added to the `script` tag and the fact that we now import from the `*.js` versions of the scripts.

```markup
<body>
  <script type="module">
    import { DotAtlas, Theme } from "./index.js";

    const dotAtlas = DotAtlas.with(Theme).embed({ ... });
  </script>
</body>
```

## UNPKG CDN

dotAtlas is also available on the UNPKG CDN, ready to be directly imported into your page.

To reference the latest available version, use the following URL:

```http
https://unpkg.com/@carrotsearch/dotatlas/dotatlas.js
```

To reference a specific version, use a URL similar to:

```http
https://unpkg.com/@carrotsearch/dotatlas@1.1.0/dotatlas.js
```

Note that the UNPKG CDN contains all the JavaScript files available in the [distribution package](#distribution-package), for example:

dotAtlas as an ES module:

```http
https://unpkg.com/@carrotsearch/dotatlas@1.1.0/dotatlas.js
```

dotAtlas as a classic script:

```http
https://unpkg.com/@carrotsearch/dotatlas@1.1.0/dotatlas.min.js
```

dotAtlas themes plugin, ES6 modules variant:

```http
https://unpkg.com/@carrotsearch/dotatlas@1.1.0/plugin.theme.js
```

## License key

Without a license key, dotAtlas displays the dotAtlas logo over the visualization. If you purchased a dotAtlas license, you receive a license key that unlocks the branding options. To use the key, pass it in the `[licenseKey](/api-dotatlas/#licenseKey)` option:

```js
const dotAtlas = DotAtlas.embed({
  element: document.getElementById("map"),
  licenseKey: "eyJhIjp7fSwiaSI6IjIwMjYtMTAtMTUiLCJuIjoiQWNtZSBDb3Jwb3JhdGlvbiIsInAiOiJkb3RhdGxhcyIsInYiOjF9...",
  ...
});
```

The license key is a signed string that contains the licensee name, the date of issue and, for time-limited licenses, the expiry dates of the license and the maintenance period. dotAtlas verifies the key during embedding. If the key is not valid, has expired, was issued for a different product, or its maintenance period ended before the release of your dotAtlas version, dotAtlas logs the reason in the browser's console and displays the logo.

To check whether the key unlocked the branding options, call the `[version()](/api-dotatlas/#version\(\))` method of the dotAtlas instance.

In versions before 1.1.0, the licensed version of dotAtlas was a separate package that you downloaded from [https://secure.carrotsearch.com](https://secure.carrotsearch.com). Starting with version 1.1.0, there is no separate package to download: the license key is all you need.

---

# API overview

This article describes the structure of dotAtlas API and outlines the typical lifecycle of a dotAtlas instance.

The general principle behind dotAtlas API is to **provide a set of fairly low-level features** that can be combined into more complex application-specific set-ups. Therefore, the core API is limited to creating map layers and exposing low-level events, such as mouse click or hover. High-level features, such as point selection or animated effects, are implemented as [plugins](/using-plugins/) extending the core API. The plugins are open source, so you can tailor them to the needs of your specific application.

The entry point to the API is the `DotAtlas` class, which exposes a number of static methods for creating dotAtlas instances. The typical dotAtlas workflow is the following:

1.  Start by [embedding](/embedding/) a dotAtlas element inside your application. Optionally, you can provide some initial [map layers](/defining-layers/) to display.
    
    ```javascript
    import { DotAtlas } from "@carrotsearch/dotatlas";
    
    const dotatlas = DotAtlas.embed({
      element: document.getElementById("dotatlas"),
      layers: [
        // provide layer data here
      ]
    });
    ```
    
    The dotAtlas instance created during embedding exposes a number of methods for interacting with the specific instance, such as setting new data, adding and removing event listeners.
    
2.  When required, you can `set` new [map layers](/defining-layers/) to display:
    
    ```javascript
    dotatlas.set("layers", [
      // new layer data here
    ]);
    ```
    
3.  To modify properties of specific layers, [`get`](/api-common/#get\(prop\)) the instance of the [`layer`](/api-dotatlas/#layers) first:
    
    ```javascript
    const elevations = dotatlas.get("layers")[0];
    elevations.set({
      "lightIntensity": 0.25,
      "contourWidth": 0.5
    });
    ```
    
    Then, call `redraw()` to have the changes reflected in your visualization:
    
    ```javascript
    dotatlas.redraw();
    ```
    
4.  To react to dotAtlas global [events](/listening-to-events/), use the `on()` or `once()` method:
    
    ```javascript
    dotatlas.on("click", e => {
      // do something
    });
    ```
    
    The same methods are available on the layer instance object, so that you can react to layer-specific events:
    
    ```javascript
    const elevations = dotatlas.get("layers")[0];
    elevations.once("maxElevationChanged", e => {
      // do something
    });
    ```
    
5.  If your dotAtlas container changes dimensions, call the `resize()` method to reallocate internal display buffers:
    
    ```javascript
    dotatlas.resize();
    ```
    
6.  Once your application does not need dotAtlas any more, make sure to dispose of the instance to remove the internal DOM elements and the associated resources:
    
    ```javascript
    dotatlas.dispose();
    ```
    
7.  dotAtlas comes with a number of [plugins](/using-plugins/). To use them, you'll need to attach the plugins when embedding dotAtlas:
    
    ```javascript
    import { DotAtlas, Theme, Effects } from "@carrotsearch/dotatlas";
    
    const dotatlas = DotAtlas.with(Theme, Effects).embed({
      element: document.getElementById("dotatlas"),
      layers: [
        // provide layer data here
      ]
    });
    ```
    
    Plugins may add extra options for you to set:
    
    ```javascript
    dotatlas.set({
      "theme": "dark",
      "rolloutDuration": 1000
    });
    ```

---

# Embedding

Before dotAtlas can display anything, it needs to be embedded in your HTML page.

To embed dotAtlas into your page:

1.  Inspect the result of the [`DotAtlas.supported()`](/api-dotatlas/#DotAtlas.supported\(\)) static method to make sure it returns `true`, which confirms the browser meets [dotAtlas requirements](/requirements/). If the browser is not supported, consider displaying an appropriate message to the user.
    
2.  Define the HTML element that will contain your dotAtlas visualization. dotAtlas will occupy the full width and height of the element.
    
3.  Initialize dotAtlas by calling the [`DotAtlas.embed()`](/api-dotatlas/#DotAtlas.embed\(\)) static method and providing the options object as a parameter. The only required option during initialization is a reference to the HTML element you defined earlier. In most cases, you will be providing other options during initialization as well, such as the [`layers`](/api-dotatlas/#layers) to display, some visual customizations and event handlers. See the options reference for a complete list of options.
    

> [!WARNING]
> **Heads up!**
>
> The HTML element you embed into needs to be attached to the DOM and have non-zero dimensions at the time dotAtlas initializes.
>
> In most cases it is enough to initialize dotAtlas once the DOM is ready. In certain cases, however, the element will receive its size a bit later. To avoid race conditions, you can initialize dotAtlas in the `onload` event.
>
> ```markup
> <script>
>   window.addEventListener("load", function() {
>     // Perform dotAtlas embedding here
>   });
> </script>
> ```
>
> When using dotAtlas in a React application, embed dotAtlas after the component mounts. Also remember about disposing of your dotAtlas instance when the component is unmounted:
>
> ```jsx
> import React, { useEffect, useRef } from "react";
> import { DotAtlas as DotAtlasImpl } from "@carrotsearch/dotatlas";
>
> export const DotAtlas = () => {
>   const element = useRef(null);
>   useEffect(() => {
>     const dotatlas = DotAtlasImpl.embed({
>       element: element.current,
>       layers: [ /* ... */ ]
>     });
>
>     return () => dotatlas.dispose();
>   }, []);
>
>   return <div ref={element} style={{ width: 400, height: 300 }} />;
> };
> ```

---

# Defining layers

dotAtlas displays sets of points organized into layers. This article shows how to define a layer and describes all the layer types you can use.

> [!WARNING]
> **Visualizing data from the Lingo4G engine**
>
> If you use dotAtlas to visualize 2D embeddings produced by the [Lingo4G engine](https://carrotsearch.com/lingo4g/), consider using the [Lingo4G dotAtlas plugin](/using-plugins/#lingo4g). The plugin automatically handles the creation and updating of dotAtlas layers.

## Layer definition

A dotAtlas layer is defined by a literal object containing a number of common and layer-specific properties, for example:

```javascript
const elevationLayerDefinition = {
  "type": "elevation",
  "points": [
    { "x":  0, "y": 0, "elevation": 1.0 },
    { "x": -1, "y": 0, "elevation": 0.8 },
    { "x":  0, "y": 1, "elevation": 0.5 }
  ],
  "visible": true,
  "opacity": 0.7,
  "lightIntensity": 0.2,
  "contourWidth": 1.0,
  "onPointClick": e => {
    // do something
  }
};
```

Two mandatory properties are `type` and `points`. The `type` property determines the layer type, such as `elevation`, `marker` or `label`. The `points` property is an array of objects defining the 2d points to display. Each point object must contain the `x` and `y` properties defining the coordinates. Additional properties, such as `elevation`, `label` or `markerColor`, will be layer-specific.

See the [Common layer API](/api-common-layer/) and specific layer API references, such as [Elevations layer API](/api-elevations-layer/), for a complete list of available properties.

## Layer creation

To display your layers, pass the layer definition objects to dotAtlas in the [`layers`](/api-dotatlas/#layers) option. You can pass the option during embedding and also later on using the `set()` method:

```javascript
const points = [
  { x:  0, y: 0,  elevation: 1.0, label: "Central peak" },
  { x: -1, y: 0,  elevation: 0.6, label: "West peak" },
  { x:  1, y: 0,  elevation: 0.6, label: "East peak" },
  { x:  0, y: -1, elevation: 0.4, label: "North peak" },
  { x:  0, y: 1,  elevation: 0.4, label: "South peak" },
];

const dotatlas = DotAtlas.embed({
  "element": element,
  "layers": [
    { "points": points, "type": "elevation" },
    { "points": points, "type": "marker", "markerColor": "rgb(255, 0, 0)" },
    { "points": points, "type": "label" }
  ]
});
```

The layers you provided in the [`layers`](/api-dotatlas/#layers) property will be **stacked in the order they appear in the array, bottom-up**. In the above example, the elevations layer will come at the bottom, the markers layer will come in the middle and the labels layer will be at the top.

Note that **if different layers share points** of the same coordinates, for example when elevations, markers and labels need to be drawn for each point, layers can share one array of points like in the above example. In many cases a convenient way to organize input data is to have a single array of points, and for each layer supply a filtered version of the array narrowed down to the specific point types.

Once connected to dotAtlas, each layer is converted to an **API-bearing object** you can use to modify layer properties or event listeners at runtime. When you [`get()`](/api-common/#get\(prop\)) the [`layers`](/api-dotatlas/#layers) property, instead of the input definitions, you'll get an array of layer implementation objects. They define the common API methods to modify layer properties or manage event listeners:

```javascript
const elevationsLayer = dotatlas.get("layers")[0];
elevationsLayer.set("lightIntensity", 0.3);
dotatlas.redraw();

elevationsLayer.once("maxElevationChanged", e => {
  // do something
});
```

You can also create layer implementation objects directly using the [`DotAtlas.createLayer()`](/api-dotatlas/#DotAtlas.createLayer\(\)) method:

```javascript
const elevations = DotAtlas.createLayer({
  "type": "elevation",
  "points": [
    { "x":  0, "y": 0, "elevation": 1.0 },
    { "x": -1, "y": 0, "elevation": 0.8 },
    { "x":  0, "y": 1, "elevation": 0.5 }
  ],
  "lightIntensity": 0.2,
  "contourWidth": 1.0
});
elevations.on("pointClick", e => {
  // do something
});

const dotatlas = DotAtlas.embed({
  "element": element,
  "layers": [
    elevations
  ]
});
```

Both layer creation styles are equivalent, choose the one that better suits your specific code or preference.

## Layer types

dotAtlas currently offers layers of 4 types: elevations, markers, labels and outlines. This section describes the layers in more detail.

### Elevations

The elevations layer **serves as the background for the whole visualization** and renders the map-like image of "hills" and "valleys", along with elevation contours and light shading:

![dotAtlas elevation layer.](/assets/apidocs/img/7wUdEWDzJ_-1835.jpeg)

To create an elevations layer, set the `type` property to `elevation`, provide coordinates at which elevation "peaks" should be created and define the height of each peak in the `elevation` property:

```javascript
const elevations = {
  "type": "elevation",
  "points": [
    { "x":  0, "y": 0, "elevation": 1.0 },
    { "x": -1, "y": 0, "elevation": 0.8 },
    { "x":  0, "y": 1, "elevation": 0.5 }
  ],
  "contourWidth": 1.0
}
```

Notes:

-   dotAtlas will allow at maximum one elevation layer, it must come at index `0` of the array passed in the [`layers`](/api-dotatlas/#layers) property, which will put it at the bottom of the layer stack.
    
-   Elevation values must be in the `0`...`1` range, other values will be clamped to that range.
    

See the [Elevation layer API](/api-elevations-layer/) for a list of all properties and events of this layer type.

> **For the curious: how dotAtlas creates the "hills" and "valleys"**
>
> dotAtlas generates the map like this: each point raises the elevation within a certain circle around the point's coordinates:
>
> ![Heightmap created around a single elevation point.](/assets/apidocs/img/ll0i4gYIpb-757.jpeg)
>
> The radius of the circle depends on the elevation value you define in the data, the larger the elevation, the larger the radius. Additionally, to avoid "sharp edges", the elevation around the point falls off along a Bezier curve rather than, for example, linearly. When there are multiple elevation points in the input data, their elevation circles add up. When the number of points is large enough, a visually-pleasing map emerges.
>
> Note that elevation values computed in this way are only a very rough approximation of the elevation point density around the area in question.

### Markers

The markers layer draws small shapes at the coordinates of the points you provide. You can define the size, color, shape and opacity of each individual marker:

![dotAtlas markers layer.](/assets/apidocs/img/re_STGd9yp-1835.jpeg)

The simplest use case of the markers layer is to **show the locations of points on your map**. You can use various marker properties, such as color, opacity or size, to represent specific properties of the object the point represents. For example, when visualizing a set of textual documents, color may represent the document's category and size may be proportional to the relevance to the user's query.

Since dotAtlas can display multiple marker layers, another common use case is to have an extra markers layer for highlighting selected or hovered markers.

To create a markers layer, set the `type` property to `marker` and provide coordinates at which to display markers. Optionally, you can provide extra per-point properties, such as color or size:

```javascript
const markers = {
  "type": "marker",
  "points": [
    { "x":  0, "y": 0, "markerSize": 1.0, "markerColor": "rgb(255, 0, 0)" },
    { "x": -1, "y": 0, "markerSize": 0.8, "markerColor": "rgb(0, 255, 0)" },
    { "x":  0, "y": 1, "markerSize": 0.6, "markerColor": "rgb(0, 0, 255)" }
  ],
  "markerSizeMultiplier": 20
}
```

Notes:

-   By default, the maximum size of a single point is about 10 pixels. Use the `markerSizeMultiplier` layer property to provide the scaling factor. For example, when the multiplier is set to `20`, markers of `markerSize` `1.0` will be about 20 pixels large.
    
-   A single visualization can display multiple markers layers.
    

See the [Marker layer API](/api-markers-layer/) for a list of all properties and events of this layer type.

### Labels

The labels layer draws short fragments of text at the specified 2d coordinates:

![dotAtlas labels layer.](/assets/apidocs/img/_nyu-tTJGZ-1828.jpeg)

The primary use case for this layer type is to **describe specific areas of the map**. The textual labels will usually be relevant to a group of nearby markers or elevation points.

To create a labels layer, set the `type` property to `label` and provide coordinates and labels to display:

```javascript
const labels = {
  "type": "label",
  "points": [
    { "x":  0, "y": 0, "label": "Center", "labelBoxOpacity": 1.0 },
    { "x": -1, "y": 0, "label": "Left" },
    { "x":  1, "y": 0, "label": "Right" }
  ]
}
```

You can set the `labelBoxOpacity` property for a point to a non-zero value to draw a box around the label. You can customize the color of the box using the `labelBoxColor` point property.

See the [Label layer API](/api-labels-layer/) for a list of all properties and events of this layer type.

> **For the curious: how dotAtlas determines which labels to show**
>
> dotAtlas draws only those labels that do not overlap any other labels. This means that at a certain zoom level only a limited number of labels will be revealed. As the zoom level increases, more labels located in the zoomed area will show.
>
> To control which labels show first, you can set the `labelPriority` of the point. If label priorities are provided, dotAtlas will place labels in the decreasing order of priority.

### Outlines

The outline layer draws circular highlights around groups of points:

![dotAtlas outline layer.](/assets/apidocs/img/ZLWsduBWaF-1835.jpeg)

The primary use case of this type of layer is to **temporarily highlight a set of points**, for example to show that the points are selected. An extra temporary markers layer can be drawn on top of the outline to further emphasize the points.

To create an outline layer, set the `type` property to `outline` and provide coordinates which should be outlined. Optionally, you can provide the relative outline size to create for specific points in their `markerSize` property.

```javascript
const outline = {
  "type": "outline",
  "points": [
    { "x":  0, "y": 0, "markerSize": 1.0 },
    { "x": -1, "y": 0, "markerSize": 0.8 },
    { "x":  0, "y": 1, "markerSize": 0.6 }
  ],
  "outlineSizeMultiplier": 20,
  "outlineOffset": 10
}
```

Notes:

-   By default, the maximum size of a single outlined point is about one pixel. Use the `outlineSizeMultiplier` layer property to provide the scaling factor. For example, when the multiplier is set to `20`, dotAtlas will assume that the points to outline have the radius of 20 pixels.
    
-   A single visualization can display multiple outline layers.
    

See the [Outline layer API](/api-outline-layer/) for a list of all properties and events of this layer type.

---

# Managing properties

Properties control various aspects of your visualization, such as marker shape or elevation contour width.

dotAtlas properties can be defined at three different levels:

-   **global properties** control instance-level aspects of your visualization, such as the array of layers to display or zoom level. Read-only global properties allow, for example, obtaining the current visualization image in the PNG or JPEG format.
    
-   **layer properties** control characteristics of one dotAtlas layer, such as the font family used to draw labels on the labels layer or the intensity of light shading on the elevations layer.
    
-   **point properties** control how an individual point on a specific layer is displayed. Mandatory point properties are its `x` and `y` coordinates, but other properties are available depending on the layer type. For the markers layer this could be, for example, marker shape or color.
    
    Certain per-point properties have their counterparts on the layer level. In this case they serve as the default value that can be overridden on the point level.
    

## Initialization

You can provide the initial global property values when [embedding](/embedding/) dotAtlas using the [`DotAtlas.embed()`](/api-dotatlas/#DotAtlas.embed\(\)) method. Pass all your properties as a literal object, where property names correspond to the dotAtlas properties you'd like to initialize:

```javascript
import { DotAtlas } from "@carrotsearch/dotatlas";

const dotatlas = DotAtlas.embed({
  "element": document.getElementById("dotatlas"),
  "layers": [
    // provide layer data here
  ]
});
```

Layer- and point-specific properties are initialized when [defining layers](/defining-layers/):

```javascript
const elevations = DotAtlas.createLayer({
  "type": "elevation",
  "points": [
    { "x":  0, "y": 0, "elevation": 1.0 },
    { "x": -1, "y": 0, "elevation": 0.8 },
    { "x":  0, "y": 1, "elevation": 0.5 }
  ],
  "lightIntensity": 0.2,
  "contourWidth": 1.0
});
```

## Updating

### Global properties

You can change global property values at any time using the [`set(props)`](/api-common/#set\(props\)) method. For certain properties you may need to call `[redraw()](/api-dotatlas/#redraw\(\))` for the changes to take effect. Please see the reference documentation for specific properties for details.

```javascript
dotatlas.set({
  "transform": {
    "translateX": 10,
    "translateY": 10,
    "scale": 1
  }
});
dotatlas.redraw();
```

### Layer properties

Similarly, you can call the `[set(props)](/api-common/#set\(props\))` method on a layer instance to set layer-specific properties. Again, many properties will require a `[redraw()](/api-dotatlas/#redraw\(\))` call for the changes to appear on the screen.

```javascript
const elevations = dotatlas.get("layers")[0];
elevations.set({
  "lightIntensity": 0.5,
  "contourWidth": 0.5
});
dotatlas.redraw();
```

### Point properties

Updating point properties is different from updating global and layer properties. The reason is that dotAtlas copies point properties, such as coordinates or marker color, to an internal buffer when the layer is created. If you change any of the point properties, you will need to let dotAtlas know by calling the layer's `[update()](/api-common-layer/#update\(\))` method to refresh the internal buffers. To reflect the changes on the screen, you will also need to call `[redraw()](/api-dotatlas/#redraw\(\))`.

```javascript
const dotatlas = DotAtlas.embed({
  "element": document.getElementById("dotatlas"),
  "layers": [
    {
      "type": "marker",
      "points": [{ x: 0, y: 0 }],
      "markerSizeMultiplier": 60
    }
  ]
});

window.setTimeout(() => {
  const markers = dotatlas.get("layers")[0];
  markers.get("points")[0].markerShape = "square";
  markers.update("markerShape");
  dotatlas.redraw();
}, 2000);
```

## Read-only properties

dotAtlas exposes a number of read-only properties you can access using the `[get(prop, args...)](/api-common/#get\(prop,_args...\))` method. Getting some properties, such as `[imageData](/api-dotatlas/#imageData)`, may require passing extra arguments as the second method argument:

```javascript
const image = dotatlas.get("imageData", {
  "format": "image/jpeg",
  "quality": 0.9
});
```

---

# Listening to events

You can attach listeners to react to various events, such as mouse movement or some points being hovered over.

Event listeners are functions invoked by dotAtlas when certain conditions or triggers are met. Some listeners are invoked only for user-triggered actions, such as `[onMouseMove](/api-dotatlas/#onMouseMove)`, others may be a result of internal state changes like `[onRedraw](/api-dotatlas/#onRedraw)`.

You can listen to global dotAtlas events, such as `[onRedraw](/api-dotatlas/#onRedraw)`, but also to layer-specific events, such as `[onMaxElevationChanged](/api-elevations-layer/#onMaxElevationChanged)`. Events related to user's interactions with specific data points, such as `[onPointClick](/api-common-layer/#onPointClick)`, are available on the layer level.

You can manage event listeners by setting the relevant properties or by calling the event management methods.

## Using event properties

One way to manage event listeners is by getting or setting the related properties, or, most commonly, by providing the listeners during initial embedding and layer creation:

```javascript
const dotatlas = DotAtlas.embed({
  "element": document.getElementById("dotatlas"),
  "layers": [
    {
      "type": "marker",
      "points": [ ],
      "onPointClick": e => { console.log("point clicked", e); }
    }
  ],
  "onClick": e => { console.log("clicked", e); },
  "onMouseWheel": [
    e => { console.log("scrolled 1", e); },
    e => { console.log("scrolled 2", e); }
  ]
});
```

For each event property you can provide an individual function or an array of functions. However, when you get the option value, always an array of functions will be returned, even if there is only one function registered for a specific event.

> [!WARNING]
> **Heads up!**
>
> Setting a new function for a specific event will remove all previously registered functions for that event. This may remove event listeners registered by [plugins](/using-plugins/) and prevent them from functioning. Therefore, if you use plugins, the safest way to register listeners for core dotAtlas events is by calling [event management methods](#using-event-management-methods).

## Using event methods

Another way to manage dotAtlas events is to use the `[on()](/api-common/#on\(\))`, `[once()](/api-common/#once\(\))` and `[off()](/api-common/#off\(\))` methods on the dotAtlas or layer instance.

```javascript
const dotatlas = DotAtlas.embed({
  "element": document.getElementById("dotatlas"),
  "layers": [
    {
      "type": "marker",
      "points": []
    }
  ]
});

dotatlas.on("click", e => {
  console.log("clicked", e);
});
dotatlas.on("mouseWheel", e => {
  console.log("scrolled 1", e);
});
dotatlas.on("mouseWheel", e => {
  console.log("scrolled 2", e);
});

const points = dotatlas.get("layers")[0];
points.on("pointClick", e => {
  console.log("point clicked", e);
});
```

Notes:

-   To get the event name to use with the `on()`, `once()` and `off()` methods, take the event property name, remove the leading "on" and lower-case the first letter, for example:
    
    | Property name for `set()` | Event name for `on()`, `once()` and `off()` |
    | --- | --- |
    | `onClick` | `click` |
    | `onPointClick` | `pointClick` |
    | `onMaxElevationChanged` | `maxElevationChanged` |
    
-   Use the `once()` method to register one-off listeners. There is no equivalent mechanism in the property-based listener management.
    
-   Using event management methods does not affect other listeners registered for the specific event.
    
-   When calling the `off()` method, make sure you supply the same function instance you provided for the `on()` method:
    
    ```javascript
    const handler = e => console.log("clicked", e);
    dotatlas.on("click", handler);
    dotatlas.off("click", handler);
    ```

## Low- vs high-level events

dotAtlas reports mouse interactions at two levels. Low-level events, such as `[onClick](/api-dotatlas/#onClick)`, are available on the dotAtlas instance and report only where the interaction happened. High-level events, such as `[onPointClick](/api-common-layer/#onPointClick)`, are available on layers and additionally report the layer's points near that location in the `points` property.

| Low-level event | High-level event |
| --- | --- |
| `[onClick](/api-dotatlas/#onClick)` | `[onPointClick](/api-common-layer/#onPointClick)` |
| `[onDoubleClick](/api-dotatlas/#onDoubleClick)` | `[onPointDoubleClick](/api-common-layer/#onPointDoubleClick)` |
| `[onHold](/api-dotatlas/#onHold)` | `[onPointHold](/api-common-layer/#onPointHold)` |
| `[onMouseMove](/api-dotatlas/#onMouseMove)` | `[onPointHover](/api-common-layer/#onPointHover)` |

For each interaction, dotAtlas calls the low-level listeners first, then the high-level listeners of each visible layer. Note the following:

-   Calling `[preventDefault()](/api-common/#event-details:preventDefault\(\))` in a low-level listener stops the high-level event. High-level events do not have this method.
    
-   High-level click, double-click and hold events also fire when there are no points near the event location. In that case, the `points` array is empty.
    
-   `[onPointHover](/api-common-layer/#onPointHover)` fires only when the set of points near the mouse pointer changes, while `[onMouseMove](/api-dotatlas/#onMouseMove)` fires for every mouse movement.
    

```javascript
dotatlas.on("click", e => {
  console.log("clicked at", e.layerX, e.layerY);
});

dotatlas.get("layers")[0].on("pointClick", e => {
  if (e.points.length > 0) {
    console.log("closest point", e.points[0]);
  }
});
```

---

# Setting new points

To display a new set of points in an already initialized visualization, re-create and set the new set of layers.

> [!WARNING]
> **Lingo4G plugins handle the updates automatically.**
>
> If you use the [Lingo4G](/api-lingo4g-plugin/) plugin, the plugin automatically performs all the necessary updates when you set a new `[lingo4g:result](/api-lingo4g-plugin/#lingo4g:result)` value.

Assuming your code defines a method for creating layers, for example:

```javascript
const createLayers = (points) => {
  // Elevations layer.
  const elevations = {
    points: points.filter(p => p.elevation !== undefined),
    type: "elevation"
  };

  // Point markers layer.
  const markers = {
    points: points.filter(p => p.markerSize !== undefined),
    type: "marker",
    markerSizeMultiplier: 10
  };

  // Labels layer.
  const labels = {
    points: points.filter(p => p.label !== undefined),
    type: "label"
  };

  return { elevations, markers, labels };
}
```

you can redraw the visualization with new data by setting the `[layers](/api-dotatlas/#layers)` property to the newly created layers:

```javascript
const { elevations, markers, labels } = createLayers(points);

dotatlas.set("layers", [
  elevations,
  markers,
  labels
]);
```

---

# Using plugins

dotAtlas comes with a number of plugins that extend the core API with high-level features, such as selection tracking or dark color mode. This article shows how to use the available plugins.

## Preparation

Before you can use a dotAtlas plugin you need to import the plugin class and register it using the `[DotAtlas.with()](/api-dotatlas/#DotAtlas.with\(\))` method. You can import plugin classes using ES modules or as globals of classic scripts.

### ES6 modules

You can import all dotAtlas plugin classes by name from the `@carrotsearch/dotatlas` namespace:

```javascript
import { DotAtlas, Theme, Effects, Selection } from "@carrotsearch/dotatlas";

const dotAtlas = DotAtlas.with(Theme, Effects, Selection).embed({
  ...
});
```

### Classic scripts

To use the classic scripts, include the desired `*.min.js` scripts in your page and use the global symbols they provide.

```markup
<body>
  <script src="dotatlas.min.js"></script>
  <script src="plugin.theme.min.js"></script>
  <script src="plugin.effects.min.js"></script>
  <script src="plugin.selection.min.js"></script>

  <script>
    const dotAtlas = DotAtlas.with(Theme, Effects, Selection).embed({
      ...
    });
  </script>
</body>
```

## Plugin properties

Plugins can contribute extra dotAtlas properties. You can provide initial values for those properties when calling the `[DotAtlas.embed()](/api-dotatlas/#DotAtlas.embed\(\))` method. Once dotAtlas is initialized, you can `[get()](/api-common/#get\(prop\))` and `[set()](/api-common/#set\(prop,_value\))` plugin properties in the same way as the dotAtlas core properties.

The following example initializes dotAtlas with the `[Theme](#theme)` and `[Effects](#effects)` plugins, passing the initial values for the plugin-contributed `theme` and `rolloutDuration` properties. Later on, the `theme` property is set to a new value.

```javascript
import { DotAtlas, Theme, Effects } from "@carrotsearch/dotatlas";

const dotAtlas = DotAtlas.with(Theme, Effects).embed({
  "element": document.querySelector("#visualization"),
  "layers": [],
  "theme": "dark",
  "rolloutDuration": 3000
});
dotAtlas.set("theme", "light");
```

## Combining with core API

Plugins hide the complexity of implementing common high-level functionalities, such as [selection tracking](#selection) – instead of dealing with dotAtlas core API, you use the high-level plugin API.

However, you can combine the use of plugin and core dotAtlas APIs to customize specific aspects of the visualization. For example, when working with the [Lingo4G plugin](#lingo4g), you can use its `[lingo4g:customize:layers](/api-lingo4g-plugin/#lingo4g:customize:layers)` property to configure the layers the plugin creates. Or, you can use the `[selection:layer:hoverOutline](/api-selection-plugin/#selection:layer:hoverOutline)` property of the [selection plugin](#selection) to get the [outline layer](/api-outline-layer/) the plugin creates to customize its look.

## AutoResizing

The `AutoResizing` plugin adds automatic resizing of the visualization area on window size changes. It will call the fast-to-execute `[resize()](/api-dotatlas/#resize\(\))` method on every change of window size and will recompute label layout when window size stops changing.

The `AutoResizing` plugin does not contribute any extra properties.

## Theme

The `Theme` plugin adds the dark color scheme for rendering elevations and labels. The plugin contributes the `theme` property, which accepts the `light` and `dark` values.

```javascript
import { DotAtlas, Theme } from "@carrotsearch/dotatlas";

const dotAtlas = DotAtlas.with(Theme).embed({
  "element": document.querySelector("#visualization"),
  "theme": "dark"
});
```

## Effects

The `Effects` plugin adds animated "rollout" and "pullback" animations when new layer data is set. You can define the duration in milliseconds of both effects using the `rolloutDuration` and `pullbackDuration` properties.

```javascript
import { DotAtlas, Effects } from "@carrotsearch/dotatlas";

const dotAtlas = DotAtlas.with(Effects).embed({
  "element": document.querySelector("#visualization"),
  "rolloutDuration": 3000,
  "pullbackDuration": 3000
});
```

## Selection

The `Selection` plugin adds a mechanism for interactive selection of individual or multiple markers.

![The selection and hover outline layers added by the selection plugin.](/assets/apidocs/img/ffMqIXCnPk-1080.jpeg)

The `Selection` plugin tracks the markers under the mouse pointer (outlined in white) and markers currently selected by the user (outlined in blue).

### Layers

The `Selection` plugin adds two extra outline layers on top of the existing ones:

**selection layer**

highlights the currently selected markers, drawn in blue by default.

**hover layer**

highlights the markers under the mouse pointer and ready for selection, drawn in white by default.

### Interactions

The plugin listens to the following interactions:

**mouse move**

The hover layer is updated with the marker or markers lying under the mouse pointer. Which specific markers are included in the hover layer depends on the [selection mode](#selection:mode).

**click**

Selection is **replaced** with the current contents of the hover layer.

**Shift + click**

Current contents of the hover layer are **added** to the selection.

**Ctrl + click**

Current contents of the hover layer are **removed** from the selection.

### Selection mode

The `Selection` plugin offers three selection modes listed below. The selection mode determines which markers are included in the hover layer given the current position of the mouse pointer. You can change the selection mode using the `[selection:mode](/api-selection-plugin/#selection:mode)` property.

The plugin supports the following selection modes:

**single**

The hover layer contains a single marker that is closest to the current mouse pointer location.

![Single marker selection mode.](/assets/apidocs/img/J6XtTE_4L0-994.jpeg)

**circle**

The hover layer contains all markers lying within a specified circle around the current mouse pointer location. The radius of the circle can be specified using the `[selection:clusterRadius](/api-selection-plugin/#selection:clusterRadius)` property.

![Circle selection mode illustration.](/assets/apidocs/img/YN8vR5iil6-994.jpeg)

**cluster**

The hover layer contains all markers lying in the densely-populated region of the map determined by the current mouse pointer location. The size of the region can be adjusted using the `[selection:clusterRadius](/api-selection-plugin/#selection:clusterRadius)` property.

Compared to the `circle` selection mode, the cluster mode tends to choose markers lying close to each other. Also, the choice is more stable with respect to the mouse pointer location: if the mouse pointer moves to a different location within the highlighted dense region, the highlighted markers will not change.

![Cluster selection mode illustration.](/assets/apidocs/img/5tuuP9I8i5-994.jpeg)

### Code examples

This section shows the common use cases of the `Selection` plugin. For a complete list of properties and events, see [Selection plugin API](/api-selection-plugin/).

#### Minimal example

The minimal code example required for selection tracking is shown below. It imports the plugin and adds a listener for the `selection:onSelectionChanged` event to get notifications of selection changes. By default, the plugin will track selection of points provided in the bottom-most [markers layer](/defining-layers/#markers).

```javascript
import { DotAtlas, Selection } from "@carrotsearch/dotatlas";

const dotAtlas = DotAtlas.with(Selection).embed({
  "element": document.querySelector("#visualization"),
  "layers": [
    {
      "type": "marker",
      "points": [ /* ... */ ]
    }
  ],
  "selection:onSelectionChanged": e => {
    console.log("Selected markers", e.points);
  }
});
```

#### Selection hover events

You can also listen to hover change events as shown below. As opposed to the core `[onMouseMove](/api-dotatlas/#onMouseMove)` event, the event exposed by this plugin comes with an array of points lying around the mouse pointer location.

```javascript
dotAtlas.on("selection:mouseMove", e => {
  console.log("Hovered markers", e.points);
});
```

#### Changing selection programmatically

To get or set the current selection programmatically, use the `[selection:selection](/api-selection-plugin/#selection:selection)` property. The following code sets the initial selection to contain the point at index 0 and later on changes the selection to consist of points at index 1 and 2.

```javascript
const points = [
  { "x": 0.0, "y": 0 },
  { "x": 1, "y": 0 },
  { "x": -1, "y": 0 }
];

const dotAtlas = DotAtlas.with(Selection).embed({
  "element": document.querySelector("#visualization"),
  "layers": [
    { "type": "marker", "points": points }
  ],
  "selection:selection": [ points[0] ]
});
dotAtlas.set("selection:selection", [ points[1], points[2] ]);
```

#### Properties of selection layers

If you'd like to modify the visual properties of the hover or selection outline layers, you can get the layer objects and change their properties directly:

```javascript
dotAtlas.get("selection:layer:hoverOutline").set({
  "outlineFillColor": "hsla(40, 75%, 80%, 0.5)",
  "outlineBorderWidth": 0.65
});
```

## Legend

The `Legend` plugin adds an HTML-based elevation color legend to your visualization:

![The elevation color legend added by the legend plugin.](/assets/apidocs/img/GZf2cWT3SL-1267.jpeg)

The elevation color legend box added by the `Legend` plugin.

The `Legend` plugin does not expose any properties, but it comes with its own default CSS stylesheet you need to include in your design:

```javascript
import { DotAtlas, Legend } from "@carrotsearch/dotatlas";
import "@carrotsearch/dotatlas/plugin.legend.css";

const dotAtlas = DotAtlas.with(Legend).embed({
  "element": document.querySelector("#visualization")
});
```

The stylesheet defines a number of CSS variables you can override to customize the colors and support dark mode:

| CSS variable | Usage |
| --- | --- |
| `--dotatlas-legend-background-color` | background color of the legend box |
| `--dotatlas-legend-background-color-hover` | background color of the highlighted legend box |
| `--dotatlas-legend-border-color` | border color of the legend box |

## Lingo4G

The `Lingo4GDocumentMap` plugin makes it easy to display the [2d document embeddings](https://get.carrotsearch.com/lingo4g/2.0.1/doc/v2/analysis-json-embedding2d/) produced by [Lingo4G](https://carrotsearch.com/lingo4g/) [analysis API v2](https://get.carrotsearch.com/lingo4g/2.0.1/doc/v2/analysis/). All you need to do is pass the JSON response received from Lingo4G API as the plugin's `[lingo4g:result](/api-lingo4g-plugin/#lingo4g:result)` property:

```javascript
import { DotAtlas, Lingo4GDocumentMap } from "@carrotsearch/dotatlas";

// Fetch results from Lingo4G (pseudo code below)
const lingo4GApiUrl = "https://yourserver.com/lingo4g/api/v2";
const result = await fetch(lingo4GApiUrl + "/analysis");

const dotAtlas = DotAtlas.with(Lingo4GDocumentMap).embed({
  "element": document.querySelector("#visualization"),
  "lingo4g:result": result
});
```

Note that you do not need to specify any map `[layers](/api-dotatlas/#layers)`, the plugin creates the elevations, markers and labels layers automatically. You can use the `[lingo4g:customize:layers](/api-lingo4g-plugin/#lingo4g:customize:layers)` callback to customize the layers the plugin created.

To get a natural-looking map, you usually need at least a few thousand documents in the Lingo4G 2d embedding.

See the [Lingo4G plugin reference](/api-lingo4g-plugin/) for a complete list of properties added by this plugin.

> [!WARNING]
> **This plugin is for Lingo4G 2.x responses.**
>
> To handle responses for Lingo4G analysis API v1, use the [Lingo4G v1 plugin](/api-lingo4g-v1-plugin/).

---

# Common API

This reference describes the common API elements exposed by the top-level dotAtlas instance and layer instances.

All methods described in this reference are available on dotAtlas instance objects created using the `[DotAtlas.embed()](/api-dotatlas/#DotAtlas.embed\(\))` method as well as on layer instance objects retrieved from dotAtlas or created with the `[DotAtlas.createLayer()](/api-dotatlas/#DotAtlas.createLayer\(\))` method.

## Methods

### get()

Returns an object containing current values of all properties.

```javascript
console.log("dotAtlas properties", dotatlas.get());
```

```javascript
const elevations = dotatlas.get("layers")[0];
console.log("elevation layer properties", elevations.get());
```

### get(prop)

Returns the current value of one `prop`. If the provided string does not correspond to any property name, the result is undefined.

```javascript
console.log(dotatlas.get("layers"));
```

```javascript
const elevations = dotatlas.get("layers")[0];
console.log("light intensity", elevations.get("lightIntensity"));
```

### get(prop, args...)

Returns the current value of the requested read-only `prop`, optionally parameterized by the provided `args`. The number and type of arguments depends on the requested read-only property, see the documentation of the specific property for details.

The following example retrieves the current visualization image in the JPEG format.

```javascript
const bitmap = dotatlas.get("imageData", {
  format: "image/jpeg", quality: 0.8
});
```

The following example gets the elevation value at the provided screen coordinates:

```javascript
const elevations = dotatlas.get("layers")[0];
const elevationValue = elevations.get("elevationAt", 150, 200);
```

### set(prop, value)

Sets a new value for one property of dotAtlas or layer instance. If the string passed in the `prop` parameter does not correspond to any property, the call will be ignored.

```javascript
dotatlas.set("layers", [ /* layers to set */ ]);
```

```javascript
const elevations = dotatlas.get("layers")[0];
elevations.set("lightAzimuth", 2 * Math.PI);
```

### set(props)

Sets values of the properties provided in the literal object `props`: the global properties when called on the dotAtlas instance, the layer properties when called on a layer.

```javascript
dotatlas.set({
  "maxZoomScale": 32768,
  "layers": [
    // layers to set
  ]
});
```

```javascript
const elevations = dotatlas.get("layers")[0];
elevations.set({
  "lightIntensity": 0.5,
  "lightAzimuth": 2 * Math.PI
});
```

### on()

Registers a listener for a dotAtlas or layer event.

```javascript
dotatlas.on(event, listener);
```

The `event` parameter is the event name. The `listener` parameter is the function to call when the event occurs. For most events, the function will receive the [event details object](#event-details) as the first and only parameter.

Note that event names here are slightly different from the event names used in the `set()` method. To get the event name to use with the `on()`, `once()` and `off()` methods, take the event property name, remove the leading "on" and lower-case the first letter, for example:

| Property name for `set()` | Event name for `on()`, `once()` and `off()` |
| --- | --- |
| `onClick` | `click` |
| `onPointClick` | `pointClick` |
| `onMaxElevationChanged` | `maxElevationChanged` |
| `selection:onSelectionChanged` | `selection:selectionChanged` |

As opposed to using the `[set()](#set\(props\))` method, this method preserves the previously registered listeners. Typical invocations of this method will be similar to:

```javascript
dotatlas.on("redraw", e => { /* react to visualization redraw */ });
```

```javascript
const elevations = dotatlas.get("layers")[0];
elevations.on("maxElevationChanged", e => { /* react to peak change */ });
```

For an overview of dotAtlas event handling, see the [Listening to events](/listening-to-events/) guide.

### once()

Registers a one-time listener for a dotAtlas or layer event. Once the event is triggered, the listener will be removed from the listeners list and will not be notified of further events.

```javascript
dotatlas.once(event, listener);
```

The `event` parameter is the event name. Note the [event naming convention differences](#on\(\):event-naming) when using `on()`, `once()` and `off()` methods. The `listener` parameter is the function to call when the event occurs.

The typical invocations of this method will look like this:

```javascript
dotatlas.once("redraw", e => { /* react to visualization redraw */ });
```

```javascript
const elevations = dotatlas.get("layers")[0];
elevations.once("maxElevationChanged", e => { /* react to peak change */ });
```

If the `listener` parameter is not provided, this method returns a `Promise` that is resolved once the event is triggered:

```javascript
dotatlas.once("layersChanged").then(e => {
  // handle the one-time event
});
```

For an overview of dotAtlas event handling, see the [Listening to events](/listening-to-events/) guide.

### off()

Removes a listener from the list of listeners registered for the specified event.

```javascript
dotatlas.off(event, listener);
```

The `event` parameter is the event name. Note the [event naming convention differences](#on\(\):event-naming) when using `on()`, `once()` and `off()` methods. The `listener` parameter is the function to remove from the listener list.

As opposed to using the `[set()](#set\(props\))` method, this method will preserve the other listeners registered for the event.

The invocations of this method will typically be similar to:

```javascript
const redrawListener = e => { console.log("visualization redrawn", e ); };
dotatlas.on("redraw", redrawListener);
dotatlas.off("redraw", redrawListener);
```

## Data structures

### 2d point

Many parts of the API require 2d points on input or return them as a result of some computation. In all such cases the 2d point is represented by a literal object containing the coordinates in the `x` and `y` properties, for example:

```javascript
const point = {
  "x":  0.125,
  "y": -0.5
};
```

The exact semantics of the point depends on the context. Typically, the points will be expressed in one of the two 2d spaces:

**element space**

coordinates refer to the on-screen pixels where point `(0, 0)` is the upper left corner of the DOM `[element](/api-dotatlas/#element)` in which dotAtlas is embedded. Typically, points in the element space will appear in screen-based events, such as `[onMouseMove](/api-dotatlas/#onMouseMove)`.

**layer space**

coordinates refer to the 2d space defined by the data points you provide in the `[layers](/api-dotatlas/#layers)` to be visualized. Layer space coordinates will typically appear in events related to specific data points, such as `[onPointClick](/api-common-layer/#onPointClick)`.

### Colors

In all properties involving colors, such as `[markerColor](/api-markers-layer/#markerColor)` or `[colorBands](/api-elevations-layer/#colorBands)`, dotAtlas supports CSS3 color strings, such as:

-   `#aaa`
-   `#f0e0e0`
-   `#ff0000a0`
-   `rgb(255, 128, 128)`
-   `rgba(64, 192, 32, 0.25)`
-   `hsl(60, 100%, 50%)`
-   `hsla(60, 60%, 80%, 0.4)`
-   `transparent`

Please note that descriptive color names, such as `red` or `hotpink` are not supported to limit the size of dotAtlas code. Use [color-name](https://github.com/colorjs/color-name) or a similar utility to retrieve RGBA values for named colors.

In addition to CSS3 color strings, you can pass object- or array-based color specifications:

-   `{ r: 255, g: 128, b: 64, a: 0.5 }`
-   `{ h: 85, s: 50, l: 80, a: 1.0 }`
-   `[ 255, 192, 64, 64 ]` – RGBA components in the 0...255 range.

### Event details

Mouse event handler functions will be called with an event details object as the first parameter. The event details object will contain the following properties:

**`type`**

Type of the low-level event that gave rise to this event, such as `click` or `move`.

**`inside`**

`true` if the event happened inside the dotAtlas DOM element. While this will be the case most of the time, some `[onMouseMove](/api-dotatlas/#onMouseMove)` events may be raised with `inside` equal to `false`, which means the mouse pointer left the dotAtlas element area.

**`elementX`, `elementY`**

[element space](#2d-point:element-space) coordinates of the point over which the event was triggered. You can use them when, for example, positioning an HTML tooltip over dotAtlas area.

**`x`, `y`**

Aliases for `[elementX](#event-details:elementX)` and `[elementY](#event-details:elementY)`.

**`layerX`, `layerY`**

[layer space](#2d-point:layer-space) coordinates of the point over which the event was triggered. You can use these coordinates as start locations for [point clustering](/api-common-layer/#cluster\(\)), center for zooming or adding new markers.

**`delta`**

The direction in which the mouse wheel was rotated. Positive values mean the upwards rotation, negative values mean downwards rotation. Meaningful only for the `onMouseWheel` event, `undefined` for other events.

**`ctrlKey`**

Set to `true` if the Ctrl key was pressed at the time of the event.

**`shiftKey`**

Set to `true` if the Shift key was pressed at the time of the event.

**`altKey`**

Set to `true` if the Alt key was pressed at the time of the event.

**`preventDefault()`**

Call this function to prevent the default dotAtlas action bound to this event, for example map zooming on the `onMouseWheel` event.

Only the dotAtlas mouse events have this function: `[onClick](/api-dotatlas/#onClick)`, `[onDoubleClick](/api-dotatlas/#onDoubleClick)`, `[onHold](/api-dotatlas/#onHold)`, `[onMouseMove](/api-dotatlas/#onMouseMove)` and `[onMouseWheel](/api-dotatlas/#onMouseWheel)`. The layer point events, such as `[onPointClick](/api-common-layer/#onPointClick)`, don't have it.

Certain event types, such as `[onPointClick](/api-common-layer/#onPointClick)`, come with additional properties, see the specific event documentation for details.

---

# DotAtlas API

This reference describes the `DotAtlas` class, which exposes the top-level API, including visualization embedding, layer creation or global event handling.

For the description of the general dotAtlas API structure, see [API overview](/api-overview/).

## Properties

### element

A reference to the HTML element into which to embed dotAtlas. A non-empty `element` property must be provided when calling `[DotAtlas.embed()](#DotAtlas.embed\(\))`, and can't be changed afterwards:

```javascript
const dotatlas = DotAtlas.embed({
  element: document.querySelector("#visualization")
});
```

> [!WARNING]
> **Heads up, non-zero dimensions!**
>
> Note that the provided HTML element must have non-zero dimensions, otherwise an exception will be thrown when embedding dotAtlas.
>
> The most common causes of the element having zero dimensions are:
>
> -   **the element does not have dimensions set and is not stretched to fill its container.** Make sure you provide the element size explicitly or cause it to stretch to fill its parent.
>     
> -   **the element is not displayed during embedding** due to the `display: none` CSS applied to the element or any of its parents. If this is the case, delay embedding until the element becomes visible. Once dotAtlas embeds successfully, the element can be hidden and shown using `display: none` without affecting the visualization.
>     
> -   **dotAtlas is initialized too early** and the element has not yet been styled and laid out by the browser. If this is the case, consider delaying embedding until the page fully loads using the document's `load` event.

### layers

An array of map layers to display.

Each element of the array must be either a [layer specification object](/defining-layers/#layer-definition) or a layer instance created using the `[DotAtlas.createLayer()](#DotAtlas.createLayer\(\))` method. The layers you provide will be **stacked in the order they appear in the array, bottom-up**.

Once passed to dotAtlas, each layer will be converted to an **API-bearing object** you can use to modify layer properties or event listeners at runtime. When you [`get()`](/api-common/#get\(prop\)) the `layers` property, instead of the input definitions, you'll get an array of layer implementation objects. They define the common API methods to modify layer properties or manage event listeners:

```javascript
const elevationsLayer = dotatlas.get("layers")[0];
elevationsLayer.set("lightIntensity", 0.3);
dotatlas.redraw();

elevationsLayer.once("maxElevationChanged", e => {
  // do something
});
```

See [Defining layers](/defining-layers/) for an overview of the layer definition and management process.

### transform

The current 2d transform determining the zoom scale and translation offset.

The transform is represented by a literal object with the following properties:

**`translateX`**

Horizontal offset.

**`translateY`**

Vertical offset.

**`scale`**

Scale factor.

The initial transform is `{ translateX: 0, translateY: 0, scale: 1 }`, which brings all points in all layers into view. When the `[layers](#layers)` property is set, the transform also gets automatically reset to the initial value.

To start the visualization with a non-default transform, set the desired values along with the `[layers](#layers)` property. The following code initializes the visualization to a non-default transform. After a short delay, it increases the zoom level even further.

```javascript
const dotatlas = DotAtlas.embed({
  "element": document.getElementById("dotatlas"),
  "layers": [
    {
      "type": "elevation",
      "points": [{ "x": 0, "y": 0, "elevation": 1 }]
    }
  ],
  "transform": {
    "translateX": -300,
    "translateY": -200,
    "scale": 2
  }
});

window.setTimeout(() => {
  dotatlas.set("transform", {
    "translateX": -900,
    "translateY": -600,
    "scale": 4
  });
  dotatlas.redraw();
}, 1000);
```

### maxZoomScale

The maximum zoom scale dotAtlas will allow to set.

The supplied value will be rounded down to the nearest power of 2. The default value is the scale at which rendering artifacts related to limited precision of floating point computations start showing up.

### licenseKey

The license key that unlocks the branding options, see [License key](/installation/#license-key). Without a valid key, dotAtlas draws its logo over the map. The default is `null`.

If you change the key after embedding, dotAtlas redraws the visualization. If the key is not valid, dotAtlas logs the reason in the browser's console.

### imageData

Returns the current state of the visualization as an image in the [data URL](http://en.wikipedia.org/wiki/Data_URI_scheme) format. Unlike most attributes, this one accepts an optional object which can specify the image format details. This object can contain the following keys:

**`format`**

format of the image data: `image/png` (default) or `image/jpeg`

**`quality`**

if `format` is `image/jpeg`, specifies the desired quality of JPEG compression in the `0`...`1` range, where `1` means the highest quality and largest image data. The default quality is `0.8`. Note that JPEG images are always opaque, use PNG images to handle background transparency.

### pixelRatio

Determines the pixel density of the visualization.

The default value of `auto` causes dotAtlas to use the `[devicePixelRatio](https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio)` value reported by the browser. With the `auto` value, dotAtlas picks up changes to the device pixel ratio, such as those caused by browser viewport zoom level changes, on the next call to `[resize()](#resize\(\))`. The [AutoResizing plugin](/using-plugins/#autoresizing) makes this call when the window size changes.

You can override the default pixel density by providing a floating point value, such as `1.0`, `1.5` or `2.0` in this property. A higher pixel density value can improve clarity in high-resolution displays but may adversely affect performance.

We recommend keeping the `auto` value of the `pixelRatio` property to ensure the best rendering across different devices and browser viewport zoom levels.

You can only provide this property when calling `[DotAtlas.embed()](#DotAtlas.embed\(\))`.

### boundingBox

The bounding box of the points in the visualization.

The bounding box is an object with the following properties. Values of all properties are in [layer space](/api-common/#2d-point:layer-space).

**`x`**

The left edge of the bounding box.

**`y`**

The top edge of the bounding box.

**`w`**

The width of the bounding box.

**`h`**

The height of the bounding box.

The bounding box determines the set of points visible in the non-zoomed viewport.

If you don't provide the bounding box when initializing the visualization, dotAtlas computes the bounding box automatically, taking into account all points across all layers. Getting the `boundingBox` property returns the bounding box dotAtlas computed.

One reason you may want to provide your own bounding box instead of using the automatically computed one is when you incrementally load and display a large dataset. In this case, you can initialize the bounding box right away and add points to the visualization as the data becomes available. Pre-setting the bounding box ensures that the viewport remains stable during data updates. See the [Visualizing 1m points](../../demos/visualizing-1m-points.html) demo for an implementation of this technique.

## Events

### onClick

Called when the user clicks inside the visualization area. Listeners will be called with one parameter – the [event details object](/api-common/#event-details).

If any listener prevents the default action of this event, the point-specific `[onPointClick](/api-common-layer/#onPointClick)` listeners will not be called.

### onDoubleClick

Called when the user double clicks inside the visualization area. Listeners will be called with one parameter – the [event details object](/api-common/#event-details).

If any listener prevents the default action of this event, the point-specific `[onPointDoubleClick](/api-common-layer/#onPointDoubleClick)` listeners will not be called.

### onHold

Called when the user clicks and holds mouse button inside the visualization area. Listeners will be called with one parameter – the [event details object](/api-common/#event-details).

If any listener prevents the default action of this event, the point-specific `[onPointHold](/api-common-layer/#onPointHold)` listeners will not be called.

### onMouseMove

Called when the mouse pointer hovers over the visualization area or leaves it. Listeners will be called with one parameter – the [event details object](/api-common/#event-details).

If any listener prevents the default action of this event, the point-specific `[onPointHover](/api-common-layer/#onPointHover)` listeners will not be called.

### onMouseWheel

Called when the mouse wheel is rotated over the visualization area. Listeners will be called with one parameter – the [event details object](/api-common/#event-details).

If any listener prevents the default action of this event, the default mouse-wheel-based zooming will not be performed.

### onRedraw

Called after an internal- or API-triggered redraw of the visualization.

### onDispose

Called after `[dispose()](#dispose\(\))` has been called but before dotAtlas element is removed from the DOM.

You can use this callback to clean up any custom event listeners registered on the dotAtlas DOM element. The [`AutoResizing`](/using-plugins/#autoresizing) plugin uses this callback to remove the window resize listener it registers.

## Methods

### DotAtlas.supported()

Returns `true` if the current platform meets all dotAtlas [requirements](/requirements/).

dotAtlas will function properly if and only if this method returns `true`. If the method returns `false`, an attempt to embed dotAtlas will fail.

### DotAtlas.branded()

**Deprecated.** This method always returns `true`.

Each dotAtlas instance has its own `[licenseKey](#licenseKey)`, so a static method cannot tell whether the branding options are available. To check this, call the `[version()](#version\(\))` method of the dotAtlas instance and read the `licensed` property.

### DotAtlas.embed()

Embeds dotAtlas into the provided DOM element.

```javascript
const dotatlas = DotAtlas.embed(props)
```

Use the `DotAtlas.embed()` static method to embed dotAtlas into your page and pass initial layer data, property values and event listeners. The method returns the dotAtlas instance you can use to change layer data or properties.

This method accepts one parameter – a literal object containing the initial property values to use. You will most likely include there the `element` property to pass the HTML element into which to embed dotAtlas and the `layers` option containing the map layers to display.

A typical invocation of this method will look like this:

```javascript
const dotatlas = DotAtlas.embed({
  "element": document.getElementById("dotatlas"),
  "layers": [
    // layer specifications
  ],
  "onClick": e => {
    console.log("visualization area clicked", e);
  }
});
```

### DotAtlas.createLayer()

Creates a dotAtlas layer instance.

```javascript
const layer = DotAtlas.createLayer(spec)
```

The `DotAtlas.createLayer()` static method creates a layer instance based on the specification you provide.

The method accepts one parameter – a literal object containing the specification of the layer to create. The provided object must contain the `type` property that determines which specific layer to create. The following types are currently supported:

**`elevation`**

creates an [elevations layer](/api-elevations-layer/)

**`marker`**

creates a [markers layer](/api-markers-layer/)

**`label`**

creates a [labels layer](/api-labels-layer/)

**`outline`**

creates an [outline layer](/api-outline-layer/)

The [specification object](/defining-layers/#layer-definition) will likely contain some of the [common layer properties](/api-common-layer/), such as [`points`](/api-common-layer/#points), and properties specific to the layer type.

To display the layers you created, pass the obtained instances in the [`layers`](#layers) property, for example when initializing dotAtlas.

```javascript
const elevations = DotAtlas.createLayer({
  type: "elevation",
  points: [ /* some points */ ],
  maxRadius: 1
});
dotatlas.set("layers", [ elevations ]);
```

Additionally, you can use individual layer instances to modify properties of the layer after initialization.

```javascript
elevations.set("maxRadius", 0.7);
dotatlas.redraw();
```

### DotAtlas.with()

Returns an object with the `[embed()](#DotAtlas.embed\(\))` and `with()` methods, which embed and extend dotAtlas with the provided plugins.

```javascript
const DotAtlasWithPlugins = DotAtlas.with(plugin1, plugin2, ...);
```

Most of the time, you will chain the call to the `with()` method with the `[embed()](#DotAtlas.embed\(\))` method to create a dotAtlas instance with extra plugins enabled. Many of the plugins will expose additional options you can initialize when calling the `[embed()](#DotAtlas.embed\(\))` method and change later on.

```javascript
import { DotAtlas, Theme, Effects } from "@carrotsearch/dotatlas";

const dotAtlas = DotAtlas.with(Theme, Effects).embed({
  "element": document.querySelector("#visualization"),
  "layers": [],
  "theme": "dark",
  "rolloutDuration": 3000
});
```

See the [Using plugins](/using-plugins/) article for the list of available plugins.

### redraw()

Schedules a visualization redraw to happen in the next animation frame. If a redraw has already been scheduled but not yet performed, this call does nothing.

This method returns a `Promise`, which gets resolved after the render completes.

```javascript
dotatlas.redraw().then(() => {
  // do something when render is complete
});
```

You can also use the `await` syntax to ensure that some code executes after a redraw actually completed:

```javascript
const redrawWithAwait = async () => {
  await dotatlas.redraw();
  // At this point redraw has completed.
};
```

### resize()

Resizes and redraws the visualization to accommodate the new size of the container element.

The invocation cost of this function is low, comparable with a single `[redraw()](#redraw\(\))`, so there is no need to throttle the calls made from, for example, the window's resize listener:

```javascript
window.addEventListener("resize", () => {
  dotatlas.resize();
});
```

> [!WARNING]
> **Heads up, overlapping labels.**
>
> After the container element shrinks by a large amount, a call to `resize()` alone may cause crowding and overlapping of labels.
>
> ![Crowded and overlapping labels after the container element gets smaller.](/assets/apidocs/img/N8nCdhJXQ1-1168.jpeg)
>
> Similarly, when the container element grows by a large amount, a call to `resize()` alone will spread the labels too much.
>
> To correct this, you will need to force dotAtlas to recompute label display order to match the new container size:
>
> ```javascript
> const layers = dotatlas.get("layers");
> const labelLayers = layers.filter(l => l.get("type") === "label");
> for (let labelLayer of labelLayers) {
>   labelLayer.update("labelVisibilityScales");
> }
> dotatlas.redraw();
> ```
>
> Updating `labelVisibilityScales` may be costly for large data sets, so it's best to throttle the calls to the above code. The `[AutoResizing](/using-plugins/#autoresizing)` plugin combines all the necessary code in one place.

### reset()

Resets the zoom level and offset back to the initial state, bringing all points into view.

By default, dotAtlas will also reset the view when the user presses Esc.

### center()

Centers the view on the specified 2d coordinate.

```javascript
dotatlas.center(x, y, scale, duration);
```

This method requires the following parameters:

**`x`, `y`**

The 2d coordinates to which to center the view. The coordinates must be expressed in the same space as the points in the layers being visualized.

**`scale`**

The zoom scale to apply when centering. If you are zooming to a small area of the map, using a scale value larger than 1 may help better present the area.

**`duration`**

Duration of the centering animation, in milliseconds.

The typical invocation of this method will be similar to:

```javascript
const elevations = dotatlas.get("layers")[0];
const centerPoint = elevations.get("points")[0];
dotatlas.center(centerPoint.x, centerPoint.y, 4, 500);
```

### layerToElementSpace()

Converts 2d coordinates from the [layer space](/api-common/#2d-point:layer-space) to the [element space](/api-common/#2d-point:element-space).

```javascript
const pointInScreenSpace = dotatlas.layerToElementSpace(pointInLayerSpace)
```

The method requires one parameter: a [2d point](/api-common/#2d-point) object in the [layer space](/api-common/#2d-point:layer-space) to convert. The return value is the [2d point](/api-common/#2d-point) object converted to the [element space](/api-common/#2d-point:element-space).

Use this method when you need, for example, to show an HTML popup over a specific point in one of the layers. In this case, you'd pass the layer point to this method and get its screen coordinates.

Note that the **screen coordinates of a layer point depend on the zoom level and offset**. If the user zooms or pans the viewport, the screen coordinates will change. Moreover, if a point is outside of the current viewport, its coordinates will be smaller than zero or larger than the visualization element width and height.

### elementToLayerSpace()

Converts 2d coordinates from the [element space](/api-common/#2d-point:element-space) to the [layer space](/api-common/#2d-point:layer-space).

```javascript
const pointInLayerSpace = dotatlas.elementToLayerSpace(pointInElementSpace)
```

The method requires one parameter: a [2d point](/api-common/#2d-point) object in the [element space](/api-common/#2d-point:element-space) to convert. The return value is the [2d point](/api-common/#2d-point) object converted to the [layer space](/api-common/#2d-point:layer-space).

Use this method when you need, for example, to find layer points that lie close to the current mouse pointer position. In this case, you can convert the pointer's screen coordinates to the layer space and use the converted point to call the `[within()](/api-common-layer/#within\(\))` or `[cluster()](/api-common-layer/#cluster\(\))` method.

Note that the **conversion result depends on the zoom level and offset**. If the user zooms or pans the viewport, the conversion will produce a different result.

### version()

Returns the version of the library and the license state of this instance:

**`version`**

the version string, such as `1.1.0`,

**`build`**

the build identifier,

**`licensed`**

`true` if the `[licenseKey](#licenseKey)` option contains a valid key that unlocks the branding options,

**`license`**

the details of the license key, with the `product`, `issued`, `expires` and `maintenance` properties. The dates are `Date` objects, `null` date means no expiry.

This property describes any correctly signed key, even if the key does not cover this version of dotAtlas. If the key is missing or not valid, this property is `null`.

The static `DotAtlas.version()` method returns only the `version` and `build` properties.

### dispose()

Releases the resources allocated by the dotAtlas instance.

When you don't need a dotAtlas instance any more, call the `dispose()` method, so that dotAtlas can remove all the DOM elements it created and free the WebGL resources. Note that the DOM element you passed in the `[element](#element)` property will not be removed from the DOM.

One typical use case for this method is when you use dotAtlas in a React component. When the component unmounts, you'll need to call `dispose()` to remove the internal DOM elements:

```javascript
import { DotAtlas as DotAtlasImpl } from "@carrotsearch/dotatlas";
import React, { useEffect, useRef } from "react";

export const DotAtlas = () => {
  const element = useRef(null);
  useEffect(() => {
    // Embed dotAtlas when mounted
    const dotatlas = DotAtlasImpl.embed({
      element: element.current,
      layers: [
        /* your layer spec */
      ]
    });

    // Dispose of dotAtlas when unmounted
    return () => dotatlas.dispose();
  }, []);

  return <div ref={element} style={{ width: 400, height: 300 }} />;
};
```

## Defaults

You can obtain default DotAtlas and layer property values by accessing the special `defaults` static literal objects listed below.

### DotAtlas.defaults

A literal object containing default values of the [top-level dotAtlas properties](#properties).

```javascript
const defaultTransform = DotAtlas.defaults["transform"];
```

### DotAtlas.ElevationsLayer.defaults

A literal object containing default values of the [elevation layer properties](/api-elevations-layer/#layer-properties).

```javascript
const defaultColorBands = DotAtlas.ElevationsLayer.defaults["colorBands"];
```

### DotAtlas.MarkersLayer.defaults

A literal object containing default values of the [marker layer properties](/api-markers-layer/#layer-properties).

```javascript
const defaultMarkerColor = DotAtlas.MarkersLayer.defaults["markerColor"];
```

### DotAtlas.LabelsLayer.defaults

A literal object containing default values of the [labels layer properties](/api-labels-layer/#layer-properties).

```javascript
const defaultLabelBoxColor = DotAtlas.LabelsLayer.defaults["labelBoxColor"];
```

### DotAtlas.OutlineLayer.defaults

A literal object containing default values of the [outline layer properties](/api-outline-layer/#layer-properties).

```javascript
const defaultOutlineOffset = DotAtlas.OutlineLayer.defaults["outlineOffset"];
```

---

# Common layer API

All dotAtlas layers share some common API methods and properties. This part of the reference describes them in detail.

## Point properties

### x, y

The x and y coordinate of the point, required.

There are no constraints on the coordinate values, so you can use a coordinate system that makes the most sense for your data. dotAtlas will ensure that the initial view includes all points from all [layers](/api-dotatlas/#layers).

When you mutate the `x` or `y` property of a specific point object, call the `[update()](#update\(\))` and then the `[redraw()](/api-dotatlas/#redraw\(\))` method to see the changes on the screen.

## Layer properties

### points

The array of [2d points](/api-common/#2d-point) to display on this layer.

Each point is represented by a JavaScript object with the mandatory `[x](#xy)` and `[y](#xy)` properties. Specific layer types use other properties of the point object, such as the `[elevation](/api-elevations-layer/#elevation)` property in the [elevations layer](/api-elevations-layer/) or the optional `markerColor` property in the [markers layer](/api-markers-layer/).

When different layers share points of the same coordinates, for example when elevations, markers and labels need to be drawn for each point, you can set the same array of points for all layers.

### visible

Determines if this layer is visible. Set this property to `false` to hide the layer. When a layer is hidden, its layer-specific events, such as `[onPointClick](#onPointClick)` will not be triggered.

### opacity

Opacity level of this layer.

The default opacity value is `1.0`, which will render a fully opaque layer. A value of `0.0` will hide the layer. If the layer's opacity is `0.0`, its layer-specific events, such as `[onPointClick](#onPointClick)` will still be triggered.

### pointHoverRadiusMultiplier

How much the point's active area should be larger than the actual point.

To improve usability of point-related events, the point's active area can be made larger than its on-screen size. This property determines what the scaling factor should be.

## Events

### onPointHover

Triggered when the user hovers over a specific point of this layer, when the mouse pointer moves to an area without points or moves out of the visualization area completely.

In addition to the common [event details](/api-common/#event-details) properties, this event comes with the following additional properties:

**points**

An array of point objects hovered by the user. The array may contain zero, one or more points. In case the array contains more than one point, the points will be sorted in the increasing distance from the mouse pointer location.

### onPointClick

Triggered when the user clicks the visualization, also when the click misses all points of this layer.

In addition to the common [event details](/api-common/#event-details) properties, this event comes with the following additional properties:

**points**

An array of point objects clicked by the user. The array may contain zero, one or more points. In case the array contains more than one point, the points will be sorted in the increasing distance from the mouse pointer location.

### onPointDoubleClick

Triggered when the user double-clicks the visualization, also when the double click misses all points of this layer.

In addition to the common [event details](/api-common/#event-details) properties, this event comes with the following additional properties:

**points**

An array of point objects double-clicked by the user. The array may contain zero, one or more points. In case the array contains more than one point, the points will be sorted in the increasing distance from the mouse pointer location.

### onPointHold

Triggered when the user clicks and holds the mouse button on the visualization, also when the pointer misses all points of this layer.

In addition to the common [event details](/api-common/#event-details) properties, this event comes with the following additional properties:

**points**

An array of point objects click-and-held by the user. The array may contain zero, one or more points. In case the array contains more than one point, the points will be sorted in the increasing distance from the mouse pointer location.

## Methods

### update()

Notifies dotAtlas that some property has been changed for some of the points of this layer. Upon the next redraw, dotAtlas will refresh its internal buffers and reflect the change on the screen.

```javascript
layer.update(prop);
```

The following `prop` parameter values are supported:

<table><thead><tr><th style="white-space: nowrap"><code>prop</code> parameter</th><th style="white-space: nowrap">layer type</th><th>use when...</th></tr></thead><tbody><tr><td><p><code>xy</code></p></td><td>all types</td><td><p>you change point coordinates represented by the <code>x</code> and <code>y</code> point properties.</p></td></tr><tr><td><p><code>elevation</code></p></td><td>elevation</td><td><p>point's <code><a href="/api-elevations-layer/#elevation">elevation</a></code> property changes.</p></td></tr><tr><td><p><code>markerColor</code></p></td><td>marker</td><td><p>point's <code>markerColor</code> property changes.</p></td></tr><tr><td><p><code>markerOpacity</code></p></td><td>marker</td><td><p>point's <code>markerOpacity</code> property changes.</p></td></tr><tr><td><p><code>markerSize</code></p></td><td>marker</td><td><p>point's <code>markerSize</code> property changes.</p></td></tr><tr><td><p><code>markerShape</code></p></td><td>marker</td><td><p>point's <code>markerShape</code> property changes.</p></td></tr><tr><td><p><code>labelColor</code></p></td><td>label</td><td><p>point's <code>labelColor</code> property changes.</p></td></tr><tr><td><p><code>labelOpacity</code></p></td><td>label</td><td><p>point's <code>labelOpacity</code> property changes.</p></td></tr><tr><td><p><code>labelBoxColor</code></p></td><td>label</td><td><p>point's <code>labelBoxColor</code> property changes.</p></td></tr><tr><td><p><code>labelBoxOpacity</code></p></td><td>label</td><td><p>point's <code>labelBoxOpacity</code> property changes.</p></td></tr><tr><td><p><code>labelVisibilityScales</code></p></td><td>label</td><td><p>you change label point <code>x</code> or <code>y</code> properties or visualization container size changes. This will ensure that dotAtlas recomputes label layout so that the labels don't overlap.</p></td></tr><tr><td><p><code>markerSize</code></p></td><td>outline</td><td><p>point's <code>markerSize</code> property changes.</p></td></tr></tbody></table>

The typical workflow for updating point properties will look like this:

```javascript
const markers = dotatlas.get("layers")[0];
const points  = markers.get("points");

points[0].x += 0.1;
points[0].y += 0.1;
points[0].markerSize *= 1.2;

markers.update("xy");
markers.update("markerSize");
dotatlas.redraw();
```

Note that if several layers share the same point instances, you still need to notify each involved layer about the changed properties:

```javascript
const points = [
  { x: 0.0, y: 0.0, elevation: 0.5 },
  { x: 0.0, y: 0.5, elevation: 0.3 }
];

const elevations = DotAtlas.createLayer({
  "type": "elevation",
  "points": points
});

const markers = DotAtlas.createLayer({
  "type": "marker",
  "points": points
});

const dotatlas = DotAtlas.embed({
  "element": document.getElementById("dotatlas"),
  "layers": [ elevations, markers ]
});

points[0].x += 0.1;
points[0].y += 0.1;
points[0].elevation += 0.1;

elevations.update("elevation");
elevations.update("xy");
markers.update("xy");
```

### within()

Computes points lying within the requested 2d circle.

![A circular group of points.](/assets/apidocs/img/RAD4f4doXF-1442.jpeg)

A group of points obtained from the `within()` method. The start point is marked with the mouse pointer. The method includes all points lying within a certain distance from the start point. Therefore, isolated within-circle points can also be included in the group. Compare how the `[cluster()](#cluster\(\))` method returns a different set of points based on the same start point.

```javascript
const withinCircle = await layer.within(params);
```

This method returns a `Promise` resolving to the array of points inside the circle.

The `params` literal object contains the definition of the circle:

**`startX`, `startY`**

Coordinates of the center of the circle. The coordinates must be in the same space as coordinates of the layer's points.

**`radius`**

Circle radius, relative to the dimension of the bounding box of the point's layer, `0.4` by default. The dimension of the bounding box is assumed to be the minimum of the box width and height. The radius is scaled by `0.1`, so that values from the `0...1` range give groups similar in size to those of the `[cluster()](#cluster\(\))` method.

For example, if the point's bounding box is a `2.5` x `2.0` rectangle, and `radius` is `0.1`, then all points within the distance of `0.02` (`0.1` × `2.0` × `0.1`) from the center will be returned.

**`sortByDistance`**

If `true`, the returned points will be sorted by the increasing distance to the center. If this property is not defined, `false` will be assumed and points will be returned in an arbitrary order.

You can use this method to build a simple mechanism for selecting multiple points at once. Alternatively, use the `[cluster()](#cluster\(\))` method to find non-circular density-based clusters of nearby points.

The typical invocation looks like this:

```javascript
const markers = dotatlas.get("layers")[1];
const points = await markers.within({
  "startX": 0.2,
  "startY": 0.5
});
console.log(`${points.length} point(s) found.`);
```

### cluster()

Computes a density-based cluster of nearby points around some start point:

![A density-based cluster of points.](/assets/apidocs/img/gdeQAPOIr0-1442.jpeg)

A cluster of points obtained from the `cluster()` method. The start point is marked with the mouse pointer. Notice how the cluster is asymmetrical and follows the density of the markers. Non-connected outlier points are not included in the cluster. Compare how the `[within()](#within\(\))` method returns a different group of points based on the same start point.

```javascript
const cluster = await layer.cluster(params);
```

This method returns a `Promise` resolving to the array of points in the cluster.

The `params` literal object contains parameters for the clustering algorithm:

**`startX`, `startY`**

Coordinates of the start point from which to build the cluster. If the point lies inside a densely-populated area, most points in that area will be included in the cluster. If there are no points close to the start coordinates, the cluster will be empty; if the coordinates match an isolated point, the cluster will contain only that point.

**`radius`**

Defines the desired size of the cluster, `0.4` by default. The larger the radius, the larger the cluster. In most cases, a value from the `0...1` range will produce the best results. In an interactive selection scenario, you can let the user change the size and dynamically re-compute and present the cluster.

**`maxClusterRadius`**

Defines the maximum allowed cluster radius, relative to the bounding box of all points in the layer, `0.1` by default. The limit on the maximum cluster radius prevents a situation where all points in the layer are included in the cluster.

You can use this method to build a mechanism for selecting entire regions of related points on the map. As opposed to the `[within()](#within\(\))` method, this method will usually return non-circular clusters that match the densely-populated region around the start point.

See the implementation of the [Selection](/using-plugins/#selection) plugin for example invocations of this method.

---

# Elevations layer API

This reference describes the elevations layer API.

The elevations layer serves as the background for the whole visualization and renders the map-like image of "hills" and "valleys", along with elevation contours and light shading:

![dotAtlas elevation layer.](/assets/apidocs/img/7wUdEWDzJ_-1835.jpeg)

The point objects you provide in the `[points](/api-common-layer/#points)` property, in addition to the `x` and `y` coordinates must define the point's elevation in the `[elevation](#elevation)` property.

You can create an example elevations layer using the following code:

```javascript
const elevations = DotAtlas.createLayer({
  points: [],
  type: "elevation",
  lightIntensity: 0.15
});
```

See the following documentation for all the point and layer properties you can use.

## Point properties

### elevation

Defines the elevation (altitude) of the point, required.

Elevation values must be in the `0.0` – `1.0` range, where `0.0` is no elevation and `1.0` is peak elevation. Values outside of this range will be clamped to the required range.

When you mutate the `elevation` property of a specific point object, call the `[update()](/api-common-layer/#update\(\))` and then the `[redraw()](/api-dotatlas/#redraw\(\))` method to see the changes on the screen.

## Layer properties

### colorBands

Determines the colors used to draw the elevation bands and the number of bands.

Values of this property must be an array of JavaScript literal objects. Each object defines one elevation band and can contain the following properties, of which `end` and `color` are required:

### end

The upper bound of the elevation range covered by this band, must fall in the `0.0` – `1.0` range. Note that the lower bound of the range is defined by the upper bound of the previous band or is `0.0` for the first band in the array.

### color

The [color](/api-common/#data-structures:colors) in which to draw the band.

### shading

Set to `true` to apply hill shading when rendering this band. If this property is not provided, shading will not be applied. The default dotAtlas color bands don't apply shading to the blue "sea" bands and do apply shading to the "land" bands.

### contours

Determines where contour lines start. Contour lines are drawn between all bands from the first band whose `contours` property is `true` or not provided; the property is ignored on the bands that follow. The default dotAtlas color bands don't draw contours between the blue "sea" bands and do draw contours between the "land" bands.

The following example defines five green-to-red heatmap-style bands, all with contours and without hill shading.

```javascript
const dotatlas = DotAtlas.embed({
  "element": element,
  "layers": [
    {
      "type": "elevation",
      "colorBands": [
        { "end": 0.005, "color": "hsl(90, 70%, 60%)" },
        { "end": 0.050, "color": "hsl(70, 70%, 60%)" },
        { "end": 0.200, "color": "hsl(50, 70%, 60%)" },
        { "end": 0.500, "color": "hsl(30, 70%, 60%)" },
        { "end": 1.000, "color": "hsl(10, 70%, 60%)" }
      ],
      "points": [
        { "x":  0, "y": 0, "elevation": 1.0 }
      ]
    }
  ]
});
```

The [Theme](/using-plugins/#theme) plugin uses this property to add map colors suitable for dark mode UIs.

### contourOpacity

Opacity of contour lines between elevation bands on this layer. If set to `0.0`, contours will not be drawn at all.

### contourWidth

Width of contour lines between elevation bands on this layer, in pixels. A reasonable range of contour widths is `0.5`–`2.5`. If set to `0.0`, contours will not be drawn at all.

### lightIntensity

Intensity of the hill shading light source. Values in the `0.0` – `1.0` range are accepted, where `0.0` means no light and no hill shading.

### lightAzimuth

The angular direction from which the hill shading light comes.

Values of this property will be treated as an angle in radians. Assuming `[lightAltitude](#lightAltitude)` is `0`, mapping between `lightAzimuth` and geographical directions is the following:

| `lightAzimuth` | Light direction |
| --- | --- |
| `0` | West |
| `Math.PI / 4` | South-West |
| `Math.PI / 2` | South |
| `3 * Math.PI / 4` | South-East |
| `Math.PI` | East |
| `5 * Math.PI / 4` | North-East |
| `3 * Math.PI / 2` | North |
| `7 * Math.PI / 4` | North-West |

### lightAltitude

Altitude of the hill shading light source above the ground. Values of this property will be treated as an angle in radians, for example:

| `lightAltitude` | Light position |
| --- | --- |
| `0` | On the ground level, "sunrise". |
| `Math.PI / 2` | Directly above the ground, "noon". Note that hill shading will not be visible in this setting. |
| `Math.PI` | On the ground level, "sunset". Note that this setting reverses the example light directions provided in the `[lightAzimuth](#lightAzimuth)` property documentation. |

### lightness

Lightness correction for the whole layer. Correction values must fall in the `-1.0` ... `1.0` range and result in the following corrections:

| Value | Correction |
| --- | --- |
| `-1.0` | Zero lightness, all colors black. |
| `-1.0` ... `0.0` | Lowered lightness. |
| `0.0` | No correction. |
| `0.0` ... `1.0` | Increased lightness. |
| `1.0` | Maximum lightness, all colors white. |

### saturation

Saturation correction for the whole layer. Correction values must fall in the `-1.0` ... `1.0` range and result in the following corrections:

| Value | Correction |
| --- | --- |
| `-1.0` | Zero saturation, grayscale. |
| `-1.0` ... `0.0` | Lowered saturation. |
| `0.0` | No correction. |
| `0.0` ... `1.0` | Increased saturation. |
| `1.0` | Maximum saturation. |

### maxElevationPoints

The maximum number of points from the `[points](/api-common-layer/#points)` to consider when drawing elevations.

The elevations layer can be costly to draw, especially when the number of elevation points is large. In some cases it may be beneficial to allow the users to balance the rendering performance and the amount of detail on their maps.

You can use the `maxElevationPoints` property to render fewer elevation points than provided in the `[points](/api-common-layer/#points)` array. If you sort the elevation points in the decreasing order of elevation, lowering `maxElevationPoints` below the length of the points array will discard the least important information.

### maxRadius

Determines how much of "land" each elevation point generates. The larger the value, the more "land" generated. The smaller the value, the more "islandy" the map.

In most cases, the reasonable range of `maxRadius` values will be `0.1` ... `2.0`. Please note that large `maxRadius` values may slow down rendering of the elevations layer.

### elevationPow

Determines the sharpness of each elevation peak.

This property is the power to which to raise each point's elevation value before rendering:

```javascript
const renderedElevation = Math.pow(point.elevation, elevationPow);
```

The impact of this property on elevation peaks is the following:

| `elevationPow` | Impact on elevations |
| --- | --- |
| `0` ... `1.0` | Flattens the peaks |
| `1.0` | No correction |
| `1.0` and more | Sharpens the peaks |

### maxElevation

The current maximum elevation value, that is the altitude of the highest peak on the map.

While the range of elevation values for individual points is `0.0` ... `1.0`, the range of elevation values across the whole map will be larger than `1.0` because elevations of points in the same area add up.

You can read this property to get the elevation value of the currently highest point on the map. The maximum elevation value may be useful as a normalization factor when, for example, building a map legend.

dotAtlas maps elevations to [color bands](#colorBands) relative to this value. You can set it to normalize elevations against a fixed value instead, for example to keep the colors of several maps comparable. dotAtlas computes the value again when the elevation points or the properties that shape the elevations change.

### elevationAt

Returns the elevation value at the specified [element space](/api-common/#2d-point:element-space) coordinate of the map:

```javascript
dotatlas.on("mouseMove", e => {
  const elevationsLayer = dotatlas.get("layers")[0];
  const elevationAtMouseLocation =
      elevationsLayer.get("elevationAt", e.elementX, e.elementY);
});
```

### prefilter

Controls pre-filtering of the elevation values before upsampling, enabled by default.

Pre-filtering improves the rendering accuracy of small isolated point islands. However, on small zoom levels, pre-filtering may result in small "fringing" artifacts.

### refreshMargin

How much larger than the visible part of the map the cached elevations are, `0.5` (50% larger) by default.

dotAtlas computes elevations for an area larger than the view and reuses them while the user pans and zooms within that area. It computes them again only when the view leaves the area. Larger values recompute less often, but spread the same resolution over a larger area, which softens the elevations between recomputations. Set this property to `0` to compute the elevations for the exact view on every frame where the view changes, which is noticeably slower on large data sets.

### elevationOffset

Offset added to elevation values, relative to the `[maxElevation](#maxElevation)`, before they are mapped to [color bands](#colorBands), `0` by default.

Negative values lower the whole map, so that the lower parts sink below the "sea" bands; positive values raise it. For example, the [Effects plugin](/using-plugins/#effects) animates this property from `-1` to make the map rise from the sea.

## Events

### onMaxElevationChanged

Triggered when the [maximum elevation value](#maxElevation) has changed. The change may be a result of some of the elevation layer property changes or a change in point elevations.

The event listener will be called with one parameter equal to the current maximum elevation value:

```javascript
elevationsLayer.on("maxElevationChanged", maxElevation => {
  // Use the new maxElevation value
});
```

This event may be useful when your code somehow depends on knowing the maximum elevation value, for example to normalize [elevation values](#elevationAt) to the 0...1 range for legend display purposes.

### onColorBandsChanged

Triggered when new `[colorBands](#colorBands)` have been set.

This event may be useful when implementing a map legend display to follow the changes of the elevations layer color bands.

---

# Markers layer API

This reference describes the markers layer API.

The markers layer draws small shapes at the coordinates of the points you provide. You can define the size, color, shape and opacity of each individual marker:

![dotAtlas markers layer.](/assets/apidocs/img/re_STGd9yp-1835.jpeg)

You can create an example markers layer using the following code:

```javascript
const markers = DotAtlas.createLayer({
  points: [],
  type: "marker",
  markerSizeMultiplier: 10
});
```

See the following documentation for all the point and layer properties you can use.

## Point properties

### markerColor

Determines the [color](/api-common/#data-structures:colors) of the marker. If the color is not provided for a point, the layer-wide `[markerColor](#markerColor)` is used.

### markerShape

Determines the shape of the marker. The following shapes are supported: `circle`, `square` and `triangle`. If the property is not defined for a point, the layer-wide `[markerShape](#markerShape)` is used.

### markerSize

Determines the size of the marker.

Marker size value must fall in the `0.0` ... `1.0` range. Values outside of this range will be clamped. If marker size is not provided, a size of `1.0` will be assumed.

See the `[markerSizeMultiplier](#markerSizeMultiplier)` property for the correspondence between the `markerSize` property and the actual on-screen representation of the marker.

### markerOpacity

Determines the opacity of the marker. Values must fall in the `0.0` ... `1.0` range. If not provided, opacity of `1.0` is assumed.

## Layer properties

### markerColor

Determines the default [color](/api-common/#data-structures:colors) of markers on this layer, black by default.

### markerShape

Determines the default shape of markers on this layer. The following shapes are supported: `circle`, `square` and `triangle`.

### markerBorderWidth

Relative size of the outline drawn around markers on this layer.

Values must fall in the `0.0` ... `1.0` range, where `0.0` is no outline and `1.0` is the marker filled entirely with the outline color.

### markerBorderOpacity

Opacity of the outline part of the marker, `1.0` by default.

### markerFillOpacity

Opacity of the inner part of the marker, `0.35` by default.

### markerSizeMultiplier

The scale to use to determine the on-screen size of markers.

When this layer is rendered, the on-screen size of markers will be computed in the following way:

-   At zoom level 1.0, the on-screen size of markers will be computed as: `[markerSize](#markerSize)` \* `markerSizeMultiplier`.
    
-   At zoom levels between 1.0 and 16.0, an additional scale factor of `sqrt(zoomLevel)` will be applied to increase the on-screen marker size of the magnified visualization.
    
-   At zoom levels larger than 16.0, the on-screen marker size will be computed as: `4` \* `[markerSize](#markerSize)` \* `markerSizeMultiplier`.
    

Additionally, the on-screen size will not be smaller than `[minAbsoluteMarkerSize](#minAbsoluteMarkerSize)`.

### minAbsoluteMarkerSize

The minimum allowed on-screen size of markers on this layer, `1.0` by default.

See the documentation of `[markerSizeMultiplier](#markerSizeMultiplier)` for an overview of how the on-screen marker size is computed.

---

# Labels layer API

This reference describes the labels layer API.

The labels layer draws short fragments of text at the specified 2d coordinates. You can define the color and opacity of each label. Additionally, you can draw boxes around specific labels:

![dotAtlas labels layer.](/assets/apidocs/img/_nyu-tTJGZ-1828.jpeg)

You can create a labels layer using the following code:

```javascript
const labels = DotAtlas.createLayer({
  points: [],
  type: "label",
  labelFontSize: 16,
  labelColor: "rgb(0, 0, 0)"
});
```

Before drawing, the layer pre-renders text into a GPU texture called an _atlas_ — a shared sheet of text sprites. To draw a label, dotAtlas looks up the corresponding sprites in the atlas and stamps them at the point's position on screen. Two options control how those sprites are organized and how they are rendered:

**`[labelAtlas](#labelAtlas)`**

What pieces go into the atlas, fixed at layer construction.

**`[word](#labelAtlas.word)`**

Each unique word is rendered into its own sprite with full native shaping, including kerning and ligatures. Drawing a label stamps one sprite per word. The atlas grows with the number of distinct words across all labels.

**`[glyph](#labelAtlas.glyph)`**

Each unique character is rendered once into its own sprite. Drawing a label stamps the characters one by one. The atlas grows with the alphabet size rather than the label count, scaling to very large label sets – at the cost of unkerned character spacing.

**`[auto](#labelAtlas.auto)` (default)**

Prefers `word` for its higher rendering quality, falling back to `glyph` when there are too many distinct words to fit the word atlas. Resolved once at construction; reading `[labelAtlas](#labelAtlas)` back returns the chosen engine.

**`[labelRendering](#labelRendering)`**

How the atlas sprites are drawn on screen.

**`[raster](#labelRendering.raster)`**

Draws the sprite pixels directly to the visualization, crisp at `[labelFontSize](#labelFontSize)`, softer when scaled up or down.

**`[sdf](#labelRendering.sdf)`**

The atlas sprites store distances to glyph outlines. dotAtlas uses these to reconstruct crisp edges at draw time. While negligibly softer than `raster` in general, stays noticeably sharper when scaled up, though quality degrades at large magnifications. Also supports per-label outlines.

The two settings combine to four rendering modes:

-   `[word](#labelAtlas.word)` + `[raster](#labelRendering.raster)` — what the defaults give unless there are too many distinct words for the word atlas. Full native shaping and correct kerning; crisp at the configured `[labelFontSize](#labelFontSize)`, softening when scaled up. Good fit for typical map label sets of up to a few thousand distinct labels.
    
-   `[word](#labelAtlas.word)` + `[sdf](#labelRendering.sdf)` — full native shaping and correct kerning, crisp at any size, with outline support. Atlas still grows with the distinct word count; suitable for moderate-sized label sets that need differently sized labels in the same visualization or per-label outlines.
    
-   `[glyph](#labelAtlas.glyph)` + `[raster](#labelRendering.raster)` — scales to very large label counts. Crisp at the configured `[labelFontSize](#labelFontSize)`, softening when scaled up. No kerning or ligatures.
    
-   `[glyph](#labelAtlas.glyph)` + `[sdf](#labelRendering.sdf)` — scales to very large label counts and supports per-label outlines. Use this mode for large datasets that need crisply scaled `[labelSize](#point-properties:labelSize)` variation or per-label outlines. No kerning or ligatures.
    

> [!WARNING]
> **Heads up!**
>
> Some options only apply in certain modes and are accepted but ignored otherwise. See the reference documentation for a specific option to check if it is available in the specific atlas and rendering mode.

## Point properties

### label

The text drawn for this point. Points without a `label` are not rendered by the layer. The string is shaped according to the layer-wide font properties (`[labelFontFamily](#labelFontFamily)`, `[labelFontSize](#labelFontSize)`, and the related `labelFont*` options).

### labelColor

The [color](/api-common/#data-structures:colors) of the label. If the color is not provided for a point, the layer-wide `[labelColor](#labelColor)` is used.

### labelOpacity

The opacity of the label. If opacity is not provided for a point, the layer-wide `[labelOpacity](#labelOpacity)` is used.

### labelPriority

Controls the display of the labels at various zoom levels.

dotAtlas draws only those labels that do not overlap any other labels. This means that at a certain zoom level only a limited number of labels will show on the screen. As the zoom level increases, more labels located in the zoomed area will show.

To control which labels show first, set the `labelPriority` of the point. If you provide label priorities, dotAtlas displays labels in the decreasing order of priority.

### labelSize

Per-label size multiplier applied on top of the layer-wide `[labelFontSize](#labelFontSize)`, `1.0` by default. A label with `labelSize: 2.0` will be rendered roughly twice as tall as a label with `labelSize: 1.0`.

The value is clamped to the `[[labelMinSizeScale](#labelMinSizeScale), [labelMaxSizeScale](#labelMaxSizeScale)]` range configured on the layer. Both default to `1.0`, so per-point `labelSize` has no visible effect until you widen that range. Larger labels also occupy proportionally larger collision boxes, so they will suppress more nearby smaller labels at low zoom levels. Under `[raster](#labelRendering.raster)` rendering the pre-rendered sprite is scaled, so oversized labels will appear softer; under `[sdf](#labelRendering.sdf)` rendering edges stay crisp at any size.

### labelOutlineColor

[Color](/api-common/#data-structures:colors) of the outline drawn around the glyphs of this label. If not provided, the layer-wide `[labelOutlineColor](#labelOutlineColor)` is used.

Only visible when `[labelRendering](#labelRendering)` is `[sdf](#labelRendering.sdf)`.

### labelOutlineWidth

Width of the outline drawn around the glyphs of this label, in CSS pixels. If not provided, the layer-wide `[labelOutlineWidth](#labelOutlineWidth)` is used. Set to `0` to disable the outline for this label.

Only visible when `[labelRendering](#labelRendering)` is `[sdf](#labelRendering.sdf)`.

### labelBoxColor

[Color](/api-common/#data-structures:colors) of the box to draw around the label. If not provided, the layer-wide `[labelBoxColor](#labelBoxColor)` is assumed.

### labelBoxOpacity

Opacity of the box to draw around the label. If not provided, the layer-wide `[labelBoxOpacity](#labelBoxOpacity)` will be used.

## Layer properties

### labelAtlas

Atlas granularity, set once when the layer is created and fixed afterwards.

### `auto`

Default. Picks `word` when every unique word fits the word atlas, otherwise `glyph`.

### `glyph`

Rasterizes each character once and scales to very large label counts, at the cost of unkerned glyph advances.

### `word`

Rasterizes whole words with full native shaping.

Because the atlas selects the render context bound at construction, this property is read-only afterwards: assigning to it on an existing layer is silently ignored, and reading it back always returns the resolved concrete engine (`word` or `glyph`), never `auto`. To switch atlas, re-create the layer.

### labelRendering

How the atlas is drawn. Can be changed at any time.

### `raster`

Default, for either atlas. Samples the pre-rendered sprite pixels directly – crisp at the configured `[labelFontSize](#labelFontSize)`, softening when scaled up.

### `sdf`

Reconstructs crisp edges at any size and enables outlines.

### labelCollisionModel

How labels are packed when computing visibility.

### `per-label-box`

Default, for every atlas. Reserves a single box around the whole label, resulting in slightly sparser packing.

### `per-word`

Reserves one collision box per word for tighter packing.

### labelFontSize

The font size to use to draw all labels on this layer, `16` by default. Only numeric values in pixels are accepted; CSS length specifications such as `1em` are not supported.

Per-point `[labelSize](#point-properties:labelSize)` values are applied as a multiplier on top of `labelFontSize`.

### labelFontFamily

The font family to use to draw all labels on this layer, `sans-serif` by default. This property accepts CSS-compliant font family specification.

### labelFontWeight

The font weight to use to draw all labels on this layer, `normal` by default. This property accepts CSS-compliant font weight definitions, such as `bold` or `300`.

### labelFontStyle

The font style to use to draw all labels on this layer, `normal` by default. This property accepts CSS-compliant font style definitions, such as `italic`.

### labelFontVariant

The font variant to use to draw all labels on this layer, `normal` by default. This property accepts CSS-compliant font variant definitions, such as `small-caps`.

### labelColor

Layer-wide label [color](/api-common/#data-structures:colors), `rgba(0, 0, 0, 1.0)` by default.

Labels for which the point-specific `[labelColor](#point-properties:labelColor)` was not provided will be drawn in the color defined by this property.

### labelOpacity

Layer-wide label opacity, `1.0` by default.

Labels for which the point-specific `[labelOpacity](#point-properties:labelOpacity)` was not provided will be drawn with the opacity defined by this property.

### labelMinSizeScale

Lower clamp for the per-point `[labelSize](#point-properties:labelSize)` multiplier, `1.0` by default. Per-point `labelSize` values smaller than this will be rendered as if they were equal to `labelMinSizeScale`.

### labelMaxSizeScale

Upper clamp for the per-point `[labelSize](#point-properties:labelSize)` multiplier, `1.0` by default. Per-point `labelSize` values larger than this will be rendered as if they were equal to `labelMaxSizeScale`.

The clamp lets you derive `labelSize` directly from a domain quantity (such as a score) without a few outliers dominating the visualization.

### labelOutlineColor

Layer-wide outline [color](/api-common/#data-structures:colors) drawn around the glyphs of all labels on this layer, `rgba(255, 255, 255, 0.9)` by default.

Labels for which the point-specific `[labelOutlineColor](#point-properties:labelOutlineColor)` was not provided will use the outline color defined by this property. The outline is only visible when `[labelOutlineWidth](#labelOutlineWidth)` is greater than zero.

Only visible when `[labelRendering](#labelRendering)` is `[sdf](#labelRendering.sdf)`.

### labelOutlineWidth

Layer-wide outline width drawn around the glyphs of all labels on this layer, in CSS pixels, `0` by default (no outline).

Labels for which the point-specific `[labelOutlineWidth](#point-properties:labelOutlineWidth)` was not provided will use the outline width defined by this property. Outlines remain screen-fixed regardless of the per-label `[labelSize](#point-properties:labelSize)`, so they look uniform across labels of different sizes.

Outlines can only grow to a fairly small limit. The limit is a few pixels on the `[glyph](#labelAtlas.glyph)` atlas, and smaller still on the `[word](#labelAtlas.word)` atlas.

Only applies when `[labelRendering](#labelRendering)` is `[sdf](#labelRendering.sdf)`.

### labelBoxColor

Layer-wide label box [color](/api-common/#data-structures:colors), `hsla(40, 75%, 80%, 0.5)` by default.

Labels for which the point-specific `[labelBoxColor](#point-properties:labelBoxColor)` was not provided will use the box color defined in this property.

### labelBoxOpacity

Layer-wide label box opacity, `0.0` by default.

Labels for which the point-specific `[labelBoxOpacity](#point-properties:labelBoxOpacity)` was not provided will be drawn with the box opacity defined by this property. As a result, if you set this property to a non-zero value, all labels for which label box opacity was not overridden will be drawn inside boxes.

### labelShadowColor

[Color](/api-common/#data-structures:colors) of the drop shadow to draw under all labels on this layer, transparent by default.

Drop shadows are a good way to lift labels off busy or dark backgrounds. The shadow is sampled from the shared label-mask, so it follows the visible glyph silhouette rather than the glyph bounding box. The shadow is only visible when `[labelShadowSize](#labelShadowSize)` is greater than zero.

### labelShadowSize

Strength of the drop shadow under all labels on this layer, `0` by default (no shadow). Larger values produce a wider and more opaque shadow.

### labelAtlasQuality

SDF glyph atlas quality preset, `standard` by default. Picks the source raster font size and the SDF reach radius used to build the glyph atlas. Higher tiers produce visibly crisper labels when zoomed in or scaled up via `[labelSize](#point-properties:labelSize)`, at the cost of fitting fewer unique glyphs in the atlas.

Accepted values:

### `low`

Smaller atlas footprint; best for dashboards with many small labels and no aggressive zoom-in.

### `standard`

Default. A good balance for ASCII at typical device pixel ratios.

### `high`

Noticeably crisper edges when zoomed in or with large `[labelSize](#point-properties:labelSize)` values.

### `ultra`

For Latin-only maps with heavy zoom-in or very large labels. Multilingual label sets (CJK) may overflow the atlas at this tier.

Higher presets fit fewer glyphs in the atlas, so a large alphabet – or a high preset at a high device pixel ratio – can overflow it. Labels that use a glyph which did not fit are dropped whole rather than drawn with missing characters, and the count is reported by `[droppedLabelCount](#droppedLabelCount)`. Lower the preset (or reduce the alphabet) if labels go missing.

Changing this property rebuilds the glyph atlas, so pick a preset at layer construction and avoid changing it per frame.

Applies only to the `[glyph](#labelAtlas.glyph)` atlas with `[sdf](#labelRendering.sdf)` rendering; the raster glyph atlas is rendered at `[labelFontSize](#labelFontSize)` and ignores this property.

### labelEdgeSharpness

Scales the SDF antialiasing band width, `4.0` by default. Higher values produce crisper glyph edges; lower values soften the antialiasing band, which can read better at very small sizes.

Only applies when `[labelRendering](#labelRendering)` is `[sdf](#labelRendering.sdf)`.

### labelEdgeThinning

Thins glyphs by fading their antialiased rim toward transparent, `0.75` by default. Higher values produce thinner strokes, up to `1.0`; `0` disables thinning. Useful for light fonts that appear overly bold at small sizes.

Only applies when `[labelRendering](#labelRendering)` is `[sdf](#labelRendering.sdf)`.

### labelMaskExpansion

Controls how far the label mask is fattened past the label edge, in source-raster pixels, `1.0` by default. Increase it to widen the area where markers fade out behind labels and the shadow cast by `[labelShadowSize](#labelShadowSize)`.

Only applies when `[labelRendering](#labelRendering)` is `[sdf](#labelRendering.sdf)`.

### labelDensity

Divisor of the spacing reserved around each label for collision, `1.0` by default. Values above `1.0` tighten the spacing so more labels fit at a given zoom level; values below `1.0` widen it for more breathing room between labels. Changing this property triggers a full visibility recomputation.

### maxScaleForLabelVisibilityScales

Maximum zoom scale considered when precomputing per-label visibility thresholds, `Infinity` by default.

At larger label counts the visibility computation runs across many zoom steps and becomes the dominant cost of setting `[points](/api-common-layer/#points)`. Capping this value (for example to `64` or `128`) reduces the number of zoom steps evaluated. The trade-off is that labels which would only be revealed beyond the cap stay hidden no matter how far the view is zoomed in, so set it past the deepest zoom you expect to use.

### maxSyncScaleForLabelVisibilityScales

Maximum zoom scale computed synchronously before the first frame, with the remainder filled in on idle frames. Defaults to one double-click worth of zoom from the base view.

Raising this value (up to `Infinity` for a fully synchronous sweep) ensures more zoom levels are pre-computed before the first paint, at the cost of a longer initial blocking pause. Lowering it reduces first-paint latency but may cause labels to pop in when zooming beyond the precomputed range before the idle sweep catches up. The current view is always covered regardless of this setting.

### droppedLabelCount

Read-only. The number of labels that could not be rendered in the most recent layout because the atlas overflowed; `0` when everything fits.

Both atlases have a finite capacity. The `[word](#labelAtlas.word)` atlas overflows when there are too many distinct words for its sprite sheet; the `[glyph](#labelAtlas.glyph)` atlas overflows when the alphabet is too large for the glyph sheet (most likely at a high `[labelAtlasQuality](#labelAtlasQuality)` preset or device pixel ratio). In both cases the affected labels are dropped whole rather than drawn with missing pieces.

Read it after a redraw to detect an overflowing layer — for example to fall back to a smaller `[labelAtlasQuality](#labelAtlasQuality)`, or to rely on `[labelAtlas](#labelAtlas)` `auto`, which picks the glyph atlas when the word atlas would drop labels.

## Methods

### state(point)

Returns layout-derived state for a single point as an object with one field, `labelVisible` — `true` when the label is being drawn at the current zoom level, `false` when it was suppressed by a higher-priority neighbor (see `[labelPriority](#point-properties:labelPriority)`). Read it after a redraw, for example to drive hit-testing or a hover affordance only for visible labels.

---

# Outline layer API

This reference describes the outline layer API.

The outline layer draws circular highlights around groups of points.

![dotAtlas outline layer.](/assets/apidocs/img/ZLWsduBWaF-1835.jpeg)

The primary use case of this type of layer is to **temporarily highlight a set of points**, for example to show that the points are selected. An extra temporary markers layer can be drawn on top of the outline to further emphasize the points.

You can create an example outline layer using the following code:

```javascript
const outline = DotAtlas.createLayer({
  points: [],
  type: "outline",
  outlineFillColor: "rgba(255, 255, 0, 0.2)",
  outlineBorderColor: "rgba(255, 255, 0, 0.8)",
  outlineSizeMultiplier: 6
});
```

See the following documentation for all the point and layer properties you can use.

## Point properties

### markerSize

Determines the diameter of the outline drawn for the specific point.

Marker size value must fall in the `0.0` ... `1.0` range. Values outside of this range will be clamped. If marker size is not provided, a size of `1.0` will be assumed.

For best results, the `markerSize` properties of the points on the outline and on the related marker layers should be equal. The easiest way to achieve this is to pass the same point instances to the outline and marker layers.

Additionally, the `[outlineSizeMultiplier](#outlineSizeMultiplier)` outline layer property should be equal to or greater than the `[markerSizeMultiplier](/api-markers-layer/#markerSizeMultiplier)` property on the related marker layers. This will ensure that the outline layer is aligned with the markers.

## Layer properties

### outlineFillColor

The [color](/api-common/#data-structures:colors) to use to fill the inside area of the outline.

### outlineBorderColor

The [color](/api-common/#data-structures:colors) to use when drawing the border around the outline.

### outlineBorderWidth

Relative size of the border drawn around the outlined area.

Values must fall in the `0.0` ... `1.0` range, where `0.0` is no outline and `1.0` is the outline filled entirely with the border color.

### outlineSizeMultiplier

The scale to use to determine the on-screen diameter of the outlined area for each point.

For the details of the on-screen size computation, see the `[markerSizeMultiplier](/api-markers-layer/#markerSizeMultiplier)` property of the markers layer.

### outlineOffset

The extra distance to apply to offset the outline boundary from the marker boundary, in pixels.

If `outlineOffset` is `0.0`, outline border would overwrite the marker's border making the visualization hard to interpret. A non-zero value will leave an extra margin around markers for the outline to stand out.

---

# Effects plugin API

This reference describes the API of the [Effects plugin](/using-plugins/#effects).

The Effects plugin adds "rollout" and "pullback" animations when new layer data is set.

## Properties

### rolloutDuration

The duration of the map "reveal" animation, in milliseconds.

### pullbackDuration

The duration of the map "conceal" animation, in milliseconds.

## Events

### onRolloutComplete

Triggered after the rollout animation is complete.

### onPullbackComplete

Triggered after the pullback animation is complete.

---

# Selection plugin API

This reference describes the API of the [Selection plugin](/using-plugins/#selection).

The `Selection` plugin adds a mechanism for interactive selection of individual or multiple markers. See the [Using selection plugin](/using-plugins/#selection) section for a high-level overview and basic code examples.

## Properties

### selection:selection

Array of currently selected points.

By default, the Selection plugin operates on points contained in the [active layer](#selection:activeLayerProvider), which by default is the bottom-most markers layer. When you get the value of the `selection:selection` property, you will receive an array of point instances corresponding to the currently selected active layer points.

When setting the `selection:selection` property, make sure you pass an array of references to point instances contained in the [active layer](#selection:activeLayerProvider). Points not belonging to the active layer won't be drawn as selected, but getting the property back will still return them.

### selection:hover

Array of points under the mouse pointer and ready for selection.

### selection:mode

Determines the [selection mode](/using-plugins/#selection:mode).

The selection mode determines which markers are included in the [selection hover layer](/using-plugins/#selection:layers) given the current position of the mouse pointer.

The `selection:mode` property supports the following values:

### `single`

The hover layer contains a single marker that is closest to the current mouse pointer location.

### `circle`

The hover layer contains all markers lying within a specified circle around the current mouse pointer location. The radius of the circle can be specified using the `[selection:clusterRadius](#selection:clusterRadius)` property.

### `cluster`

The hover layer contains all markers lying in the densely-populated region of the map determined by the current mouse pointer location. The size of the region can be adjusted using the `[selection:clusterRadius](#selection:clusterRadius)` property.

### selection:clusterRadius

Determines the selection size in the `[circle](#selection:mode:circle)` and `[cluster](#selection:mode:cluster)` selection modes.

The larger the value of this property, the larger the number of points highlighted for selection.

### selection:activeLayerProvider

Determines the layer whose points will be made selectable by this plugin.

Value of this property must be a function that returns the active layer given an array of all currently available layers. The default implementation of the active layer provider function returns the first (bottom-most) markers layer:

```javascript
layers => layers.find(l => l.get("type") === "marker");
```

### selection:layer:hoverOutline

The hover outline layer object.

This property is useful if you'd like to modify some visual properties of the hover outline layer added by this plugin:

```javascript
dotAtlas.get("selection:layer:hoverOutline").set({
  "outlineFillColor": "hsla(40, 75%, 80%, 0.5)",
  "outlineBorderWidth": 0.65
});
```

### selection:layer:hoverMarkers

The hover markers layer object.

Use this property to modify visual properties of the hover markers layer added by this plugin.

### selection:layer:selectionOutline

The selection outline layer object.

Use this property to modify visual properties of the selection outline layer added by this plugin.

## Events

### selection:onSelectionChanged

Triggered after the selection has been changed by the user.

In addition to the common [event details](/api-common/#event-details) properties, this event comes with the following additional properties:

**points**

An array of point objects corresponding to the current selection.

Please note that this event will not be triggered when the selection was changed programmatically using the `[selection:selection](#selection:selection)` property.

### selection:onMouseMove

An enhanced version of the `[onMouseMove](/api-dotatlas/#onMouseMove)` event with a list of points highlighted for selection.

In addition to the common [event details](/api-common/#event-details) properties, this event comes with the following additional properties:

**points**

An array of points highlighted for selection.

Please note that the set of highlighted points may also change as a result of `[selection:clusterRadius](#selection:clusterRadius)` and `[selection:mode](#selection:mode)` change. In those cases the `selection:onMouseMove` will not be triggered.

### selection:onClusterRadiusChanged

An enhanced version of the `[onMouseWheel](/api-dotatlas/#onMouseWheel)` event with information about the cluster radius value.

In addition to the common [event details](/api-common/#event-details) properties, this event comes with the following additional properties:

**clusterRadius**

Current value of cluster radius.

Please note that this event will not be triggered when the cluster radius was changed programmatically using the `[selection:clusterRadius](#selection:clusterRadius)` property.

---

# Lingo4G plugin API

This reference describes the API of the [Lingo4G plugin](/using-plugins/#lingo4g).

The Lingo4G plugin makes it easy to display 2d embeddings produced by Lingo4G version 2.x. The `Lingo4GDocumentMap` plugin creates the layers required to display a [2d document embedding](https://get.carrotsearch.com/lingo4g/2.0.1/doc/v2/analysis-json-embedding2d/) produced by [Lingo4G](https://carrotsearch.com/lingo4g/) [analysis API v2](https://get.carrotsearch.com/lingo4g/2.0.1/doc/v2/analysis/).

```javascript
import { DotAtlas, Lingo4GDocumentMap } from "@carrotsearch/dotatlas";

// Fetch results from Lingo4G (pseudo code below)
const lingo4GApiUrl = "https://yourserver.com/lingo4g/api/v2";
const result = await fetch(lingo4GApiUrl + "/analysis");

const dotAtlas = DotAtlas.with(Lingo4GDocumentMap).embed({
  "element": document.querySelector("#visualization"),
  "lingo4g:result": result
});
```

When you provide a new `[lingo4g:result](#lingo4g:result)`, the `Lingo4GDocumentMap` plugin creates three layers:

**elevation layer**

The plugin derives point coordinates on the elevations layer from the [2d document coordinates](https://get.carrotsearch.com/lingo4g/2.0.1/doc/v2/analysis-json-embedding2d/) returned by Lingo4G.

The plugin derives elevation values from the document's [similarity to the cluster exemplar](https://get.carrotsearch.com/lingo4g/2.0.1/doc/v2/analysis-json-clusters/), which should highlight the "importance" of each document and create a natural-looking map.

**markers layer**

Point coordinates on the markers layer represent the [2d document coordinates](https://get.carrotsearch.com/lingo4g/2.0.1/doc/v2/analysis-json-embedding2d/) returned by Lingo4G, marker size depends on the [similarity to the cluster exemplar](https://get.carrotsearch.com/lingo4g/2.0.1/doc/v2/analysis-json-clusters/). Marker color will represent the cluster the document belongs to.

The plugin uses a heuristic to compute a marker size scaling factor that makes the visualization legible regardless of the number of documents being visualized. You can use the `[lingo4g:baseMarkerSize](#lingo4g:baseMarkerSize)` property to fine-tune the size of markers this plugin produces.

**labels layer**

Coordinates and text of labels represent the labels embedding part of the Lingo4G response. The atlas granularity is chosen by `[lingo4g:labelAtlas](#lingo4g:labelAtlas)`.

See the `[lingo4g:result](#lingo4g:result)` documentation for the list of Lingo4G analysis stage results the JSON response must contain to build the layers. To customize the layers this plugin creates, use the `[lingo4g:customize:layers](#lingo4g:customize:layers)` callback.

Note that in order to get a natural-looking map, you will usually need an embedding with at least a few thousand documents.

## Properties

### lingo4g:result

The result JSON returned by the Lingo4G analysis API v2.

For the plugin to work, the response must contain results of the following analysis stages:

| Stage type | Stage name | Purpose |
| --- | --- | --- |
| [labels:\*](https://get.carrotsearch.com/lingo4g/2.0.1/doc/v2/analysis-json-labels/) | `labels` | The text of labels to display on the map. |
| [embedding2d:\*](https://get.carrotsearch.com/lingo4g/2.0.1/doc/v2/analysis-json-embedding2d/) | `labelEmbeddings2d` | Coordinates of the labels. |
| [embedding2d:\*](https://get.carrotsearch.com/lingo4g/2.0.1/doc/v2/analysis-json-embedding2d/) | `documentEmbeddings2d` | Coordinates of the documents to display on the map. |
| [clusters:\*](https://get.carrotsearch.com/lingo4g/2.0.1/doc/v2/analysis-json-clusters/) | `documentClusters` | Clusters of documents to show on the map. The plugin uses the clusters to determine the colors and elevation values of documents' markers. |
| [labelClusters:\*](https://get.carrotsearch.com/lingo4g/2.0.1/doc/v2/analysis-json-labelClusters/) | `documentClusterLabels` | Document cluster labels. The plugin uses document cluster labels to determine the [display priority](/api-labels-layer/#point-properties:labelPriority) for the labels on the map. |

By default, the plugin expects the stages to be named as listed in the **Stage name** column of the table. You can customize the stage names using the `lingo4g:result:stageName:*` properties of this plugin.

The following figure shows an example Lingo4G analysis request JSON that generates all the data required for the plugin to display a 2d map of documents. See [Lingo4G documentation](https://get.carrotsearch.com/lingo4g/2.0.1/doc/v2/) for more information about building Lingo4G analysis request JSONs.

```json
{
  "name": "Document 2d embedding with labels and clusters by embedding similarity",
  "comment": "Puts documents on a 2d map based on the multidimensional document embedding similarity. Additionally, computes 2d coordinates of labels to describe specific areas of the map and clusters documents based on their 2d embedding distance.",
  "variables": {
    "query": {
      "name": "Query",
      "comment": "Selects documents to arrange into a 2d map.",
      "value": "clustering"
    },
    "maxDocuments": {
      "name": "Max documents",
      "comment": "Maximum number of documents to include in the 2d map.",
      "value": 5000
    },
    "maxLabels": {
      "name": "Max labels",
      "comment": "Maximum number of labels to put on the 2d map.",
      "value": 500
    }
  },
  "stages": {
    "documents": {
      "type": "documents:byQuery",
      "query": {
        "type": "query:string",
        "query": {
          "@var": "query"
        }
      },
      "limit": {
        "@var": "maxDocuments"
      }
    },
    "labels": {
      "type": "labels:fromDocuments",
      "maxLabels": {
        "type": "labelCount:fixed",
        "value": {
          "@var": "maxLabels"
        }
      }
    },
    "documentEmbeddings2d": {
      "type": "embedding2d:lv",
      "matrix": {
        "type": "matrix:knnVectorsSimilarity",
        "vectors": {
          "type": "vectors:precomputedDocumentEmbeddings"
        }
      }
    },
    "labelEmbeddings2d": {
      "type": "embedding2d:lvOverlay",
      "matrix": {
        "type": "matrix:keywordLabelDocumentSimilarity",
        "labels": {
          "type": "labels:reference",
          "use": "labels"
        }
      },
      "embedding2d": {
        "type": "embedding2d:reference",
        "use": "documentEmbeddings2d"
      }
    },
    "documentClusters": {
      "type": "clusters:ap",
      "matrix": {
        "type": "matrix:knn2dDistanceSimilarity",
        "embedding2d": {
          "type": "embedding2d:reference",
          "use": "documentEmbeddings2d"
        },
        "maxNearestPoints": 96
      },
      "softening": 0.2,
      "inputPreference": -10000
    },
    "documentClusterLabels": {
      "type": "labelClusters:documentClusterLabels"
    }
  },
  "output": {
    "stages": [
      "documents",
      "documentEmbeddings2d",
      "documentClusters",
      "documentClusterLabels",
      "labels",
      "labelEmbeddings2d"
    ]
  },
  "tags": ["2D Embeddings"]
}
```

### lingo4g:result:stageName:labels

Name of the stage that provides the labels to display, `labels` by default.

### lingo4g:result:stageName:labelEmbeddings2d

Name of the stage that provides the 2d embeddings of the labels, `labelEmbeddings2d` by default.

### lingo4g:result:stageName:documentEmbeddings2d

Name of the stage that provides the 2d embeddings of the documents to display, `documentEmbeddings2d` by default.

### lingo4g:result:stageName:documentClusters

Name of the stage that provides the clusters of documents to display, `documentClusters` by default.

### lingo4g:result:stageName:documentClusterLabels

Name of the stage that provides the labels of the document clusters, `documentClusterLabels` by default.

### lingo4g:baseMarkerSize

A base value used to compute the size of document markers, `5.0` by default.

The size of markers created by this plugin is proportional to `lingo4g:baseMarkerSize`. To make the markers smaller or larger, decrease or increase this property.

### lingo4g:labelAtlas

The `[labelAtlas](/api-labels-layer/#labelAtlas)` granularity for the labels layer this plugin creates, `null` by default. When left unset the plugin uses `[auto](/api-labels-layer/#labelAtlas.auto)`, which picks the word atlas for small label sets and the glyph atlas when the word atlas would overflow – set it to `[word](/api-labels-layer/#labelAtlas.word)` or `[glyph](/api-labels-layer/#labelAtlas.glyph)` to force a specific atlas instead.

Like `[labelAtlas](/api-labels-layer/#labelAtlas)` on the layer, this is applied at layer construction; change it before the layers are created.

### lingo4g:customize:layers

A function called before the layers created by this plugin are displayed in dotAtlas. You can use this callback to customize the properties or data points of the automatically created layers.

The provided value must be a function with the following signature:

```javascript
const customizeLayers = function (layersMap, result) { };
```

The function will be called with the following parameters:

**`layersMap`**

A map of layers ready to be displayed.

The map will contain the following keys: `elevations`, `markers`, `labels`. Under each key there is the [layer object](/api-common-layer/) representing the specific layer. Use the [Elevation layer API](/api-elevations-layer/), [Marker layer API](/api-markers-layer/) and [Labels layer API](/api-labels-layer/), respectively, to tune the layers as required.

**`result`**

The `[lingo4g:result](#lingo4g:result)` for which the layers were created.

Below is an example customization function that displays the labels in italic, derives marker color from point elevation and "sharpens" elevations.

```javascript
import { DotAtlas, Lingo4GDocumentMap } from "@carrotsearch/dotatlas";

const dotAtlas = DotAtlas.with(Lingo4GDocumentMap).embed({
  "element": document.querySelector("#visualization"),
  "lingo4g:result": { /* Lingo4G result here */ },
  "lingo4g:customize:layers": ({ markers, elevations, labels }, result) => {
    labels.set("labelFontStyle", "italic");
    elevations.get("points").forEach(p => p.elevation = Math.pow(p.elevation, 2))
    markers.get("points").forEach(p => {
      p.markerColor = `rgb(${(255 * p.elevation).toFixed(0)}, 0, 0)`;
    });
  }
});
```

### lingo4g:layer:elevations

The elevations layer object created by this plugin.

You can use this property to change the visual properties of the layer, register event listeners or call layer-specific methods.

```javascript
const elevations = dotAtlas.get("lingo4g:layer:elevations");
elevations.set("lightAzimuth", Math.PI);
```

### lingo4g:layer:markers

The markers layer object created by this plugin. Use this property to get and set properties of the markers layer.

### lingo4g:layer:labels

The labels layer object created by this plugin. Use this property to get and set properties of the labels layer.

---

# Lingo4G v1 plugin API

This reference describes the API of the Lingo4G v1 [plugin](/using-plugins/).

The Lingo4G plugin makes it easy to display 2d embeddings produced by Lingo4G. The `Lingo4GDocumentMapV1` plugin creates the layers required to display a [2d document embedding](https://get.carrotsearch.com/lingo4g/latest/doc/#overview-of-document-embedding) produced by Lingo4G.

```javascript
import { DotAtlas, Lingo4GDocumentMapV1 } from "@carrotsearch/dotatlas";

// Fetch results from Lingo4G (pseudo code below)
const lingo4GApiUrl = "https://yourserver.com/lingo4g/api/v1";
const result = await fetch(lingo4GApiUrl + "/spec={}&async=false");

const dotAtlas = DotAtlas.with(Lingo4GDocumentMapV1).embed({
  "element": document.querySelector("#visualization"),
  "lingo4g:result": result
});
```

When you provide a new `[lingo4g:result](#lingo4g:result)`, the `Lingo4GDocumentMapV1` plugin creates three layers:

**elevation layer**

The plugin derives point coordinates on the elevations layer from the [2d document coordinates](https://get.carrotsearch.com/lingo4g/latest/doc/#/v1/analysis/{id}/result.response.documents.embedding) returned by Lingo4G.

The plugin derives elevation values from the document's [similarity to the cluster exemplar](https://get.carrotsearch.com/lingo4g/latest/doc/#/v1/analysis/{id}/result.response.documents.arrangement), which should highlight the "importance" of each document and create a natural-looking map.

**markers layer**

Point coordinates on the markers layer represent the [2d document coordinates](https://get.carrotsearch.com/lingo4g/latest/doc/#/v1/analysis/{id}/result.response.documents.embedding) returned by Lingo4G, marker size depends on the [similarity to the cluster exemplar](https://get.carrotsearch.com/lingo4g/latest/doc/#/v1/analysis/{id}/result.response.documents.arrangement). Marker color represents the cluster the document belongs to.

The plugin uses a heuristic to compute a marker size scaling factor that makes the visualization legible regardless of the number of documents being visualized. You can use the `[lingo4g:baseMarkerSize](#lingo4g:baseMarkerSize)` property to fine-tune the size of markers produced by this plugin.

**labels layer**

Coordinates and text of labels will represent the [label part](https://get.carrotsearch.com/lingo4g/latest/doc/#/v1/analysis/{id}/result.response.documents.embedding) of the embedding produced by Lingo4G.

See the `[lingo4g:result](#lingo4g:result)` documentation for a list of Lingo4G JSON response elements required to build the layers. To customize the layers created by this plugin, use the `[lingo4g:customize:layers](#lingo4g:customize:layers)` callback.

Note that to get a natural-looking map, you usually need an embedding with at least a few thousand documents.

## Properties

### lingo4g:result

The result JSON obtained from Lingo4G API.

For the plugin to work, the response must contain the following parts:

-   [label list](https://get.carrotsearch.com/lingo4g/latest/doc/#/v1/analysis/{id}/result.response.labels.list), enabled in Lingo4G by default.
    
-   [document embeddings](https://get.carrotsearch.com/lingo4g/latest/doc/#/v1/analysis/{id}/result.response.documents.embedding), which need to be enabled by setting the `[documents.embedding.enabled](https://get.carrotsearch.com/lingo4g/latest/doc/#documents.embedding.enabled)` Lingo4G request parameter to `true`.
    
-   [document clusters](http://get.carrotsearch.com/lingo4g/latest/doc/#/v1/analysis/{id}/result.response.documents.arrangement), which need to be enabled by setting the `[documents.arrangement.enabled](https://get.carrotsearch.com/lingo4g/latest/doc/#documents.arrangement.enabled)` Lingo4G request parameter to `true`.

### lingo4g:baseMarkerSize

A base value used to compute the size of document markers, `5.0` by default.

The size of markers created by this plugin is proportional to `lingo4g:baseMarkerSize`. To make the markers smaller or larger, decrease or increase this property.

### lingo4g:customize:layers

A function called before the layers created by this plugin are displayed in dotAtlas. You can use this callback to customize the properties or data points of the automatically created layers.

The provided value must be a function with the following signature:

```javascript
const customizeLayers = function (layersMap, result) { };
```

The function will be called with the following parameters:

**`layersMap`**

A map of layers ready to be displayed.

The map will contain the following keys: `elevations`, `markers`, `labels`. Under each key there is the [layer object](/api-common-layer/) representing the specific layer. Use the [Elevation layer API](/api-elevations-layer/), [Marker layer API](/api-markers-layer/) and [Labels layer API](/api-labels-layer/), respectively, to tune the layers as required.

**`result`**

The `[lingo4g:result](#lingo4g:result)` for which the layers were created.

Below is an example customization function that displays the labels in italic, derives marker color from point elevation and "sharpens" elevations.

```javascript
import { DotAtlas, Lingo4GDocumentMapV1 } from "@carrotsearch/dotatlas";

const dotAtlas = DotAtlas.with(Lingo4GDocumentMapV1).embed({
  "element": document.querySelector("#visualization"),
  "lingo4g:result": { /* Lingo4G result here */ },
  "lingo4g:customize:layers": ({ markers, elevations, labels }, result) => {
    labels.set("labelFontStyle", "italic");
    elevations.get("points").forEach(p => p.elevation = Math.pow(p.elevation, 2))
    markers.get("points").forEach(p => {
      p.markerColor = `rgb(${(255 * p.elevation).toFixed(0)}, 0, 0)`;
    });
  }
});
```

### lingo4g:layer:elevations

The elevations layer object created by this plugin.

You can use this property to change the visual properties of the layer, register event listeners or call layer-specific methods.

```javascript
const elevations = dotAtlas.get("lingo4g:layer:elevations");
elevations.set("lightAzimuth", Math.PI);
```

### lingo4g:layer:markers

The markers layer object created by this plugin. Use this property to get and set properties of the markers layer.

### lingo4g:layer:labels

The labels layer object created by this plugin. Use this property to get and set properties of the labels layer.

---

# Releases

dotAtlas release notes, including a review of new features, improvements, bug fixes and upgrade considerations.

## 1.1.0

Not yet released

Version 1.1.0 improves the [labels layer](/api-labels-layer/): labels can now have outlines and individual sizes, enlarged labels stay sharp. A single map can show hundreds of thousands of labels without noticeable performance regressions. Panning and zooming over [elevations](/api-elevations-layer/) is much faster. This release also fixes several [bugs](#1.1.0:bug-fixes).

dotAtlas now comes as a single package for all users. By default, the package shows the dotAtlas logo. To remove the logo, set the `[licenseKey](/api-dotatlas/#licenseKey)` option to your [license key](/installation/#license-key).

### Improvements

**Single package with a license key**

Previous versions came as separate demo and licensed packages. Version 1.1.0 replaces them with a single package, available from npm or as a distribution archive. To remove the dotAtlas logo, pass the license key string you received from Carrot Search in the new `[licenseKey](/api-dotatlas/#licenseKey)` option.

The new `[version()](/api-dotatlas/#version\(\))` instance method returns the version of dotAtlas and the details of the license. The static `[DotAtlas.branded()](/api-dotatlas/#DotAtlas.branded\(\))` method is deprecated and always returns `true`.

Both the ES module and the classic script versions of dotAtlas now require ES2022. The ES5 version is no longer available.

dotAtlas now requires [WebGL 2](/requirements/#technological-requirements).

**Crisp labels at larger sizes**

A new [label rendering mode](/api-labels-layer/#labelRendering.sdf) keeps labels sharp when they are drawn larger than their original size, for example with [per-label sizes](/api-labels-layer/#point-properties:labelSize). In previous versions, enlarged labels were blurry.

**Outlines around labels**

Labels can now have an [outline](/api-labels-layer/#labelOutlineColor), also set per label. Outlines keep labels readable over busy or dark backgrounds without the need for opaque label boxes.

**Per-label sizes**

You can now set the [size of each label](/api-labels-layer/#point-properties:labelSize), for example to make the most important labels larger.

**Many more labels on a single map**

A new [label engine](/api-labels-layer/#labelAtlas) can show hundreds of thousands of labels on a single map without noticeable performance regressions. By default, dotAtlas [picks the engine automatically](/api-labels-layer/#labelAtlas.auto). Smaller maps keep the best text quality. Larger maps trade slightly less precise letter spacing for the ability to show many more labels.

See the [Lots of labels](../../demos/labels-advanced.html) demo for an example.

**Smoother panning and zooming with elevations**

The elevations layer now caches the computed terrain and reuses it during panning and zooming. Previous versions recomputed the terrain on every frame. Changing elevation [colors](/api-elevations-layer/#colorBands), for example when switching between the light and dark theme, is also much faster. The new `[refreshMargin](/api-elevations-layer/#refreshMargin)` property controls how much larger than the view the cached area is.

**More consistent elevation rendering**

The shape of elevations no longer depends on the size and aspect ratio of the viewport. The same data produces the same terrain on any screen. Elevations with small radii stay sharp. Contour lines are more precise.

**Faster label visibility computation**

Version 1.1.0 computes the zoom levels at which labels appear more than twice as fast. On maps with many labels, labels show up sooner after loading and after label changes.

**Point double-click event and elevation offset**

Previous versions documented the `[onPointDoubleClick](/api-common-layer/#onPointDoubleClick)` layer event but never called its listeners. Version 1.1.0 fixes the issue. The `[elevationOffset](/api-elevations-layer/#elevationOffset)` property of the elevations layer, available in earlier versions, is now documented.

### Bug fixes

**Memory leak on color changes**

Previous versions leaked GPU memory every time the elevation `[colorBands](/api-elevations-layer/#colorBands)` property changed. Version 1.1.0 fixes the leak.

**Label boxes for invisible labels**

Version 1.0.0 might render [label boxes](/api-labels-layer/#point-properties:labelBoxOpacity) for labels that are not visible at the current zoom level, producing a distorted visualization. Version 1.1.0 fixes the issue.

**Elevation artifacts in Chrome**

When zooming in, previous versions might show streaks, black speckles or regular patterns in the elevations in Chrome. The artifacts were caused by reduced shader precision in Chrome. Version 1.1.0 renders elevations at full precision, which fixes the issue.

**View jumping during mouse-wheel zoom**

In previous versions, the view could jump back and forth when you zoomed with the mouse wheel while a zoom animation was still running. Version 1.1.0 fixes the issue. Continuous mouse-wheel zooming is also cheaper to animate.

**Zero marker size**

Previous versions drew markers and outlines whose `[markerSize](/api-markers-layer/#markerSize)` is `0` at full size. Version 1.1.0 draws such markers at the layer's `[minAbsoluteMarkerSize](/api-markers-layer/#minAbsoluteMarkerSize)`, as documented. Outlines of such markers are drawn at just their `[outlineOffset](/api-outline-layer/#outlineOffset)`.

## 1.0.0

Version 1.0.0 is the first official release of dotAtlas. Release 1.0.0 speeds up initialization, improves rendering of labels, makes zoom animations more fluid and improves the documentation.

### Improvements

**Faster initialization**

Version 1.0.0 makes the initialization of elevations and markers layers several times faster compared to the earlier releases. The improvement is especially visible when [visualizing large data sets](../../demos/visualizing-1m-points.html).

**Unlimited label length**

Earlier versions of dotAtlas limited labels to the first 6 words, adding an ellipsis to truncated labels. Version 1.0.0 supports labels of any length.

**More fluid mouse-wheel zoom animations**

When rapidly scrolling with the mouse wheel, previous versions would produce a stuttering zoom-in animation. dotAtlas 1.0.0 combines these multiple events into one smooth, continuous zoom transition.

**Improved elevation colors**

Release 1.0.0 improves the coloring of elevation bands for better legibility of markers and labels in the light and dark themes.

**1m+ data points demo**

Version 1.0.0 adds the [Visualizing 1M+ points](../../demos/visualizing-1m-points.html) demo. The demo shows techniques for streaming large datasets and rendering them incrementally to maintain smooth performance.

## 0.3.4

Version 0.3.4 fixes the long-standing bug causing rendering artifacts in the labels layer and improves the way dotAtlas handles the browser's viewport zooming.

### Bug fixes

**Label rendering artifacts**

Previous versions would render illegible labels when the browser's viewport was zoomed-in or -out. Version 0.3.4 fixes the issue and significantly improves handling of non-integer `devicePixelRatio` values reported by the browser. dotAtlas now dynamically reacts to both zooming-in and zooming-out of the viewport by scaling the map appropriately.

> [!WARNING]
> **Heads up, code update required!**
>
> To take advantage of the pixel density improvements, let dotAtlas manage the density automatically by removing the `pixelRatio` property from the set of options you pass during dotAtlas initialization. Alternatively, leave `pixelRatio` value explicitly set to `auto`:
>
> ```js
> const dotatlas = DotAtlas.embed({
>   element: document.getElementById("dotatlas"),
>   pixelRatio: "auto",
>   layers: []
> });
> ```

**Registration of plugin event handlers**

In the previous versions, the `[on()](/api-common/#on\(\))`, `[off()](/api-common/#off\(\))` and `[once()](/api-common/#once\(\))` methods would fail to register event handlers exposed by plugins, where the handler names contain colon-separated segments, such as `[selection:onSelectionChanged](/api-selection-plugin/#selection:onSelectionChanged)`. Version 0.3.4 fixes the problem.

## 0.3.2

Version 0.3.2 corrects the [Lingo4G plugin](/api-lingo4g-plugin/) code to use only ES6 language features to increase compatibility with legacy bundlers.

## 0.3.1

Version 0.3.1 updates the [Lingo4GDocumentMap plugin](/api-lingo4g-plugin/) to use the recently-released [Lingo4G analysis API v2](https://get.carrotsearch.com/lingo4g/2.0.1/doc/v2/).

Version 0.3.1 also fixes "choppy" mouse-wheel based zooming of the visualization.

## 0.3.0

Version 0.3.0 is a major new release that comes with proper API documentation, NPM package distribution, finalized core and plugin API and 6 example plugins.

dotAtlas 0.3.0 is mostly a drop-in upgrade for the 0.2.x line, except for the minor [API changes](#0.3.0:api-changes). However, version 0.3.0 comes with [plugins](/using-plugins/) adding many high-level features, such as [point selection](/using-plugins/#selection). You may therefore be able to replace a large portion of low-level code with an invocation of the appropriate plugin.

### New features

**NPM package**

You can now install dotAtlas as an [NPM dependency](/installation/#npm-dependency).

**Plugins**

dotAtlas 0.3.0 adds support for creating [plugins](/using-plugins/). Currently, 6 plugins are available with functionality ranging from automatic resizing of the visualization area, adding support for marker selection, to animated effects and adding map elevation legends.

**CSS3 colors**

All color-related properties, such as `[markerColor](/api-markers-layer/#markerColor)` or `[colorBands](/api-elevations-layer/#colorBands)`, now support [CSS3 color strings](/api-common/#data-structures:colors).

**Maximum zoom scale**

dotAtlas exposes the [maxZoomScale](/api-dotatlas/#maxZoomScale) option that limits the maximum scale to which the visualization can be zoomed. The default value is the scale at which rendering artifacts caused by limited precision of floating point computations start showing up.

### Bug fixes

**Label rendering artifacts**

Previous versions might render single-pixel artifacts around labels. Version 0.3.0 fixes the issue.

**Choppy mouse wheel zoom**

Previous versions would produce a stuttering animation when zoom was initiated with mouse wheel on screens with pixel ratio smaller than 1.0. Version 0.3.0 fixes the issue.

### API changes

**Elevation values not normalized**

Previous versions would normalize the points' elevation values to the `0.0`...`1.0` range. As of version 0.3.0, for consistency with the markerSize property, elevation values will be _clamped_ to the `0.0`...`1.0` range. If your code uses elevation values larger than 1.0, make sure you normalize them to the `0.0`...`1.0` range.

**`maxRadiusDivider` replaced with `maxRadius`**

Version 0.3.0 replaces the `maxRadiusDivider` property of the elevations layer with a more intuitive `maxRadius` property. With the new property, the amount of "land" on the map is now proportional to the value of `maxRadius`.

**`onHover` renamed to `onMouseMove`**

The global dotAtlas `onHover` event has been renamed to `[onMouseMove](/api-dotatlas/#onMouseMove)` to better reflect that it is different from the per-layer `[onPointHover](/api-common-layer/#onPointHover)` events. The former is fired on every mouse move regardless of whether there are any points near the mouse location or not. The latter is fired only when the mouse pointer is near some point or has just moved to an empty area.

**Properties renamed**

Two properties of the markers layer have been renamed, replacing "outline" with the more familiar "border":

| Old name | New property |
| --- | --- |
| `markerOutlineOpacity` | `[markerBorderOpacity](/api-markers-layer/#markerBorderOpacity)` |
| `markerOutlineWidth` | `[markerBorderWidth](/api-markers-layer/#markerBorderWidth)` |

Two properties of the outline layer have been renamed, replacing "stroke" with the more familiar "border". Also names of two other properties have been shortened:

| Old name | New property |
| --- | --- |
| `outlineStrokeColor` | `[outlineBorderColor](/api-outline-layer/#outlineBorderColor)` |
| `outlineStrokeWidth` | `[outlineBorderWidth](/api-outline-layer/#outlineBorderWidth)` |
| `outlineRadiusOffset` | `[outlineOffset](/api-outline-layer/#outlineOffset)` |
| `outlineRadiusMultiplier` | `[outlineSizeMultiplier](/api-outline-layer/#outlineSizeMultiplier)` |

## 0.2.1

Version 0.2.1 fixes a JavaScript error causing dotAtlas to fail on Internet Explorer 11 and Edge. Version 0.2.1 is a drop-in upgrade for version 0.2.0.

## 0.2.0

Version 0.2.0 introduces the final shape of the dotAtlas JavaScript API. While the API is not compatible with the 0.1.x releases, further compatibility-breaking changes to the API are unlikely.

### New features

**Custom elevation color bands**

You can now customize the colors used to draw elevation bands using the `[colorBands](/api-elevations-layer/#colorBands)` option of the elevations layer.

**Map legend**

You can also read the current colors and the corresponding elevation levels to create a [legend](/using-plugins/#legend) for your map.

**Label font customization**

You can now change the size, family, style, weight and variant of the font used when drawing dotAtlas labels. See the [labels layer documentation](/api-labels-layer/) for more details.

### Improvements

**Rendering performance**

Version 0.2.0 improves the speed of rendering by reducing the size and the number of costly blur operations.

### API changes

**Per-layer API**

Each dotAtlas layer is now an API-bearing object, having the `get()`, `set()`, `on()` and `off()` methods, along with layer-specific options, events and methods.

Layers can now be created using the `[DotAtlas​.createLayer()](/api-dotatlas/#DotAtlas.createLayer\(\))` static method. The returned object is the entry point to layer-specific options, events and methods.

**`DotAtlas.embed()`**

Version 0.2.0 changes the way dotAtlas is initialized. Instead of calling the constructor, use `[DotAtlas​.embed()](/api-dotatlas/#DotAtlas.embed\(\))` to embed dotAtlas into the page.

**`dataObject` option replaced with `layers`**

Data to visualize is now provided as the `[layers](/api-dotatlas/#layers)` option of dotAtlas instance. The value of the option must be an array of layer object instances created using `[DotAtlas​.createLayer()](/api-dotatlas/#DotAtlas.createLayer\(\))`.

**Extensions**

The API comes with experimental support for creating extensions to the base dotAtlas API. dotAtlas currently ships with two extensions:

-   `carrotsearch.dotatlas.theme.js`: adds support for switching between light and dark color theme for the map,
    
-   `carrotsearch.dotatlas.autoresizing.js`: resizes dotAtlas on every change of the browser window dimensions.
    

Please see the [Using plugins](/using-plugins/) article for more details.

## 0.1.2

Demo of a [workaround](../../demos/label-hover.html) for the lack of label hover detection.

## 0.1.1

WebGL support detection fix.

## 0.1.0

Initial version.

---

# Page not found

Sorry, the page you are looking for cannot be found.

Here are some options:

-   Try the search box up 👆 there, it should return what you are looking for.
    
-   Try browsing the articles listed in the menu on the left.
    
-   If you think this is an error on our part, please [let us know](mailto:info@carrotsearch.com).

---

# Performance tuning

> [!WARNING]
> Under construction, please check back later.

---

# Tutorial

This article is a step by step guide on building a more complex dotAtlas visualization, explaining: layer set-up, handling user interactions, managing selection, updating point properties and custom zooming.

In this tutorial we'll be building a visualization of a set of research papers fetched from arXiv. Our input data will be the 2d embedding of the data set generated by the Lingo4G clustering engine.

> [!WARNING]
> Under construction, please check back later.
