> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gp.scale.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Bar Chart Widget

> Visualize comparisons across categories using bar charts

<Info>
  **Using Sample Data**: The examples on this page use fields from our <a href="/assets/sample-data/sample-evaluation.csv" download>sample dataset</a>. Download it and create an evaluation with it to follow along with this tutorial.
</Info>

<Frame>
  <img src="https://mintcdn.com/scalegp/3SJ3nurBJCdCWISt/images/v5/evaluation-dashboards/widget-types/bar/bar-base-result.png?fit=max&auto=format&n=3SJ3nurBJCdCWISt&q=85&s=ed928382a9eccb12116947aa3c415e22" alt="Bar Chart Widget Example" width="1232" height="826" data-path="images/v5/evaluation-dashboards/widget-types/bar/bar-base-result.png" />
</Frame>

## When to Use

Use bar chart widgets to:

* Compare values across categories or groups
* Show rankings or relative performance
* Visualize aggregated metrics by dimension
* Make patterns and outliers immediately visible

## Configuration

### Required Fields

<ParamField body="title" type="string" required>
  Widget display name shown on the dashboard
</ParamField>

<ParamField body="type" type="string" required>
  Must be set to "bar"
</ParamField>

<ParamField body="query" type="object" required>
  SeriesQuery with `GROUP BY` for categorical breakdown
</ParamField>

### X-Axis Configuration (One Required)

You must provide **either** `x_column` **or** `x_column_group`, but not both:

<ParamField body="config.x_column" type="string">
  Single column name to use for x-axis categories. Use for simple bar charts grouping by one dimension.

  **Example:** `"agent_name"` - creates bars for each agent
</ParamField>

<ParamField body="config.x_column_group" type="string[]">
  Array of column names for multi-dimensional grouping. Use for complex bar charts that group by multiple dimensions.

  **Example:** `["agent_name", "task_type"]` - creates grouped bars combining agent and task type
</ParamField>

### Optional Config Fields

<ParamField body="config.stacked" type="boolean" default="true">
  Controls whether multiple series are stacked or displayed side-by-side.

  * `true` (default): Stack bars on top of each other (useful for showing totals)
  * `false`: Display bars side-by-side (better for comparing individual values)
</ParamField>

<ParamField body="config.show_value_labels" type="boolean" default="false">
  When `true`, each bar's value is rendered directly on the chart so you don't have to hover to read it.

  Value labels apply to single-series charts only (charts with one aggregation). They are ignored on multi-series charts, which use a legend instead.
</ParamField>

### Query Requirements

Bar chart widgets require a **SeriesQuery** with:

* `groupBy` for categorical breakdown (required)
* Should have at least one aggregation for y-axis values
* Can include `filter` for row filtering

## Creating in the UI

<Steps>
  <Step title="Open Widget Creator">
    From your dashboard, click "Add Widget" and select "Bar Chart"
  </Step>

  <Step title="Enter Title">
    Give your chart a descriptive name (e.g., "Agent Name Accuracy Average")
  </Step>

  <Step title="Configure Query">
    <Frame>
      <img src="https://mintcdn.com/scalegp/3SJ3nurBJCdCWISt/images/v5/evaluation-dashboards/widget-types/bar/bar-base-form.png?fit=max&auto=format&n=3SJ3nurBJCdCWISt&q=85&s=49c77c9ef5908415371769d39aae5759" alt="Bar Chart Query Builder" width="2490" height="2056" data-path="images/v5/evaluation-dashboards/widget-types/bar/bar-base-form.png" />
    </Frame>

    * **Group By**: Select the categorical dimension - these will be the bars on the y-axis
    * **Aggregation**: Choose the metric to visualize (`AVG`, `SUM`, `COUNT`)
    * **Filter**: Add conditions to narrow the data (optional)
  </Step>

  <Step title="Show Values on Bars (Optional)">
    For single-series charts, toggle **Show values on bars** to render each bar's value directly on the chart. This sets `config.show_value_labels`.
  </Step>

  <Step title="Create Widget">
    Click "Add" to generate the bar chart

    <Frame>
      <img src="https://mintcdn.com/scalegp/3SJ3nurBJCdCWISt/images/v5/evaluation-dashboards/widget-types/bar/bar-base-result-hover.png?fit=max&auto=format&n=3SJ3nurBJCdCWISt&q=85&s=463281f15b8e7f20a14547a41dbb7b7a" alt="Created Bar Chart Widget" width="1210" height="814" data-path="images/v5/evaluation-dashboards/widget-types/bar/bar-base-result-hover.png" />
    </Frame>
  </Step>
