Skip to content
New issue

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

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

Already on GitHub? # to your account

[Docs] Remove redundant provision of id in docs examples #713

Closed
huong-li-nguyen opened this issue Sep 17, 2024 · 3 comments
Closed

[Docs] Remove redundant provision of id in docs examples #713

huong-li-nguyen opened this issue Sep 17, 2024 · 3 comments
Labels
Docs 🗒️ Issue for markdown and API documentation Good first issue 🐤 Issue suitable for first-time contributors hacktoberfest A month-long celebration of all things open-source

Comments

@huong-li-nguyen
Copy link
Contributor

We still have some examples where an id is provided to a component even though it is not required.

  1. Look through the code examples in our docs e.g. vizro-core/docs and vizro-ai/docs
  2. Remove the id from vm.Graph, vm.Table, vm.AgGrid or vm.Card if it is not required

When is it not required?

The id is normally not required if that component is not the target of any kind of action e.g. filter_interaction, export, filters or parameters. A good rule of thumb is, if the id appears only once in the entire app configuration, it's probably not required.

Example of a redundant id provision (and the first example where you can remove it from the docs):

In the first example the id="scatter_chart" is not required, because the Graph is not being targeted by any action. Also the id only appears once in the entire app configuration. In the second example it is required though, because it is now the target of the Filter.

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

iris = px.data.iris()

page = vm.Page(
    title="My first page",
    components=[
        vm.Graph(id="scatter_chart", figure=px.scatter(iris, x="sepal_length", y="petal_width", color="species")),
    ],
)

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

Example where the id is required:

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

iris = px.data.iris()

page = vm.Page(
    title="My first page",
    components=[
        vm.Graph(id="scatter_chart", figure=px.scatter(iris, x="sepal_length", y="petal_width", color="species")),
        vm.Graph(id="scatter_chart2", figure=px.scatter(iris, x="petal_length", y="sepal_width", color="species")),
    ],
    controls=[
        vm.Filter(column="petal_length",targets=["scatter_chart"],selector=vm.RangeSlider(step=1)),
    ],
)

dashboard = vm.Dashboard(pages=[page])
Vizro().build(dashboard).run()
@huong-li-nguyen huong-li-nguyen added Nice to have 🍒 Possible projects for a rainy day Good first issue 🐤 Issue suitable for first-time contributors Docs 🗒️ Issue for markdown and API documentation and removed Nice to have 🍒 Possible projects for a rainy day labels Sep 17, 2024
@bhavanaeh
Copy link
Contributor

Hi, I'd like to help here :)

@huong-li-nguyen
Copy link
Contributor Author

Perfect - thank you! 👍

@antonymilne
Copy link
Contributor

@bhavanaeh Did this issue make any progress? No worries if not, but it would be great to know so we can figure out if there's still something to be done here.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Docs 🗒️ Issue for markdown and API documentation Good first issue 🐤 Issue suitable for first-time contributors hacktoberfest A month-long celebration of all things open-source
Projects
None yet
Development

No branches or pull requests

4 participants