Bar Chart Widget
The Bar Chart widget renders a vertical or horizontal bar chart from discrete labeled values. Unlike the Graph widget (which plots a time series), the Bar Chart shows a snapshot comparison — e.g. power consumption per channel, counts per category, or daily totals.
Default size: 4 × 3 grid cells
Configuration
| Property | Type | Default | Description |
|---|---|---|---|
orientation | vertical | horizontal | vertical | Bar direction |
color | hex color | #6366F1 | Bar fill color |
colors | hex[] | [] | Per-bar colors (overrides color) |
| Device | device | — | The device to read from |
| Pin | V0–V255 | — | The virtual pin providing data |
| Label | string | — | Widget label |
Data format
The device sends a JSON array of {label, value} objects:
[
{ "label": "CH1", "value": 120 },
{ "label": "CH2", "value": 85 },
{ "label": "CH3", "value": 200 },
{ "label": "CH4", "value": 45 }
]
Firmware example: 4-channel power monitor
float power[4] = {0};
void readPower() {
for (int i = 0; i < 4; i++)
power[i] = readChannel(i);
}
void sendBarChart() {
char buf[256];
snprintf(buf, sizeof(buf),
"[{\"label\":\"CH1\",\"value\":%.1f},"
"{\"label\":\"CH2\",\"value\":%.1f},"
"{\"label\":\"CH3\",\"value\":%.1f},"
"{\"label\":\"CH4\",\"value\":%.1f}]",
power[0], power[1], power[2], power[3]);
Vwire.virtualSend(V0, buf);
}
void loop() {
Vwire.run();
readPower();
sendBarChart();
delay(5000);
}
Tips
- Maximum of 12 bars is recommended for readability.
- Use per-bar
colorsfor categorical data (e.g. phase colors in a 3-phase system). - For time-series bar data (hourly totals), use data already aggregated on the device before sending.