Identify the use of specific filters


#1

Hi everyone, I am working on a react application using the Chartfactor toolkit and I need to identify when a specific filter is applied and execute an action when that happens, my question is: is it possible to know the type of filter applied and the value it contains using the interaction manager?


#2

Hi @davisg, sounds like you need to subscribe to an event, the chart factor widgets have many events that you can subscribe to, but I don’t understand what kind of filter you want to detect, in any case, the interaction manager has a list of events that you could use, for example the filter called filter:added:

im.on('filter:added', e => {/* do something*/})

is this what you are looking for?


#3

Hi @davisg i was trying something similar, that was mi solution:

  1. Get the IM (Interaction manager) instance:
  • You can do this:
const im = cf.AktiveInstances.find(instance => instance.get('visualization') === "Interaction Manager")
  • Or this:
const im = cf.getVisualization("your_im_id");
  1. Get all the IM filters:
im.get('api').getFilters()
// it returns all filters and their values
  1. Evaluate the filter content you need.

#4

Yes @emoya i saw that event in the documentation, thanks for reply, but the thing is… i want to evaluate the filters in other event.


#5

Hi @dani, this is just what i was looking for because i need to evaluate filters using an onClick event in my app, thanks a lot. :woman_technologist: :smiley::pray:


#6

Hi @dani and @davisg, we can improve a little more, using this:

const im = cf.getIManager()

to get the Interaction manager.