Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data Grid column width doesn't work for wide dataframes #1825

Open
gshotwell opened this issue Jan 20, 2025 · 0 comments
Open

Data Grid column width doesn't work for wide dataframes #1825

gshotwell opened this issue Jan 20, 2025 · 0 comments

Comments

@gshotwell
Copy link
Contributor

gshotwell commented Jan 20, 2025

Seems like there's some kind of conflict between scrolling data grids horizontally and setting the column width, I'd expect the first column in both of these grids to be the same width.

from shiny import App, render, ui
import polars as pl
import numpy as np

# Create a DataFrame with 50 columns
df = pl.DataFrame({f"col_{i}": np.random.randn(100) for i in range(50)})

app_ui = ui.page_fillable(
    ui.card(ui.output_data_frame("wide_df")),
    ui.card(ui.output_data_frame("narrow_df")),
)


style = [
    {
        "cols": [0],
        "style": {"width": "500px"},
    }
]


def server(input, output, session):
    @render.data_frame
    def wide_df():
        return render.DataGrid(
            df,
            filters=True,
            styles=style,
        )

    @render.data_frame
    def narrow_df():
        return render.DataGrid(
            df.select(pl.col("^col_[0-3]$")), filters=True, styles=style
        )


app = App(app_ui, server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant