-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Category filtering in DataFilterExtension #7915
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f400cda
b8d52d7
e1761df
89c5a1b
d4384b4
b56b41f
3bb112c
1fc4506
57f27a0
cb17634
de6b99c
e8b1dbd
fec02f8
fc45b28
ca70323
814908e
90c58bf
cf50efb
56da6e3
12458fd
acdba21
b0ed6aa
ddd8686
e609c2b
27412dc
12d5b54
85bf4e1
3ccc11d
5277a97
ec7dbc3
094feaf
9c5895a
15ca037
e21a0d2
df6e26a
773f04b
5aafa93
fbe40d4
1cc4007
a122db6
e6f2d3a
2a07836
4ee73a3
4afe168
318b8cf
7a48643
dc1d53f
f73a919
1e94235
cec57c9
2978069
0c97897
2628519
0344ca7
11cb8c5
2dfd6e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,6 +71,7 @@ new DataFilterExtension({filterSize, fp64}); | |
| ``` | ||
|
|
||
| * `filterSize` (Number) - the size of the filter (number of columns to filter by). The data filter can show/hide data based on 1-4 numeric properties of each object. Default `1`. | ||
| * `categorySize` (Number) - the size of the category filter (number of columns to filter by). The category filter can show/hide data based on 1-4 properties of each object. Default `1`. | ||
| * `fp64` (Boolean) - if `true`, use 64-bit precision instead of 32-bit. Default `false`. See the "remarks" section below for use cases and limitations. | ||
| * `countItems` (Boolean) - if `true`, reports the number of filtered objects with the `onFilteredItemsChange` callback. Default `false`. | ||
|
|
||
|
|
@@ -153,6 +154,63 @@ Format: | |
| * If `filterSize` is `1`: `[softMin, softMax]` | ||
| * If `filterSize` is `2` to `4`: `[[softMin0, softMax0], [softMin1, softMax1], ...]` for each filtered property, respectively. | ||
|
|
||
| ##### `getFilterCategory` ([Function](../../developer-guide/using-layers.md#accessors), optional) {#getfiltercategory} | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: This name didn't click immediately for me. I would probably have gone with
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't love it either, I was trying to stay "consistent" with |
||
|
|
||
| * Default: `0` | ||
|
|
||
| Called to retrieve the category for each object that it will be filtered by. Returns either a category as a number or string (if `categorySize: 1`) or an array. | ||
|
|
||
| For example, consider data in the following format: | ||
|
|
||
| ```json | ||
| [ | ||
| {"industry": "retail", "coordinates": [-122.45, 37.78], "size": 10}, | ||
| ... | ||
| ] | ||
| ``` | ||
|
|
||
| To filter by industry: | ||
|
|
||
| ```js | ||
| new ScatterplotLayer({ | ||
| data, | ||
| getPosition: d => d.coordinates, | ||
| getFilterCategory: d => d.industry, | ||
| filterCategories: ['retail', 'health'], | ||
| extensions: [new DataFilterExtension({categorySize: 1})] | ||
| }) | ||
| ``` | ||
|
|
||
| To filter by both industry and size: | ||
|
|
||
| ```js | ||
| new ScatterplotLayer({ | ||
| data, | ||
| getPosition: d => d.coordinates, | ||
| getFilterCategory: d => [d.industry, d.size], | ||
| filterCategories: [['retail', 'health'], [10, 20, 50]], | ||
| extensions: [new DataFilterExtension({categorySize: 2})] | ||
| }) | ||
| ``` | ||
|
|
||
| ##### `filterCategories` (Array, optional) {#filtercategories} | ||
|
|
||
| * Default: `[0]` | ||
|
|
||
| The list of categories that should be rendered. If an object's filtered category is in the list, the object will be rendered; otherwise it will be hidden. This prop can be updated on user input or animation with very little cost. | ||
|
|
||
| Format: | ||
|
|
||
| * If `categorySize` is `1`: `['category1', 'category2']` | ||
| * If `categorySize` is `2` to `4`: `[['category1', 'category2', ...], ['category3', ...], ...]` for each filtered property, respectively. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we avoid the overloading and always required nested array, and just use firm typescript typing?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could it be a map with column names?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, I prioritized consistency with existing API here |
||
|
|
||
| The maximum number of supported is determined by the `categorySize`: | ||
felixpalmer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - If `categorySize` is `1`: 128 categories | ||
| - If `categorySize` is `2`: 64 categories per dimension | ||
| - If `categorySize` is `3` or `4`: 32 categories per dimension | ||
|
|
||
| If this value is exceeded any categories beyond the limit will be ignored. | ||
|
|
||
| ##### `filterTransformSize` (Boolean, optional) {#filtertransformsize} | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be auto-detected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps in a followup PR. But in that case
filterSizeshould also support it. Part of me thinks it is good to have it be explicit as then the user intention is clear. For auto detection, should we usefilterCategoriesor thegetFilterCategoryaccessor? What if they don't match?