Sensor readings
Create stunning reports for your industrial temperature sensors
- Template type document docx simple
- Carbone min. v4.24.0+
- Features bidirectional-loop color aggregator
- Target datasheet audit monitoring industrie tests reports custom
Objectives
Generate a report with the following features:
- Display sensor measurement values over time using a horizontal loop.
- Display sensor measurement values across different locations using a vertical loop.
- Dynamically colorize cells based on the values.
Solution
Since the goal of the template is to color the cells based on the data values, the first step is to define the color scale to be used. Then, insert the data as expected.
Here’s how to construct a template to achieve this with Carbone:
Define your temperature scale and colors
- Design a simple table to act as a legend, displaying values alongside their corresponding colors.
Create a table for data placement
Insert the expected values into the cells using Carbone tags.
Describe the vertical loop. Example:
{d.town[i].name}
and{d.town[i+1]}
Describe the horizontal loop. Examples:
{d.town[0].data[i].month}
and{d.town[0].data[i+1].month}
for the first row (title){d.town[i].data[i].month}
and{d.town[i].data[i+1].month}
for the complete dataNote: each
[i+1]
must be repeated in the horizontal loop, while a single[i+1]
is sufficient to define the vertical loop.
Color the cells
- Use a Carbone tag to set the color of the cell by applying:
- conditional operators formatters,
:ifGTE
and:ifLT
, to evaluate the value - the :show() formatter to transmit the cell's colorization,
- the :color formatter to set the background color,
- conditional operators formatters,
Example:
{d.town[i].data[i].temperature:ifGTE(-15):and:ifLT(-10):show(#0661FF):color(cell,background)}
- The value can be tested multiple times using the :or() formatter to define the color for each level of the previously defined scale.
Example:
{d.town[i].data[i].temperature:ifGTE(-15):and:ifLT(-10):show(#0661FF):or(.temperature):ifGTE(-10):and:ifLT(-5):show(#0395FF) :or(.temperature):ifGTE(-5):and:ifLT(0):show(#03CBFF):or(.temperature):ifGTE(0):and:ifLT(5):show(#00FEFD) :or(.temperature):ifGTE(5):and:ifLT(10):show(#B3FFFD):or(.temperature):ifGTE(10):and:ifLT(15):show(#FBFD35) :or(.temperature):ifGTE(15):and:ifLT(20):show(#FFD800):or(.temperature):ifGTE(20):and:ifLT(25):show(#FFB201) :or(.temperature):ifGTE(25):and:ifLT(30):show(#FC9203):or(.temperature):ifGTE(30):show(#FF5F03):color(cell,background)}
Tip: Add spaces within the Carbone tag to improve formula readability and ensure better text wrapping within the cell.
- Use a Carbone tag to set the color of the cell by applying:
Compute the Average
- Consider the whole array with
[]
- Use the :aggAvg formatter to calculate the average of the set.
- Use the :round() formatter to round the result.
Example:
{d.town[i].data[].temperature:aggAvg:round(2)}
- Consider the whole array with
And there you go!
You might also like
Trusted by 600+ paid customers in 40+ countries














