Bar Chart
A grouped bar chart with named, colored bars. Use it to compare a few values side by side — sensor readings, channel levels, scores per category.
[image] Bar Chart on canvas, three vertical bars labeled Temp / Humidity / Pressure with different colors
What it does
Bar Chart shows N bars side by side. You define each bar in the Inspector — its label, color, and unit — then your sketch pushes a number for each bar in slot order.
When to use it
- Environment dashboard — 3 bars: Temperature (red), Humidity (blue), Pressure (green). Update every few seconds with
setValues(). - Channel meter — Up to 8 bars, one per audio channel.
Properties
The Inspector opens as a bottom sheet with a Widget ID field at the top, then these sections in order.
Widget ID
| Property | Type | What it controls |
|---|---|---|
| Widget ID | text | Identifier used by your sketch (IBarChart("…")). |
1. Essential
| Property | Type | Default | What it controls |
|---|---|---|---|
| Enabled | toggle | on | Whether the widget displays content. |
| Animate on appear | toggle | on | Bars animate in when the widget loads. |
2. Header
| Property | Type | Default | What it controls |
|---|---|---|---|
| Show header | toggle | off | Display a header above the chart. |
| Header text | text | empty (placeholder Sensors) | Header text. Only when Show header is on. |
| Alignment | Left / Center / Right | Center | Header text position. Only when Show header is on. |
3. Bars
A dynamic list of bars. Each bar receives one value from your sketch — send them in this order via setValues(values, count).
For each bar slot:
| Property | Type | Placeholder | What it controls |
|---|---|---|---|
| Label | text | Temp, Humidity, Pressure… | Bar label shown on the chart. |
| Unit (optional) | text | %, °C, hPa, V… | Unit appended to the value. |
| Color | color picker | — | Bar color. |
Plus per-bar action:
| Action | Type | What it does |
|---|---|---|
| Delete | button | Remove this bar slot. |
Plus list-level action:
| Action | Type | What it does |
|---|---|---|
| Add a bar | button | Appends a new bar with an auto-generated label and a cycled color. |
4. Range
| Property | Type | Default | What it controls |
|---|---|---|---|
| Auto scale | toggle | on | Adjust min/max from current values. |
| Min value | number | 0 | Lower bound. Only when Auto scale is off. |
| Max value | number | 100 | Upper bound. Only when Auto scale is off. |
5. Grid
| Property | Type | Default | What it controls |
|---|---|---|---|
| Show grid | toggle | on | Show grid lines. |
| Show axis | toggle | on | Show value axis. |
| Grid steps | 1–20 | 5 | Number of grid divisions. |
6. Appearance
| Property | Type | Default | What it controls |
|---|---|---|---|
| Orientation | Vertical / Horizontal | Vertical | Bar direction. |
| Bar corner radius | 0–20 | 4 | Corner roundness. |
| Show legend | toggle | on | Series legend. |
7. Colors · Chart
| Property | Type | What it controls |
|---|---|---|
| Background | color | Chart background. |
| Labels (axis, categories) | color | Axis and category text. |
| Grid lines | color | Grid line color. |
| Axis lines | color | Axis line color. |
8. Animation
| Property | Type | Default | What it controls |
|---|---|---|---|
| Animation duration (ms) | 100–3000 | 500 | Length of value-change animation. |
States and behavior
[image] Two orientations side by side — Vertical (3 bars) and Horizontal (3 bars)
Bars animate to new heights when their values change. With Auto scale on, the chart re-scales as the maximum value moves.
In code
The widget mirrors what your sketch sends. To update all bars at once:
float values[3] = { 22.5, 65.0, 1013.0 };
instant.barChart("env").setValues(values, 3);
That’s the minimum — push an array, the bars match the slots in the Inspector. Don’t put this call directly in loop() — Arduino’s loop() runs thousands of times per second, which would flood the link. Use a timer to push at a sensible rate (200–1000 ms is plenty).
Available methods:
.setValues(const float* arr, uint8 count)— Push the whole array at once..setBar(uint8 index, float value)— Update a single bar by 0-based index..clear()— Reset all bars to 0.
See InstantIoT Library / Send Data to App.
Working Arduino code example
A complete sketch you can flash. The Widget ID env matches the one you set on your Bar Chart in the app. The chart has 3 slots in this order: Temperature, Humidity, Pressure.
[gif] Bar Chart on the dashboard, three bars updating their heights as the ESP32 pushes values
Direct Mode
Your phone connects directly to the ESP32’s SoftAP — no router, no server. Best for prototyping and standalone setups.
#include <InstantIoTWiFiAP.hpp>
#include <utils/InstantIoTTimer.hpp>
const char* AP_SSID = "InstantIoT-Greenhouse";
const char* AP_PASS = "12345678";
InstantIoTWiFiAP instant(AP_SSID, AP_PASS);
InstantTimer timers;
float readTemp() { return 20.0f + (random(0, 100) / 10.0f); }
float readHumidity() { return 40.0f + (random(0, 200) / 10.0f); }
float readPressure() { return 1010.0f + (random(0, 100) / 10.0f); }
void pushBars() {
if (!instant.connected()) return;
float values[3] = { readTemp(), readHumidity(), readPressure() };
instant.barChart("env").setValues(values, 3);
}
void setup() {
instant.begin();
timers.every(1000, pushBars);
}
void loop() {
instant.loop();
timers.run();
}
Server Mode
The ESP32 connects to your self-hosted InstantIoT Server over WiFi. Multiple devices, persistent state, history.
#include <InstantIoTWiFiServer.hpp>
#include <utils/InstantIoTTimer.hpp>
const char* WIFI_SSID = "YOUR_WIFI_SSID";
const char* WIFI_PASS = "YOUR_WIFI_PASSWORD";
const char* SERVER_IP = "192.168.1.42";
const uint16_t SERVER_PORT = 9001;
const char* DEVICE_TOKEN = "YOUR_DEVICE_TOKEN";
InstantIoTWiFiServer instant(SERVER_IP, SERVER_PORT, DEVICE_TOKEN);
InstantTimer timers;
float readTemp() { return 20.0f + (random(0, 100) / 10.0f); }
float readHumidity() { return 40.0f + (random(0, 200) / 10.0f); }
float readPressure() { return 1010.0f + (random(0, 100) / 10.0f); }
void pushBars() {
if (!instant.connected()) return;
float values[3] = { readTemp(), readHumidity(), readPressure() };
instant.barChart("env").setValues(values, 3);
}
void setup() {
instant.begin(WIFI_SSID, WIFI_PASS);
timers.every(1000, pushBars);
}
void loop() {
instant.loop();
timers.run();
}
The widget code is identical — only the include and constructor change.
Notes
- This is a Display — no Target Devices dropdown.
- The order of values matches the order of bars in the Inspector. Reordering bars in the app reorders them on the device side too.
- For time-evolving data (history), use Advanced Chart instead.
Next
→ Advanced Chart — When values evolve over time and you want history.
→ Horizontal / Vertical Level — When the value is a single fill, not a comparison.