Streamlit-echarts

Hello everyone!

Thanks to @Bright who has created st_echarts_events, streamlit 0.4.0 is out now :partying_face: and brings

:information_source: 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

:rocket: 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 :slight_smile:

Happy echarting with Streamlit :balloon:
Fanilo

4 Likes