This element lets you write an analytic expression for a function and use it to evaluate the function on given arguments.
The expressions are parsed to make the computations. Check here for the right syntax.
The expressions may contain any number of variables. To make the computation, you need to invoke the element evaluate() function with a JavaScript object with all these variables as properties.
For instance, if your function element is called myFunction and the expression it contains is x+y, you can evaluate the function as in:
var result = _view.myFunction.evaluate( { x : 3 , y : 2 } );
result should be 5.
If your expression contains many parameters (variables which rarely change their value), as in a*x^3+b*x^2+c*x+d, you can save the effort of passing each time the values of the parameters a,b,c,d, by setting:
_view.myFunction.setParameters( { a : 1 , b : 3 , c : -1, d : -2 } );
and then evaluate the function by simply invoking:
var result = _view.myFunction.evaluate( { x : 3 } );
The parameters do not change until you call setParameter again.
If you invoke once:
var result = _view.myFunction.evaluate( { a : 0, x : 3 } );
then this value of a will be called for this particular evaluation. But the next time, the value of the parameter a will still be 1.
Main |
Name | Description | Values accepted | Default |
Value | The value displayed by the element. | A constant or variable of type double or int. | - |
Editable | Whether the element is editable. | A constant or variable. | - |
OnChange | The action to invoke when the element is pressed. | The JavaScript code to invoke for the action. | - |
OnError | The action to invoke when on error. | The JavaScript code to invoke for the action. | - |
Name | Description | Values Accepted | Default |
Visibility | The visibility of the element. | Boolean variable or constants true or false. | true |
Display | Display style, can use "none," "inline-block," etc. | Boolean variable or constants true or false. | "block" |
Width | Width in pixels (e.g., 400px) or percentage (e.g., 100%). | - | 400px |
Height | Height in pixels (e.g., 300px) or viewport height (e.g., 90vh). | - | 300px |
Background | The background color for the element. Use the editor provided or read about colors. | - | - |
Foreground | The color to use when drawing or writing in the element. Use the editor provided or read about colors. | - | - |
Font | The font used to display text in the element. Use the editor provided to select name, style, and size of the font. | - | "normal normal 10px " |
Tooltip | Text displayed when the mouse is over the element. | String constant or variable. | - |
ClassName | Class name. | String constant or variable. | - |
CSS | CSS. | String constant or variable. | - |
Transform | Transform. | String constant or variable. | - |