> For the complete documentation index, see [llms.txt](https://docs.thingsup.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.thingsup.io/widgets/bar-chart-widget.md).

# Bar Chart Widget

**General Setting**

User can change following things in Bar Chart widget:

* Name for widget which will be used data reference. For Example, if widget name is 'Bar Chart', then data of widget is referenced as Bar Chart.data
* Show title - User can show/hide widget title
* Title Color
* Background Color

![Configure Bar Chart Widget](/files/I6q1YAOJxFNxux1XYwbn)

**Widget Setting**

In Widget Setting option, user can change following parameters:

* Index By - Parameter of JSON Object which will define X-Axis Data for Line Chart Widget.
* Keys -  Key parameter of JSON Object which will define Y-Axis Data for Line Chart Widget.
* Y Legend - string value as Y axis legend
* Show Legend -Enable to show legends
* Grouped  -Enable to show bars as grouped. Default bar chart will be stacked bar chart.
* Show grid X -  Enable to show X axis grid lines
* Show grid Y - Enable to show Y axis grid lines
* Horizontal - Enable to show bars horizontally

![Configure Bar Chart Widget](/files/s2zV2IUwCnhI7e251uLE)

![Configure Bar Chart Widget](/files/QursFCIOYO4lYiRbMyW6)

#### Source <a href="#source" id="source"></a>

User can select a source mode as MQTT or Action.

**Using MQTT**

Here, to update data on Bar Chart user can publish JSON array on given **data** MQTT topic. No need to provide \<account\_id> while providing the MQTT topic. The JSON object will be as below.

```
// Example 1
// Grouped/Stacked Bar Chart

[
  {
    "country": "India",
    "first": 94,
    "second": 114,
    "third": 14
  },
  {
    "country": "Australia",
    "first": 22,
    "second": 65,
    "third": 16
  },
  {
    "country": "US",
    "first": 21,
    "second": 85,
    "third": 12
  }
]

// here 'country' is set as IndexBy key and 'first', 'second' and 'third' are set as yKeys.
```

```
// Example 
// Simple Bar Chart

[
  {
    "country": "India",
    "first": 94
  },
  {
    "country": "Australia",
    "first": 22
  },
  {
    "country": "US",
    "first": 21
  }
]

// here 'country' is set as IndexBy key and 'first' is set as yKey.
```

![Configure Bar Chart Widget](/files/eocaX1EidhGF9LbCT0H5)

**Using Action**

Here, to update the Bar Chart widget, output of the action should contain JSON array as given in above example. User can also update the widget either onLoad or periodically by providing refresh interval.

![Configure Bar Chart Widget](/files/F2s6WXOIgVnjUnUo4ahh)

#### Event Handling

Bar Chart widget does not support any event.

#### Examples

Here, data in below format published on configured topic, will appear as shown in image.

#### 1. Simple Bar Chart

```
// Simple Bar Chart

[
  {
    "country": "India",
    "first": 94
  },
  {
    "country": "Australia",
    "first": 22
  },
  {
    "country": "US",
    "first": 21
  }
]

// here 'country' is set as IndexBy key and 'first' is set as yKey.
```

![Simple Bar Chart](/files/y7jSBc2wlGeLgoNdYXB3)

#### 2. Stacked Bar Chart

```
// Grouped/Stacked Bar Chart

[
  {
    "country": "India",
    "first": 94,
    "second": 114,
    "third": 14
  },
  {
    "country": "Australia",
    "first": 22,
    "second": 65,
    "third": 16
  },
  {
    "country": "US",
    "first": 21,
    "second": 85,
    "third": 12
  }
]

// here 'country' is set as IndexBy key and 'first', 'second' and 'third' are set as yKeys.
```

![Stacked Bar Chart Example](/files/oMsRWVLHW7PejalHZkRF)


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.thingsup.io/widgets/bar-chart-widget.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
