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

[Docs] Simplify our docs code examples #740

Open
4 tasks
huong-li-nguyen opened this issue Sep 24, 2024 · 0 comments
Open
4 tasks

[Docs] Simplify our docs code examples #740

huong-li-nguyen opened this issue Sep 24, 2024 · 0 comments
Labels
Nice to have 🍒 Possible projects for a rainy day

Comments

@huong-li-nguyen
Copy link
Contributor

huong-li-nguyen commented Sep 24, 2024

I believe someone from the development team should help streamline our code examples in the documentation. Upon rereading them, I noticed many instances where simplification is possible. Here are some specific recommendations:

In general, we should remove everything that isn't required to demonstrate the feature in question. This approach will keep the tutorials focused and prevent distractions from the main purpose.

Example:

from vizro import Vizro
import vizro.models as vm
import vizro.plotly.express as px

df = px.data.gapminder()
gapminder_data = (
        df.groupby(by=["continent", "year"]).
            agg({"lifeExp": "mean", "pop": "sum", "gdpPercap": "mean"}).reset_index()
    )

first_page = vm.Page(
    title="First Page",
    layout=vm.Layout(grid=[[0, 0], [1, 2], [1, 2], [1, 2]]),
    components=[
        vm.Card(
            text="""
                # First dashboard page
                This pages shows the inclusion of markdown text in a page and how components
                can be structured using Layout.
            """,
        ),
        vm.Graph(
            id="box_cont",
            figure=px.box(gapminder_data, x="continent", y="lifeExp", color="continent",
                            labels={"lifeExp": "Life Expectancy", "continent": "Continent"}),
        ),
        vm.Graph(
            id="line_gdp",
            figure=px.line(gapminder_data, x="year", y="gdpPercap", color="continent",
                            labels={"year": "Year", "continent": "Continent",
                            "gdpPercap":"GDP Per Cap"}),
            ),
    ],
    controls=[
        vm.Filter(column="continent", targets=["box_cont", "line_gdp"]),
    ],
)

dashboard = vm.Dashboard(pages=[first_page])
Vizro().build(dashboard).run()

What could be removed:

  • id provision inside the charts
  • Removal of targets inside vm.Filter as it will target all charts if not specified
  • Removal of labels argument inside charts
@huong-li-nguyen huong-li-nguyen added the Nice to have 🍒 Possible projects for a rainy day label Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Nice to have 🍒 Possible projects for a rainy day
Projects
None yet
Development

No branches or pull requests

1 participant