Skip to content

Commit 375b781

Browse files
committed
Fix: support multiple filters on widgets (fixes #461)
1 parent dc292ae commit 375b781

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/app/components/widgets/base-widget.class.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2126,18 +2126,25 @@ export class BaseWidget implements OnInit, OnDestroy {
21262126
private applyFilters(filters: IFilter[]) {
21272127
const active = filters.filter(flt => {
21282128
// Skip all apply variable filters
2129-
if (flt.action === 'applyVariable') {
2129+
if (flt.action === 'applyVariable') {
21302130
return false;
21312131
}
21322132
return flt.value !== '';// && !flt.isInterval
21332133
});
21342134

2135+
if (active.length === 0) {
2136+
return '';
2137+
}
21352138
if (active.length === 1) {
2136-
// One dimension
2137-
return ' %FILTER ' + this.getFilterString(active[0])
2138-
} else {
2139-
const strings = active.map(flt => this.getFilterString(flt));
2140-
return ' %FILTER NONEMPTYCROSSJOIN(' + strings.join(',') + ')';
2139+
return ' %FILTER ' + this.getFilterString(active[0]);
2140+
}
2141+
2142+
// Nested NONEMPTYCROSSJOIN for any number of filters > 1
2143+
const strings = active.map(flt => this.getFilterString(flt));
2144+
let crossjoin = strings[0];
2145+
for (let i = 1; i < strings.length; i++) {
2146+
crossjoin = `NONEMPTYCROSSJOIN(${crossjoin},${strings[i]})`;
21412147
}
2148+
return ' %FILTER ' + crossjoin;
21422149
}
21432150
}

0 commit comments

Comments
 (0)