Skip to main content


filters items in the diagram

filter(rule?: IFilterCallback | IFilterMode, config?: IFilterConfig): void;


  • rule: function | object - the filtering criteria
  • config: object - optional, defines the parameters of filtering


// filtering by the key of the shape attribute{ by: "text", match: "Read N" });

// filtering by a function (shape) {
return > 3;

Related sample: Diagram. Data. Filtering shapes

To revert the diagram to the initial state, call the filter() method without parameters.;

The rule parameter:

  • if set as a function, the filtering will be applied by the rule specified in the function:

For example: (shape) {
return > 3;
  • if set as an object, the parameter has the following attributes:
by(string) mandatory, the key of the item attribute
match(string) mandatory, a pattern to match
compare(function) optional, a function for extended filtering that takes three parameters:
  • value - the value to compare
  • match - a pattern to match
  • item - a data item the values of which should be compared (e.g. a shape)

For instance:{ by: "text", match: "Read N" });

The config parameter may contain two properties:

add(boolean) defines whether each next filtering will be applied to the already filtered data (true), or to the initial data (false, default)
smartFilter(boolean) defines whether a filtering rule will be applied after adding and editing items of the collection

Filtering items