# Bar chart

Bar charts facilitate the viewing of data broken down by segmentation.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-6d97cc2da2188c6415089051f22867c4773f1ef0%2Fdash-1673275889.png?alt=media" alt="Bar chart example"><figcaption></figcaption></figure>

The NQL query requires a segmentation label and an aggregation.

## Data shape <a href="#barchart-datashape" id="barchart-datashape"></a>

`<segmentation 1>, (<segmentation 2>, <segmentation 3>,...), <kpi 1>, (<kpi 2>, <kpi 3>, ...)`

Bar charts NQL query structure depends on the following cases:

* [NQL for bar charts with default breakdown disabled](#nql-for-bar-charts-without-a-breakdown-dropdown)
* [NQL for bar charts with default breakdowns enabled](#nql-for-bar-charts-with-a-breakdown-dropdown)

## NQL structure for bar charts with disabled default breakdowns <a href="#barcharts-without-breakdowns" id="barcharts-without-breakdowns"></a>

When [configuring visualization fields](#linechart-linechartspecificsettings) specific to the bar chart, if you do not **Enable default breakdowns** you must follow the NQL structure below.

```
...
summarize <kpi1>, <kpi2>, ... by <segmentation1>, <segmentation2>, ...
```

In this case, you should always specify `by <segmentation1>,...` in the query.

{% hint style="info" %}
Refer to the [Live Dashboards NQL examples](https://docs.nexthink.com/platform/user-guide/live-dashboards-nql-examples#livedashboardsnqlexamples-barchart) documentation for query examples.
{% endhint %}

## NQL structure for bar charts with enabled default breakdowns <a href="#barcharts-with-breakdowns" id="barcharts-with-breakdowns"></a>

When [configuring visualization fields](#linechart-linechartspecificsettings) specific to the bar chart, if you **Enable default breakdowns** you must follow the NQL structure below.

<pre><code><strong>...
</strong><strong>summarize &#x3C;kpi1>, &#x3C;kpi2>, ... 
</strong></code></pre>

In this case, you can omit `by <segmentation1>,...` from the query since the system defaults to the options in the breakdown dropdown. See the **Preview** section in the image below.

{% hint style="info" %}
Refer to the [Live Dashboards NQL examples](https://docs.nexthink.com/platform/user-guide/live-dashboards-nql-examples#livedashboardsnqlexamples-barchart) documentation for query examples.
{% endhint %}

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-5d713a142e96ab29fd972a454319f5dc317e291d%2Fimage.png?alt=media" alt=""><figcaption></figcaption></figure>

## Bar chart column names—regardless of default breakdowns <a href="#barchart-columnnames" id="barchart-columnnames"></a>

The variable names in the NQL query are used as labels for the columns.

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-e6ba03f20429db0816fc19a62216288f16dec400%2Fdash-1673863439.png?alt=media" alt="Column names"><figcaption></figcaption></figure>

The variable names are formatted with the following heuristic:

* Underscores are replaced with spaces.
* The first character of the variable is changed to uppercase.

{% hint style="info" %}
In bar-chart widgets on live dashboards, you can sort the results by clicking on the chart column headers.
{% endhint %}

<figure><img src="https://268444917-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxJSUDk9NTtCHYPG5EWs3%2Fuploads%2Fgit-blob-be8111827a4cad93f9124d53f07f51c87af01c68%2Fimage.png?alt=media" alt="Sorting bar chart results by column data."><figcaption></figcaption></figure>

***

## Configuring visualization fields specific to Bar charts <a href="#linechart-linechartspecificsettings" id="linechart-linechartspecificsettings"></a>

{% hint style="info" %}
Refer to the [Managing Live Dashboards](https://docs.nexthink.com/platform/user-guide/managing-live-dashboards#filling-in-widget-visualization-fields) documentation to learn how to fill in the remaining configuration fields that are not specific to this widget.
{% endhint %}

After selecting the **Bar chart** option from the **Chart type** drop-down in the [Add widget](https://docs.nexthink.com/platform/user-guide/managing-live-dashboards#adding-widgets)/[Edit a widget](https://docs.nexthink.com/platform/user-guide/managing-live-dashboards#managing-widgets) pop-up:

1. Give the widget a **Title (optional)**.
2. Enter a **Widget description (optional)** to explain, for example, how the metric should be interpreted, calculated, or any subtleties to the metric.
   * The widget description appears when hovering over the info icon next to the bar chart widget in the dashboard.
3. Determine if the bar-chart results update according to the selected **Global timepicker** (timeframe) and/or **Global filters** applied to the dashboar&#x64;**.**
   * In bar-chart widgets on live dashboards, the action menu lets you either **Show all** results or **Show filtered** data—based on global dashboard filters.
4. Define the **Maximum number of rows to be displayed** in the container.
   * The dashboard displays a **Load more** button if the chart results exceed the defined limit.

***

RELATED TOPIC

* [KPI](https://docs.nexthink.com/platform/user-guide/live-dashboards/widget-types/kpi)
* [Line chart](https://docs.nexthink.com/platform/user-guide/live-dashboards/widget-types/line-chart)
* [Single-metric gauge chart](https://docs.nexthink.com/platform/user-guide/live-dashboards/widget-types/single-metric-gauge-chart)
* [Multi-metric gauge chart](https://docs.nexthink.com/platform/user-guide/live-dashboards/widget-types/multi-metric-gauge-chart)
* [Table](https://docs.nexthink.com/platform/user-guide/live-dashboards/widget-types/table)
* [Heading](https://docs.nexthink.com/platform/user-guide/live-dashboards/widget-types/heading)
* [Filter widget](https://docs.nexthink.com/platform/user-guide/live-dashboards/widget-types/filter-widget)
* [Timeframe picker](https://docs.nexthink.com/platform/user-guide/live-dashboards/widget-types/timeframe-picker)
