Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
huong-li-nguyen committed Jul 17, 2024
1 parent 1972303 commit 9733b79
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Contains re-usable constants, data sets and custom charts."""
"""Contains re-usable data sets and constants."""

import json
from urllib.request import urlopen
Expand Down Expand Up @@ -36,5 +36,15 @@
}
)

# CONSTANTS ---------------------------------------------------------
DATA_DICT = {
"gapminder": gapminder,
"gapminder_2007": gapminder_2007,
"iris": iris,
"stocks": stocks,
"tips": tips,
"tips_agg": tips_agg,
"ages": ages,
"fips_unemp": fips_unemp,
"sankey_data": sankey_data,
}
PAGE_GRID = [[0, 0, 0, 0, 0]] * 2 + [[1, 1, 1, 2, 2]] * 5
20 changes: 10 additions & 10 deletions vizro-core/examples/_chart-gallery/utils/chart_factory.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"""Contains re-usable page functions.
"""Contains re-usable page functions to create identical content with a different `id`.
Note: Given the restriction that one page can only be mapped to one navigation group,
we have to create a new page with a new ID for each chart type being re-used per navigation group.
Note: Since each page can only belong to one navigation group, we need a new page with a unique ID for
each chart type used in different groups.
"""

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

from .custom_charts_comp import CodeClipboard, butterfly
from .helper import PAGE_GRID, ages, gapminder_2007, iris, stocks, tips_agg
from ._page_utils import DATA_DICT, PAGE_GRID
from .custom_extensions import CodeClipboard, butterfly


def line_factory(id: str, title: str):
Expand All @@ -35,7 +35,7 @@ def line_factory(id: str, title: str):
same chart, try to limit yourself to 3-4 to avoid cluttering up your chart.
"""
),
vm.Graph(figure=px.line(stocks, x="date", y="GOOG")),
vm.Graph(figure=px.line(DATA_DICT["stocks"], x="date", y="GOOG")),
CodeClipboard(
text="""
```python
Expand Down Expand Up @@ -89,7 +89,7 @@ def scatter_factory(id: str, title: str):
that correlation is not causation. Make sure your audience does not draw the wrong conclusions.
"""
),
vm.Graph(figure=px.scatter(iris, x="sepal_width", y="sepal_length", color="species")),
vm.Graph(figure=px.scatter(DATA_DICT["iris"], x="sepal_width", y="sepal_length", color="species")),
CodeClipboard(
text="""
```python
Expand Down Expand Up @@ -151,7 +151,7 @@ def bar_factory(id: str, title: str):
),
vm.Graph(
figure=px.bar(
data_frame=tips_agg,
data_frame=DATA_DICT["tips_agg"],
x="total_bill",
y="day",
orientation="h",
Expand Down Expand Up @@ -222,7 +222,7 @@ def column_factory(id: str, title: str):
),
vm.Graph(
figure=px.bar(
data_frame=tips_agg,
data_frame=DATA_DICT["tips_agg"],
y="total_bill",
x="day",
)
Expand Down Expand Up @@ -291,7 +291,7 @@ def treemap_factory(id: str, title: str):
),
vm.Graph(
figure=px.treemap(
gapminder_2007,
DATA_DICT["gapminder_2007"],
path=[px.Constant("world"), "continent", "country"],
values="pop",
color="lifeExp",
Expand Down
20 changes: 10 additions & 10 deletions vizro-core/examples/_chart-gallery/utils/chart_pages.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Contains custom components and charts used inside the dashboard."""
"""Contains variables that store each chart page."""

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

from ._page_utils import DATA_DICT, PAGE_GRID
from .chart_factory import (
bar_factory,
butterfly_factory,
Expand All @@ -11,8 +12,7 @@
scatter_factory,
treemap_factory,
)
from .custom_charts_comp import CodeClipboard, FlexContainer, Markdown, sankey
from .helper import PAGE_GRID, counties, fips_unemp, sankey_data, tips
from .custom_extensions import CodeClipboard, FlexContainer, Markdown, sankey

# COMPONENTS --------------------------------------------------------
vm.Page.add_type("components", CodeClipboard)
Expand Down Expand Up @@ -62,7 +62,7 @@
),
vm.Graph(
figure=px.pie(
data_frame=tips,
data_frame=DATA_DICT["tips"],
values="tip",
names="day",
)
Expand Down Expand Up @@ -121,7 +121,7 @@
),
vm.Graph(
figure=px.pie(
data_frame=tips,
data_frame=DATA_DICT["tips"],
values="tip",
names="day",
hole=0.4,
Expand Down Expand Up @@ -185,7 +185,7 @@
),
vm.Graph(
figure=px.box(
data_frame=tips,
data_frame=DATA_DICT["tips"],
y="total_bill",
x="day",
color="day",
Expand Down Expand Up @@ -245,7 +245,7 @@
),
vm.Graph(
figure=px.violin(
data_frame=tips,
data_frame=DATA_DICT["tips"],
y="total_bill",
x="day",
color="day",
Expand Down Expand Up @@ -308,8 +308,8 @@
),
vm.Graph(
figure=px.choropleth(
fips_unemp,
geojson=counties,
DATA_DICT["fips_unemp"],
geojson=DATA_DICT["counties"],
locations="fips",
color="unemp",
range_color=(0, 12),
Expand Down Expand Up @@ -390,7 +390,7 @@
),
vm.Graph(
figure=sankey(
data_frame=sankey_data,
data_frame=DATA_DICT["sankey_data"],
labels=["A1", "A2", "B1", "B2", "C1", "C2", "D1"],
source="Origin",
target="Destination",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Contains custom components and charts used inside the dashboard."""

from typing import Literal, List
from typing import List, Literal

import dash_bootstrap_components as dbc
import pandas as pd
Expand Down
4 changes: 2 additions & 2 deletions vizro-core/examples/_chart-gallery/utils/tab_containers.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Contains custom components and charts used inside the dashboard."""
"""Contains code for the containers used inside the tabs (homepage)."""

import re

import vizro.models as vm

from .custom_charts_comp import FlexContainer, Markdown
from .custom_extensions import FlexContainer, Markdown

vm.Container.add_type("components", Markdown)
vm.Container.add_type("components", FlexContainer)
Expand Down

0 comments on commit 9733b79

Please sign in to comment.