Advanced reporting
and data visualization components for .NET
LIVE CHAT Welcome, guest

How to use expressions to design gauges?

Sometimes it is necessary to design non-standard interactive gauges with unique functionality, for example to indicate value exceeding some range and in this way to allow a user to perform data analysis and get data that is more comprehensible. Such interactivity can be easily added to any gauge element or to the whole gauge with help of expressions. No sophisticated code, just a couple of expressions and you get the instrument with required behavior.

The expressions are used to provide elements interaction and to assign the required gauge functionality. Expressions can be used for the whole instrument and all its elements. An expression, which calculation result will be bound to the property, can be assigned to the majority of gauge properties.

Expressions are calculated in the following way. If the element state is changed, recalculation of expressions of this element as well as of all elements included in it occurs. The expression calculation result is assigned to the appropriate element property.

In order to have all gauge element expression values recalculated when the element state is changed, it is necessary to set the RecalculateAll property to “true”. The alteration of some properties, assigning the element appearance, doesn’t invoke expressions recalculation. For example, the alteration of such properties as Fill, Stroke doesn’t invoke expressions recalculation; therefore there is no need to apply to the values of such properties. If the expression contains syntax, semantic errors, or the exception appears during the calculation process, the expression is ignored.

The expression is built out of constants, objects and their properties and methods, operators, function callings and round brackets.

Data types used: all data types available in .NET framework are used in the expressions. Also there is a special support for integer-valued, fractional, logical values, strings and vectors. The PerpetuumSoft.Framework.Drawing.Vector data type is used for vectors.

It is possible to realize custom functions and variables in the expressions.

In order to make custom functions and variables available in the element expressions, it is necessary to realize a custom element, which will correspondingly realize the PerpetuumSoft.Framework.Expressions.IExpressionSite interface.

After that you need to register your function. It can be done in the following way:
PerpetuumSoft.Framework.Expressions.BuiltInFunctions.RegisterFunction(, );

More information on expressions language syntax and semantics can be found in the SharpShooter Collection User Guide. Example of using expression to assign custom gauge behavior can be found in the SharpShooter Gauges Samples Center: Functionality -> Expressions.