Skip to content

Commit

Permalink
Remove factory function for line
Browse files Browse the repository at this point in the history
  • Loading branch information
huong-li-nguyen committed Jul 17, 2024
1 parent a720697 commit 5a0e5f4
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 78 deletions.
4 changes: 1 addition & 3 deletions vizro-core/examples/_chart-gallery/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
sankey_page,
scatter,
time_column,
time_line,
treemap,
violin,
)
Expand Down Expand Up @@ -69,7 +68,6 @@
violin,
ordered_bar,
ordered_column,
time_line,
time_column,
treemap,
magnitude_treemap,
Expand Down Expand Up @@ -109,7 +107,7 @@
),
vm.NavLink(
label="Time",
pages={"Time": ["Time-Line", "Time-Column"]},
pages={"Time": ["Line", "Time-Column"]},
icon="Timeline",
),
vm.NavLink(
Expand Down

This file was deleted.

55 changes: 0 additions & 55 deletions vizro-core/examples/_chart-gallery/utils/chart_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,61 +11,6 @@
from .custom_extensions import CodeClipboard, butterfly


def line_factory(id: str, title: str):
"""Reusable function to create the page content for the line chart with a unique ID."""
return vm.Page(
id=id,
title=title,
layout=vm.Layout(grid=PAGE_GRID),
components=[
vm.Card(
text="""
#### What is a line chart?
A line chart presents a series of data points over a continuous interval or time period, joined together
with straight lines.
 
#### When to use it?
You should select a line chart when you want to show trends over time. Usually, your y-axis will show a
quantitative value and your x-axis will be marked as a timescale or a sequence of intervals. You can also
display negative values below the x-axis. If you wish to group several lines (different data series) in the
same chart, try to limit yourself to 3-4 to avoid cluttering up your chart.
"""
),
vm.Graph(figure=px.line(DATA_DICT["stocks"], x="date", y="GOOG")),
CodeClipboard(
text="""
```python
import vizro.models as vm
import vizro.plotly.express as px
from vizro import Vizro
stocks = px.data.stocks()
page = vm.Page(
title="Line",
components=[
vm.Graph(
figure=px.line(
stocks, x="date", y="GOOG"
)
)
],
)
dashboard = vm.Dashboard(pages=[page])
Vizro().build(dashboard).run()
```
"""
),
],
)


def scatter_factory(id: str, title: str):
"""Reusable function to create the page content for the scatter chart with a unique ID."""
return vm.Page(
Expand Down
54 changes: 51 additions & 3 deletions vizro-core/examples/_chart-gallery/utils/chart_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
bar_factory,
butterfly_factory,
column_factory,
line_factory,
scatter_factory,
treemap_factory,
)
Expand All @@ -21,8 +20,6 @@


# PAGES -------------------------------------------------------------
line = line_factory("Line", "Line")
time_line = line_factory("Time-Line", "Line")
time_column = column_factory("Time-Column", "Column")
scatter = scatter_factory("Scatter", "Scatter")
bar = bar_factory("Bar", "Bar")
Expand All @@ -35,6 +32,57 @@
distribution_butterfly = butterfly_factory("Distribution-Butterfly", "Butterfly")


line = vm.Page(
title="Line",
layout=vm.Layout(grid=PAGE_GRID),
components=[
vm.Card(
text="""
#### What is a line chart?
A line chart presents a series of data points over a continuous interval or time period, joined together
with straight lines.
 
#### When to use it?
You should select a line chart when you want to show trends over time. Usually, your y-axis will show a
quantitative value and your x-axis will be marked as a timescale or a sequence of intervals. You can also
display negative values below the x-axis. If you wish to group several lines (different data series) in the
same chart, try to limit yourself to 3-4 to avoid cluttering up your chart.
"""
),
vm.Graph(figure=px.line(DATA_DICT["stocks"], x="date", y="GOOG")),
CodeClipboard(
text="""
```python
import vizro.models as vm
import vizro.plotly.express as px
from vizro import Vizro
stocks = px.data.stocks()
page = vm.Page(
title="Line",
components=[
vm.Graph(
figure=px.line(
stocks, x="date", y="GOOG"
)
)
],
)
dashboard = vm.Dashboard(pages=[page])
Vizro().build(dashboard).run()
```
"""
),
],
)

pie = vm.Page(
title="Pie",
layout=vm.Layout(grid=PAGE_GRID),
Expand Down

0 comments on commit 5a0e5f4

Please sign in to comment.