# 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](https://github.com/CartoDB/gitbook-documentation/blob/master/carto-for-developers/key-concepts/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%2Fgit-blob-45eb179e2e70924e5be4b46b354f881f9343978e%2FScreenshot%202024-10-07%20at%2015.12.59.png?alt=media" 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.

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](https://docs.carto.com/carto-for-developers/key-concepts/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%2Fgit-blob-7cd62ca5a1504cb8ea81389738076159634aacff%2FScreenshot%202024-10-07%20at%2015.56.21.png?alt=media" alt=""><figcaption></figcaption></figure>

## Get started

* Complete [technical reference for CARTO Widgets](https://docs.carto.com/carto-for-developers/reference/carto-widgets-reference)
* We have prepared a set of [examples showcasing charts and widgets](https://docs.carto.com/carto-for-developers/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" %}
