Pricing changes are coming in January. Contact our Sales team to secure the current price for your desired license.
All documentation
  • API Reference for older versions
  • addCondition

    addCondition(condition: ConditionalFormatObject)

    [starting from version: 1.5]

    Adds a conditional formatting rule for cell values to format them with specific styles if the condition for the cell value is met. Learn more in this guide: Conditional formatting.

    Use refresh() API call after to redraw the component and see changes.

    Parameters

    Parameter/TypeDescription
    condition
    ConditionalFormatObject
    The object that describes the conditional formatting rule.

    Examples

    1) If cell value is more than 400000, then apply format to this cell:

    let condition = {
    id: 1,
    formula: '#value > 400000',
    format: { fontSize : "10px", backgroundColor: "#33BB33" }
    };

    pivot.addCondition(condition);
    pivot.refresh();

    Open the example on JSFiddle.

    2) This rule will be applied only to the Price measure's total and subtotal cells. If Price is between 100000 and 1000000, then the format is applied:

    let condition = {
    id: 2,
    measure: "Price",
    aggregation: "sum",
    isTotal: true,
    formula: 'AND(#value > 100000, #value < 1000000)',
    format: { fontSize : "11px", backgroundColor: "#00FF00" }
    };

    pivot.addCondition(condition);
    pivot.refresh();

    Check how it works on JSFiddle.

    3) If cell value is empty, then apply format to this cell:

    let condition = {
    id: 1,
    formula: 'isNaN(#value)',
    format: { backgroundColor: "#FFFF11" }
    };

    pivot.addCondition(condition);
    pivot.refresh();

    Open the example on JSFiddle.

    See also

    getCondition
    getAllConditions
    removeCondition
    removeAllConditions
    refresh
    Conditional formatting tutorial