> 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/echarts-templates.md). Agents can also search and read this documentation through its [MCP server](https://docs.rierino.com/~gitbook/mcp).

# E-Charts templates

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

A template is an [E-Charts](https://docs.rierino.com/sdk-dv-ui/charts/echarts.md) item with its option already set up. Each one reads **fixed field names**, so its query names its fields after them with `AS`:

| Template                        | `type`                | Fields                                     |
| ------------------------------- | --------------------- | ------------------------------------------ |
| [Bar](#bar)                     | `REChartsBar`         | `x_value`, `y_value`                       |
| [Bar with line](#bar-with-line) | `REChartsBarWScatter` | a label field, `x_value`, `y_value`, `val` |
| [Stack bar](#stack-bar)         | `REChartsStackBar`    | `name`, `value`, `color`                   |
| [Treemap](#treemap)             | `REChartsTreemap`     | `name`, `value`, `color`                   |

The templates take the same props as [E-Charts](https://docs.rierino.com/sdk-dv-ui/charts/echarts.md#props). They aren't in the Rierino designer's component list: write the `type` in the item's JSON.

All four are 14rem tall (the stack bar 5rem), and their tooltips are on, except the stack bar's.

## Bar

Vertical bars with rounded tops: one per row, `x_value` the label under it and `y_value` its height. The template hides the labels under the bars and the y axis; this example shows the labels again.

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

```json
{
  "sources": [{ "key": "goals", "url": "SourceVisData?queryId=goals", "params": {} }],
  "layout": {
    "type": "RCard",
    "props": { "title": "Progress by goal", "classes": { "rootExtra": "relative h-72" } },
    "items": [
      {
        "type": "REChartsBar",
        "bind": { "query": "SELECT goal AS x_value, progress AS y_value FROM goals" },
        "props": { "option": { "xAxis": { "show": true }, "grid": { "bottom": 8 } } }
      }
    ]
  }
}
```

{% endtab %}

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

`goals` (3 rows)

```json
[
  { "goal": "Revenue", "progress": 0.72 },
  { "goal": "New customers", "progress": 0.45 },
  { "goal": "Repeat orders", "progress": 0.9 }
]
```

{% endtab %}
{% endtabs %}

```json
{
  "type": "REChartsBar",
  "bind": { "query": "SELECT goal AS x_value, progress AS y_value FROM goals" },
  "props": { "option": { "xAxis": { "show": true }, "grid": { "bottom": 8 } } }
}
```

The template's grid ends below the chart (`"bottom": "-10%"`), so the labels need a `grid.bottom` of their own.

## Bar with line

Horizontal bars, with a line through a second value on each bar, such as a target. The **first field** of the query labels the bars, `x_value` is the bar's length, `y_value` the line's point on it, and `val` the text written on the bar.

{% 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": "REChartsBarWScatter",
        "bind": {
          "query": "SELECT city, SUM(revenue) AS x_value, 30000 AS y_value, '$' + SUM(revenue) AS val FROM orders GROUP BY city"
        }
      }
    ]
  }
}
```

{% 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": "REChartsBarWScatter",
  "bind": {
    "query": "SELECT city, SUM(revenue) AS x_value, 30000 AS y_value, '$' + SUM(revenue) AS val FROM orders GROUP BY city"
  }
}
```

The first row is drawn at the bottom. Without `val`, the bars have no text.

## Stack bar

One thin horizontal bar split into segments, one per row, with a legend below: `name` is the segment's name, `value` its size and `color` its colour. Set `repeatContents: true`: without it, only the first row is drawn.

{% 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-40" } },
    "items": [
      {
        "type": "REChartsStackBar",
        "bind": {
          "query": "SELECT channel AS name, share AS [value], CASE channel WHEN 'Web store' THEN '#9a42ff' WHEN 'Mobile app' THEN '#ff7e47' ELSE '#22c55e' 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": "REChartsStackBar",
  "bind": {
    "query": "SELECT channel AS name, share AS [value], CASE channel WHEN 'Web store' THEN '#9a42ff' WHEN 'Mobile app' THEN '#ff7e47' ELSE '#22c55e' END AS color FROM channels"
  },
  "props": { "repeatContents": true }
}
```

## Treemap

A box per row, sized by `value` and labelled with `name`. `color` gives the boxes' colours.

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

```json
{
  "sources": [{ "key": "orders", "url": "SourceVisData?queryId=orders", "params": {} }],
  "layout": {
    "type": "RCard",
    "props": {
      "title": "Revenue by city, coloured by region",
      "classes": { "rootExtra": "relative h-72" }
    },
    "items": [
      {
        "type": "REChartsTreemap",
        "bind": {
          "query": "SELECT city AS name, SUM(revenue) AS [value], CASE region WHEN 'North' THEN '#9a42ff' WHEN 'South' THEN '#ff7e47' ELSE '#22c55e' END AS color FROM orders GROUP BY city, region ORDER BY [value] DESC"
        }
      }
    ]
  }
}
```

{% 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": "REChartsTreemap",
  "bind": {
    "query": "SELECT city AS name, SUM(revenue) AS [value], CASE region WHEN 'North' THEN '#9a42ff' WHEN 'South' THEN '#ff7e47' ELSE '#22c55e' END AS color FROM orders GROUP BY city, region ORDER BY [value] DESC"
  }
}
```

## Changing a template

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

* **`option`** and **`style`**: your settings are merged in, the template's others stay, as in the bar example above.
* **`series`**: the first entry is merged onto the template's **first** series.

### What each template sets

All four are merged onto the [E-Charts built-in option](https://docs.rierino.com/sdk-dv-ui/charts/echarts.md#built-in-option).

<details>

<summary>Bar</summary>

```json
{
  "style": { "height": "14rem" },
  "option": {
    "color": ["rgb(132.0, 126.0, 246.0)", "#FF7E47"],
    "itemStyle": { "borderRadius": 10 },
    "tooltip": { "show": true, "trigger": "item" },
    "xAxis": { "type": "category" },
    "yAxis": {
      "show": true,
      "type": "value",
      "axisLine": { "show": false },
      "axisTick": { "show": false },
      "axisLabel": { "show": false }
    },
    "grid": { "top": "0%", "left": "3%", "right": "4%", "bottom": "-10%", "containLabel": true },
    "series": [
      {
        "type": "bar",
        "tooltip": { "_formatter": "…" },
        "emphasis": { "focus": "series" },
        "encode": { "x": "x_value", "y": "y_value", "tooltip": ["x_value", "y_value", "category"] }
      }
    ]
  }
}
```

</details>

<details>

<summary>Bar with line</summary>

```json
{
  "style": { "height": "14rem" },
  "option": {
    "color": ["rgb(132.0, 126.0, 246.0)", "#FF7E47"],
    "itemStyle": { "borderRadius": 10 },
    "tooltip": { "show": true, "trigger": "item" },
    "xAxis": { "type": "value" },
    "yAxis": {
      "show": true,
      "type": "category",
      "axisLabel": { "formatter": "{v|{value}}", "rich": { "v": { "fontFamily": "Montserrat", "fontSize": 11, "color": "#363B4A" } } },
      "axisLine": { "show": false },
      "axisTick": { "show": false }
    },
    "grid": { "top": "0%", "left": "3%", "right": "4%", "bottom": "-10%", "containLabel": true },
    "series": [
      {
        "type": "bar",
        "label": {
          "show": true,
          "formatter": "{v|{@val}}",
          "rich": { "v": { "fontFamily": "Montserrat", "fontSize": 16, "color": "#f0f0ff" } }
        },
        "emphasis": { "focus": "series" },
        "encode": { "x": "x_value" }
      },
      { "type": "line", "encode": { "x": "y_value" } }
    ]
  }
}
```

</details>

<details>

<summary>Stack bar</summary>

```json
{
  "style": { "height": "5rem" },
  "option": {
    "color": "{{color}}",
    "itemStyle": { "borderRadius": 10 },
    "xAxis": { "type": "value" },
    "yAxis": { "type": "category" },
    "grid": { "top": "0%", "left": "4%", "right": "4%", "bottom": "0%", "containLabel": true },
    "legend": { "type": "scroll", "bottom": 5, "textStyle": { "fontFamily": "Montserrat", "fontSize": 11 } },
    "series": [
      {
        "type": "bar",
        "stack": "total",
        "name": "{{name[0]}}",
        "emphasis": { "disabled": true },
        "barWidth": "10",
        "data": ["{{value[0]}}"]
      }
    ]
  }
}
```

</details>

<details>

<summary>Treemap</summary>

```json
{
  "style": { "height": "14rem" },
  "option": {
    "color": "{{color}}",
    "tooltip": { "show": true, "backgroundColor": "#FFFFFF", "borderColor": "#FFFFFF" },
    "series": [
      {
        "type": "treemap",
        "roam": "move",
        "nodeClick": false,
        "breadcrumb": { "show": false },
        "bottom": "0%",
        "width": "100%",
        "height": "90%",
        "label": { "show": true, "formatter": "{b}", "fontFamily": "Montserrat", "fontSize": 12 },
        "itemStyle": { "borderColor": "#fff", "borderRadius": 10 },
        "levels": [
          { "itemStyle": { "borderWidth": 0, "gapWidth": 5 } },
          { "itemStyle": { "gapWidth": 1 } },
          { "colorSaturation": [0.35, 0.5], "itemStyle": { "gapWidth": 1, "borderColorSaturation": 0.6 } }
        ]
      }
    ]
  }
}
```

</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/echarts-templates.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.
