Skip to content

Commit

Permalink
Add more charts and tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
huong-li-nguyen committed Jul 5, 2024
1 parent 718a748 commit cd1ff04
Show file tree
Hide file tree
Showing 2 changed files with 129 additions and 6 deletions.
9 changes: 7 additions & 2 deletions vizro-core/examples/_dev/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@


dashboard = vm.Dashboard(
pages=[homepage, bar, column, line, scatter, pie, donut],
pages=[homepage, bar, column, line, scatter, pie, donut,boxplot, violin],
navigation=vm.Navigation(
nav_selector=vm.NavBar(
items=[
Expand All @@ -45,9 +45,14 @@
),
vm.NavLink(
label="Distribution",
pages={"Distribution": ["Pie", "Donut"]},
pages={"Distribution": ["Pie", "Donut", "Violin"]},
icon="Pie Chart",
),
vm.NavLink(
label="Ranking",
pages={"Ranking": ["Boxplot"]},
icon="Trail Length Short",
),
]
)
),
Expand Down
126 changes: 122 additions & 4 deletions vizro-core/examples/_dev/utils/_pages_charts.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
 
#### When to use the bar chart?
#### When to use it?
Select a Bar chart when you want to help your audience draw size comparisons and identify
patterns between categorical data, i.e., data that presents **how many?** in each category. You can
Expand Down Expand Up @@ -196,7 +196,7 @@
 
#### When to use the column chart?
#### When to use it?
Select a Column chart when you want to help your audience draw size comparisons and identify
patterns between categorical data, i.e., data that presents `how many?` in each category. You can
Expand Down Expand Up @@ -258,7 +258,7 @@
 
#### When to use the chart?
#### When to use it?
Use the Pie chart when you need to show your audience a quick view of how data is distributed proportionately, with percentages highlighted. The different values you present must add up to a total and equal 100%.
Expand Down Expand Up @@ -318,7 +318,7 @@
 
#### When to use the chart?
#### When to use it?
A Donut chart can be used in place of a Pie chart, particularly when you are short of space or have extra information you would like to share about the data. It may also be more effective if you wish your audience to focus on the length of the arcs of the sections instead of the proportions of the segment sizes.
Expand Down Expand Up @@ -359,3 +359,121 @@
),
],
)



boxplot = vm.Page(
title="Boxplot",
layout=vm.Layout(
grid=[[0, 0, 0, 0, 0]] * 1 + [[1, 1, 1, 2, 2]] * 2,
),
components=[
vm.Card(
text="""
#### What is a boxplot?
A Box Plot (also known as a Box and Whisker Plot) provides a visual display of multiple datasets, indicating the median (centre) and the range of the data for each.
 
#### When to use it?
Choose a Box Plot when you need to summarise distributions between many groups or datasets. It takes up less space than many other charts.
Create boxes to display the median, and the upper and lower quartiles. Add ‘whiskers’ to highlight variability outside the upper and lower quartiles. You can add outliers as dots beyond, but in line with the whiskers.
"""
),
vm.Graph(
figure=px.box(
data_frame=tips,
y='total_bill', x='day', color='day',
)
),
CodeClipboard(
text="""
```python
import vizro.models as vm
import vizro.plotly.express as px
from vizro import Vizro
tips = px.data.tips()
page = vm.Page(
title="Boxplot",
components=[
vm.Graph(
figure=px.boxplot(
data_frame=tips,
y='total_bill', x='day', color='day',
)
),
]
)
dashboard = vm.Dashboard(pages=[page])
Vizro().build(dashboard).run()
```
"""
),
],
)


violin = vm.Page(
title="Violin",
layout=vm.Layout(
grid=[[0, 0, 0, 0, 0]] * 1 + [[1, 1, 1, 2, 2]] * 2,
),
components=[
vm.Card(
text="""
#### What is a violin?
A Violin Plot is similar to a Box Plot, but works better for visualising more complex distributions and their probability density at different values.
 
#### When to use it?
Use this chart to go beyond the simple Box Plot and show the distribution shape of the data, the inter-quartile range, the confidence intervals and the median.
"""
),
vm.Graph(
figure=px.violin(
data_frame=tips,
y='total_bill', x='day', color='day',
)
),
CodeClipboard(
text="""
```python
import vizro.models as vm
import vizro.plotly.express as px
from vizro import Vizro
tips = px.data.tips()
page = vm.Page(
title="Violin",
components=[
vm.Graph(
figure=px.violin(
data_frame=tips,
y='total_bill', x='day', color='day',
)
),
]
)
dashboard = vm.Dashboard(pages=[page])
Vizro().build(dashboard).run()
```
"""
),
],
)

0 comments on commit cd1ff04

Please sign in to comment.