Skip to content

Commit

Permalink
plotly: treat data as a dict-type Var in _render
Browse files Browse the repository at this point in the history
this allows the data to be passed directly as a figure or from a state var
  • Loading branch information
masenf committed May 28, 2024
1 parent 7351fb7 commit 8177acf
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions reflex/components/plotly/plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ class Plotly(PlotlyLib):

def _render(self):
tag = super()._render()
figure = self.data.to(dict)
if self.layout is None:
tag.remove_props("data", "layout")
tag.special_props.add(Var.create_safe(f"{{...{self.data._var_name_unwrapped}}}"))
tag.special_props.add(
Var.create_safe(f"{{...{figure._var_name_unwrapped}}}")
)
else:
tag.add_props(data=self.data.to(dict)["data"])
return tag
tag.add_props(data=figure["data"])
return tag

0 comments on commit 8177acf

Please sign in to comment.