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

# Dashboard

The React component that shows a Rierino dashboard by its id.

```tsx
import { Dashboard } from '@rierino-open/dv';
import '@rierino-open/dv/styles.css';

<Dashboard client={client} id="store-overview" loading={<p>Loading the dashboard…</p>} />;
```

`<Dashboard>` shows one data visualization of your Rierino server: `id` is its id on the **Data Visualizations** screen, and `client` is the [api-client](https://docs.rierino.com/sdk-dv-ui/getting-started/quick-start.md#create-a-client) that sets the server and signs the requests.

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

```json
{
  "sources": [{ "key": "orders", "url": "SourceVisData?queryId=orders", "params": {}, "refresh": 0 }],
  "layout": {
    "type": "RCol",
    "items": [
      {
        "type": "RGrid",
        "props": { "cols": 3 },
        "items": [
          {
            "type": "RCard",
            "props": { "classes": { "rootExtra": "relative h-20" } },
            "items": [
              {
                "type": "RIconStat",
                "bind": {
                  "query": "SELECT SUM(revenue) AS [value], 0.12 AS trend FROM orders WHERE [month] = '2026-12'"
                },
                "props": {
                  "title": "Revenue this month",
                  "icon": "value",
                  "classes": { "rootExtra": "h-full items-center", "left": "px-2 mr-2" },
                  "valueFormat": {
                    "options": { "style": "currency", "currency": "USD", "maximumFractionDigits": 0 }
                  }
                }
              }
            ]
          },
          {
            "type": "RCard",
            "props": { "classes": { "rootExtra": "relative h-20" } },
            "items": [
              {
                "type": "RIconStat",
                "bind": {
                  "query": "SELECT SUM(orders) AS [value], -0.03 AS trend FROM orders WHERE [month] = '2026-12'"
                },
                "props": {
                  "title": "Orders this month",
                  "icon": "quantity",
                  "classes": { "rootExtra": "h-full items-center", "left": "px-2 mr-2" },
                  "valueFormat": { "options": { "maximumFractionDigits": 0 } }
                }
              }
            ]
          },
          {
            "type": "RCard",
            "props": { "classes": { "rootExtra": "relative h-20" } },
            "items": [
              {
                "type": "RIconStat",
                "bind": {
                  "query": "SELECT SUM(revenue) / SUM(orders) AS [value], 0 AS trend FROM orders"
                },
                "props": {
                  "title": "Average order",
                  "icon": "average",
                  "classes": { "rootExtra": "h-full items-center", "left": "px-2 mr-2" },
                  "valueFormat": {
                    "options": { "style": "currency", "currency": "USD", "maximumFractionDigits": 0 }
                  }
                }
              }
            ]
          }
        ]
      },
      {
        "type": "RGrid",
        "props": { "cols": 3 },
        "items": [
          {
            "type": "RCard",
            "props": {
              "title": "Revenue by month",
              "classes": { "rootExtra": "relative h-72 col-span-2" }
            },
            "items": [
              {
                "type": "RECharts",
                "bind": {
                  "query": "SELECT [month], SUM(revenue) AS revenue FROM orders GROUP BY [month] ORDER BY [month]"
                },
                "props": {
                  "style": { "height": 230 },
                  "option": {
                    "grid": { "left": 48, "right": 8, "top": 16, "bottom": 24 },
                    "xAxis": { "show": true, "type": "category" },
                    "yAxis": { "show": true },
                    "tooltip": { "show": true, "trigger": "axis" },
                    "series": [
                      {
                        "type": "bar",
                        "encode": { "x": "month", "y": "revenue" },
                        "itemStyle": { "color": "#9a42ff" }
                      }
                    ]
                  }
                }
              }
            ]
          },
          {
            "type": "RCard",
            "props": { "title": "Top cities", "classes": { "rootExtra": "relative h-72" } },
            "items": [
              {
                "type": "RList",
                "bind": {
                  "query": "SELECT city, SUM(revenue) AS revenue FROM orders GROUP BY city ORDER BY revenue DESC"
                },
                "props": {
                  "icon": "●",
                  "nameField": "city",
                  "valueField": "revenue",
                  "valueFormat": {
                    "options": { "style": "currency", "currency": "USD", "maximumFractionDigits": 0 }
                  }
                }
              }
            ]
          }
        ]
      }
    ]
  }
}
```

{% 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 %}

{% tab title="Code" %}
{% code title="dashboard/basic.tsx" %}

```tsx
import { Dashboard } from "@rierino-open/dv";
import { client } from "@/lib/rierino";

export default function Basic() {
  return <Dashboard client={client} id="store-overview" loading={<p>Loading the dashboard…</p>} />;
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Filters

```tsx
<Dashboard client={client} id="store-overview" filter={{ region, city }} />
```

`filter` is an object of values that the dashboard sends to its sources. Changing it loads the data again.

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

```json
{
  "sources": [{ "key": "orders", "url": "SourceVisData?queryId=orders", "params": {}, "refresh": 0 }],
  "layout": {
    "type": "RCol",
    "items": [
      {
        "type": "RGrid",
        "props": { "cols": 3 },
        "items": [
          {
            "type": "RCard",
            "props": { "classes": { "rootExtra": "relative h-20" } },
            "items": [
              {
                "type": "RIconStat",
                "bind": {
                  "query": "SELECT SUM(revenue) AS [value], 0.12 AS trend FROM orders WHERE [month] = '2026-12'"
                },
                "props": {
                  "title": "Revenue this month",
                  "icon": "value",
                  "classes": { "rootExtra": "h-full items-center", "left": "px-2 mr-2" },
                  "valueFormat": {
                    "options": { "style": "currency", "currency": "USD", "maximumFractionDigits": 0 }
                  }
                }
              }
            ]
          },
          {
            "type": "RCard",
            "props": { "classes": { "rootExtra": "relative h-20" } },
            "items": [
              {
                "type": "RIconStat",
                "bind": {
                  "query": "SELECT SUM(orders) AS [value], -0.03 AS trend FROM orders WHERE [month] = '2026-12'"
                },
                "props": {
                  "title": "Orders this month",
                  "icon": "quantity",
                  "classes": { "rootExtra": "h-full items-center", "left": "px-2 mr-2" },
                  "valueFormat": { "options": { "maximumFractionDigits": 0 } }
                }
              }
            ]
          },
          {
            "type": "RCard",
            "props": { "classes": { "rootExtra": "relative h-20" } },
            "items": [
              {
                "type": "RIconStat",
                "bind": {
                  "query": "SELECT SUM(revenue) / SUM(orders) AS [value], 0 AS trend FROM orders"
                },
                "props": {
                  "title": "Average order",
                  "icon": "average",
                  "classes": { "rootExtra": "h-full items-center", "left": "px-2 mr-2" },
                  "valueFormat": {
                    "options": { "style": "currency", "currency": "USD", "maximumFractionDigits": 0 }
                  }
                }
              }
            ]
          }
        ]
      },
      {
        "type": "RGrid",
        "props": { "cols": 3 },
        "items": [
          {
            "type": "RCard",
            "props": {
              "title": "Revenue by month",
              "classes": { "rootExtra": "relative h-72 col-span-2" }
            },
            "items": [
              {
                "type": "RECharts",
                "bind": {
                  "query": "SELECT [month], SUM(revenue) AS revenue FROM orders GROUP BY [month] ORDER BY [month]"
                },
                "props": {
                  "style": { "height": 230 },
                  "option": {
                    "grid": { "left": 48, "right": 8, "top": 16, "bottom": 24 },
                    "xAxis": { "show": true, "type": "category" },
                    "yAxis": { "show": true },
                    "tooltip": { "show": true, "trigger": "axis" },
                    "series": [
                      {
                        "type": "bar",
                        "encode": { "x": "month", "y": "revenue" },
                        "itemStyle": { "color": "#9a42ff" }
                      }
                    ]
                  }
                }
              }
            ]
          },
          {
            "type": "RCard",
            "props": { "title": "Top cities", "classes": { "rootExtra": "relative h-72" } },
            "items": [
              {
                "type": "RList",
                "bind": {
                  "query": "SELECT city, SUM(revenue) AS revenue FROM orders GROUP BY city ORDER BY revenue DESC"
                },
                "props": {
                  "icon": "●",
                  "nameField": "city",
                  "valueField": "revenue",
                  "valueFormat": {
                    "options": { "style": "currency", "currency": "USD", "maximumFractionDigits": 0 }
                  }
                }
              }
            ]
          }
        ]
      }
    ]
  }
}
```

{% 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 %}

{% tab title="Code" %}
{% code title="dashboard/filter.tsx" %}

```tsx
import { useState, type CSSProperties } from "react";
import { Dashboard } from "@rierino-open/dv";
import { client } from "@/lib/rierino";

const regions = ["North", "South", "West"];
const citiesByRegion: Record<string, string[]> = {
  North: ["Boston", "Chicago"],
  South: ["Austin", "Miami"],
  West: ["Denver"],
};

export default function WithFilters() {
  const [region, setRegion] = useState("");
  const [city, setCity] = useState("");
  const cities = region ? citiesByRegion[region] : Object.values(citiesByRegion).flat();

  function pickRegion(value: string) {
    setRegion(value);
    // a city of another region would leave nothing to show
    if (value && !citiesByRegion[value].includes(city)) setCity("");
  }

  function clear() {
    setRegion("");
    setCity("");
  }

  // only the filters that are set
  const filter = { ...(region && { region }), ...(city && { city }) };

  return (
    <div>
      <div style={styles.bar}>
        <div>
          <div style={styles.label}>Region</div>
          <div style={styles.segments}>
            {["", ...regions].map((value) => (
              <button
                key={value}
                onClick={() => pickRegion(value)}
                style={{ ...styles.segment, ...(region === value ? styles.selected : {}) }}
              >
                {value || "All"}
              </button>
            ))}
          </div>
        </div>

        <label>
          <div style={styles.label}>City</div>
          <select value={city} onChange={(e) => setCity(e.target.value)} style={styles.select}>
            <option value="">All cities</option>
            {cities.map((value) => (
              <option key={value}>{value}</option>
            ))}
          </select>
        </label>

        {(region || city) && (
          <button onClick={clear} style={styles.clear}>
            Clear filters
          </button>
        )}
      </div>

      <Dashboard client={client} id="store-overview" filter={filter} />
    </div>
  );
}

const chevron =
  "url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7794' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E\")";

const styles: Record<string, CSSProperties> = {
  bar: {
    display: "flex",
    flexWrap: "wrap",
    alignItems: "flex-start",
    gap: 20,
    marginBottom: 16,
    padding: "12px 16px",
    background: "#fff",
    border: "1px solid #e9e8fc",
    borderRadius: 12,
  },
  label: { marginBottom: 6, fontSize: 11, fontWeight: 600, letterSpacing: 0.4, textTransform: "uppercase", color: "#8f97ae" },
  segments: { display: "inline-flex", gap: 2, padding: 3, background: "#f4f0ff", borderRadius: 10 },
  segment: {
    padding: "6px 14px",
    border: "none",
    borderRadius: 8,
    background: "transparent",
    color: "#515a70",
    font: "inherit",
    fontSize: 13,
    fontWeight: 500,
    cursor: "pointer",
  },
  selected: { background: "#fff", color: "#6c3bde", boxShadow: "0 1px 3px rgb(27 6 76 / 0.12)" },
  select: {
    minWidth: 160,
    height: 36,
    padding: "0 32px 0 12px",
    border: "1px solid #d3d6df",
    borderRadius: 8,
    background: `#fff ${chevron} no-repeat right 10px center`,
    color: "#363b4a",
    font: "inherit",
    fontSize: 13,
    appearance: "none",
    outlineColor: "#9a42ff",
    cursor: "pointer",
  },
  clear: {
    alignSelf: "flex-end",
    marginLeft: "auto",
    padding: "9px 4px",
    border: "none",
    background: "none",
    color: "#6c3bde",
    font: "inherit",
    fontSize: 13,
    fontWeight: 500,
    cursor: "pointer",
  },
};
```

{% endcode %}
{% endtab %}
{% endtabs %}

Each value is sent to every source as a query parameter, and the source's API decides what to do with it, for example use it in the query that selects the rows. Leave out the filters that aren't set, rather than sending them empty.

{% hint style="info" %}
In this example, the stand-in server keeps the rows whose fields match the filter.
{% endhint %}

## Loading and errors

```tsx
<Dashboard
  client={client}
  id="store-overview"
  loading={<Spinner />}
  error={(e) => <p>Couldn't load the dashboard ({e.status}).</p>}
  onError={(e) => report(e)}
/>
```

A dashboard loads in two steps, its definition and then its sources, and each can fail on its own:

|                | While it loads                       | When it fails                               |
| -------------- | ------------------------------------ | ------------------------------------------- |
| **Definition** | `loading`, or nothing                | `error`, or nothing; `onError` is called    |
| **A source**   | A spinner on each item that reads it | Those items stay empty; `onError` is called |

### Loading

`loading` is shown until the definition is in, also after each [filter](#filters) change. Without it, the dashboard shows nothing until then.

After that, the layout is shown, and each item shows a spinner over itself until the sources its query reads are in. Items whose sources are in already show their data, so a dashboard fills in item by item.

### The dashboard can't be loaded

When the definition can't be loaded, `error` is shown in place of the dashboard. It can be an element, or a function that gets the [error](#dashboarderror):

{% code title="dashboard/not-found.tsx" %}

```tsx
import { useState } from "react";
import { Dashboard } from "@rierino-open/dv";
import { client } from "@/lib/rierino";

export default function NotFound() {
  const [last, setLast] = useState("");

  return (
    <div>
      <Dashboard
        client={client}
        id="no-such-dashboard"
        loading={<p>Loading the dashboard…</p>}
        error={(error) => <p style={{ color: "#c0392b" }}>Couldn't load the dashboard ({error.status}).</p>}
        onError={(error) => setLast(`${error.status} ${error.message}`)}
      />
      <p style={{ marginTop: 12, opacity: 0.7 }}>onError: {last || "-"}</p>
    </div>
  );
}
```

{% endcode %}

Without `error`, the dashboard shows nothing.

### A source can't be loaded

The rest of the dashboard still works: the items that read the source show no data, and `onError` is called. Here the second card reads a source the server doesn't have:

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

```json
{
  "sources": [
    { "key": "orders", "url": "SourceVisData?queryId=orders", "params": {} },
    { "key": "refunds", "url": "SourceVisData?queryId=refunds", "params": {} }
  ],
  "layout": {
    "type": "RGrid",
    "props": { "cols": 2 },
    "items": [
      {
        "type": "RCard",
        "props": { "title": "Orders", "classes": { "rootExtra": "relative h-28" } },
        "items": [
          {
            "type": "RIconStat",
            "bind": { "query": "SELECT SUM(orders) AS [value] FROM orders" },
            "props": { "title": "All orders", "icon": "quantity" }
          }
        ]
      },
      {
        "type": "RCard",
        "props": { "title": "Refunds", "classes": { "rootExtra": "relative h-28" } },
        "items": [
          {
            "type": "RIconStat",
            "bind": { "query": "SELECT COUNT(*) AS [value] FROM refunds" },
            "props": { "title": "All refunds", "icon": "quantity" }
          }
        ]
      }
    ]
  }
}
```

{% 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 }
]
```

`refunds` (0 rows)

```json
[

]
```

{% endtab %}

{% tab title="Code" %}
{% code title="dashboard/source-error.tsx" %}

```tsx
import { useState } from "react";
import { Dashboard } from "@rierino-open/dv";
import { client } from "@/lib/rierino";

export default function SourceError() {
  const [errors, setErrors] = useState<string[]>([]);

  return (
    <div>
      <Dashboard
        client={client}
        id="missing-source"
        onError={(error) => setErrors((list) => [...list, `${error.status} ${error.message}`])}
      />
      <p style={{ marginTop: 12, opacity: 0.7 }}>onError: {errors.join(", ") || "-"}</p>
    </div>
  );
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

`onError` is called once for each request that fails, after any retries, for the definition and for each source. Requests that were cancelled, because the dashboard was removed from the page or its filter changed, aren't errors.

## Several dashboards on a page

Each `<Dashboard>` has its own data, so dashboards can be next to each other, even the same one with different filters:

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

```json
{
  "sources": [{ "key": "orders", "url": "SourceVisData?queryId=orders", "params": {}, "refresh": 0 }],
  "layout": {
    "type": "RCol",
    "items": [
      {
        "type": "RGrid",
        "props": { "cols": 3 },
        "items": [
          {
            "type": "RCard",
            "props": { "classes": { "rootExtra": "relative h-20" } },
            "items": [
              {
                "type": "RIconStat",
                "bind": {
                  "query": "SELECT SUM(revenue) AS [value], 0.12 AS trend FROM orders WHERE [month] = '2026-12'"
                },
                "props": {
                  "title": "Revenue this month",
                  "icon": "value",
                  "classes": { "rootExtra": "h-full items-center", "left": "px-2 mr-2" },
                  "valueFormat": {
                    "options": { "style": "currency", "currency": "USD", "maximumFractionDigits": 0 }
                  }
                }
              }
            ]
          },
          {
            "type": "RCard",
            "props": { "classes": { "rootExtra": "relative h-20" } },
            "items": [
              {
                "type": "RIconStat",
                "bind": {
                  "query": "SELECT SUM(orders) AS [value], -0.03 AS trend FROM orders WHERE [month] = '2026-12'"
                },
                "props": {
                  "title": "Orders this month",
                  "icon": "quantity",
                  "classes": { "rootExtra": "h-full items-center", "left": "px-2 mr-2" },
                  "valueFormat": { "options": { "maximumFractionDigits": 0 } }
                }
              }
            ]
          },
          {
            "type": "RCard",
            "props": { "classes": { "rootExtra": "relative h-20" } },
            "items": [
              {
                "type": "RIconStat",
                "bind": {
                  "query": "SELECT SUM(revenue) / SUM(orders) AS [value], 0 AS trend FROM orders"
                },
                "props": {
                  "title": "Average order",
                  "icon": "average",
                  "classes": { "rootExtra": "h-full items-center", "left": "px-2 mr-2" },
                  "valueFormat": {
                    "options": { "style": "currency", "currency": "USD", "maximumFractionDigits": 0 }
                  }
                }
              }
            ]
          }
        ]
      },
      {
        "type": "RGrid",
        "props": { "cols": 3 },
        "items": [
          {
            "type": "RCard",
            "props": {
              "title": "Revenue by month",
              "classes": { "rootExtra": "relative h-72 col-span-2" }
            },
            "items": [
              {
                "type": "RECharts",
                "bind": {
                  "query": "SELECT [month], SUM(revenue) AS revenue FROM orders GROUP BY [month] ORDER BY [month]"
                },
                "props": {
                  "style": { "height": 230 },
                  "option": {
                    "grid": { "left": 48, "right": 8, "top": 16, "bottom": 24 },
                    "xAxis": { "show": true, "type": "category" },
                    "yAxis": { "show": true },
                    "tooltip": { "show": true, "trigger": "axis" },
                    "series": [
                      {
                        "type": "bar",
                        "encode": { "x": "month", "y": "revenue" },
                        "itemStyle": { "color": "#9a42ff" }
                      }
                    ]
                  }
                }
              }
            ]
          },
          {
            "type": "RCard",
            "props": { "title": "Top cities", "classes": { "rootExtra": "relative h-72" } },
            "items": [
              {
                "type": "RList",
                "bind": {
                  "query": "SELECT city, SUM(revenue) AS revenue FROM orders GROUP BY city ORDER BY revenue DESC"
                },
                "props": {
                  "icon": "●",
                  "nameField": "city",
                  "valueField": "revenue",
                  "valueFormat": {
                    "options": { "style": "currency", "currency": "USD", "maximumFractionDigits": 0 }
                  }
                }
              }
            ]
          }
        ]
      }
    ]
  }
}
```

{% 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 %}

{% tab title="Code" %}
{% code title="dashboard/two-dashboards.tsx" %}

```tsx
import { Dashboard } from "@rierino-open/dv";
import { client } from "@/lib/rierino";

export default function TwoDashboards() {
  return (
    <div style={{ display: "grid", gap: 16 }}>
      <section>
        <h3 style={{ margin: "0 0 8px" }}>North</h3>
        <Dashboard client={client} id="store-overview" filter={{ region: "North" }} />
      </section>
      <section>
        <h3 style={{ margin: "0 0 8px" }}>South</h3>
        <Dashboard client={client} id="store-overview" filter={{ region: "South" }} />
      </section>
    </div>
  );
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

Their sources can have the same keys: each dashboard's queries only see its own tables.

## Server paths

The dashboard reads from two APIs of the Rierino server. Each request goes through the client, which puts its `baseUrl` in front:

| Request    | Path                                                                  | Read from the response |
| ---------- | --------------------------------------------------------------------- | ---------------------- |
| Definition | `uiPath` + `id`, by default `request/crud/data_visualization/<id>`    | `data`                 |
| Source     | `sourcePath` + the source's `url`, by default `request/ins_rpc/<url>` | `list` (the rows)      |

Change `uiPath` or `sourcePath` when your gateway serves these APIs on other paths. Both end with `/`.

## Props

| Prop           | Type                                                              | Default                              | Description                                                                                                                                   |
| -------------- | ----------------------------------------------------------------- | ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `client`       | `DashboardClient`                                                 |                                      | **Required.** Client from `createClient()` of `@rierino-open/api-client`; it sets the server and the authentication.                          |
| `id`           | `string`                                                          |                                      | **Required.** Id of the data visualization.                                                                                                   |
| `filter`       | `object`                                                          |                                      | Added to every source request as query parameters; changing it reloads the data.                                                              |
| `uiPath`       | `string`                                                          | `"request/crud/data_visualization/"` | Path the dashboard definition is read from, followed by the id.                                                                               |
| `sourcePath`   | `string`                                                          | `"request/ins_rpc/"`                 | Path the sources are read from, followed by each source's url.                                                                                |
| `allowScripts` | `boolean`                                                         | `false`                              | Runs code in the dashboard definition (ECharts tooltip `_formatter`). Off by default; turn it on only for dashboards from a server you trust. |
| `loading`      | `React.ReactNode`                                                 |                                      | Shown while the dashboard definition is loading.                                                                                              |
| `error`        | `((error: DashboardError) => React.ReactNode) \| React.ReactNode` |                                      | Shown when the dashboard definition can't be loaded.                                                                                          |
| `onError`      | `((error: DashboardError) => void)`                               |                                      | Called when the dashboard definition or one of its sources can't be loaded.                                                                   |

### DashboardError

What `error` and `onError` get. `status` is the HTTP status, or `"FETCH_ERROR"` when there was no response; a source that answers without rows (no `list` in its response) is a `"FETCH_ERROR"` too.

| Prop      | Type               | Default | Description                                                              |
| --------- | ------------------ | ------- | ------------------------------------------------------------------------ |
| `status`  | `string \| number` |         | **Required.** HTTP status, or "FETCH\_ERROR" when there was no response. |
| `message` | `string`           |         | **Required.**                                                            |
| `data`    | `any`              |         | Response body, when there was one.                                       |


---

# 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/using-dashboard/dashboard.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.
