-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Externalizing Crossfilter specific behavior
- Loading branch information
1 parent
ee9dd26
commit 618dc0a
Showing
7 changed files
with
81 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { MinimalCFDimension, MinimalCFGroup } from '../core/index.js'; | ||
import { ICFHelper } from './i-c-f-helper.js'; | ||
|
||
export const cfHelper: ICFHelper = { | ||
applyFilters: (dimension: MinimalCFDimension, filters: any[]) => { | ||
if (!(dimension && dimension.filter)) { | ||
return; | ||
} | ||
if (filters.length === 0) { | ||
dimension.filter(null); | ||
} else if (filters.length === 1 && !filters[0].isFiltered) { | ||
// single value and not a function-based filter | ||
dimension.filterExact(filters[0]); | ||
} else if (filters.length === 1 && filters[0].filterType === 'RangedFilter') { | ||
// single range-based filter | ||
dimension.filterRange(filters[0]); | ||
} else { | ||
dimension.filterFunction(d => { | ||
for (let i = 0; i < filters.length; i++) { | ||
const filter = filters[i]; | ||
if (filter.isFiltered) { | ||
if (filter.isFiltered(d)) { | ||
return true; | ||
} | ||
} else if (filter <= d && filter >= d) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}); | ||
} | ||
}, | ||
|
||
storageKey: (provider: any) => { | ||
const { shareFilters, dimension } = provider.conf(); | ||
if (shareFilters) { | ||
return dimension; | ||
} else { | ||
return provider; | ||
} | ||
}, | ||
|
||
getGroupings: (dimension: any, group: MinimalCFGroup) => { | ||
return group.all(); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { CFGrouping, MinimalCFDimension, MinimalCFGroup } from '../core/index.js'; | ||
|
||
export interface ICFHelper { | ||
applyFilters(dimension: MinimalCFDimension, filters: any[]): void; | ||
storageKey(provider: any): any; | ||
getGroupings(dimension: any, group: MinimalCFGroup): ReadonlyArray<CFGrouping>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters