filter()
Description
Filters items in the diagram
Usage
filter(
    rule?: function, 
    config?: {
        id?: string,
        add?: boolean,
        permanent?: boolean
    }
): void;
// or
filter(
    rule?:{
        by?: string | number,
        match?: string | number | boolean,
        compare?: (value, match, item) => {}
    },
    config?:{
        id?: string,
        add?: boolean,
        permanent?: boolean
    }
): void;
Parameters
rule- (optional) the filtering criteria- If set as a function, filtering will be applied by the rule specified in the function. The function takes an object of a data item as a parameter
 - If set as an object, the parameter can have the following attributes:
by- (optional) the key of the item attributematch- (optional) a pattern to matchcompare- (optional) a function for extended filtering. The function returns either true or false and takes three parameters:value- the value to comparematch- a pattern to matchitem- a data item the values of which should be compared (e.g. a shape)
 
config- (optional) an object which defines the parameters of filtering. The object may contain the following properties:id- (optional) the id of the filteradd- (optional) defines whether each next filtering will be applied to the already filtered data (true), or to the initial data (false, default)permanent- (optional) true to make the current filter permanent. It will be applied even if the next filtering doesn't have theadd:trueproperty in its configuration object. Such a filter can be removed just with the resetFilter() method
Example
const diagram = new dhx.Diagram("diagram_container", {
    type: "default"
});
diagram.data.parse(data);
// filtering by the rule specified in the function
diagram.data.filter(function (shape) {
    return shape.id > 3;
});
// filtering by the key of the shape attribute
diagram.data.filter({ by: "text", match: "Read N" });
To revert the diagram to the initial state, call the filter() method without parameters.
diagram.data.filter();
Related articles: Filtering items
Related sample: Diagram. Data. Filtering shapes
Change log: Updated in v6.0