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

# Donut Percent

Shows a fraction as a percentage in a ring.

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

```json
{
  "sources": [{ "key": "goals", "url": "SourceVisData?queryId=goals", "params": {} }],
  "layout": {
    "type": "RGrid",
    "props": { "cols": 3 },
    "items": [
      {
        "type": "RCol",
        "props": { "classes": { "root": "flex flex-col items-center" } },
        "items": [
          {
            "type": "RDonutPercent",
            "bind": { "query": "SELECT progress FROM goals WHERE goal = 'Revenue'" },
            "props": { "valueField": "progress", "color": "#9a42ff" }
          },
          {
            "type": "RLabel",
            "props": {
              "label": "Revenue",
              "classes": { "root": "text-center", "sublabel": "hidden" }
            }
          }
        ]
      },
      {
        "type": "RCol",
        "props": { "classes": { "root": "flex flex-col items-center" } },
        "items": [
          {
            "type": "RDonutPercent",
            "bind": { "query": "SELECT progress FROM goals WHERE goal = 'New customers'" },
            "props": { "valueField": "progress", "color": "#366dba" }
          },
          {
            "type": "RLabel",
            "props": {
              "label": "New customers",
              "classes": { "root": "text-center", "sublabel": "hidden" }
            }
          }
        ]
      },
      {
        "type": "RCol",
        "props": { "classes": { "root": "flex flex-col items-center" } },
        "items": [
          {
            "type": "RDonutPercent",
            "bind": { "query": "SELECT progress FROM goals WHERE goal = 'Repeat orders'" },
            "props": { "valueField": "progress", "color": "#02BC77" }
          },
          {
            "type": "RLabel",
            "props": {
              "label": "Repeat orders",
              "classes": { "root": "text-center", "sublabel": "hidden" }
            }
          }
        ]
      }
    ]
  }
}
```

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

## Usage

```json
{
  "type": "RDonutPercent",
  "bind": { "query": "SELECT progress FROM goals WHERE goal = 'Revenue'" },
  "props": { "valueField": "progress", "color": "#9a42ff" }
}
```

The value comes from the first row of the data, as a fraction: `0.72` fills 72% of the ring. `color` colours the filled part, the rest of the ring (at half opacity) and the percentage.

The donut is 80px wide. To make it fill the width of the place it's in, such as a grid cell, set `classes.root` to `relative w-full`.

## Props

| Prop         | Type     | Default          | Description                                     |
| ------------ | -------- | ---------------- | ----------------------------------------------- |
| `valueField` | `string` | `"value"`        | Field the fraction is read from.                |
| `color`      | `string` | `"#9a42ff"`      | Colour of the ring and the percentage.          |
| `sample`     | `object` | `{ value: 0.5 }` | Row shown when there is no data, for designing. |
| `classes`    | `object` |                  | Class names for the parts, see Classes below.   |

In the Rierino designer: **Value Field**, **Color** and **Classes**.

## Classes

| Part           | Built-in classes                        | Styles                 |
| -------------- | --------------------------------------- | ---------------------- |
| `root`         | `relative w-[80px]`                     | The donut              |
| `hole`         | `fill-white`                            | The centre             |
| `segment`      | `fill-transparent stroke-[3px]`         | Both parts of the ring |
| `valueSegment` | none                                    | The filled part        |
| `clearSegment` | none                                    | The rest of the ring   |
| `value`        | `absolute w-full text-center top-[35%]` | The percentage         |

Set `classes.<part>` to replace the built-in classes, or `classes.<part>Extra` to add to them.


---

# 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/values/donut-percent.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.
