function getFilterValues()

in packages/network-navigator-powerbi/src/NetworkNavigatorVisual.ts [324:354]


function getFilterValues(dv: powerbi.DataView, filterPath: string): string[] {
    const savedFilter: any = get(
        dv,
        `metadata.objects.${filterPath}`,
    );
    if (savedFilter) {
        const appliedFilter = filter.FilterManager.restoreFilter(savedFilter);
        if (appliedFilter) {
            // The way we do this is a little funky
            // Cause it doesn't always produce what the interface says it should
            // sometimes it has 'values' property, other times it has conditions
            const conditions = get(appliedFilter, "conditions", get(appliedFilter, "values", []));
            return conditions.map((n: any) => {
                // This is also a little funky cause sometimes the actual value is nested under a 'value'
                // property, other times it is just the value
                let text = pretty(n);

                // Is an array
                if (n && n.splice) {
                    text = pretty(n[0].value);

                // If we have a non empty value property
                } else if (n && (n.value !== undefined && n.value !== null)) {
                    text = pretty(n.value);
                }
                return text;
            });
        }
    }
    return [];
}