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

# Visualize relative data with bar charts

<Note>
  [Classic dashboards](/observe/dashboards/classic-dashboards) have their own panels
  and methods of configuring them. For details about panels in classic dashboards,
  see [Classic dashboard panels](/observe/dashboards/classic-dashboards/classic-panels).
</Note>

A *bar chart* visualizes numeric data returned by a [query](/investigate/querying).
The chart depicts a specified value, such as the last numeric value in a time series
or the result's sum, average, or minimum or maximum value, as a bar.

Using Chronosphere Observability Platform, you can visualize the results of multiple
queries in a single bar chart panel to visually compare them. This can help you
quickly compare relative values from related queries, such as resource usage of
different services, a single service at different points in time, or cumulative
failure and error counts.

To create a bar chart or learn more about the configuration options common
to all panels, see [Panels](/observe/dashboards/panels).

## Use a bar chart's tooltip

When you hold the pointer over a bar in a bar chart, Observability Platform displays
a tooltip that shows the bar's full label and value. Click a bar to pin the value.

## Bar chart queries

Bar charts use one or more
[queries](/observe/dashboards/panels#change-a-panels-query) to retrieve data to
visualize. Bar charts use the following query **Options** to refine the
displayed information, depending on your **Datasource**:

<Tabs>
  <Tab title="Metrics (Prometheus)" id="queries-metrics">
    * **Series naming**: Select a method to filter for metrics:
      * **Labels** require a **Naming pattern**. Use `{{ label_name }}` to include a
        label value. For example, `{{ env }}` will be replaced with values like staging-1, prod-1.
      * **Regex**: Use a [regular expression](/investigate/querying/regular-expressions)
        in the **Regex** text field to match a time series. You can also use a
        **Naming pattern** to rename series using capture groups.
    * **Type**: The [PromQL query](/investigate/querying/promql#basic-querying)
      type: **Instant**, or **Range**.

    - **Truncation strategy**: Truncation strategy to apply to the query. This modifies
      the raw query. Observability Platform selects the best strategy for fit when
      possible, and displays `Auto` as the selected strategy.

      Available strategies are:

      * `Auto`
      * `Off`
      * `Avg`
      * `Min`
      * `Max`

      Changing your truncation strategy adds truncation information as additional bands
      or bars on your chart and details into the legend.
  </Tab>

  <Tab title="Logs" id="queries-logs">
    **Series naming**: Select a method to filter for metrics:

    * **Labels** require a **Naming pattern**. Use `{{ label_name }}` to include a
      label value. For example, `{{ env }}` will be replaced with values like staging-1, prod-1.
    * **Regex**: Use a [regular expression](/investigate/querying/regular-expressions)
      in the **Regex** text field to match a time series. You can also use a
      **Naming pattern** to rename series using capture groups.
  </Tab>
</Tabs>

## Configure a bar chart

You can configure a bar chart by [modifying its <Icon icon="settings" /> **Settings**](/observe/dashboards/panels#edit-a-panel).

Any changes you make in the panel's **Settings** tab are reflected immediately in
the **Preview** pane, but take effect only when you click **Apply** in the **Edit panel**
interface and then **Save** the dashboard.

Observability Platform doesn't fully support directly editing a panel's JSON
representation, and recommends configuring panels in the user interface. Use the JSON
representation only for managing your configuration as code with tools such as
[Chronoctl](/tooling/chronoctl) and [Terraform](/tooling/infrastructure/terraform).

### Miscellaneous settings

The **Misc** tab contains these settings:

* **Mode**: Determines whether the panel depicts a bar's numeric value as its literal
  **Value** or as a **Percentage** of the sum of all bars in the chart.
* **Sort**: Determines how the bar chart sorts the rendered bars.
  * **Default** sorts the bars in their original data order.
  * **Ascending** sorts the bars from the lowest value at the top, to the highest
    value at the bottom. **Descending** sorts in the opposite direction.
* **Limit**: The maximum number of returned values.

### Modify units and formatting

The **Unit and formatting** section changes the display of units on the chart.

* **Unit**: Defines the unit used to render the Y-axis. This has the most significant
  effect when you enable Abbreviate. Defaults to `Decimal`.
  * **Decimal**: Base 10 values. Observability Platform renders a value of
    `1000000` as `1M`.
  * **Bytes**: As decimal multiple-byte units. Observability Platform renders a
    value of `1000000` as `1MB`.
  * **Time**: Determines the [unit of time](/overview/concepts/time-units)
    that Observability Platform uses to interpret a numeric value.
  * **Percent**: Interprets the value as a percentile, representing 0% to 100% in a
    range of either 0.0 to 1.0 (**Percent (0.0-1.0)**) or 0 and 100
    (**Percent (0-100)**).

    For example, Observability Platform renders a value of `1.0` in **Percent
    (0.0-1.0)** as `100%`, and in **Percent (0-100)** as `1%`.
* **Decimals**: Defines how many decimal places Observability Platform renders for
  values.
  **Default** renders decimal places only if necessary and rounds to the nearest
  value. Numeric values from `0` to `4` render the corresponding number of decimal
  places.
* **Abbreviate**: Toggles whether to abbreviate units on the Y-axis. For example, if
  enabled, Observability Platform renders a value of `100000000` as `100M`. You can
  toggle this setting only if you set the **Unit** to `Decimal` or `Bytes`; `Time`
  units are always abbreviated and `Percent` values don't require the toggle.
  Defaults to `true`.

### Modify a bar chart's thresholds

The **Thresholds** section in a chart's **Settings** tab defines values
where Observability Platform renders threshold lines over the chart. You can define
threshold values as either absolute numeric values or percentiles. Observability
Platform renders threshold lines as dashed lines.

The threshold's **Mode** defines whether all thresholds use **Absolute** numeric
values or **Percent** values. Percent values are relative to the Y axis' minimum and
maximum. Defaults to **Absolute**.

To create a new threshold:

1. Click the plus sign (**+**) in the **Thresholds** section header.
2. In the field that appears, enter a value where you want Observability Platform to
   render the threshold line.
3. Optional: Click the color indicator, depicted as a colored circle, to open a
   selector where you can choose a color for the threshold line.
4. Optional: Click the caret (**>**) to expand the threshold definition, and enter text
   in the **Label** field to display on the chart if the threshold is met. This
   text displays when you hold the pointer over the area of the chart exceeding the
   threshold.
5. In the **Edit panel** dialog, click **Apply** to save your changes.
6. After you've finished editing the panel, click **Save** on the dashboard to save
   your changes.

To delete a threshold line, click the caret (**>**) to expand the threshold definition,
and then click the **<Icon icon="trash" alt="Delete icon" /> Delete** icon
on its corresponding row of the Thresholds section.

### Mark a query as a dynamic threshold

<Note>
  This feature isn't available to all Chronosphere Observability Platform users and
  might not be visible in your app. For information about enabling this feature in your
  environment, contact [Chronosphere Support](/support).
</Note>

In addition to [static threshold lines](#modify-a-bar-charts-thresholds) defined in
the panel settings, mark an individual query as a *dynamic threshold*. Observability
Platform uses the query's returned value to draw a horizontal threshold line across
the bar chart rather than rendering the result as a bar. Use dynamic thresholds to
display reference values alongside your bars, such as a maximum capacity limit or an
expected baseline value.

To mark a query as a dynamic threshold:

1. In the **Edit panel** interface, click the **Query** tab.
2. Next to the query you want to use as a threshold, click the
   **Render query as threshold** button. The query is marked as a threshold
   and its series render differently from regular data series.
3. Optional: Click the colored circle icon that appears to open a color picker
   and choose a custom threshold color.
4. Click **Apply**, and then click **Save** to save the dashboard.

To remove the threshold flag from a query, click the colored circle icon next to
the query, and then click the **<Icon icon="trash" /> Remove threshold from query**
icon in the color picker.

### Modify a bar chart's colors

The **Advanced** tab in a bar chart's **Edit panel** interface contains an **Override**
section where you can add, remove, and configure colors. You can apply color overrides
to a specific series or all series that match a
[regular expression](/investigate/querying/regular-expressions).

## Bar chart example

The following example is [JSON formatted](/observe/dashboards/panels/json-representation)
dashboard code. Modify it for your tenant.

This bar chart renames an existing label returned by a query and gives it a
customized name in the chart:

```json Bar chart with custom label expandable theme={null}
{
  "kind": "Panel",
  "spec": {
    "display": {
      "name": "Bar chart by category",
      "description": ""
    },
    "plugin": {
      "kind": "BarChart",
      "spec": {
        "calculation": "LastNumber",
        "limit": 25,
        "mode": "value",
        "sort": "desc",
        "unit": {
          "abbreviate": true,
          "kind": "Decimal"
        }
      }
    },
    "queries": [
      {
        "kind": "DataQuery",
        "spec": {
          "plugin": {
            "kind": "LogsDataQuery",
            "spec": {
              "query": "# \"query\": \"$Variable service:example-service @event.category:*\"\nfilter_id =~ \"$Variable\"\nservice = \"example-service\"\n| summarize by category = event.category",
              "reducer": "Last"
            }
          }
        }
      }
    ],
    "formulas": [],
    "links": []
  }
}
```
