跳转至

Conditional formatting enables the configuration of rules for any property and dictates how that property’s values will be rendered (e.g. coloring, alignment, etc.) in user facing applications. When you configure conditional formatting in the Ontology Manager, the formatting rules will apply in Object Explorer, Object Views, Quiver, and Workshop.

Example

For the example Aircraft object type in Object Explorer, pictured above, the type and wifi properties have their values in colored boxes that are applied based on certain conditions. The main benefit of adding these is to make information easier to understand quickly. If an analyst was looking for all “A320” planes without wifi in “JFK”, just by glancing at the results above, we could tell that “Q-AAY” is the plane we’re after.

Let’s take a look at how these conditions are applied.

  • For property wifi, we assign green if the value of the property is “true” for each object in the table, and red if it is “false."

Example rules

  • For property type, we assign colors based on exact match between “A320”, “A321” and “A330”.

Example type colors

Add conditional formatting

In the property editor:

  1. Select the property to which you want to add conditional formatting.
  2. You will see conditional formatting on the properties pane; select the Add a rule button.

Add a rule

  1. Click on the newly created default rule to open the Edit conditional formatting rule editor. Read on for more information about the components of the Rule editor.
  2. Modify the rule.

Modifying a rule

Edit rules using the Rule editor

Rule editor

Label Description Usage
A Switch between a Standard rule, an Always true rule, or a Math rule. Use Always true as a fallback in case your other rules don't match. In the example above, we could have grey as the fallback case when neither of the type values match.

Use a Math rule when you want to run math operators on some of your properties.
B The rule will always be applied to the property from which you selected Add a rule; however, this dropdown allows you to choose to apply the rule based on the value of another property. In the case above, assume we want to color the value for Type in red when the value of Performance factor drops underneath a certain threshold. We would choose Performance factor in our logic instead of Type; however, the color would still show on Type.
C Types of comparisons available are based on the type of the property. For example, for strings String comparison and Is null are available. For numeric types, Numeric range or Exact numeric match are available. To color the type in grey if the value is null, select this dropdown and choose Is null instead of String comparison.
D Subtypes of comparisons, String comparison has Is exactly, Contains, Starts with, etc. Use this to color all plane type values that Start with "A32".
E Compare against a constant or a property reference. In this case, we are specifically looking for the constant "A320", but we could also add a reference from another property from the same object type.
F Toggle between a True or False rule. To color all planes in blue that are not A320, switch this to False.
Formatting Use Blueprint colors and intents or add your own custom color. You can also switch alignment. Switch between hex, RGB or Blueprint colors based on need; you can also align the boxes on the right hand side for easier readability for numbers.
Preview View how conditional formatting appears in various contexts. Preview an Objects table or a Property card.

Copy rules

In the property editor:

  1. Select the property from which you want to copy the conditional formatting rule.

  2. You will see conditional formatting on the properties pane; select the Copy rules button to open the Copy rule dialog.

Property editor

  1. Select the properties to which you want to copy the conditional formatting rules.

:::callout{theme="neutral"} If the properties you are copying to already have their own conditional formatting rules, they will be overwritten by the new rules. :::

Copy rule

Copied rules will continue referencing their original properties. For example, if a rule states that wifi values should appear green when “true,” and that rule is copied to the customer experience property, values of the customer experience property will also be green when the object’s wifi value is “true.” To change the property a rule references, simply select the rule and choose a new property from the Property dropdown in the rule editor.

FAQ

Will this work with existing type classes?

Conditional formatting takes precedence over existing type classes (with one exception detailed in the following question). If you have both configured, conditional formatting will be displayed. You can however, use conditional formatting on one property and type classes on another.

Will this work with editable properties in Object Views?

Conditional formatting is supported for properties configured for inline edits. Conditional formatting is disabled for properties with the legacy hubble:editable property type class.


中文翻译

条件格式化(Conditional formatting) 允许为任意属性配置规则,并决定该属性值在面向用户的应用程序中的渲染方式(例如颜色、对齐方式等)。当您在本体管理器(Ontology Manager)中配置条件格式化时,这些格式化规则将应用于对象浏览器(Object Explorer)、对象视图(Object Views)、Quiver 和 Workshop。

示例

