Check documentation for the latest version of dhtmlxSuite Filtering DHTMLX Docs

Filtering

Charts provides ability to filter data by one or several criteria. In this case, only items that match the parameters will be shown.

To filter a dataset, you need to call the filter() method. Each time the method is called, all chart data are refiltered (previous results aren't preserved).

It's possible to call the filter method in two modes:

  • filter(property,value)

This approach is used for 'contains' filtering. It is simple, but isn't flexible. The method shows items where "property" (the first parameter) contains 'value' (the second parameter). Such a filtering isn't case-sensitive:

chart.filter("#country#","Russia");
  • filter(function)

Using function as a parameter allows to define different filter rules and to filter by multiple properties. Filtering function is called for each object of dataset, and if it returns true, the object will be displayed:

chart.filter(function(obj){
    if (obj.sales > 10 && obj.company == "Company 3") return true;
    return false;
})

Related sample:  Filtering

Back to top