Skip to content

Chart Bar ​

The ui-chart-bar widget draws a bar chart from an object in msg.payload: each key is a bar label and its value the bar length. Each message replaces the whole chart. Bars are vertical columns or horizontal rows. A bar without a color gets one from a 10-color palette, picked from its label, so a label keeps the same color from one message to the next (two labels can share a color).

The header holds the title, a settings button and an expand button. Settings lets the viewer show or hide the title and the legend and switch between columns and rows; the expand button opens the chart in a larger dialog with a legend switch and the layout toggle. These choices are saved per widget in the browser and, once a viewer changes one, override the editor values in that browser. Without data the widget shows No data available.

Axis labels wrap on up to two lines (12 characters per line in columns, 18 in rows) and are cut with ... beyond that. In columns at most 8 labels are written along the axis. The tooltip of a bar shows its full label and value; the legend, when shown, has one entry per bar.

Chart Bar

Palette: category Charts, label bar chart. 1 input, 1 output.

Configuration ​

PropertyDescriptionDefault
NameNode name shown in the editor.""
GroupDashboard group where the chart is displayed.(required)
SizeWidget width and height; 0 means automatic.0 x 0
TitleText in the chart header. When empty, BAR CHART.BAR CHART
Bar layoutColumns: vertical bars. Rows: horizontal bars, 42 px per row; the chart scrolls when they do not fit.columns
Show titleShows the title in the header.true
Show legendShows a legend above the chart.false

Input ​

msg.payload is an object. Each key becomes a bar, in the order of the keys, and its value is either:

  • a number, or a string holding a number;
  • an object { value, color }, where color is optional and is a CSS color such as #FF0000 or rgb(255,0,0).
js
msg.payload = {
    "Line 1": 42,
    "Line 2": { value: 35 },
    "Line 3": { value: 28, color: "#E15759" }
};

The value axis starts at 0, so negative values are not visible, and values that are not numbers draw no bar. Arrays and payloads that are not objects are ignored.

msg.payload = "reset", "clear" or { action: "clear" } empties the chart.

A message that carries msg._client (for example one produced by a click in another dashboard widget) updates only the browser it names; other messages update every open dashboard. The node adds itself to the dashboard's Accept Client Data list, so nothing has to be ticked there.

The node keeps the last message: a browser that opens the page shows the current chart.

Output ​

This node does not send messages. Input messages are not passed on.

Usage example ​

A function node that sends the defect counts of the current shift, with a fixed color for one of them:

js
const counts = flow.get("defectCounts") || {};
msg.payload = {
    "Scratch": counts.scratch || 0,
    "Dent": counts.dent || 0,
    "Stain": { value: counts.stain || 0, color: "#F28E2B" }
};
return msg;

At the start of the next shift, msg.payload = "reset" empties the chart.