以上图对象浏览器中的 Aircraft 对象类型为例,typewifi 属性的值显示在根据特定条件应用颜色的框中。添加这些格式的主要好处是让信息更易于快速理解。如果分析师正在寻找所有位于“JFK”且没有 wifi 的“A320”飞机,只需扫一眼上述结果,我们就能判断出“Q-AAY”正是我们要找的飞机。

让我们看看这些条件是如何应用的。

  • 对于 wifi 属性,如果表格中每个对象的该属性值为“true”,则分配绿色;如果为“false”,则分配红色。

示例规则

  • 对于 type 属性,我们根据与“A320”、“A321”和“A330”的精确匹配来分配颜色。

示例类型颜色

添加条件格式化

在属性编辑器中:

  1. 选择要添加条件格式化的属性。
  2. 您将在属性面板上看到条件格式化;选择 添加规则(Add a rule) 按钮。

添加规则

  1. 点击新创建的默认规则,打开 编辑条件格式化规则(Edit conditional formatting rule) 编辑器。继续阅读以了解规则编辑器(Rule editor)组件的更多信息
  2. 修改规则。

修改规则

使用规则编辑器编辑规则

规则编辑器

标签 描述 用法
A 标准(Standard) 规则、始终为真(Always true) 规则或 数学(Math) 规则之间切换。 当其他规则不匹配时,使用 始终为真(Always true) 作为回退规则。在上面的示例中,当 type 值都不匹配时,我们可以将灰色作为回退情况。

当您希望对某些属性运行数学运算符时,使用 数学(Math) 规则。
B 该规则将始终应用于您选择 添加规则(Add a rule) 的属性;但是,此下拉菜单允许您选择基于另一个属性的值来应用规则。 在上述情况下,假设我们希望在 Performance factor 值低于某个阈值时将 Type 的值显示为红色。我们会在逻辑中选择 Performance factor 而不是 Type;但颜色仍会显示在 Type 上。
C 可用的比较类型基于属性的类型。例如,对于字符串,可使用 字符串比较(String comparison)为空(Is null)。对于数值类型,可使用 数值范围(Numeric range)精确数值匹配(Exact numeric match) 如果值为空,要将 type 显示为灰色,请选择此下拉菜单并选择 为空(Is null) 而不是 字符串比较(String comparison)
D 比较的子类型,字符串比较(String comparison) 包含 精确等于(Is exactly)包含(Contains)以...开头(Starts with) 等。 使用此选项为所有 以(Starts with) "A32" 开头的飞机 type 值着色。
E 与常量或属性引用进行比较。 在这种情况下,我们专门查找常量"A320",但我们也可以从同一对象类型的另一个属性添加引用。
F 真(True)假(False) 规则之间切换。 要为所有 不是(not) A320 的飞机着蓝色,请将其切换为 假(False)
格式化(Formatting) 使用 Blueprint 颜色和意图,或添加您自己的自定义颜色。您还可以切换对齐方式。 根据需要切换十六进制、RGB 或 Blueprint 颜色;您还可以将框右对齐,以便更轻松地阅读数字。
预览(Preview) 查看条件格式化在不同上下文中的显示效果。 预览 对象表(Objects table)属性卡(Property card)。

复制规则

在属性编辑器中:

  1. 选择要从中复制条件格式化规则的属性。

  2. 您将在属性面板上看到条件格式化;选择 复制规则(Copy rules) 按钮以打开 复制规则(Copy rule) 对话框。

属性编辑器

  1. 选择要复制条件格式化规则的目标属性。

:::callout{theme="neutral"} 如果您复制到的属性已有自己的条件格式化规则,这些规则将被新规则覆盖。 :::

复制规则

复制的规则将继续引用其原始属性。例如,如果一条规则规定当 wifi 值为“true”时应显示绿色,并且该规则被复制到 customer experience 属性,那么当对象的 wifi 值为“true”时,customer experience 属性的值也将显示为绿色。要更改规则引用的属性,只需选择该规则,然后在规则编辑器的 属性(Property) 下拉菜单中选择一个新属性。

常见问题解答

这能与现有的类型类(Type classes)一起使用吗?

条件格式化优先于现有的类型类(下一个问题中详述的一个例外情况除外)。如果您同时配置了这两者,将显示条件格式化。但是,您可以在一个属性上使用条件格式化,在另一个属性上使用类型类。

这能与对象视图中的可编辑属性一起使用吗?

条件格式化支持配置了内联编辑(inline edits)的属性。对于具有旧版 hubble:editable 属性类型类的属性,条件格式化将被禁用。