@@ -219,6 +219,29 @@ class DataFilterExtension(BaseExtension):
219
219
This extension dynamically enables the following properties onto the layer(s) where
220
220
it is included:
221
221
222
+ ## `filter_categories`
223
+
224
+ The list of categories that should be rendered. If an object's filtered category is
225
+ in the list, the object will be rendered; otherwise it will be hidden. This prop can
226
+ be updated on user input or animation with very little cost.
227
+
228
+ Format:
229
+
230
+ - If category_size is 1: ['category1', 'category2']
231
+ - If category_size is 2 to 4:
232
+ [['category1', 'category2', ...], ['category3', ...], ...] for each filtered
233
+ property, respectively.
234
+
235
+ The maximum number of supported is determined by the category_size:
236
+
237
+ - If category_size is 1: 128 categories
238
+ - If category_size is 2: 64 categories per dimension
239
+ - If category_size is 3 or 4: 32 categories per dimension.
240
+
241
+ If this value is exceeded any categories beyond the limit will be ignored.
242
+
243
+ Default: `[0]`
244
+
222
245
## `filter_enabled`
223
246
224
247
Enable/disable the data filter. If the data filter is disabled, all objects are
@@ -275,16 +298,36 @@ class DataFilterExtension(BaseExtension):
275
298
276
299
Accessor to retrieve the value for each object that it will be filtered by.
277
300
278
- - Type:
279
- [FilterValueAccessor][lonboard.traits.FilterValueAccessor]
301
+ - Type: [FilterValueAccessor][lonboard.traits.FilterValueAccessor]
280
302
- If a scalar value is provided, it is used as the value for all objects.
281
- - If an array is provided, each value in the array will be used as the value
282
- for the object at the same row index.
303
+ - If an array is provided, each value in the array will be used as the value for
304
+ the object at the same row index.
305
+
306
+ ## `get_filter_category`
307
+
308
+ Accessor to retrieve the category for each object that it will be filtered by.
309
+
310
+ - Type: [FilterValueAccessor][lonboard.traits.FilterValueAccessor]
311
+ - If a scalar value is provided, it is used as the value for all objects.
312
+ - If an array is provided, each value in the array will be used as the value for
313
+ the object at the same row index.
283
314
"""
284
315
285
316
_extension_type = traitlets .Unicode ("data-filter" ).tag (sync = True )
286
317
287
318
_layer_traits = {
319
+ "filter_categories" : traitlets .Union (
320
+ [
321
+ traitlets .List (traitlets .Any ()),
322
+ traitlets .List (
323
+ traitlets .List (traitlets .Any ()),
324
+ minlen = 2 ,
325
+ maxlen = 4 ,
326
+ ),
327
+ ],
328
+ default_value = None ,
329
+ allow_none = True ,
330
+ ).tag (sync = True ),
288
331
"filter_enabled" : traitlets .Bool (True ).tag (sync = True ),
289
332
"filter_range" : traitlets .Union (
290
333
[
@@ -294,14 +337,17 @@ class DataFilterExtension(BaseExtension):
294
337
minlen = 2 ,
295
338
maxlen = 4 ,
296
339
),
297
- ]
340
+ ],
341
+ default_value = None ,
342
+ allow_none = True ,
298
343
).tag (sync = True ),
299
344
"filter_soft_range" : traitlets .Tuple (
300
345
traitlets .Float (), traitlets .Float (), default_value = None , allow_none = True
301
346
).tag (sync = True ),
302
347
"filter_transform_size" : traitlets .Bool (True ).tag (sync = True ),
303
348
"filter_transform_color" : traitlets .Bool (True ).tag (sync = True ),
304
- "get_filter_value" : FilterValueAccessor (None , allow_none = False ),
349
+ "get_filter_value" : FilterValueAccessor (default_value = None , allow_none = True ),
350
+ "get_filter_category" : FilterValueAccessor (default_value = None , allow_none = True ),
305
351
}
306
352
307
353
filter_size = traitlets .Int (1 , min = 1 , max = 4 ).tag (sync = True )
@@ -313,6 +359,15 @@ class DataFilterExtension(BaseExtension):
313
359
- Default 1.
314
360
"""
315
361
362
+ category_size = traitlets .Int (1 , min = 1 , max = 4 ).tag (sync = True )
363
+ """The size of the category filter (number of columns to filter by).
364
+
365
+ The category filter can show/hide data based on 1-4 properties of each object.
366
+
367
+ - Type: `int`, optional
368
+ - Default 0.
369
+ """
370
+
316
371
317
372
class PathStyleExtension (BaseExtension ):
318
373
"""
0 commit comments