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

altair chart is size 0 when shown hidden then shown again #172

Closed
cpsievert opened this issue Dec 18, 2024 · 1 comment · Fixed by #180
Closed

altair chart is size 0 when shown hidden then shown again #172

cpsievert opened this issue Dec 18, 2024 · 1 comment · Fixed by #180

Comments

@cpsievert
Copy link
Collaborator

cpsievert commented Dec 18, 2024

Click tab B, then tab A. The plot size is 0.

import altair as alt
import pandas as pd
from shiny import reactive
from shiny.express import ui

from shinywidgets import render_altair

@reactive.calc
def plt():
    main_df = pd.DataFrame({
        "x": [1, 2, 3, 4, 5, 6],
        "y": [3, 4, 5, 6, 7, 8],
    })

    return (
        alt.Chart(main_df)
        .mark_circle()
        .encode(x="x", y="y")
    )


with ui.card():
    with ui.navset_pill(id="tab"):
        with ui.nav_panel("A"):

            @render_altair
            def x_y_graph():
                return plt()

        with ui.nav_panel("B"):

            @render_altair
            def y_x_graph():
                return plt()
@chendaniely
Copy link

chendaniely commented Jan 23, 2025

Cross-posting Carson's workaround posted in discord:

you can add a ui.tags.script that triggers a resize when a tab is shown to workaround it for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants