> For the complete documentation index, see [llms.txt](https://docs.rierino.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rierino.com/sdk-dv-ui/charts/plotly-presets.md). Agents can also search and read this documentation through its [MCP server](https://docs.rierino.com/~gitbook/mcp).

# Plotly presets

Ready-made Plotly charts that only need a query with the right field names.

A preset is a [Plotly](https://docs.rierino.com/sdk-dv-ui/charts/plotly.md) item with its traces and layout already set up. Each one reads **fixed field names**, so its query names its fields after them with `AS`:

| Preset                                                  | `type`                     | In the designer | Fields                                |
| ------------------------------------------------------- | -------------------------- | --------------- | ------------------------------------- |
| [Bar chart](#bar-chart)                                 | `RPlotlyBarChart`          | Bar Chart       | `x_value`, `y_value`                  |
| [Stack bar](#stack-bar)                                 | `RPlotlyStackBarChart`     | Stack Bar       | `name`, `x_value`, `y_value`, `color` |
| [Bar with scatter](#bar-with-scatter)                   | `RPlotlyBarWScatterChart`  | Bar-Scatter     | `y_value`, `xb_value`, `xs_value`     |
| [Vertical bar with scatter](#vertical-bar-with-scatter) | `RPlotlyVBarWScatterChart` | Bar-Scatter V   | `x_value`, `yb_value`, `ys_value`     |
| [Pie chart](#pie-chart)                                 | `RPlotyPieChart`           | Pie Chart       | `label`, `value`                      |
| [Treemap](#treemap)                                     | `RPlotlyTreeMap`           | Tree Map        | `label`, `parent`, `value`            |
| [Choropleth](#choropleth)                               | `RPlotlyChoropleth`        | Choropleth      | `location`, `z_value`                 |

All but the stack bar also read an optional `custom_data` field into the trace's `customdata`, for a [`hovertemplate`](https://plotly.com/javascript/hover-text-and-formatting/) of your own.

The presets take the same props as [Plotly](https://docs.rierino.com/sdk-dv-ui/charts/plotly.md#props), and the same settings in the Rierino designer. They show **no tooltips** on hover; see [Changing a preset](#changing-a-preset) to turn them on.

## Bar chart

Vertical bars: one per row, `x_value` the label under it and `y_value` its height. The y axis has no labels.

{% tabs %}
{% tab title="Definition" %}

```json
{
  "sources": [{ "key": "orders", "url": "SourceVisData?queryId=orders", "params": {} }],
  "layout": {
    "type": "RCard",
    "props": { "title": "Revenue by month", "classes": { "rootExtra": "relative h-72" } },
    "items": [
      {
        "type": "RPlotlyBarChart",
        "bind": {
          "query": "SELECT [month] AS x_value, SUM(revenue) AS y_value FROM orders GROUP BY [month]"
        },
        "props": {}
      }
    ]
  }
}
```

{% endtab %}

{% tab title="Sample data" %}
The rows the dashboard's sources return.

`orders` (30 rows)

```json
[
  { "month": "2026-07", "city": "Boston", "region": "North", "orders": 40, "revenue": 3200 },
  { "month": "2026-07", "city": "Chicago", "region": "North", "orders": 53, "revenue": 3777 },
  { "month": "2026-07", "city": "Austin", "region": "South", "orders": 41, "revenue": 4354 },
  { "month": "2026-07", "city": "Miami", "region": "South", "orders": 54, "revenue": 4931 },
  { "month": "2026-07", "city": "Denver", "region": "West", "orders": 42, "revenue": 5508 },
  { "month": "2026-08", "city": "Boston", "region": "North", "orders": 47, "revenue": 4291 },
  { "month": "2026-08", "city": "Chicago", "region": "North", "orders": 60, "revenue": 4868 },
  { "month": "2026-08", "city": "Austin", "region": "South", "orders": 48, "revenue": 5445 },
  { "month": "2026-08", "city": "Miami", "region": "South", "orders": 61, "revenue": 3622 },
  { "month": "2026-08", "city": "Denver", "region": "West", "orders": 49, "revenue": 4199 },
  { "month": "2026-09", "city": "Boston", "region": "North", "orders": 54, "revenue": 5382 },
  { "month": "2026-09", "city": "Chicago", "region": "North", "orders": 42, "revenue": 5959 },
  { "month": "2026-09", "city": "Austin", "region": "South", "orders": 55, "revenue": 4136 },
  { "month": "2026-09", "city": "Miami", "region": "South", "orders": 43, "revenue": 4713 },
  { "month": "2026-09", "city": "Denver", "region": "West", "orders": 56, "revenue": 5290 },
  { "month": "2026-10", "city": "Boston", "region": "North", "orders": 61, "revenue": 4073 },
  { "month": "2026-10", "city": "Chicago", "region": "North", "orders": 49, "revenue": 4650 },
  { "month": "2026-10", "city": "Austin", "region": "South", "orders": 62, "revenue": 5227 },
  { "month": "2026-10", "city": "Miami", "region": "South", "orders": 50, "revenue": 5804 },
  { "month": "2026-10", "city": "Denver", "region": "West", "orders": 63, "revenue": 3981 },
  { "month": "2026-11", "city": "Boston", "region": "North", "orders": 43, "revenue": 5164 },
  { "month": "2026-11", "city": "Chicago", "region": "North", "orders": 56, "revenue": 5741 },
  { "month": "2026-11", "city": "Austin", "region": "South", "orders": 44, "revenue": 6318 },
  { "month": "2026-11", "city": "Miami", "region": "South", "orders": 57, "revenue": 4495 },
  { "month": "2026-11", "city": "Denver", "region": "West", "orders": 45, "revenue": 5072 },
  { "month": "2026-12", "city": "Boston", "region": "North", "orders": 50, "revenue": 6255 },
  { "month": "2026-12", "city": "Chicago", "region": "North", "orders": 63, "revenue": 4432 },
  { "month": "2026-12", "city": "Austin", "region": "South", "orders": 51, "revenue": 5009 },
  { "month": "2026-12", "city": "Miami", "region": "South", "orders": 64, "revenue": 5586 },
  { "month": "2026-12", "city": "Denver", "region": "West", "orders": 52, "revenue": 6163 }
]
```

{% endtab %}
{% endtabs %}

```json
{
  "type": "RPlotlyBarChart",
  "bind": { "query": "SELECT [month] AS x_value, SUM(revenue) AS y_value FROM orders GROUP BY [month]" }
}
```

## Stack bar

A single horizontal bar split into segments, with a legend under it: one segment per row, sized by `x_value`, named by `name` and coloured by `color`. Rows with different `y_value`s make separate bars, stacked the same way.

{% tabs %}
{% tab title="Definition" %}

```json
{
  "sources": [{ "key": "channels", "url": "SourceVisData?queryId=channels", "params": {} }],
  "layout": {
    "type": "RCard",
    "props": { "title": "Revenue by channel", "classes": { "rootExtra": "relative h-44" } },
    "items": [
      {
        "type": "RPlotlyStackBarChart",
        "bind": {
          "query": "SELECT channel AS name, share AS x_value, 'all' AS y_value, CASE channel WHEN 'Web store' THEN '#9a42ff' WHEN 'Mobile app' THEN '#5f59cf' ELSE '#ff7e47' END AS color FROM channels"
        },
        "props": { "repeatContents": true }
      }
    ]
  }
}
```

{% endtab %}

{% tab title="Sample data" %}
The rows the dashboard's sources return.

`channels` (3 rows)

```json
[
  { "channel": "Web store", "share": 0.54 },
  { "channel": "Mobile app", "share": 0.31 },
  { "channel": "Marketplace", "share": 0.15 }
]
```

{% endtab %}
{% endtabs %}

```json
{
  "type": "RPlotlyStackBarChart",
  "bind": {
    "query": "SELECT channel AS name, share AS x_value, 'all' AS y_value, CASE channel WHEN 'Web store' THEN '#9a42ff' WHEN 'Mobile app' THEN '#5f59cf' ELSE '#ff7e47' END AS color FROM channels"
  },
  "props": { "repeatContents": true }
}
```

{% hint style="warning" %}
**Set repeatContents**

The preset draws one segment from one row. Without `repeatContents: true`, only the first row is shown.
{% endhint %}

## Bar with scatter

Horizontal bars with a line of points over them, such as a target or last year's value: one row per bar, `y_value` its label (the first row at the top), `xb_value` the bar's length and `xs_value` the point's position. The x axis has no labels.

{% tabs %}
{% tab title="Definition" %}

```json
{
  "sources": [{ "key": "orders", "url": "SourceVisData?queryId=orders", "params": {} }],
  "layout": {
    "type": "RCard",
    "props": {
      "title": "Revenue by city, against a $30,000 target",
      "classes": { "rootExtra": "relative h-72" }
    },
    "items": [
      {
        "type": "RPlotlyBarWScatterChart",
        "bind": {
          "query": "SELECT city AS y_value, SUM(revenue) AS xb_value, 30000 AS xs_value FROM orders GROUP BY city"
        },
        "props": {}
      }
    ]
  }
}
```

{% endtab %}

{% tab title="Sample data" %}
The rows the dashboard's sources return.

`orders` (30 rows)

```json
[
  { "month": "2026-07", "city": "Boston", "region": "North", "orders": 40, "revenue": 3200 },
  { "month": "2026-07", "city": "Chicago", "region": "North", "orders": 53, "revenue": 3777 },
  { "month": "2026-07", "city": "Austin", "region": "South", "orders": 41, "revenue": 4354 },
  { "month": "2026-07", "city": "Miami", "region": "South", "orders": 54, "revenue": 4931 },
  { "month": "2026-07", "city": "Denver", "region": "West", "orders": 42, "revenue": 5508 },
  { "month": "2026-08", "city": "Boston", "region": "North", "orders": 47, "revenue": 4291 },
  { "month": "2026-08", "city": "Chicago", "region": "North", "orders": 60, "revenue": 4868 },
  { "month": "2026-08", "city": "Austin", "region": "South", "orders": 48, "revenue": 5445 },
  { "month": "2026-08", "city": "Miami", "region": "South", "orders": 61, "revenue": 3622 },
  { "month": "2026-08", "city": "Denver", "region": "West", "orders": 49, "revenue": 4199 },
  { "month": "2026-09", "city": "Boston", "region": "North", "orders": 54, "revenue": 5382 },
  { "month": "2026-09", "city": "Chicago", "region": "North", "orders": 42, "revenue": 5959 },
  { "month": "2026-09", "city": "Austin", "region": "South", "orders": 55, "revenue": 4136 },
  { "month": "2026-09", "city": "Miami", "region": "South", "orders": 43, "revenue": 4713 },
  { "month": "2026-09", "city": "Denver", "region": "West", "orders": 56, "revenue": 5290 },
  { "month": "2026-10", "city": "Boston", "region": "North", "orders": 61, "revenue": 4073 },
  { "month": "2026-10", "city": "Chicago", "region": "North", "orders": 49, "revenue": 4650 },
  { "month": "2026-10", "city": "Austin", "region": "South", "orders": 62, "revenue": 5227 },
  { "month": "2026-10", "city": "Miami", "region": "South", "orders": 50, "revenue": 5804 },
  { "month": "2026-10", "city": "Denver", "region": "West", "orders": 63, "revenue": 3981 },
  { "month": "2026-11", "city": "Boston", "region": "North", "orders": 43, "revenue": 5164 },
  { "month": "2026-11", "city": "Chicago", "region": "North", "orders": 56, "revenue": 5741 },
  { "month": "2026-11", "city": "Austin", "region": "South", "orders": 44, "revenue": 6318 },
  { "month": "2026-11", "city": "Miami", "region": "South", "orders": 57, "revenue": 4495 },
  { "month": "2026-11", "city": "Denver", "region": "West", "orders": 45, "revenue": 5072 },
  { "month": "2026-12", "city": "Boston", "region": "North", "orders": 50, "revenue": 6255 },
  { "month": "2026-12", "city": "Chicago", "region": "North", "orders": 63, "revenue": 4432 },
  { "month": "2026-12", "city": "Austin", "region": "South", "orders": 51, "revenue": 5009 },
  { "month": "2026-12", "city": "Miami", "region": "South", "orders": 64, "revenue": 5586 },
  { "month": "2026-12", "city": "Denver", "region": "West", "orders": 52, "revenue": 6163 }
]
```

{% endtab %}
{% endtabs %}

```json
{
  "type": "RPlotlyBarWScatterChart",
  "bind": {
    "query": "SELECT city AS y_value, SUM(revenue) AS xb_value, 30000 AS xs_value FROM orders GROUP BY city"
  }
}
```

## Vertical bar with scatter

The same, upright: `x_value` the label under each bar, `yb_value` its height and `ys_value` the point's height. The bars and points share the y axis, so their values should be on the same scale.

{% tabs %}
{% tab title="Definition" %}

```json
{
  "sources": [{ "key": "orders", "url": "SourceVisData?queryId=orders", "params": {} }],
  "layout": {
    "type": "RCard",
    "props": {
      "title": "Revenue by month, against a $25,000 target",
      "classes": { "rootExtra": "relative h-72" }
    },
    "items": [
      {
        "type": "RPlotlyVBarWScatterChart",
        "bind": {
          "query": "SELECT [month] AS x_value, SUM(revenue) AS yb_value, 25000 AS ys_value FROM orders GROUP BY [month]"
        },
        "props": {}
      }
    ]
  }
}
```

{% endtab %}

{% tab title="Sample data" %}
The rows the dashboard's sources return.

`orders` (30 rows)

```json
[
  { "month": "2026-07", "city": "Boston", "region": "North", "orders": 40, "revenue": 3200 },
  { "month": "2026-07", "city": "Chicago", "region": "North", "orders": 53, "revenue": 3777 },
  { "month": "2026-07", "city": "Austin", "region": "South", "orders": 41, "revenue": 4354 },
  { "month": "2026-07", "city": "Miami", "region": "South", "orders": 54, "revenue": 4931 },
  { "month": "2026-07", "city": "Denver", "region": "West", "orders": 42, "revenue": 5508 },
  { "month": "2026-08", "city": "Boston", "region": "North", "orders": 47, "revenue": 4291 },
  { "month": "2026-08", "city": "Chicago", "region": "North", "orders": 60, "revenue": 4868 },
  { "month": "2026-08", "city": "Austin", "region": "South", "orders": 48, "revenue": 5445 },
  { "month": "2026-08", "city": "Miami", "region": "South", "orders": 61, "revenue": 3622 },
  { "month": "2026-08", "city": "Denver", "region": "West", "orders": 49, "revenue": 4199 },
  { "month": "2026-09", "city": "Boston", "region": "North", "orders": 54, "revenue": 5382 },
  { "month": "2026-09", "city": "Chicago", "region": "North", "orders": 42, "revenue": 5959 },
  { "month": "2026-09", "city": "Austin", "region": "South", "orders": 55, "revenue": 4136 },
  { "month": "2026-09", "city": "Miami", "region": "South", "orders": 43, "revenue": 4713 },
  { "month": "2026-09", "city": "Denver", "region": "West", "orders": 56, "revenue": 5290 },
  { "month": "2026-10", "city": "Boston", "region": "North", "orders": 61, "revenue": 4073 },
  { "month": "2026-10", "city": "Chicago", "region": "North", "orders": 49, "revenue": 4650 },
  { "month": "2026-10", "city": "Austin", "region": "South", "orders": 62, "revenue": 5227 },
  { "month": "2026-10", "city": "Miami", "region": "South", "orders": 50, "revenue": 5804 },
  { "month": "2026-10", "city": "Denver", "region": "West", "orders": 63, "revenue": 3981 },
  { "month": "2026-11", "city": "Boston", "region": "North", "orders": 43, "revenue": 5164 },
  { "month": "2026-11", "city": "Chicago", "region": "North", "orders": 56, "revenue": 5741 },
  { "month": "2026-11", "city": "Austin", "region": "South", "orders": 44, "revenue": 6318 },
  { "month": "2026-11", "city": "Miami", "region": "South", "orders": 57, "revenue": 4495 },
  { "month": "2026-11", "city": "Denver", "region": "West", "orders": 45, "revenue": 5072 },
  { "month": "2026-12", "city": "Boston", "region": "North", "orders": 50, "revenue": 6255 },
  { "month": "2026-12", "city": "Chicago", "region": "North", "orders": 63, "revenue": 4432 },
  { "month": "2026-12", "city": "Austin", "region": "South", "orders": 51, "revenue": 5009 },
  { "month": "2026-12", "city": "Miami", "region": "South", "orders": 64, "revenue": 5586 },
  { "month": "2026-12", "city": "Denver", "region": "West", "orders": 52, "revenue": 6163 }
]
```

{% endtab %}
{% endtabs %}

```json
{
  "type": "RPlotlyVBarWScatterChart",
  "bind": {
    "query": "SELECT [month] AS x_value, SUM(revenue) AS yb_value, 25000 AS ys_value FROM orders GROUP BY [month]"
  }
}
```

## Pie chart

A donut with a legend: one slice per row, `label` its name and `value` its size. The slices are sorted from largest to smallest and have no text on them.

{% tabs %}
{% tab title="Definition" %}

```json
{
  "sources": [{ "key": "channels", "url": "SourceVisData?queryId=channels", "params": {} }],
  "layout": {
    "type": "RCard",
    "props": { "title": "Revenue by channel", "classes": { "rootExtra": "relative h-64" } },
    "items": [
      {
        "type": "RPlotyPieChart",
        "bind": { "query": "SELECT channel AS label, share AS [value] FROM channels" },
        "props": {}
      }
    ]
  }
}
```

{% endtab %}

{% tab title="Sample data" %}
The rows the dashboard's sources return.

`channels` (3 rows)

```json
[
  { "channel": "Web store", "share": 0.54 },
  { "channel": "Mobile app", "share": 0.31 },
  { "channel": "Marketplace", "share": 0.15 }
]
```

{% endtab %}
{% endtabs %}

```json
{
  "type": "RPlotyPieChart",
  "bind": { "query": "SELECT channel AS label, share AS [value] FROM channels" }
}
```

## Treemap

Nested rectangles sized by value: one per row, `label` its name, `parent` the `label` of the rectangle it's in (empty for the outer ones) and `value` its size. A parent's value should be the total of its children.

{% tabs %}
{% tab title="Definition" %}

```json
{
  "sources": [{ "key": "orders", "url": "SourceVisData?queryId=orders", "params": {} }],
  "layout": {
    "type": "RCard",
    "props": { "title": "Revenue by region and city", "classes": { "rootExtra": "relative h-72" } },
    "items": [
      {
        "type": "RPlotlyTreeMap",
        "bind": {
          "query": "SELECT region AS label, '' AS parent, SUM(revenue) AS [value] FROM orders GROUP BY region UNION ALL SELECT city AS label, region AS parent, SUM(revenue) AS [value] FROM orders GROUP BY city, region"
        },
        "props": {}
      }
    ]
  }
}
```

{% endtab %}

{% tab title="Sample data" %}
The rows the dashboard's sources return.

`orders` (30 rows)

```json
[
  { "month": "2026-07", "city": "Boston", "region": "North", "orders": 40, "revenue": 3200 },
  { "month": "2026-07", "city": "Chicago", "region": "North", "orders": 53, "revenue": 3777 },
  { "month": "2026-07", "city": "Austin", "region": "South", "orders": 41, "revenue": 4354 },
  { "month": "2026-07", "city": "Miami", "region": "South", "orders": 54, "revenue": 4931 },
  { "month": "2026-07", "city": "Denver", "region": "West", "orders": 42, "revenue": 5508 },
  { "month": "2026-08", "city": "Boston", "region": "North", "orders": 47, "revenue": 4291 },
  { "month": "2026-08", "city": "Chicago", "region": "North", "orders": 60, "revenue": 4868 },
  { "month": "2026-08", "city": "Austin", "region": "South", "orders": 48, "revenue": 5445 },
  { "month": "2026-08", "city": "Miami", "region": "South", "orders": 61, "revenue": 3622 },
  { "month": "2026-08", "city": "Denver", "region": "West", "orders": 49, "revenue": 4199 },
  { "month": "2026-09", "city": "Boston", "region": "North", "orders": 54, "revenue": 5382 },
  { "month": "2026-09", "city": "Chicago", "region": "North", "orders": 42, "revenue": 5959 },
  { "month": "2026-09", "city": "Austin", "region": "South", "orders": 55, "revenue": 4136 },
  { "month": "2026-09", "city": "Miami", "region": "South", "orders": 43, "revenue": 4713 },
  { "month": "2026-09", "city": "Denver", "region": "West", "orders": 56, "revenue": 5290 },
  { "month": "2026-10", "city": "Boston", "region": "North", "orders": 61, "revenue": 4073 },
  { "month": "2026-10", "city": "Chicago", "region": "North", "orders": 49, "revenue": 4650 },
  { "month": "2026-10", "city": "Austin", "region": "South", "orders": 62, "revenue": 5227 },
  { "month": "2026-10", "city": "Miami", "region": "South", "orders": 50, "revenue": 5804 },
  { "month": "2026-10", "city": "Denver", "region": "West", "orders": 63, "revenue": 3981 },
  { "month": "2026-11", "city": "Boston", "region": "North", "orders": 43, "revenue": 5164 },
  { "month": "2026-11", "city": "Chicago", "region": "North", "orders": 56, "revenue": 5741 },
  { "month": "2026-11", "city": "Austin", "region": "South", "orders": 44, "revenue": 6318 },
  { "month": "2026-11", "city": "Miami", "region": "South", "orders": 57, "revenue": 4495 },
  { "month": "2026-11", "city": "Denver", "region": "West", "orders": 45, "revenue": 5072 },
  { "month": "2026-12", "city": "Boston", "region": "North", "orders": 50, "revenue": 6255 },
  { "month": "2026-12", "city": "Chicago", "region": "North", "orders": 63, "revenue": 4432 },
  { "month": "2026-12", "city": "Austin", "region": "South", "orders": 51, "revenue": 5009 },
  { "month": "2026-12", "city": "Miami", "region": "South", "orders": 64, "revenue": 5586 },
  { "month": "2026-12", "city": "Denver", "region": "West", "orders": 52, "revenue": 6163 }
]
```

{% endtab %}
{% endtabs %}

The query returns the outer rectangles and the inner ones together, with `UNION ALL`:

```sql
SELECT region AS label, '' AS parent, SUM(revenue) AS [value] FROM orders GROUP BY region
UNION ALL
SELECT city AS label, region AS parent, SUM(revenue) AS [value] FROM orders GROUP BY city, region
```

Labels must be unique: a city and a region with the same name would be one rectangle. Click a rectangle to zoom into it, and the bar at the top to go back.

## Choropleth

A world map with countries coloured by value: one per row, `location` the country's [ISO 3166-1 alpha-3](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3) code (`USA`, `DEU`, `TUR`) and `z_value` its value. Countries without a row are left blank.

{% tabs %}
{% tab title="Definition" %}

```json
{
  "sources": [{ "key": "countries", "url": "SourceVisData?queryId=countries", "params": {} }],
  "layout": {
    "type": "RCard",
    "props": { "title": "Revenue by country", "classes": { "rootExtra": "relative h-72" } },
    "items": [
      {
        "type": "RPlotlyChoropleth",
        "bind": { "query": "SELECT code AS location, revenue AS z_value FROM countries" },
        "props": { "contents": [{ "colorscale": [[0, "#e9e0ff"], [1, "#5b14b8"]] }] }
      }
    ]
  }
}
```

{% endtab %}

{% tab title="Sample data" %}
The rows the dashboard's sources return.

`countries` (12 rows)

```json
[
  { "code": "USA", "country": "United States", "revenue": 182400 },
  { "code": "CAN", "country": "Canada", "revenue": 46300 },
  { "code": "MEX", "country": "Mexico", "revenue": 21800 },
  { "code": "BRA", "country": "Brazil", "revenue": 33900 },
  { "code": "GBR", "country": "United Kingdom", "revenue": 71200 },
  { "code": "DEU", "country": "Germany", "revenue": 84500 },
  { "code": "FRA", "country": "France", "revenue": 52700 },
  { "code": "TUR", "country": "Türkiye", "revenue": 38600 },
  { "code": "IND", "country": "India", "revenue": 27400 },
  { "code": "JPN", "country": "Japan", "revenue": 49800 },
  { "code": "AUS", "country": "Australia", "revenue": 31200 },
  { "code": "ZAF", "country": "South Africa", "revenue": 12900 }
]
```

{% endtab %}
{% endtabs %}

```json
{
  "type": "RPlotlyChoropleth",
  "bind": { "query": "SELECT code AS location, revenue AS z_value FROM countries" },
  "props": { "contents": [{ "colorscale": [[0, "#e9e0ff"], [1, "#5b14b8"]] }] }
}
```

Without a `colorscale`, Plotly picks its default blue to red scale. The scale's legend is hidden; set `"showscale": true` in `contents` to show it. For country names instead of codes, set `"locationmode": "country names"`.

The map is loaded from `https://cdn.plot.ly/world_110m.json` when the chart is shown; see [Maps](https://docs.rierino.com/sdk-dv-ui/charts/plotly.md#maps) to serve it yourself.

## Changing a preset

`props` are merged onto the preset, so you only write what you change:

* **`layout` and `config`**: your settings are merged in, the preset's others stay.
* **`contents`**: the first entry is merged onto the preset's **first** trace. Here the pie gets a smaller hole, percentages on its slices, tooltips and colours of its own:

{% tabs %}
{% tab title="Definition" %}

```json
{
  "sources": [{ "key": "channels", "url": "SourceVisData?queryId=channels", "params": {} }],
  "layout": {
    "type": "RCard",
    "props": { "title": "Revenue by channel", "classes": { "rootExtra": "relative h-64" } },
    "items": [
      {
        "type": "RPlotyPieChart",
        "bind": { "query": "SELECT channel AS label, share AS [value] FROM channels" },
        "props": {
          "contents": [
            {
              "hole": 0.4,
              "textposition": "inside",
              "textinfo": "percent",
              "hoverinfo": "label+percent",
              "marker": { "colors": ["#9a42ff", "#5f59cf", "#ff7e47"] }
            }
          ]
        }
      }
    ]
  }
}
```

{% endtab %}

{% tab title="Sample data" %}
The rows the dashboard's sources return.

`channels` (3 rows)

```json
[
  { "channel": "Web store", "share": 0.54 },
  { "channel": "Mobile app", "share": 0.31 },
  { "channel": "Marketplace", "share": 0.15 }
]
```

{% endtab %}
{% endtabs %}

```json
{
  "type": "RPlotyPieChart",
  "bind": { "query": "SELECT channel AS label, share AS [value] FROM channels" },
  "props": {
    "contents": [
      {
        "hole": 0.4,
        "textposition": "inside",
        "textinfo": "percent",
        "hoverinfo": "label+percent",
        "marker": { "colors": ["#9a42ff", "#5f59cf", "#ff7e47"] }
      }
    ]
  }
}
```

To show tooltips on another preset, set `hoverinfo` on its first trace, for example `"contents": [{ "hoverinfo": "x+y" }]` on the bar chart.

### What each preset sets

The traces and layout of each preset, which your `props` are merged onto. All of them also get the [Plotly defaults](https://docs.rierino.com/sdk-dv-ui/charts/plotly.md#size-and-axes).

<details>

<summary>Bar chart</summary>

```json
{
  "contents": [
    { "type": "bar", "orientation": "v", "x": "{{x_value}}", "y": "{{y_value}}", "hoverinfo": "none", "marker": { "color": "#847EF6" }, "xaxis": "x", "yaxis": "y" }
  ],
  "layout": {
    "margin": { "b": 20 },
    "hovermode": "x",
    "xaxis": { "anchor": "y", "type": "category", "showgrid": false, "showline": false, "zeroline": false, "linecolor": "#DFEBFB", "tickfont": { "color": "#6B7794", "family": "Montserrat", "size": 11 } },
    "yaxis": { "anchor": "x", "showgrid": false, "showline": false, "zeroline": false, "gridcolor": "#DFEBFB", "linecolor": "#DFEBFB", "tickfont": { "color": "#6B7794", "family": "Montserrat", "size": 11 } }
  }
}
```

</details>

<details>

<summary>Stack bar</summary>

```json
{
  "contents": [
    { "type": "bar", "orientation": "h", "width": 0.2, "name": "{{name[0]}}", "x": ["{{x_value[0]}}"], "y": "{{y_value}}", "marker": { "color": "{{color[0]}}" }, "hoverinfo": "none" }
  ],
  "layout": {
    "barmode": "stack",
    "showlegend": true,
    "legend": { "orientation": "h", "traceorder": "normal", "bgcolor": "#FFFFFF", "font": { "color": "#363B4A", "family": "Montserrat", "size": 11 } },
    "margin": { "b": 40, "t": 0 },
    "paper_bgcolor": "#FFFFFF",
    "xaxis": { "fixedrange": true, "showgrid": false, "showline": false, "showticklabels": false, "zeroline": false },
    "yaxis": { "fixedrange": true, "showgrid": false, "showline": false, "showticklabels": false, "zeroline": false }
  }
}
```

</details>

<details>

<summary>Bar with scatter</summary>

```json
{
  "contents": [
    { "type": "bar", "orientation": "h", "x": "{{xb_value}}", "y": "{{y_value}}", "customdata": "{{custom_data}}", "hoverinfo": "none", "marker": { "color": "#847EF6" } },
    { "type": "scatter", "orientation": "h", "mode": "markers+lines", "x": "{{xs_value}}", "y": "{{y_value}}", "customdata": "{{custom_data}}", "hoverinfo": "none", "line": { "color": "#FF7E47", "width": 2 }, "marker": { "color": "#FF7E47", "gradient": { "color": "#FFFFFF", "type": "radial" }, "sizemode": "area" } }
  ],
  "layout": {
    "hovermode": "closest",
    "margin": { "pad": 20 },
    "xaxis": { "showgrid": false, "showline": false, "showticklabels": false, "zeroline": false },
    "yaxis": { "autorange": "reversed", "type": "category", "showgrid": false, "showline": false, "zeroline": false, "tickfont": { "color": "#6B7794", "family": "Montserrat", "size": 11 } }
  }
}
```

It also sets a Plotly `layout.template` (Plotly's default look); the settings above override it.

</details>

<details>

<summary>Vertical bar with scatter</summary>

```json
{
  "contents": [
    { "type": "bar", "orientation": "v", "x": "{{x_value}}", "y": "{{yb_value}}", "customdata": "{{custom_data}}", "hoverinfo": "none", "marker": { "color": "#847EF6" } },
    { "type": "scatter", "orientation": "v", "mode": "markers+lines", "x": "{{x_value}}", "y": "{{ys_value}}", "customdata": "{{custom_data}}", "hoverinfo": "none", "line": { "color": "#FF7E47", "width": 2 }, "marker": { "color": "#FF7E47", "gradient": { "color": "#FFFFFF", "type": "radial" }, "sizemode": "area" } }
  ],
  "layout": {
    "margin": { "b": 20 },
    "hovermode": "closest",
    "xaxis": { "anchor": "y", "type": "category", "showgrid": false, "showline": false, "zeroline": false, "tickfont": { "color": "#6B7794", "family": "Montserrat", "size": 11 } },
    "yaxis": { "anchor": "x", "showgrid": false, "showline": false, "showticklabels": false, "zeroline": false }
  }
}
```

</details>

<details>

<summary>Pie chart</summary>

```json
{
  "contents": [
    { "type": "pie", "values": "{{value}}", "labels": "{{label}}", "customdata": "{{custom_data}}", "hole": 0.6, "hoverinfo": "skip", "sort": true, "textposition": "none" }
  ],
  "layout": {
    "showlegend": true,
    "legend": { "x": 1, "y": 0.5, "traceorder": "normal", "bgcolor": "#FFFFFF", "font": { "color": "#363B4A", "family": "Montserrat", "size": 11 } }
  }
}
```

</details>

<details>

<summary>Treemap</summary>

```json
{
  "contents": [
    { "type": "treemap", "values": "{{value}}", "labels": "{{label}}", "parents": "{{parent}}", "customdata": "{{custom_data}}", "marker": { "line": { "color": "#FFFFFF" } }, "textfont": { "color": "#20075A", "family": "Montserrat" }, "textposition": "middle center" }
  ],
  "layout": { "treemapcolorway": ["rgb(95.0, 89.0, 207.0)"] }
}
```

</details>

<details>

<summary>Choropleth</summary>

```json
{
  "contents": [
    { "type": "choropleth", "locations": "{{location}}", "z": "{{z_value}}", "customdata": "{{custom_data}}", "locationmode": "ISO-3", "autocolorscale": false, "showscale": false, "marker": { "line": { "color": "#FFFFFF" } } }
  ],
  "layout": {
    "geo": { "scope": "world", "projection": { "type": "equirectangular" }, "showcoastlines": false, "showcountries": true, "countrycolor": "rgb(240.0, 240.0, 255.0)", "showframe": false }
  }
}
```

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.rierino.com/sdk-dv-ui/charts/plotly-presets.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

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