@@ -319,18 +319,24 @@ def floating(self, value):
319319 self ._floating = bool (value )
320320
321321 @property
322- def item_checkbox_style (self ) -> Optional [str ]:
322+ def item_checkbox_style (self ) -> Optional [str | dict ]:
323323 """Default styling for the checkbox next to a legend item when
324324 :meth:`Legend.show_checkbox` is ``True``. Defaults to:
325325 ``'{"width": "13px", "height": "13px", "position":"absolute"}'``.
326326
327- :rtype: :class:`str <python:str>` or :obj:`None <python:None>`
327+ :rtype: :class:`str <python:str>` or :class:`dict <python:dict>` or
328+ :obj:`None <python:None>`
328329 """
329330 return self ._item_checkbox_style
330331
331332 @item_checkbox_style .setter
332333 def item_checkbox_style (self , value ):
333- self ._item_checkbox_style = validators .string (value , allow_empty = True )
334+ try :
335+ self ._item_checkbox_style = validators .dict (value , allow_empty = True )
336+ except (ValueError , TypeError ):
337+ self ._item_checkbox_style = validators .string (value ,
338+ allow_empty = True ,
339+ coerce_value = True )
334340
335341 @property
336342 def item_distance (self ) -> Optional [int | float | Decimal ]:
@@ -348,7 +354,7 @@ def item_distance(self, value):
348354 minimum = 0 )
349355
350356 @property
351- def item_hidden_style (self ) -> Optional [str ]:
357+ def item_hidden_style (self ) -> Optional [str | dict ]:
352358 """Default styling for the legend item when the corresponding series or data
353359 point is hidden. Defaults to:
354360 ``'{"color": "#cccccc"}'``.
@@ -367,10 +373,15 @@ def item_hidden_style(self) -> Optional[str]:
367373
368374 @item_hidden_style .setter
369375 def item_hidden_style (self , value ):
370- self ._item_hidden_style = validators .string (value , allow_empty = True )
376+ try :
377+ self ._item_hidden_style = validators .dict (value , allow_empty = True )
378+ except (ValueError , TypeError ):
379+ self ._item_hidden_style = validators .string (value ,
380+ allow_empty = True ,
381+ coerce_value = True )
371382
372383 @property
373- def item_hover_style (self ) -> Optional [str ]:
384+ def item_hover_style (self ) -> Optional [str | dict ]:
374385 """Default styling for the legend item when the corresponding series or data
375386 point is in a hover state. Defaults to:
376387 ``'{"color": "#000000"}'``.
@@ -383,13 +394,19 @@ def item_hover_style(self) -> Optional[str]:
383394
384395 Properties are inherited from :meth:`Legend.style` unless overridden here.
385396
386- :rtype: :class:`str <python:str>` or :obj:`None <python:None>`
397+ :rtype: :class:`str <python:str>` or :class:`dict <python:dict>` or
398+ :obj:`None <python:None>`
387399 """
388400 return self ._item_hover_style
389401
390402 @item_hover_style .setter
391403 def item_hover_style (self , value ):
392- self ._item_hover_style = validators .string (value , allow_empty = True )
404+ try :
405+ self ._item_hover_style = validators .dict (value , allow_empty = True )
406+ except (ValueError , TypeError ):
407+ self ._item_hover_style = validators .string (value ,
408+ allow_empty = True ,
409+ coerce_value = True )
393410
394411 @property
395412 def item_margin_bottom (self ) -> Optional [int | float | Decimal ]:
@@ -422,9 +439,9 @@ def item_margin_top(self, value):
422439 minimum = 0 )
423440
424441 @property
425- def item_style (self ) -> Optional [str ]:
442+ def item_style (self ) -> Optional [str | dict ]:
426443 """Default styling for each legend item. Defaults to:
427- ``' {"color": "#333333", "cursor": "pointer", "fontSize": "12px", "fontWeight": "bold", "textOverflow": "ellipsis"}' ``.
444+ ``{"color": "#333333", "cursor": "pointer", "fontSize": "12px", "fontWeight": "bold", "textOverflow": "ellipsis"}``.
428445
429446 .. warning::
430447
@@ -442,7 +459,12 @@ def item_style(self) -> Optional[str]:
442459
443460 @item_style .setter
444461 def item_style (self , value ):
445- self ._item_style = validators .string (value , allow_empty = True )
462+ try :
463+ self ._item_style = validators .dict (value , allow_empty = True )
464+ except (ValueError , TypeError ):
465+ self ._item_style = validators .string (value ,
466+ allow_empty = True ,
467+ coerce_value = True )
446468
447469 @property
448470 def item_width (self ) -> Optional [int | float | Decimal ]:
0 commit comments