Quick time range
Last 24 hours, last week, last month: the ranges people pick every day become one click each. A row of chips sets the dashboard time window, so every widget that follows it refreshes at once and the toolbar stays in sync. The active period is always marked; when the window was changed elsewhere, the widget shows that range as text instead. Each preset can carry its own aggregation and grouping interval, and an optional Custom chip opens the standard time window panel.
Who it’s for
Quick time range is for dashboard authors whose users look at the same few periods all day: the last 24 hours on a shift, the last week in a review, the last month in a report. Those users want one click to switch the period and a glance to see which one is on. The question they bring is “how do I add time range buttons to a ThingsBoard dashboard?”
What it does
Quick time range ships with four presets: 24 h, 7 d, 30 d and 90 d. Click 7 d and every widget that follows the dashboard time window reloads with the last seven days, and the time window in the dashboard toolbar shows the same period. Open the toolbar and pick 3 Nov 08:00 to 5 Nov 20:00 instead, and the widget clears the selection and prints 3 Nov 08:00 – 5 Nov 20:00 next to the presets.
- One click per period. Each preset replaces the dashboard time window with “last N”, so nobody has to open the time window panel for the everyday ranges.
- The selected period is always marked. The matching preset is filled in the primary color. When the window was set somewhere else and no preset matches, the widget shows the range as text: a fixed range,
Last 3 h, or an interval such asCurrent week so far. - Aggregation travels with the preset. A short preset can show raw readings while a long one shows hourly averages, so each period loads at a sensible density.
- A Custom chip for everything else. It opens the standard ThingsBoard time window panel, and the range you choose then shows on the chip itself.
- Fits the width it is given. The chips share the full width of the widget equally. In a narrow widget they keep their size and scroll sideways, by scroll bar or by mouse wheel.
- Leaves layout editing alone. In dashboard edit mode the chips are dimmed and do not react, so clicks move and resize the widget instead of changing the period.
- Scope. The widget changes the dashboard time window only. A widget that uses its own time window does not follow it.
How to set up
Data keys
Quick time range needs no datasource and no data keys. It reads and writes the dashboard time window, so it works on any dashboard as soon as it is added.
Presets
- Presets — 24 h, 7 d, 30 d and 90 d by default. One chip per row, left to right. A row whose duration cannot be read is skipped.
- Label — empty by default. The text on the chip. When empty, the chip shows the duration, such as
7 d. - Duration — the length of the period, such as
15m,1h,24h,7d,2wor1mo, or a number of milliseconds. - Aggregation — Auto by default. Auto keeps the aggregation the dashboard already uses; None, Average, Min, Max, Sum or Count replace it while this preset is on.
- Grouping interval — empty by default. The size of each aggregated step, such as
1hor1d. When empty, the widget picks one that suits the duration. Hidden when Aggregation is None.
- Label — empty by default. The text on the chip. When empty, the chip shows the duration, such as
- Window type — Realtime by default. Realtime keeps the period moving with the clock. History fixes the last N at the moment of the click, so the data stops updating.
- Preset on load — 0 by default. The position of the preset to apply when the dashboard opens, counting from 1. With 0 the dashboard opens with its own saved time window.
- Show Custom chip — off by default. Adds a Custom… chip after the presets that opens the standard time window panel.
How to customize
- To make the widget smaller for a card header or a tablet — set Style to Segmented. The presets become one joined control instead of separate chips.
- To match the selected chip to the platform theme — leave Theme selected color on. The widget uses the primary color of the current theme, including a white-label palette.
- To use your own selected color — turn Theme selected color off and set Selected color.
- To change the background of the other chips — set Chip color.
- To change the text of the chips and the range text — set Text color.
- To make the chips larger or smaller — set the size in Chip font.
Tips
- Place the widget across the top of the dashboard, above the charts it controls, so the selected period sits next to the data it applies to.
- Add a short preset such as
1hwith Aggregation set to None for live troubleshooting, and keep the long presets on Average so a month of data loads quickly. - Turn on Show Custom chip if your users also need ranges outside the presets. They can then pick any range without the dashboard toolbar.
Share Your Widget with the Community
Built a custom widget? Export it as a JSON from ThingsBoard and publish it to the IoT Hub through a simple 4-step wizard (Upload, Listing, Readme, Review & Submit). Share it with thousands of ThingsBoard developers worldwide and get featured in the catalog.