Skip to main content

Bar Chart Widget

📊 Chart

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

PropertyTypeDefaultDescription
orientationvertical | horizontalverticalBar direction
colorhex color#6366F1Bar fill color
colorshex[][]Per-bar colors (overrides color)
DevicedeviceThe device to read from
PinV0V255The virtual pin providing data
LabelstringWidget 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 colors for 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.