-
Notifications
You must be signed in to change notification settings - Fork 816
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1049 from quarto-dev/shiny-express
Change imports from `shiny` to `shiny.express`
- Loading branch information
Showing
19 changed files
with
78 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,71 @@ | ||
# This file generated by Quarto; do not edit by hand. | ||
# shiny_mode: core | ||
|
||
from __future__ import annotations | ||
|
||
from pathlib import Path | ||
from shiny import App, Inputs, Outputs, Session, ui | ||
|
||
import seaborn as sns | ||
penguins = sns.load_dataset("penguins") | ||
species = list(penguins["species"].value_counts().index) | ||
islands = list(penguins["island"].value_counts().index) | ||
|
||
# ======================================================================== | ||
|
||
|
||
|
||
|
||
def server(input: Inputs, output: Outputs, session: Session) -> None: | ||
from shiny import ui, render | ||
import seaborn as sns | ||
penguins = sns.load_dataset("penguins") | ||
from shiny import reactive | ||
from shiny.express import render, ui | ||
ui.input_checkbox_group( | ||
"species", "Species:", | ||
species, selected = species | ||
) | ||
|
||
# ======================================================================== | ||
|
||
ui.input_checkbox_group( | ||
"islands", "Islands:", | ||
islands, selected = islands | ||
) | ||
|
||
# ======================================================================== | ||
|
||
ui.input_select("x", "Variable:", | ||
choices=["bill_length_mm", "bill_depth_mm"]) | ||
ui.input_select("dist", "Distribution:", choices=["hist", "kde"]) | ||
ui.input_select("dist", "Distribution:", choices=["kde", "hist"]) | ||
ui.input_checkbox("rug", "Show rug marks", value = False) | ||
|
||
# ======================================================================== | ||
|
||
@reactive.calc | ||
def filtered_penguins(): | ||
data = penguins[penguins["species"].isin(input.species())] | ||
data = data[data["island"].isin(input.islands())] | ||
return data | ||
|
||
# ======================================================================== | ||
|
||
@render.plot | ||
def displot(): | ||
sns.displot( | ||
data=penguins, hue="species", multiple="stack", | ||
x=input.x(), rug=input.rug(), kind=input.dist()) | ||
def depth(): | ||
return sns.displot( | ||
filtered_penguins(), x = "bill_depth_mm", | ||
hue = "species", kind = input.dist(), | ||
fill = True, rug=input.rug() | ||
) | ||
|
||
# ======================================================================== | ||
|
||
|
||
|
||
return None | ||
|
||
|
||
_static_assets = ["toolbar_files"] | ||
_static_assets = ["column-layout_files"] | ||
_static_assets = {"/" + sa: Path(__file__).parent / sa for sa in _static_assets} | ||
|
||
app = App( | ||
Path(__file__).parent / "toolbar.html", | ||
Path(__file__).parent / "column-layout.html", | ||
server, | ||
static_assets=_static_assets, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters