From e595c38e8e3672f728cf3855269e654f43beace5 Mon Sep 17 00:00:00 2001 From: Joel Ostblom Date: Thu, 4 Apr 2024 08:55:02 -0700 Subject: [PATCH] Avoid calling `to_dict()` since `validate=False` is currently not supported for channels --- altair/vegalite/v5/api.py | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/altair/vegalite/v5/api.py b/altair/vegalite/v5/api.py index 527c29168..ec811b00b 100644 --- a/altair/vegalite/v5/api.py +++ b/altair/vegalite/v5/api.py @@ -3076,21 +3076,31 @@ def interactive( interactive_chart.mark.tooltip = tooltip if legend: if not isinstance(legend, list): - # Detect common legend encodings used in the spec + # Set the legend to commonly used encodings by default legend = [ - enc - for enc in self.encoding.to_dict().keys() - if enc - in [ - "angle", - "radius", - "color", - "fill", - "shape", - "size", - "stroke", - ] + "angle", + "radius", + "color", + "fill", + "shape", + "size", + "stroke", ] + # Detect common legend encodings used in the spec + # legend = [ + # enc + # for enc in interactive_chart.encoding.to_dict(validate=False).keys() + # if enc + # in [ + # "angle", + # "radius", + # "color", + # "fill", + # "shape", + # "size", + # "stroke", + # ] + # ] legend_selection = selection_point(bind="legend", encodings=legend) interactive_chart = interactive_chart.add_params( legend_selection,