@@ -219,6 +219,29 @@ class DataFilterExtension(BaseExtension):
219219 This extension dynamically enables the following properties onto the layer(s) where
220220 it is included:
221221
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+
222245 ## `filter_enabled`
223246
224247 Enable/disable the data filter. If the data filter is disabled, all objects are
@@ -275,16 +298,36 @@ class DataFilterExtension(BaseExtension):
275298
276299 Accessor to retrieve the value for each object that it will be filtered by.
277300
278- - Type:
279- [FilterValueAccessor][lonboard.traits.FilterValueAccessor]
301+ - Type: [FilterValueAccessor][lonboard.traits.FilterValueAccessor]
280302 - 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.
283314 """
284315
285316 _extension_type = traitlets .Unicode ("data-filter" ).tag (sync = True )
286317
287318 _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 ),
288331 "filter_enabled" : traitlets .Bool (True ).tag (sync = True ),
289332 "filter_range" : traitlets .Union (
290333 [
@@ -294,14 +337,17 @@ class DataFilterExtension(BaseExtension):
294337 minlen = 2 ,
295338 maxlen = 4 ,
296339 ),
297- ]
340+ ],
341+ default_value = None ,
342+ allow_none = True ,
298343 ).tag (sync = True ),
299344 "filter_soft_range" : traitlets .Tuple (
300345 traitlets .Float (), traitlets .Float (), default_value = None , allow_none = True
301346 ).tag (sync = True ),
302347 "filter_transform_size" : traitlets .Bool (True ).tag (sync = True ),
303348 "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 ),
305351 }
306352
307353 filter_size = traitlets .Int (1 , min = 1 , max = 4 ).tag (sync = True )
@@ -313,6 +359,15 @@ class DataFilterExtension(BaseExtension):
313359 - Default 1.
314360 """
315361
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+
316371
317372class PathStyleExtension (BaseExtension ):
318373 """
0 commit comments