Scripting

Processing Numeric Values

With Peakboard, you can manipulate numbers in various ways. This template provides the following operations and functions:

  1. Floating-point random number
  2. Integer random number
  3. Addition
  4. Rounding

Floating-point Random Number

To generate a random floating-point number, use the following code:

Random

data.Number = math.random(0, 99) + math.random()

Integer Random Number

To generate a random integer, use this code:

Int_random

data.Number = math.random(-100, 100)

Addition

Addition can be performed as follows:

Addition

data.Number = data.Number + 2.65

Rounding

When rounding, you can choose between rounding to a whole number and rounding with decimal places.

To round to a whole number, use the following code:

Round

data.Number = math.ceil(data.Number)

To round with decimal places, use this code:

Double_round

data.Number = math.roundwithdecimals(data.Number, 1)

We are learning from you!

Did you find this article helpful?

Be enlightened!

Do you need more support?

Peakboard Youtube icon Visit our YouTube channel

Our numerous videos for beginners and advanced users explain exactly how to design your dashboard.

Peakboard Templates icon Visit the Peakboard Templates

Download our templates for various use cases for free.

Peakboard icon Visit www.peakboard.com

Find out all about Peakboard and browse our different use cases and success stories.