</Steps>

## Output Format

Bar chart widgets use the same series format as tables:

```json theme={null}
{
  "type": "series",
  "data": [
    {"category": "Quality", "avg_score": 0.89},
    {"category": "Accuracy", "avg_score": 0.85},
    {"category": "Helpfulness", "avg_score": 0.91}
  ]
}
```

The chart renders each object as a bar.

## Example Use Cases

### Use Case 1: Average Score by Agent

Compare performance across different agents.

<Frame>
  <img src="https://mintcdn.com/scalegp/3SJ3nurBJCdCWISt/images/v5/evaluation-dashboards/widget-types/bar/bar-score-by-agent.png?fit=max&auto=format&n=3SJ3nurBJCdCWISt&q=85&s=0fdcb203c4150bd018c9b7a169ee8270" alt="Score by Agent Bar Chart" width="2490" height="2056" data-path="images/v5/evaluation-dashboards/widget-types/bar/bar-score-by-agent.png" />
</Frame>

<CodeGroup>
  ```python Python theme={null}
  widget = client.evaluation_dashboards.widgets.create(
      dashboard_id=dashboard.id,
      title="Average Score by Agent",
      type="bar",
      query={
          "select": [
              {
                  "expression": {
                      "type": "COLUMN",
                      "column": "agent_name",
                      "source": "data"
                  }
              },
              {
                  "expression": {
                      "type": "AGGREGATION",
                      "function": "AVG",
                      "column": "overall_score",
                      "source": "data"
                  }
              }
          ],
          "groupBy": ["agent_name"]
      },
      config={
          "x_column": "agent_name"
      }
  )
  ```

  ```json JSON theme={null}
  {
    "title": "Average Score by Agent",
    "type": "bar",
    "query": {
      "select": [
        {"expression": {"type": "COLUMN", "column": "agent_name", "source": "data"}},
        {"expression": {"type": "AGGREGATION", "function": "AVG", "column": "overall_score", "source": "data"}}
      ],
      "groupBy": ["agent_name"]
    },
    "config": {
      "x_column": "agent_name"
    }
  }
  ```
</CodeGroup>

***

### Use Case 2: Evaluation Count by Task Type

Show which task types have the most evaluations.

<Frame>
  <img src="https://mintcdn.com/scalegp/3SJ3nurBJCdCWISt/images/v5/evaluation-dashboards/widget-types/bar/bar-count-by-task-type.png?fit=max&auto=format&n=3SJ3nurBJCdCWISt&q=85&s=c3c420492cfd15dc0b97588c21e5a4e1" alt="Count by Task Type Bar Chart" width="2490" height="2056" data-path="images/v5/evaluation-dashboards/widget-types/bar/bar-count-by-task-type.png" />
</Frame>

<CodeGroup>
  ```python Python theme={null}
  widget = client.evaluation_dashboards.widgets.create(
      dashboard_id=dashboard.id,
      title="Evaluations by Task Type",
      type="bar",
      query={
          "select": [
              {"expression": {"type": "COLUMN", "column": "task_type", "source": "data"}},
              {"expression": {"type": "AGGREGATION", "function": "COUNT", "column": "*"}}
          ],
          "groupBy": ["task_type"]
      },
      config={"x_column": "task_type"}
  )
  ```

  ```json JSON theme={null}
  {
    "title": "Evaluations by Task Type",
    "type": "bar",
    "query": {
      "select": [
        {"expression": {"type": "COLUMN", "column": "task_type", "source": "data"}},
        {"expression": {"type": "AGGREGATION", "function": "COUNT", "column": "*"}}
      ],
      "groupBy": ["task_type"]
    },
    "config": {
      "x_column": "task_type"
    }
  }
  ```
