# Charts and widgets

With CARTO for Developers you can easily build customizable and interactive data widgets, using live data from your cloud data warehouse, on top of your [CARTO + deck.gl](carto-for-deck.gl) map.

<figure><img src="https://3029946802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FybPdpmLltPkzGFvz7m8A%2Fuploads%2F4giRmFlMDfNpXGEAyQ2b%2FScreenshot%202024-10-07%20at%2015.12.59.png?alt=media&#x26;token=cbed2d77-1a4f-4525-897b-b4dae0b3d061" alt=""><figcaption><p>An example using a Formula widget and a Categories widget</p></figcaption></figure>

## What is a widget?

Widgets in CARTO are a series of flexible **data models** from the same data sources you can use in your maps.&#x20;

For example, the _Formula widget_ represents a single numerical statistic, such as an average or a count out of the column you define. And the _Categories widget_ allows you to group and aggregate based on columns of your choice.

You can then turn those data models into **interactive charts, filters and other HTML elements**.

## How do I create widgets?

Adding widgets is easy. You just need to define your [data sources](data-sources) from `carto-api-client` just like you do in the CARTO module in deck.gl, and then use any of their `widgetSource` data models, such as `yourSource.widgetSource.getCategories()`:

<pre class="language-typescript"><code class="lang-typescript">import {VectorTableSource} from 'carto-api-client';

// define auth parameters in cartoConfig
  
<strong>const dataSource = await vectorTableSource({
</strong>  ...cartoConfig,
  tableName: 'carto-demo-data.demo_tables.osm_pois_usa'
})

const categories = await dataSource.widgetSource.getCategories({
  column: 'group_name',
  operation: 'count'
}) 

// categories will return the corresponding aggregation by the column group_name,
// you can then plug categories into any charting library or HTML element

</code></pre>

A widget is a purposefully ample concept because it can be transformed into pretty much anything. A widget in CARTO can turn into

* **Custom HTML data representations:** such as scorecards, tables or natural text.
* **Charts and other visualizations:** you can use your favorite JS charting library to build bar charts, pie charts, radar charts and other charts.
* **Inputs and other interactive elements:** some data models work great to build interactive inputs (such as range sliders) or you can easily build cross-filtering when users click in your charts.

<figure><img src="https://3029946802-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FybPdpmLltPkzGFvz7m8A%2Fuploads%2FOJvwHJNlHTa8C6aXXXGe%2FScreenshot%202024-10-07%20at%2015.56.21.png?alt=media&#x26;token=e81c8ecf-551c-49b8-96f9-537ec623f149" alt=""><figcaption></figcaption></figure>

## Get started

* Complete [technical reference for CARTO Widgets](../reference/carto-widgets-reference)
* We have prepared a set of [examples showcasing charts and widgets](../examples)

## Community

Our community in Slack is a great place to ask questions, share your work with other CARTO users, and get help from CARTO experts. **Join here** :arrow\_down:

{% embed url="https://join.slack.com/t/cartousercommunity/shared_invite/zt-t7t7k5s4-3c4pZJLrLlkVow3AEDt~ZQ" fullWidth="false" %}
