Hello everyone!
Thanks to @Bright who has created st_echarts_events, streamlit 0.4.0 is out now
and brings
return values in ECharts events are now sent back to Streamlit
As simple as:
option = {
"xAxis": {
"type": "category",
"data": ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
},
"yAxis": { "type": "value" },
"series": [
{"data": [820, 932, 901, 934, 1290, 1330, 1320], "type": "line" }
],
}
events = {
"click": "function(params) { console.log(params.name); return params.name }",
"dblclick":"function(params) { return [params.type, params.name, params.value] }"
}
value = st_echarts(option, events=events)
st.write(value) # shows name on bar click and type+name+value on bar double click
Demo app: https://share.streamlit.io/andfanilo/streamlit-echarts-events-demo/main
Demo code: GitHub - andfanilo/streamlit-echarts-events-demo
Announcement: https://twitter.com/andfanilo/status/1470353622374526977
pip install -U streamlit-echarts
Don’t hesitate to tell me if there is any problem as I have not tested all the echarts events on all chart items ![]()
Happy echarting with Streamlit ![]()
Fanilo