Streamlit ECharts is a Streamlit component that enables the display of highly interactive ECharts visualizations directly within Streamlit applications. The library is actively maintained, with its latest version being 0.6.0, and has a cadence of several major releases per year, often introducing significant updates and breaking changes.
pip install streamlit-echartsVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to render a basic ECharts bar chart using `st_echarts`. It also shows how to use the `key` parameter for stable component identity and `on_select='rerun'` for basic interactivity, capturing selection events in the Streamlit app state. An optional commented section illustrates usage with PyEcharts, which requires an extra installation.
Review your component interactions and event callbacks against the latest `streamlit-echarts` and Streamlit component documentation. The `key` parameter is now crucial for animations and stable component identity.
To use `st_pyecharts`, install with `pip install streamlit-echarts[pyecharts]`. Alternatively, use `import json` and `json.loads(chart.dump_options())` when passing PyEcharts chart instances to `st_echarts`.
If you rely on `pyecharts` or `simplejson`, install them explicitly: `pip install pyecharts simplejson` (or `pip install streamlit-echarts[pyecharts]` for the wrapper).
Access event data via `result.chart_event` for general events or `result['selection']` when `on_select` is used, as demonstrated in the quickstart example and official documentation.
Review your charts for unexpected visual changes. Consult the ECharts v6 changelog for details. You might need to adjust specific ECharts options or provide a custom theme to restore previous appearances.
Explicitly assign a unique `key` parameter to each `st_echarts` call within tabs. Sometimes recreating charts outside tabs or using `st.expander` can serve as a workaround, though recent versions with stable `key`s should mitigate this.
Always provide a unique `key` parameter to `st_echarts` (e.g., `key='my_chart'`). This ensures Streamlit can correctly identify and update the component rather than re-mounting it, preserving animations and state.