Streamlit Multiple Rendering Modes
In `pygwalker==0.3.7`, we added a new communication feature in streamlit, which can help us implement many new feature in streamlit.
In `pygwalker==0.3.8`, pygwalker provide two rendering modes in streamlit,include explore and renderer mode.
explore mode helps developers explore datas and develop the charts they need to display.
renderer mode can only render the chart without displaying other tool buttons.
example url: https://pygwalker-in-app-vipsfjjsyx2p6wwmm8yey9.streamlit.app/
example code:
python
from pygwalker.api.streamlit import init_streamlit_comm, StreamlitRenderer
Initialize pygwalker communication
init_streamlit_comm()
You should cache your pygwalker renderer, if you don't want your memory to explode
st.cache_resource
def get_pyg_renderer() -> "StreamlitRenderer":
df = get_data()
When you need to publish your application, you need set `debug=False`,prevent other users to write your config file.
return StreamlitRenderer(df, spec="./billion_config.json", debug=True)
renderer = get_pyg_renderer()
Display explore ui, Developers can use this to prepare the charts you need to display.
renderer.render_explore()
Display pure chart, index is the order of charts in explore mode, starting from 0.
renderer.render_pure_chart(0)
add pre-filters param in streamlit renderer.
We can pre-filter the data in the renderer and use it with other components of streamlit.
example url: https://pygwalker-in-app-vipsfjjsyx2p6wwmm8yey9.streamlit.app/
example code:
python
...
from pygwalker.api.streamlit import PreFilter
pre_filters = []
pre_filters.append(PreFilter(
field="country",
op="one of",
value=["CN", "US", "EN"]
))
set global pre-filters in renderer
renderer.set_global_pre_filters(pre_filters)
Set a pre-filter for a certain chart, it will overwrite global pre-filters
renderer.render_pure_chart(0, pre_filters=pre_filters)
...
Others
* Hoping anyone can provide us with any suggestions for improvements, thank anyone all in advance.
* We will improve the documentation and tutorials of pygwalker in the next few days.
* Optimized the usage experience of Snowflake connector (fix many bugs).
Feat
* feat: streamlit support renderer mode of graphic-walker https://github.com/Kanaries/pygwalker/pull/258
* feat: update grpahic-walker to support fold feature https://github.com/Kanaries/pygwalker/pull/259
* feat: modify single chart renderer in streamlit https://github.com/Kanaries/pygwalker/pull/261
* feat: size of chart remains the same as size of html https://github.com/Kanaries/pygwalker/pull/262
* fix: adjust returned value of StreamlitRenderer https://github.com/Kanaries/pygwalker/pull/263
* feat: streamlit add pre-filters feature https://github.com/Kanaries/pygwalker/pull/265
* feat: pure_renderer support to switch explore mode https://github.com/Kanaries/pygwalker/pull/267
Fix
* fix: snowflake connection data types https://github.com/Kanaries/pygwalker/pull/237
* fix: format sql in database parser https://github.com/Kanaries/pygwalker/pull/241
* fix: communication is not established when render geo chart https://github.com/Kanaries/pygwalker/pull/243
* fix: temporary fix for sqlglot conversion error https://github.com/Kanaries/pygwalker/pull/244
* fix: fix date feature bugs https://github.com/Kanaries/pygwalker/pull/245
* fix: DatabaseDataParser format_sql https://github.com/Kanaries/pygwalker/pull/246
* fix: DatabaseDataParser parse sub_query https://github.com/Kanaries/pygwalker/pull/249
* fix: streamlit base url https://github.com/Kanaries/pygwalker/pull/255
* fix: temporal range bug https://github.com/Kanaries/pygwalker/pull/268
Chore
* chore: add new optional dependency https://github.com/Kanaries/pygwalker/pull/238
* chore: lazy load gw_dsl_parser module https://github.com/Kanaries/pygwalker/pull/250
Refactor
* refactor: use shadcn components https://github.com/Kanaries/pygwalker/pull/253
ObservedObserver longxiaofei
**Full Changelog**: https://github.com/Kanaries/pygwalker/compare/0.3.7...0.3.8