From 673cb7e07220b9339f7d60e0363de373d52c0cdd Mon Sep 17 00:00:00 2001 From: mpetrov Date: Tue, 8 Apr 2025 17:15:52 +0300 Subject: [PATCH 1/3] Added show help on math funcs in Calculated field simple expression and math node --- .../calculated-field-dialog.component.html | 6 ++++ .../math-function-config.component.html | 8 ++++- .../arguments-map-config.component.html | 2 +- .../assets/help/en_US/math/math-methods_fn.md | 31 +++++++++++++++++++ 4 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 ui-ngx/src/assets/help/en_US/math/math-methods_fn.md diff --git a/ui-ngx/src/app/modules/home/components/calculated-fields/components/dialog/calculated-field-dialog.component.html b/ui-ngx/src/app/modules/home/components/calculated-fields/components/dialog/calculated-field-dialog.component.html index 1688685523..6952ca4fd2 100644 --- a/ui-ngx/src/app/modules/home/components/calculated-fields/components/dialog/calculated-field-dialog.component.html +++ b/ui-ngx/src/app/modules/home/components/calculated-fields/components/dialog/calculated-field-dialog.component.html @@ -80,6 +80,12 @@ +
+
@if (configFormGroup.get('expressionSIMPLE').errors && configFormGroup.get('expressionSIMPLE').touched) { @if (configFormGroup.get('expressionSIMPLE').hasError('required')) { diff --git a/ui-ngx/src/app/modules/home/components/rule-node/action/math-function-config.component.html b/ui-ngx/src/app/modules/home/components/rule-node/action/math-function-config.component.html index 6d8ac56fc1..3b91c56acf 100644 --- a/ui-ngx/src/app/modules/home/components/rule-node/action/math-function-config.component.html +++ b/ui-ngx/src/app/modules/home/components/rule-node/action/math-function-config.component.html @@ -32,6 +32,12 @@ {{'rule-node-config.custom-expression-field-input' | translate }} * +
+
rule-node-config.custom-expression-field-input-required @@ -73,7 +79,7 @@ help + matTooltip="{{ 'rule-node-config.math-templatization-tooltip' | translate }}">info rule-node-config.key-field-input-required diff --git a/ui-ngx/src/app/modules/home/components/rule-node/common/arguments-map-config.component.html b/ui-ngx/src/app/modules/home/components/rule-node/common/arguments-map-config.component.html index b98854d0e5..aa61beb32a 100644 --- a/ui-ngx/src/app/modules/home/components/rule-node/common/arguments-map-config.component.html +++ b/ui-ngx/src/app/modules/home/components/rule-node/common/arguments-map-config.component.html @@ -67,7 +67,7 @@ - help + info rule-node-config.argument-key-field-input-required diff --git a/ui-ngx/src/assets/help/en_US/math/math-methods_fn.md b/ui-ngx/src/assets/help/en_US/math/math-methods_fn.md new file mode 100644 index 0000000000..e9cb7bb13e --- /dev/null +++ b/ui-ngx/src/assets/help/en_US/math/math-methods_fn.md @@ -0,0 +1,31 @@ +## Built-in mathematical functions +The following expression field provides support for built-in mathematical functions that you can utilize for various calculations. + +| Function | Description | Example | +|---------------|---------------------------------------------------------------------|-------------------| +| `abs(x)` | Absolute value of `x`. | `abs(-7) = 7` | +| `acos(x)` | Arc cosine of `x`, result in radians. Requires `-1 ≤ x ≤ 1`. | `acos(1) = 0` | +| `asin(x)` | Arc sine of `x`, result in radians. Requires `-1 ≤ x ≤ 1`. | `asin(0) = 0` | +| `atan(x)` | Arc tangent of `x`, result in radians. | `atan(0) = 0` | +| `cbrt(x)` | Cube root of `x`. | `cbrt(8) = 2` | +| `ceil(x)` | Rounds `x` up to the nearest integer. | `ceil(3.1) = 4` | +| `cos(x)` | Cosine of `x`, where `x` is in radians. | `cos(0) = 1` | +| `cosh(x)` | Hyperbolic cosine of `x`. | `cosh(0) = 1` | +| `cot(x)` | Cotangent of `x` (1 / tan(`x`)), where `x` is in radians. | `cot(0.7854) ≈ 1` | +| `exp(x)` | Computes `e^x`. | `exp(0) = 1` | +| `expm1(x)` | Computes `e^x - 1` accurately for small `x`. | `expm1(0) = 0` | +| `floor(x)` | Rounds `x` down to the nearest integer. | `floor(3.9) = 3` | +| `ln(x)` | Natural logarithm (base *e*) of `x`. Requires `x > 0`. | `ln(1) = 0` | +| `log(x)` | Natural logarithm (base *e*) of `x`. Requires `x > 0`. | `log(1) = 0` | +| `lg(x)` | Natural logarithm (base 10) of `x`. Requires `x > 0`. | `lg(10) = 1` | +| `log10(x)` | Logarithm base 10 of `x`. Requires `x > 0`. | `log10(100) = 2` | +| `log2(x)` | Logarithm base 2 of `x`. Requires `x > 0`. | `log2(8) = 3` | +| `logab(a, b)` | Logarithm of `b` with base `a`. Requires `a > 0`, `b > 0`, `a ≠ 1`. | `logab(2, 8) = 3` | +| `log1p(x)` | Computes `ln(1 + x)` accurately for small `x`. Requires `x > -1`. | `log1p(0) = 0` | +| `pow(x, y)` | Raises `x` to the power of `y` (`x^y`). | `pow(2, 3) = 8` | +| `signum(x)` | Returns the sign of `x`: -1 if `x < 0`, 0 if `x = 0`, 1 if `x > 0`. | `signum(-5) = -1` | +| `sin(x)` | Sine of `x`, where `x` is in radians. | `sin(0) = 0` | +| `sinh(x)` | Hyperbolic sine of `x`. | `sinh(0) = 0` | +| `sqrt(x)` | Square root of `x`. Requires `x ≥ 0`. | `sqrt(4) = 2` | +| `tan(x)` | Tangent of `x`, where `x` is in radians. | `tan(0) = 0` | +| `tanh(x)` | Hyperbolic tangent of `x`. | `tanh(0) = 0` | From 1f8fa241d639464bc36c79b22cab8f968800d140 Mon Sep 17 00:00:00 2001 From: mpetrov Date: Tue, 8 Apr 2025 19:05:05 +0300 Subject: [PATCH 2/3] Adjusted doc file --- .../assets/help/en_US/math/math-methods_fn.md | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/ui-ngx/src/assets/help/en_US/math/math-methods_fn.md b/ui-ngx/src/assets/help/en_US/math/math-methods_fn.md index e9cb7bb13e..9a5ddf3530 100644 --- a/ui-ngx/src/assets/help/en_US/math/math-methods_fn.md +++ b/ui-ngx/src/assets/help/en_US/math/math-methods_fn.md @@ -1,5 +1,30 @@ +## Built-in operators +The following operators can be used in expressions: + +| Operator | Description | Example | +|----------|-------------------------------|-----------------| +| `+` | Addition or unary plus | `2 + 3` or `+3` | +| `-` | Subtraction or unary minus | `5 - 2` or `-3` | +| `*` | Multiplication | `4 * 2` | +| `/` | Division | `10 / 2` | +| `^` | Exponentiation | `2 ^ 3` | +| `%` | Modulo | `10 % 3` | + + +## Implicit multiplication +Expressions supports implicit multiplication, allowing you to omit the multiplication operator in certain cases. For example, the expression `2cos(yx)` is interpreted as `2*cos(y*x)`. Similarly, `3x` is interpreted as `3*x`, and `xy` as `x*y`. This feature makes writing expressions more concise and natural. + +## Built-in constants +Available constants for calculations: + +| Constant | Description | Value | +|-------------|-----------------------------|-------------------| +| `π` or `pi` | The mathematical constant π | 3.141592653589793 | +| `e` | Euler's number | 2.718281828459045 | +| `φ` | The golden ratio | 1.618033988749895 | + ## Built-in mathematical functions -The following expression field provides support for built-in mathematical functions that you can utilize for various calculations. +The following built-in mathematical functions can be used to perform various calculations: | Function | Description | Example | |---------------|---------------------------------------------------------------------|-------------------| From 19b18a596f2279e81e36ff998560d0309bd538d1 Mon Sep 17 00:00:00 2001 From: mpetrov Date: Wed, 9 Apr 2025 11:07:02 +0300 Subject: [PATCH 3/3] Changed back icons to helps --- .../rule-node/action/math-function-config.component.html | 2 +- .../rule-node/common/arguments-map-config.component.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/rule-node/action/math-function-config.component.html b/ui-ngx/src/app/modules/home/components/rule-node/action/math-function-config.component.html index 3b91c56acf..3147162f06 100644 --- a/ui-ngx/src/app/modules/home/components/rule-node/action/math-function-config.component.html +++ b/ui-ngx/src/app/modules/home/components/rule-node/action/math-function-config.component.html @@ -79,7 +79,7 @@ info + matTooltip="{{ 'rule-node-config.math-templatization-tooltip' | translate }}">help rule-node-config.key-field-input-required diff --git a/ui-ngx/src/app/modules/home/components/rule-node/common/arguments-map-config.component.html b/ui-ngx/src/app/modules/home/components/rule-node/common/arguments-map-config.component.html index aa61beb32a..b98854d0e5 100644 --- a/ui-ngx/src/app/modules/home/components/rule-node/common/arguments-map-config.component.html +++ b/ui-ngx/src/app/modules/home/components/rule-node/common/arguments-map-config.component.html @@ -67,7 +67,7 @@ - info + help rule-node-config.argument-key-field-input-required