Filters for new charts

Hello, I have an app for a dashboard created using react and ChartFactor for the visualizations, the users can play around and apply some Filters depending on the charts they are clicking on.
Those visualizations are in collapsable areas so they don’t exist in the DOM until the user opens the area, so when some filters are already applied and the user opens a new area, the new charts don’t have the filters applied.
So my question is, is there a way to apply the current filters to the new charts when they are created?

Well first at all, you can get the filters from the Interaction manager, then convert all the filters to a class using something like this:


const IM = cf.getIManager(); // the interaction manager

const api = IM.get('api'); // the interaction API

const currentFilters = api.getFilters(); // get the current filters



yourVisualization.filters(currentFilters.map(f => {
    return cf.Filter().fromJSON(f);
}));

With this, your visualization will be updated with the current filters from the Interaction Manager.

1 Like

I see, well it was not working for me at the beginning, but it was because the .execute() method was not there, i added it and now it works fine.

So thanks for the help!