{eval-data}
Plugin: Scaffolding Plugin
Allows for the evaluation of mathematical expressions using data set inside a scaffold.
Usage
{eval-data:Name}expression{eval-data}
Parameters
| Name | Required | Default | Description |
|---|---|---|---|
| [default]/name | | The name of the field the evaluated result will be stored in. | |
| format | | The format the resulting number should be converted to. Follows the standard java.text.DecimalFormat rules. |
Expressions
Expressions can be made up of the following:
| Description | Value |
|---|---|
| Numbers | 1.234, -987 |
| Variables | %prefix:value% |
| Basic operations | +, -, *, /, ^ |
| Trigonometry functions | sin(X), cos(X), tan(X), cot(X), sec(X), csc(X), arcsin(X), arccos(X), arctan(X) |
| Exponential functions | sqrt(X), exp(X), ln(X), log2(X), log10(X) |
| Shift functions | abs(X), trunc(X), round(X), floor(X), ceiling(X) |
| Constants | pi, e |
| Brackets | ( <expression> ) |
| Logic-valued expression | ( <logic expression> ) ? <true value> : <false value> |
| Logic operators | =, <>, <, >, <=, >=, !, &, |, |
Special Functions
There are some special functions available:
- round([number], [places]) - rounds the number to the amount of specified decimal places.
- sumtable([table], [column]) - sums all rows for the column in the specified table. Put quotes around the table and column names.
- avgtable([table], [column]) - averages all rows for the column in the specified table. Put quotes around the table and column names.
Examples
Basic Mathematics
The following example simply calculates the value of a fraction.
Numerator: {number-data:Numerator|decimal=true}1{number-data}
Denominator: {number-data:Denominator|decimal=true}2{number-data}
Result: {eval-data:Result|format=#0.0}${Numerator}/${Denominator}{eval-data}
Percentage: {eval-data:Percentage|format=##0\%}round(${Result} * 100, 0){eval-data}
Working with tables
This example
{table-data:Values}
|| Name || Value ||
| {text-data:Name}{text-data} | {number-data:Value}{number-data} |
{table-data}
Sum: {eval-data:Sum}sumtable("Values", "Value"){eval-data}
Average: {eval-data:Average}avgtable("Values", "Value"){eval-data}
Notes
- The actual expression being evaluated goes inside the macro content. Other fields in the same context can be referenced in the calculation. See the example scaffold above for more details.
Discussions