Filter visuals under external conditions


#1

I have an application with several visuals and the interaction manager. I want that whenever a visual is clicked instead of applying the filters, they should check certain conditions. If they don’t meet the condition, they shouldn’t be applied at all, otherwise they can.

I was looking at the rules that can be defined as a configuration for the interaction manager, but honestly don’t see them fitting for my case. Is there any other way to do this?


#2

Hi @oliver, Can you be more specific with your example? Interaction Manager’s rules fit for most of the cases according to what you’re describing. Probably you will have to use the filterConditions property that allows a higher level of flexibility when it comes to what filter should be applied or not and how it should be applied.


#3

The thing is that some filters aren’t simply applicable to visualizations when they meet certain conditions. As I understood the filterConditions, it allows to let the visual know that certain filter should not affect it, but the filter will appear anyway listed in the Interaction Manager, but I want to treat it as it never existed.

So for example, let’s say that I have a field of a log type, although the log type is listed for information purposes, it should not be applied under certain conditions to avoid miss-reading. I want that filter to be completely ignored so when the user clicks on its value, nothing happens.


#4

I see your point and I agree, rules work at visualizations level, which means that the Interaction Manager takes the filter, process it, and if it is a valid filter then it will be stored and then it’ll try to apply to the visuals, but the filter will be shown in the Interaction Manager anyways.

What you need then is the the combination of two Interaction Manager events and one api method:

var api = im.get('api');
var yourValidation = function(event) {
  // If your conditions are not met
  api.stopExecution()
}
im.on('filter:before-add', yourValidation),
im.on('filter:before-remove', yourValidation)

These two events are triggered before the Interaction Manager does any filter processing or anything, so it’s the best moment to validate if it should continue with the usual flow or not. api.stopExecution() is what will completely stop that flow.