Spaces:
Running
Running
Li Nguyen
commited on
Commit
·
0669404
1
Parent(s):
36d2a4f
Remove redundant custom components
Browse files- app.py +3 -4
- assets/css/custom.css +2 -16
- utils/_charts.py +1 -18
app.py
CHANGED
@@ -4,7 +4,7 @@ from dash import html, get_asset_url
|
|
4 |
import dash_bootstrap_components as dbc
|
5 |
import pandas as pd
|
6 |
import vizro.models as vm
|
7 |
-
from utils._charts import COLUMN_DEFS,
|
8 |
from utils._helper import clean_data_and_add_columns, create_data_for_kpi_cards
|
9 |
from vizro import Vizro
|
10 |
from vizro.actions import filter_interaction
|
@@ -15,11 +15,11 @@ from vizro.tables import dash_ag_grid
|
|
15 |
df_complaints = pd.read_csv("https://query.data.world/s/glbdstahsuw3hjgunz3zssggk7dsfu?dws=00000")
|
16 |
df_complaints = clean_data_and_add_columns(df_complaints)
|
17 |
df_kpi_cards = create_data_for_kpi_cards(df_complaints)
|
18 |
-
vm.Page.add_type("components", FlexContainer)
|
19 |
|
20 |
|
21 |
# SUB-SECTIONS ------------------------------------------------------------------------------------
|
22 |
-
kpi_banner =
|
|
|
23 |
components=[
|
24 |
vm.Figure(
|
25 |
id="kpi-reverse-coloring",
|
@@ -78,7 +78,6 @@ kpi_banner = FlexContainer(
|
|
78 |
)
|
79 |
),
|
80 |
],
|
81 |
-
classname="kpi-banner",
|
82 |
)
|
83 |
|
84 |
bar_charts_tabbed = vm.Tabs(
|
|
|
4 |
import dash_bootstrap_components as dbc
|
5 |
import pandas as pd
|
6 |
import vizro.models as vm
|
7 |
+
from utils._charts import COLUMN_DEFS, area, bar, choropleth, pie
|
8 |
from utils._helper import clean_data_and_add_columns, create_data_for_kpi_cards
|
9 |
from vizro import Vizro
|
10 |
from vizro.actions import filter_interaction
|
|
|
15 |
df_complaints = pd.read_csv("https://query.data.world/s/glbdstahsuw3hjgunz3zssggk7dsfu?dws=00000")
|
16 |
df_complaints = clean_data_and_add_columns(df_complaints)
|
17 |
df_kpi_cards = create_data_for_kpi_cards(df_complaints)
|
|
|
18 |
|
19 |
|
20 |
# SUB-SECTIONS ------------------------------------------------------------------------------------
|
21 |
+
kpi_banner = vm.Container(
|
22 |
+
layout=vm.Flex(direction="row"),
|
23 |
components=[
|
24 |
vm.Figure(
|
25 |
id="kpi-reverse-coloring",
|
|
|
78 |
)
|
79 |
),
|
80 |
],
|
|
|
81 |
)
|
82 |
|
83 |
bar_charts_tabbed = vm.Tabs(
|
assets/css/custom.css
CHANGED
@@ -3,23 +3,9 @@
|
|
3 |
}
|
4 |
|
5 |
.card-kpi {
|
6 |
-
min-width:
|
7 |
padding: 0.75rem;
|
8 |
-
|
9 |
-
|
10 |
-
.kpi-banner {
|
11 |
-
display: flex;
|
12 |
-
gap: 1rem;
|
13 |
-
height: 100%;
|
14 |
-
overflow: scroll;
|
15 |
-
}
|
16 |
-
|
17 |
-
.kpi-banner .figure-container {
|
18 |
-
height: unset;
|
19 |
-
}
|
20 |
-
|
21 |
-
.kpi-banner::-webkit-scrollbar-thumb {
|
22 |
-
border: 5px solid var(--main-container-bg-color);
|
23 |
}
|
24 |
|
25 |
/* Apply reverse color coding for one KPI card */
|
|
|
3 |
}
|
4 |
|
5 |
.card-kpi {
|
6 |
+
min-width: 240px;
|
7 |
padding: 0.75rem;
|
8 |
+
height: 150px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
}
|
10 |
|
11 |
/* Apply reverse color coding for one KPI card */
|
utils/_charts.py
CHANGED
@@ -1,30 +1,13 @@
|
|
1 |
"""Contains custom components and charts used inside the dashboard."""
|
2 |
|
3 |
-
from typing import List,
|
4 |
|
5 |
import pandas as pd
|
6 |
import plotly.graph_objects as go
|
7 |
-
import vizro.models as vm
|
8 |
import vizro.plotly.express as px
|
9 |
-
from dash import html
|
10 |
from vizro.models.types import capture
|
11 |
|
12 |
|
13 |
-
# CUSTOM COMPONENTS -------------------------------------------------------------
|
14 |
-
class FlexContainer(vm.Container):
|
15 |
-
"""Custom flex `Container`."""
|
16 |
-
|
17 |
-
type: Literal["flex_container"] = "flex_container"
|
18 |
-
title: str = None # Title exists in vm.Container but we don't want to use it here.
|
19 |
-
classname: str = "d-flex"
|
20 |
-
|
21 |
-
def build(self):
|
22 |
-
"""Returns a flex container."""
|
23 |
-
return html.Div(
|
24 |
-
id=self.id, children=[component.build() for component in self.components], className=self.classname
|
25 |
-
)
|
26 |
-
|
27 |
-
|
28 |
# CUSTOM CHARTS ----------------------------------------------------------------
|
29 |
@capture("graph")
|
30 |
def bar(
|
|
|
1 |
"""Contains custom components and charts used inside the dashboard."""
|
2 |
|
3 |
+
from typing import List, Optional
|
4 |
|
5 |
import pandas as pd
|
6 |
import plotly.graph_objects as go
|
|
|
7 |
import vizro.plotly.express as px
|
|
|
8 |
from vizro.models.types import capture
|
9 |
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
# CUSTOM CHARTS ----------------------------------------------------------------
|
12 |
@capture("graph")
|
13 |
def bar(
|