DHTMLX Docs & Samples Explorer

Index
dhtmlxchart

## Filtering

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

To filter dataset you need to call 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","Russua");

- 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;
        })

An example that uses mentioned above methods you can see here.