Skip to content

Bars per period

Average flow per hour: the period still running is lighter, the first one fades at the left edge

For how to set bars up, see Bars per period in the user guide.

A tag pen shown as bars (the pen's settings, Show as: Bars) has a Bars setting:

  • One bar per: Automatic (a bar per point as the chart reads the pen, the average of its slice when the range holds more points than the chart is wide), or a number and a unit: minutes, hours, days, weeks or months.
  • Each bar is the sum, the average, the median, the minimum, the maximum or the count of the values stored in its period. A period picked starts with the average. For a pen whose unit is a rate (per second, minute, hour, day, ...: m³/h, kg/min, units per hour) the average comes first ("the average (for a rate)"), the sum is called "the sum of stored values", and the settings say why (see below). A count counts every good and uncertain value, text and booleans too; the other values take numbers (a boolean as 1 or 0), so a text tag's bars are counts, and any other value for it is refused with why.

Periods follow the chart's time zone, by one fixed rule, so a pan or zoom never changes what a finished bar holds. Minutes and hours start again at every midnight: every 15 minutes falls on :00, :15, :30, :45, every 8 hours on 00:00, 08:00 and 16:00, a day the clocks change has 23 or 25 hourly bars, and a period that does not divide the day (5 hours) ends short at midnight. A bar of minutes or hours is at most a day. Days run from midnight to midnight, weeks from Monday, months from the first; several of them per bar are counted from 1970 (every 3 months falls on January, April, July and October, every 2 weeks on the same Mondays in every year). A bar is drawn across its whole period, under the line pens. The period that has not ended yet (it holds now) is drawn lighter with a dashed edge; a bar whose period the view cuts, at the left or the right edge, fades out towards that edge, as it goes on outside the view.

The gateway reads the bars from every stored value, on every historian, bad ones left out: up to 2,000,000 stored values per pen (counted first by the historian's Count, and again as they are read, whatever their quality: a read that gets more than that, because the historian's Count left some out, keeps none of them and the bars come from the aggregates instead; the Core historian reads about 600,000 a second on the dev stack, so 2,000,000 take about 3 s), and up to 2,000,000 values per read for a median (every row counted as it is read, whatever the historian's Count said first; a median takes its memory from what the gateway keeps for medians as its rows come, and one that finds none left is refused as busy). No historian's own count or share of good decides that part of a range can be taken from its aggregates instead: the Core historian counts and sums bad samples too, and the TimescaleDB historian decides what is good by a rule of its own (a quality code of 192 or more, so values stored as Good_Unspecified were not counted). Above that budget, and on a historian that cannot count its values, the bars are the historian's own Sum, Count, Minimum and Maximum per period, or per slice that fits every period exactly (an hour for days on the days the clocks change, ten minutes for 50-minute bars whose last bar of the day is 40 minutes), added up, which may count bad values: the pen's legend tooltip then says "These bars may include bad-quality values", and so does the x-trace of each bar whose own period was read so (a bar a later refresh read value by value does not). An average is the Sum over the Count only on the Core historian, whose Count counts what its Sum adds; on the TimescaleDB historian (its Count leaves out what its Sum adds) and on any other historian it is the historian's own average of a period read as one slice, and a period read in several slices has no average bar. On the TimescaleDB historian those of 5 minutes or more come from rollups of whole 5-minute buckets and whole hours on UTC, each counted in the slice it starts in, so the slices are only as long as those fit: on a chart in Asia/Kolkata (UTC+5:30) hourly bars are read in half hours, a day's bars in 45 minutes. On any other historian the slices start on a whole multiple of their own length since 1970 (UTC), as the Core historian takes an analog tag's Sum, Minimum and Maximum in such windows whatever the read's start: a day's bars in Brussels are read in hours (a day there starts at 23:00 or 22:00 UTC), in Kolkata in half hours. A period with values in a slice the historian gives no usable aggregate for (none, or one marked bad, such as a minimum of 0 at bad quality, a count marked bad or uncertain, or a count of 0 beside a sum, values its Count left out), or a slice the historian gave no row for at all (except on the TimescaleDB historian, which leaves a slice with nothing stored out), then has no bar, rather than the total of the rest of it; the legend tooltip says "Some periods have no bar". Both warnings stay only while bars they were said of are on screen: once a refresh reads those periods again whole, or they leave the view, they go. At most 5,000 bars per pen, and 200,000 bars in one answer over all the chart's bar pens (40 pens of 5,000): a pen past that is refused with why, unread. The periods at both ends are read whole, so a read reaches up to one period beyond each end of the range; the whole read must fit the configuration's maximum range (a bar of a month on a seven-day configuration is refused, with why). On a live chart, and on a range that ends later than now, the bars are read again every 30 seconds.

Only good and uncertain values count. The sum adds the values as stored: right for amounts logged per event (a count, a batch weight); for a rate such as m³/h, which a historian stores more often when it changes faster, pick the average: the sum of a rate grows with how often it was stored (an hour with 1,949 stored values against one with 60), not with the amount, so it is no total. (A total over time, the rate times the time it held, is not offered: it needs the time each value held, gaps and bad quality included, which the historian's aggregates do not give.) A sum of a rate (a unit per second, minute, hour, day, ...) is shown without a unit, as "sum of stored values": it is neither m³/h nor m³. A count has no unit either.

A plot with bars always shows zero, as a bar's height is its value. The period that has not ended yet is left out of the automatic range while finished bars are in view, so it never squashes them. A bar beyond the plot (that period once it outgrows the finished ones, or any bar on an axis scaled by hand) is cut at the plot's edge with a cap there that says its value without hovering ("▲ 102,138.9 so far"), below a note flag, or the title of a note period, it would cover; the x-trace's box of that bar goes below the cap's label, never over it. The pen's line in the Pens tab says it too ("the last one so far: 102,138.9, above the plot"). The x-trace gives the value and the pen, and under them what a bar is and its period, in one format for every bar ("sum of Fri 27 Nov 08:00 to 09:00", "sum of Fri 27 Nov 23:00 to now", a whole day as "Fri 27 Nov"). Its tooltip says when the period reaches beyond the view, so the value includes values outside it; a phone's readout says it on a line under the value.

In the chart state (saved charts and the URL) a pen has "style": "bar" and "bars": {"every": 1, "unit": "hour", "value": "sum"} (unit: minute, hour, day, week, month; value: sum, avg, median, min, max, count).


Copied from the section "Bars per period" of the README when the site is built. Source: README.md.