Conditional Formatting Rules
Conditional formatting rules help you highlight important data in your workbook visualizations based on criteria you set. For instance, you can customize cell backgrounds, font sizes, styles, and more.
For more information about conditional formatting in SuiteAnalytics Workbook, see Conditional Formatting.
You can create a conditional formatting rule using workbook.createConditionalFormatRule(options). This method creates a workbook.ConditionalFormatRule object. To create a rule, you'll need to provide these parameters:
-
filter
– A filter indicating when the conditional formatting rule should be applied. Use workbook.createTableColumnFilter(options) to create this filter as a workbook.TableColumnFilter object. To create a filter, combine an operator with a set of values. Use operators (or their string equivalents) from the query.Operator enum. Values are specified based on the column the filter is used for and the operator used.var myFilter = workbook.createTableColumnFilter({ operator: query.Operator.ANY_OF, values: [myArrayOfValues] });
-
style
– The style to apply when the filter evaluates totrue
. Create a style using workbook.createStyle(options) which returns a workbook.Style object. When you create a style, you can use supporting methods such as workbook.createColor(options) and workbook.createFontSize(options) to define the different attributes of a style. For more information, see Styles.var myStyle = workbook.createStyle({ backgroundColor: workbook.createColor({ red: 255, green: 255, blue: 0 }); });
Use both parameters to create a conditional formatting rule:
var myRule = workbook.createConditionalFormatRule({
filter: myFilter,
style: myStyle
});
Once you have your rules, use workbook.createConditionalFormat(options) to combine them into a single workbook.ConditionalFormat object:
var myConditionalFormat = workbook.createConditionalFormat({
rules: [myFirstRule, mySecondRule]
});
To apply the rules to a column, pass a workbook.ConditionalFormat object to workbook.createTableColumn(options). For more information, see Table Columns.
var myTableColumn = workbook.createTableColumn({
datasetColumnAlias: 'MyColumn',
conditionalFormats: [myFirstConditionalFormat, mySecondConditionalFormat]
});