Skip to content

Commit

Permalink
mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmmease committed Jul 20, 2023
1 parent 15937cf commit 134248b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions altair/widget/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,18 @@ def from_vega(cls, name: str, value: dict, store: List[Dict[str, Any]]):
# Transpose values e.g.
# from [{"a": 1, "b": "A"}, {"a": 2, "b": "B"}]
# to {"a": [1, 2], "b": ["A", "B"]}
value = {}
selection_value: Union[dict, list] = {}
for point in points:
for k, v in point.items():
value.setdefault(k, []).append(v)

# _vgsid_ is one-based. subtract 1 to be zero-indexed
if list(value.keys()) == ["_vgsid_"]:
value = [i - 1 for i in value["_vgsid_"]]
selection_value = [i - 1 for i in value["_vgsid_"]]
else:
selection_value = value

return SelectionParam(name=name, value=value, _store=store)
return SelectionParam(name=name, value=selection_value, _store=store)


class ChartWidget(anywidget.AnyWidget):
Expand All @@ -63,7 +65,7 @@ class ChartWidget(anywidget.AnyWidget):

@traitlets.observe("chart")
def change_chart(self, change):
new_chart: TopLevelSpec = change.new
new_chart = change.new

params = getattr(new_chart, "params", [])
selection_watches = []
Expand Down

0 comments on commit 134248b

Please sign in to comment.