Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ version = "0.1.0"
[tool.poetry.dependencies]
python = ">=3.9,<3.9.7 || >3.9.7,<4.0"
streamlit = "1.39.0"
streamlit-aggrid = "*"
quarto-cli = "*"
plotly = "5.15.0"
pyvis = "^0.3.2"
pandas = {extras = ["parquet"], version = "^2.2.3"}
Expand All @@ -21,13 +23,14 @@ xlrd = "^2.0.1"
nbformat = "^5.10.4"
nbclient = "^0.10.0"
matplotlib = "^3.9.2"
altair = "^5.4.1"
altair = "*"
itables = "^2.2.2"
kaleido = "0.2.0"
vl-convert-python = "^1.7.0"
dataframe-image = "^0.2.6"
strenum = { version = "^0.4.15", python = "<3.11" }
pyyaml = "^6.0.2"

# optional doc depencencies, follow approach as described here:
# https://github.com/python-poetry/poetry/issues/2567#issuecomment-646766059
sphinx = {version="*", optional=true}
Expand All @@ -36,15 +39,12 @@ myst-nb = {version="*", optional=true}
ipywidgets = {version="*", optional=true}
sphinx-new-tab-link = {version = "!=0.2.2", optional=true}
jupytext = {version="*", optional=true}
# quarto
quarto-cli = "*"

[tool.poetry.group.dev.dependencies]
ipykernel = {version="^6.29.5", optional=true}

[tool.poetry.requires-plugins]
poetry-dynamic-versioning = { version = ">=1.0.0,<2.0.0", extras = ["plugin"] }


[tool.poetry-dynamic-versioning]
enable = true
Expand Down
33 changes: 26 additions & 7 deletions src/vuegen/streamlit_reportview.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,9 +466,27 @@ def _generate_dataframe_content(self, dataframe) -> List[str]:
read_function = read_function_mapping[file_extension]
dataframe_content.append(f"""df = pd.{read_function.__name__}('{dataframe.file_path}')""")

# Display the dataframe
dataframe_content.append("st.dataframe(df, use_container_width=True)")

# Displays a DataFrame using AgGrid with configurable options.
dataframe_content.append("""
# Displays a DataFrame using AgGrid with configurable options.
grid_builder = GridOptionsBuilder.from_dataframe(df)
grid_builder.configure_default_column(editable=True, groupable=True)
grid_builder.configure_side_bar(filters_panel=True, columns_panel=True)
grid_builder.configure_selection(selection_mode="multiple")
grid_builder.configure_pagination(enabled=True, paginationAutoPageSize=False, paginationPageSize=20)
grid_options = grid_builder.build()

AgGrid(df, gridOptions=grid_options)

# Button to download the df
df_csv = df.to_csv(sep=',', header=True, index=False).encode('utf-8')
st.download_button(
label="Download dataframe as CSV",
data=df_csv,
file_name=f"dataframe_{df_index}.csv",
mime='text/csv',
key=f"download_button_{df_index}")
df_index += 1""")
except Exception as e:
self.report.logger.error(f"Error generating content for DataFrame: {dataframe.title}. Error: {str(e)}")
raise
Expand Down Expand Up @@ -707,7 +725,7 @@ def _generate_component_imports(self, component: r.Component) -> List[str]:
r.PlotType.PLOTLY: ['import json', 'import requests'],
r.PlotType.INTERACTIVE_NETWORK: ['import requests']
},
'dataframe': ['import pandas as pd'],
'dataframe': ['import pandas as pd', 'from st_aggrid import AgGrid, GridOptionsBuilder'],
'markdown': ['import requests'],
'chatbot': ['import time', 'import json', 'import requests']
}
Expand All @@ -720,12 +738,13 @@ def _generate_component_imports(self, component: r.Component) -> List[str]:
plot_type = getattr(component, 'plot_type', None)
if plot_type in components_imports['plot']:
component_imports.extend(components_imports['plot'][plot_type])
elif component_type == r.ComponentType.DATAFRAME:
component_imports.extend(components_imports['dataframe'])
elif component_type == r.ComponentType.MARKDOWN:
component_imports.extend(components_imports['markdown'])
elif component_type == r.ComponentType.CHATBOT:
component_imports.extend(components_imports['chatbot'])
elif component_type == r.ComponentType.DATAFRAME:
component_imports.extend(components_imports['dataframe'])
component_imports.append('df_index = 1')

# Return the list of import statements
return component_imports
return component_imports