</CodeGroup>

***

### Use Case 3: High Performance Rate by Agent

Visualize percentage of evaluations scoring 85+ across agents.

<Frame>
  <img src="https://mintcdn.com/scalegp/3SJ3nurBJCdCWISt/images/v5/evaluation-dashboards/widget-types/bar/bar-high-perf-rate.png?fit=max&auto=format&n=3SJ3nurBJCdCWISt&q=85&s=77fb24a41fcb7ed4a425b5cf352c23bb" alt="High Performance Rate Bar Chart" width="2490" height="2056" data-path="images/v5/evaluation-dashboards/widget-types/bar/bar-high-perf-rate.png" />
</Frame>

<CodeGroup>
  ```python Python theme={null}
  widget = client.evaluation_dashboards.widgets.create(
      dashboard_id=dashboard.id,
      title="High Performance Rate by Agent",
      type="bar",
      query={
          "select": [
              {"expression": {"type": "COLUMN", "column": "agent_name", "source": "data"}},
              {
                  "expression": {
                      "type": "AGGREGATION",
                      "function": "PERCENTAGE",
                      "column": "overall_score",
                      "params": {
                          "percentage_filters": {
                              "conditions": [{
                                  "column": "overall_score",
                                  "source": "data",
                                  "operator": ">=",
                                  "value": 85
                              }]
                          }
                      }
                  }
              }
          ],
          "groupBy": ["agent_name"]
      },
      config={"x_column": "agent_name"}
  )
  ```

  ```json JSON theme={null}
  {
    "title": "High Performance Rate by Agent",
    "type": "bar",
    "query": {
      "select": [
        {"expression": {"type": "COLUMN", "column": "agent_name", "source": "data"}},
        {
          "expression": {
            "type": "AGGREGATION",
            "function": "PERCENTAGE",
            "column": "overall_score",
            "params": {
              "percentage_filters": {
                "conditions": [{
                  "column": "overall_score",
                  "source": "data",
                  "operator": ">=",
                  "value": 85
                }]
              }
            }
          }
        }
      ],
      "groupBy": ["agent_name"]
    },
    "config": {
      "x_column": "agent_name"
    }
  }
  ```
</CodeGroup>

***

### Use Case 4: Multi-Dimensional Grouping with x\_column\_group

Group by multiple dimensions to create side-by-side bar comparisons. This example shows average scores grouped by both agent and task type.

<Frame>
  <img src="https://mintcdn.com/scalegp/3SJ3nurBJCdCWISt/images/v5/evaluation-dashboards/widget-types/bar/bar-multi-group.png?fit=max&auto=format&n=3SJ3nurBJCdCWISt&q=85&s=e45135baae13eb2eabdc00747c0b2b1c" alt="Multi-dimensional Grouped Bar Chart" width="2490" height="2056" data-path="images/v5/evaluation-dashboards/widget-types/bar/bar-multi-group.png" />
</Frame>

