class AppSchema(wf.WriterState):
vegas_graph: dict
# Without schema, this handler is execute only once
def handle_vega_graph(state: AppSchema):
graph = state.vega_graph
graph["data"]["values"][0]["b"] += 1000
state.vega_graph = graph
initial_state = wf.init_state({
"vegas_graph": {
"data": {
"values": [
{"a": "C", "b": 2}, {"a": "C", "b": 7}, {"a": "C", "b": 4},
{"a": "D", "b": 1}, {"a": "D", "b": 2}, {"a": "D", "b": 6},
{"a": "E", "b": 8}, {"a": "E", "b": 4}, {"a": "E", "b": 7}
]
},
"mark": "bar",
"encoding": {
"x": {"field": "a", "type": "nominal"},
"y": {"aggregate": "average", "field": "b", "type": "quantitative"}
}
},
}, schema=AppSchema)