Skip to content

Commit fb9c6ff

Browse files
adds pygwalker
1 parent 4ac4dc8 commit fb9c6ff

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

pygwalker/app.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import pandas as pd
2+
import streamlit.components.v1 as components
3+
import streamlit as st
4+
from pygwalker.api.streamlit import init_streamlit_comm, get_streamlit_html
5+
6+
st.set_page_config(
7+
page_title="Use Pygwalker In Streamlit",
8+
layout="wide"
9+
)
10+
11+
st.title("Use Pygwalker In Streamlit(support communication)")
12+
13+
# Initialize pygwalker communication
14+
init_streamlit_comm()
15+
16+
# When using `use_kernel_calc=True`, you should cache your pygwalker html, if you don't want your memory to explode
17+
@st.cache_resource
18+
def get_pyg_html(df: pd.DataFrame) -> str:
19+
# When you need to publish your application, you need set `debug=False`,prevent other users to write your config file.
20+
# If you want to use feature of saving chart config, set `debug=True`
21+
html = get_streamlit_html(df, spec="./gw0.json", use_kernel_calc=True, debug=False)
22+
return html
23+
24+
@st.cache_data
25+
def get_df() -> pd.DataFrame:
26+
return pd.read_csv("/bike_sharing_dc.csv")
27+
28+
df = get_df()
29+
30+
components.html(get_pyg_html(df), width=1300, height=1000, scrolling=True)

pygwalker/requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
streamlit
2+
pygwalker

0 commit comments

Comments
 (0)