<CodeGroup>
  ```python Python theme={null}
  widget = client.evaluation_dashboards.widgets.create(
      dashboard_id=dashboard.id,
      title="Score by Agent and Task Type",
      type="bar",
      query={
          "select": [
              {"expression": {"type": "COLUMN", "column": "agent_name", "source": "data"}},
              {"expression": {"type": "COLUMN", "column": "task_type", "source": "data"}},
              {
                  "expression": {
                      "type": "AGGREGATION",
                      "function": "AVG",
                      "column": "overall_score",
                      "source": "data"
                  }
              },
              {
                  "expression": {
                      "type": "AGGREGATION",
                      "function": "AVG",
                      "column": "relevance_score",
                      "source": "data"
                  }
              },
              {
                  "expression": {
                      "type": "AGGREGATION",
                      "function": "AVG",
                      "column": "accuracy_score",
                      "source": "data"
                  }
              }
          ],
          "groupBy": ["agent_name", "task_type"]
      },
      config={
          "x_column_group": ["agent_name", "task_type"],
          "stacked": False  # Display side-by-side for easier comparison
      }
  )
  ```

  ```json JSON theme={null}
  {
    "title": "Score by Agent and Task Type",
    "type": "bar",
    "query": {
      "select": [
        {"expression": {"type": "COLUMN", "column": "agent_name", "source": "data"}},
        {"expression": {"type": "COLUMN", "column": "task_type", "source": "data"}},
        {"expression": {"type": "AGGREGATION", "function": "AVG", "column": "overall_score", "source": "data"}}
        {"expression": {"type": "AGGREGATION", "function": "AVG", "column": "relevance_score", "source": "data"}},
        {"expression": {"type": "AGGREGATION", "function": "AVG", "column": "accuracy_score", "source": "data"}}
      ],
      "groupBy": ["agent_name", "task_type"]
    },
    "config": {
      "x_column_group": ["agent_name", "task_type"],
      "stacked": false
    }
  }
  ```
</CodeGroup>

## Stacked vs Unstacked Series

When you have multiple series (e.g., multiple aggregations or groupings), you can control how they're displayed:

### Stacked Bars (Default)

<Frame>
  <img src="https://mintcdn.com/scalegp/3SJ3nurBJCdCWISt/images/v5/evaluation-dashboards/widget-types/bar/bar-base-result-stacked.png?fit=max&auto=format&n=3SJ3nurBJCdCWISt&q=85&s=a9ffc6d6442768edad8356eaf8e9f23f" alt="Stacked Bar Chart" width="1220" height="812" data-path="images/v5/evaluation-dashboards/widget-types/bar/bar-base-result-stacked.png" />
</Frame>

Bars are stacked vertically, showing cumulative totals. Best for:

* Showing part-to-whole relationships
* Comparing total values across categories
* Visualizing composition over categories

```python theme={null}
config={"x_column": "agent_name", "stacked": True}  # Default
```

### Unstacked Bars (Side-by-Side)

<Frame>
  <img src="https://mintcdn.com/scalegp/3SJ3nurBJCdCWISt/images/v5/evaluation-dashboards/widget-types/bar/bar-base-result.png?fit=max&auto=format&n=3SJ3nurBJCdCWISt&q=85&s=ed928382a9eccb12116947aa3c415e22" alt="Unstacked Bar Chart" width="1232" height="826" data-path="images/v5/evaluation-dashboards/widget-types/bar/bar-base-result.png" />
</Frame>

Bars are displayed side-by-side, making individual values easier to compare. Best for:

* Comparing individual series values directly
* When exact values matter more than totals
* Multi-dimensional analysis (e.g., agent + task type)

```python theme={null}
config={"x_column": "agent_name", "stacked": False}
```

## Display Behavior

Bar charts apply the following formatting automatically. These behaviors are built into the rendering, so there are no extra config fields to set.

### Category labels

Category labels are shown next to each bar by default, so you can read values without hovering. Long labels are truncated to fit, and hovering a truncated label reveals its full text in a tooltip.

### Per-category colors

When a chart has a single series and more than one category (for example, an `AVG` grouped by `agent_name`), each bar is given a distinct color from a rotating palette. This makes individual categories easier to tell apart when there are many bars. Charts with multiple series keep one consistent color per series instead, so the series stay comparable across categories.

### Humanized column names

Raw column names are converted to readable Title Case in axis labels, the legend, and tooltips (for example, `experiment_param_value` becomes "Experiment Param Value" and `avgScore` becomes "Avg Score"). Aliases that already contain spaces are shown unchanged, so you can override the displayed text by aliasing a column in your query.

## Related Documentation

* [Table Widget](./table) - Tabular alternative with more detail
* [Histogram Widget](./histogram) - For numerical distributions
* [Query Language](../query-language) - `GROUP BY` and aggregation syntax
* [API Reference](/reference/v5/evaluation-dashboards) - Programmatic chart creation
