Changing filters before applying to the visualizations


#1

Hello, I have a somewhat complex situation, I need to apply a filter and intercept it before it is applied to the visualizations and thus be able to change its value according to a certain criteria, is it possible? :slightly_frowning_face:


#2

Hey @dani yes it is, yo have to use some event in theInteraction manager, just let me show you an example:

if you don’t wnat to apply that filter you just have to use this:

const im = cf.getIManager();

im.on('filter:before-add', (data) => {
    const myFilter = data.filters.find(
        (f) => f._sender.type === 'Slicer'
    );

    if (myFilter) {
        im.get('api').stopExecution();
    }
}

but if you want to change something and apply your own filter you can do this:

const im = cf.getIManager();

im.on('filter:before-add', (data) => {
    const slicerFilter = data.filters.find(
        (f) => f._sender.type === 'Slicer'
    );

    if (slicerFilter && slicerFilter._values.includes('myCriteria')) {
        // do something
    }
}

#3

this is one of the reasons why i love chartfactor, thank you so much it really helps me


#4

Great!, that ssounds really good, and actually we are working on some new stuff each moth, so you are goint to se more interesting things