Closed Lendemor closed 3 days ago
import reflex as rx import plotly.graph_objects as go app = rx.App() class State(rx.State): figure: go.Figure | None = None def create_figure(self): self.figure = go.Figure( data=[go.Bar(x=[1, 2, 3], y=[1, 3, 2])], layout=go.Layout( title=go.layout.Title(text="A Figure Specified By A Graph Object") ), ) @rx.page("/") def index() -> rx.Component: return rx.cond(State.figure, rx.plotly(data=State.figure)), rx.button( "Init & Show Figure", on_click=State.create_figure )
note, this barely works just because str({}) in python results in a valid js expression (when used in certain places). Ideally in the future, one should try to use rx.Var.create({})
str({})
rx.Var.create({})