filter

filters shapes in the diagram by the specified key

void filter(object|function criteria, [boolean mode] );

Parameters

criteriaobject|functionthe filtering criteria (either the key of the shape attribute or a filtering function)
modebooleanoptional, true to define that each next filtering will be applied to the already filtered data, not to the initial data

Example

// filtering by the key of the shape attribute
diagram.data.filter({by:"text",match:"Manager"});
 
// filtering by a function
diagram.data.filter(function(shape){
    if(shape.text==="Manager"||shape.text==="Marketer"){return true}
});

Related samples

Details

The criteria parameter set as object has the following attributes:

  • by - (string) the key of the shape attribute
  • match - (string) the value of the shape attribute

The method will render only the shapes that meet the filtering criteria. To revert the diagram to the initial state, call the filter() method without parameters.

diagram.data.filter();
See also
Back to top