Closed stephenwilliams22 closed 7 months ago
Thanks for the report, closed via #125.
By the way, if filling layout is important, you'll want to use shiny.ui.layout_column_wrap()
over altair.concat()
since the former can support filling layouts.
import altair as alt
import pandas as pd
from shiny import App, render, ui
from vega_datasets import data
from shinywidgets import output_widget, register_widget
source = data.cars()
app_ui = ui.page_fillable(
ui.layout_column_wrap(
output_widget("chart1"),
output_widget("chart2"),
width=1 / 2
)
)
def server(input, output, session):
brush = alt.selection_point(name="point", encodings=["color"], bind="legend")
chart1 = (
alt.Chart(source)
.mark_point()
.encode(
x="Horsepower:Q",
y="Miles_per_Gallon:Q",
color=alt.condition(brush, "Origin:N", alt.value("grey")),
)
.add_params(brush)
)
chart2 = (
alt.Chart(source)
.mark_point()
.encode(
x="Horsepower:Q",
y="Miles_per_Gallon:Q",
color=alt.condition(brush, "Origin:N", alt.value("grey")),
)
.add_params(brush)
)
register_widget("chart1", chart1)
register_widget("chart2", chart2)
app = App(app_ui, server)
Thanks @cpsievert. Is shiny.ui.layout_column_wrap()
compatible with a list of plots? I'm interested in rendering a variable number of plots. How would I go from a list of altair plots in the server being rendered in the UI?
Description
I'm tying to display concatenated altair plots in shiny-python using a mofied version of your altair example from https://github.com/posit-dev/py-shinywidgets/blob/5a6f7f0535732b2b18bb1bdd0c1ea088df9c9dd7/examples/altair/app.py#L2
What I Did