Documentation menu
Conditional Format Object
Each conditional formatting rule is described by the Conditional Format Object. To define conditional formatting, specify the necessary rules in the report.conditions
property.
Properties
Name | Type | Description |
---|---|---|
formula | String | Condition rule. Can include AND , OR , == , != , > , >= , < ,<= , - , + , * , / , isNaN() , !isNaN() . #value is used for referring to the value of the cell in the condition. Example: '#value > 3' . |
format | Object | Style object applied if the cell value meets the condition. Set color value as hex color codes. This is important for exports to PDF and Excel. |
id | Number | optional Identifier in the conditional formatting rule. If id is not specified, the id for the rule is set inside the component automatically. |
row | Number | optional Row index where the condition is applied. |
column | Number | optional Column index where the condition is applied. |
measure | String | optional Measure name to which the condition will be applied. |
isTotal | Boolean | optional If undefined, the condition will affect all cells. If true , the condition affects subtotals and totals cells alone. If false it affects only the regular cells. |
Example
Add a conditional formatting rule:
const pivot = new WebDataRocks({
container: "#wdr-component",
toolbar: true,
height: 395,
report: {
conditions: [{
formula: "#value > 1000000",
format: {
backgroundColor: "#C5E1A5",
color: "#000000",
fontFamily: "Arial",
fontSize: "12px"
}
}],
dataSource: {
filename: "https://cdn.webdatarocks.com/data/data.csv"
}
}
});
Try it out on CodePen.