Conditional Attributes

The Conditional Attributes feature of Chart FX provides a built in solution to configure point attributes for chart points that meet a configured condition. The value of each point is evaluated against the items in the ConditionalAttributes collection. When the point's value meets the conditions configured, that ConditionalAttributes object would be assigned to the point; retaining the configured attributes.

The conditional attributes allow coloring points and setting marker size and shape independently without the need for creating complex algorithms to evaluate chart values. The ConditionalAttributes class derives from the PointAttributes class. For more information regarding the supported members of these classes, please consult the Chart FX API Reference.

In the following chart, Stripe objects where configured to show the different ranges in a chart. The ranges are 0-33 (green), 33-66 (yellow) and 66-100 (red). Using 3 conditional attributes, one for each range, the points of the scatter plot were customized depending on their value.

There are a myriad of applications for this feature, and the API is very simple. As stated before, the ConditionalAttributes class derives from the PointAttributes class. The Condition class is what is used to configure the conditions used to evaluate each point.

The Conditional Range
The conditional range is determined by two properties, To and From. These two properties specify the beginning and ending values of a range, which the point must fall between in order for a ConditionalAttributes object to be applied. The ToOpen and FromOpen properties are used to specify whether the beginning or ending values will be included in the range.

Other Condition Class Members
Other API members included allow you to configure a selected ConditionalAttributes item as inactive (Active property), or to Evaluate a point to determine whether it would meet the conditions of a particular conditional attributes object or not.

The Inverse property allows developers to reverse the To and From attributes of a conditional attributes item. As an alternative to creating two independent ConditionalAttributes, in some situations developers may use this attribute to achieve the same functionality.

For example, lets imagine that you want to color all points less than 50 AND greater than 70 Blue, all values between are to be Red. Normally you would create 3 conditional attributes to achieve this, however, using the Inverse property this can be done using only two conditional attribute items.

  • The first attribute item will be configured: From 50, To 70, Color Blue, Inverse True.
  • The second attribute item will be configured: From 50, To 70, Color Red.

Please see the API Reference (Chart FX Resource Center) for a complete reference of the supported members for the Condition and ConditionalAttributes classes.