Skip to content

Commit

Permalink
Final tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
antonymilne committed Oct 28, 2024
1 parent 0921840 commit 3863946
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 86 deletions.
1 change: 1 addition & 0 deletions vizro-core/examples/visual-vocabulary/pages/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# TODO: eventually deduplicate page generation into a function rather than copying and pasting across files?
81 changes: 1 addition & 80 deletions vizro-core/examples/visual-vocabulary/pages/_pages_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def make_code_clipboard_from_py_file(filepath: str, mode="vizro"):
example_code = (Path(__file__).parents[1] / "pages/examples" / filepath).read_text()

if mode == "vizro":
example_code = VIZRO_CODE_TEMPLATE.format(title="Title", example_code=example_code)
example_code = VIZRO_CODE_TEMPLATE.format(example_code=example_code)
else:
replacements = {"import vizro.plotly.express as px": "import plotly.express as px", '@capture("graph")': ""}
for old_code, new_code in replacements.items():
Expand All @@ -59,82 +59,3 @@ def make_code_clipboard_from_py_file(filepath: str, mode="vizro"):


PAGE_GRID = [[0, 0, 0, 0, 0, 0, 0]] * 2 + [[1, 1, 1, 1, 2, 2, 2]] * 5

# DATA --------------------------------------------------------------
gapminder = px.data.gapminder()
iris = px.data.iris()
stocks = px.data.stocks()
tips = px.data.tips()
wind = px.data.wind()
ages = pd.DataFrame(
{
"Age": ["0-19", "20-29", "30-39", "40-49", "50-59", ">=60"],
"Male": [800, 2000, 4200, 5000, 2100, 800],
"Female": [1000, 3000, 3500, 3800, 3600, 700],
}
)
sankey_data = pd.DataFrame(
{
"Origin": [0, 1, 0, 2, 3, 3],
"Destination": [2, 3, 3, 4, 4, 5],
"Value": [8, 4, 2, 8, 4, 2],
}
)

funnel_data = pd.DataFrame(
{"Stage": ["Leads", "Sales calls", "Follow-up", "Conversion", "Sales"], "Value": [10, 7, 4, 2, 1]}
)

stepped_line_data = pd.DataFrame(
{
"year": [1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003],
"rate": [0.10, 0.12, 0.15, 0.13, 0.14, 0.13, 0.14, 0.16, 0.15],
}
)


carshare = px.data.carshare()

tasks = pd.DataFrame(
[
{"Task": "Job A", "Start": "2009-01-01", "Finish": "2009-02-28"},
{"Task": "Job B", "Start": "2009-03-05", "Finish": "2009-04-15"},
{"Task": "Job C", "Start": "2009-02-20", "Finish": "2009-05-30"},
]
)

waterfall_data = pd.DataFrame(
{
"x": ["Sales", "Consulting", "Net revenue", "Purchases", "Other expenses", "Profit before tax"],
"y": [60, 80, 0, -40, -20, 0],
"measure": ["relative", "relative", "total", "relative", "relative", "total"],
}
)

pastries = pd.DataFrame(
{
"pastry": [
"Scones",
"Bagels",
"Muffins",
"Cakes",
"Donuts",
"Cookies",
"Croissants",
"Eclairs",
],
"Profit Ratio": [-0.10, -0.05, 0.10, 0.05, 0.15, -0.08, 0.08, -0.12],
"Strongly Disagree": [20, 30, 10, 5, 15, 5, 10, 25],
"Disagree": [30, 25, 20, 10, 20, 10, 15, 30],
"Agree": [30, 25, 40, 40, 45, 40, 40, 25],
"Strongly Agree": [20, 20, 30, 45, 20, 45, 35, 20],
}
)

salaries = pd.DataFrame(
{
"Job": ["Developer", "Analyst", "Manager", "Specialist"],
"Min": [60000, 55000, 70000, 50000],
"Max": [130000, 110000, 96400, 80000],
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ def column_and_line(
return fig


gapminder = px.data.gapminder()
gapminder = px.data.gapminder().query("country == 'Vietnam'")

fig = column_and_line(gapminder.query("country == 'Vietnam'"), y_column="gdpPercap", y_line="lifeExp", x="year")
fig = column_and_line(gapminder, y_column="gdpPercap", y_line="lifeExp", x="year")
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import vizro.plotly.express as px

gapminder = px.data.gapminder()
gapminder = px.data.gapminder().query("year == 2007")

fig = px.treemap(
gapminder.query("year == 2007"), path=[px.Constant("world"), "continent", "country"], values="pop", color="lifeExp"
)
fig = px.treemap(gapminder, path=[px.Constant("world"), "continent", "country"], values="pop", color="lifeExp")

0 comments on commit 3863946

Please sign in to comment.