Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] Add Figure model and introduce KPI card functions #493

Merged
merged 79 commits into from
Jun 18, 2024
Merged
Changes from 1 commit
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
fb37101
Add KPI Card based on Plotly indicator
huong-li-nguyen May 21, 2024
9428969
Add KPI Card based on custom component
huong-li-nguyen May 21, 2024
c2c3710
Refine and leave some comments
huong-li-nguyen May 21, 2024
dbba0dd
Get dynamic Card working quickly
huong-li-nguyen May 21, 2024
a3ca6f6
Add logic to enable `text_card` and `nav_card`
huong-li-nguyen May 22, 2024
521954a
Tidy
huong-li-nguyen May 22, 2024
1081cd2
Lint
huong-li-nguyen May 22, 2024
4ceeed8
Add partially styled KPI
huong-li-nguyen May 22, 2024
1ca2be2
Simplify dynamic styled card
huong-li-nguyen May 22, 2024
bba9e01
Tidy
huong-li-nguyen May 22, 2024
e1a2858
Add styling to mkd card
huong-li-nguyen May 22, 2024
8309d9f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 22, 2024
7edfec2
Add another KPI style
huong-li-nguyen May 22, 2024
c65678e
Merge branch 'feat/create_kpi_cards' of https://github.com/mckinsey/v…
huong-li-nguyen May 22, 2024
798d8ef
Lint
huong-li-nguyen May 22, 2024
c01a3db
Add comments
huong-li-nguyen May 23, 2024
6062063
Tidy CSS
huong-li-nguyen May 23, 2024
67d41aa
Make sample page with 3 pre-selected designs
huong-li-nguyen May 23, 2024
6eedfe7
Move `dbc.Card` to `build` and remove id provision
huong-li-nguyen May 30, 2024
f3b1d6a
Refactor classNames for `kpi_card_icon`
huong-li-nguyen May 30, 2024
feaf493
Refactor simple and icon KPI card to one
huong-li-nguyen May 30, 2024
466b252
Refactor classNames for `kpi_card_ref`
huong-li-nguyen May 30, 2024
35f64aa
Refactor and tidy some more
huong-li-nguyen May 30, 2024
284f2ba
Add formatting arguments to function for discussion
huong-li-nguyen May 30, 2024
eb2c9c6
Enable coloring of higher-level card
huong-li-nguyen May 30, 2024
456eb29
Improve naming
huong-li-nguyen May 30, 2024
3f87ac9
Remove remaining `kpi-card-icon` reference
huong-li-nguyen May 30, 2024
67321aa
Tidy app
huong-li-nguyen May 30, 2024
3aab16b
Merge branch 'main' into feat/create_kpi_cards
huong-li-nguyen May 30, 2024
289ada3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 30, 2024
9f37512
Merge branch 'main' into feat/create_kpi_cards
huong-li-nguyen Jun 4, 2024
1c7eb6e
Update docstrings
huong-li-nguyen Jun 4, 2024
1554541
Return `dbc.Card` inside `CapturedCallable`
huong-li-nguyen Jun 5, 2024
98b8c1e
Replace `kpi_card` with suggested improvement
huong-li-nguyen Jun 5, 2024
26ce1be
Replace `kpi_card_ref` with suggested
huong-li-nguyen Jun 5, 2024
3ef65f2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 5, 2024
a1b1228
Remove redundant code from previous iterations
huong-li-nguyen Jun 5, 2024
4309315
Lint
huong-li-nguyen Jun 5, 2024
90dfcb3
Merge branch 'feat/create_kpi_cards' of https://github.com/mckinsey/v…
huong-li-nguyen Jun 5, 2024
faabc46
Commit this
huong-li-nguyen Jun 5, 2024
6bf46d5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 5, 2024
b005f51
Revert changes in card
huong-li-nguyen Jun 5, 2024
e964bb6
Create higher-level `Figure` model
huong-li-nguyen Jun 5, 2024
5c31faf
Merge branch 'feat/create_kpi_cards' of https://github.com/mckinsey/v…
huong-li-nguyen Jun 5, 2024
7161d15
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 5, 2024
2a92af6
Revert unwanted changes
huong-li-nguyen Jun 5, 2024
ae3e57b
Tidy
huong-li-nguyen Jun 5, 2024
d0bce82
Fix renaming
huong-li-nguyen Jun 5, 2024
ac56dba
Merge branch 'main' into feat/create_kpi_cards
huong-li-nguyen Jun 5, 2024
b6515ff
Tidy CSS
huong-li-nguyen Jun 5, 2024
bed23b4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 5, 2024
4c6969f
Merge branch 'main' into feat/create_kpi_cards
huong-li-nguyen Jun 6, 2024
acccea1
Add docstrings to kpi card functions
huong-li-nguyen Jun 6, 2024
a344db5
Merge branch 'main' into feat/create_kpi_cards
huong-li-nguyen Jun 6, 2024
72343be
Implement reverse-color coding via CSS
huong-li-nguyen Jun 7, 2024
c5c7368
Update schema
huong-li-nguyen Jun 7, 2024
8062991
Add changelog
huong-li-nguyen Jun 7, 2024
fda4a5e
Add ignore for custom format warning
huong-li-nguyen Jun 7, 2024
de649ee
Tidy redundant TODOs
huong-li-nguyen Jun 7, 2024
ec4a45b
Add unit tests for `Figure`
huong-li-nguyen Jun 7, 2024
95ebf91
Add empty doc file for now
huong-li-nguyen Jun 7, 2024
6f5b33d
Revert changes in `vizro-ai`
huong-li-nguyen Jun 7, 2024
4c71bdc
Add relevant updates in docs
huong-li-nguyen Jun 7, 2024
104b99c
Fix doc warning for now
huong-li-nguyen Jun 7, 2024
9d53cbb
Update schema
huong-li-nguyen Jun 7, 2024
f0d0304
Update components.md
stichbury Jun 7, 2024
8883285
Change icon and apply lowercase
huong-li-nguyen Jun 7, 2024
0e5fa7d
Merge branch 'feat/create_kpi_cards' of https://github.com/mckinsey/v…
huong-li-nguyen Jun 7, 2024
f07e7d1
Incorporate PR comments
huong-li-nguyen Jun 11, 2024
09ceea1
Fix height due to added container
huong-li-nguyen Jun 11, 2024
5fbfe84
Replace output with function call
huong-li-nguyen Jun 12, 2024
db8ac58
Add constants for defaults and tidy html divs
huong-li-nguyen Jun 12, 2024
41c4ca5
Handle ZeroDivisonError
huong-li-nguyen Jun 12, 2024
782127c
Simplify docstrings for `getitem` and remove TODO
huong-li-nguyen Jun 12, 2024
cea7a61
Add more context to docstrings of kpi card functions
huong-li-nguyen Jun 12, 2024
36c6a4f
Merge branch 'main' into feat/create_kpi_cards
huong-li-nguyen Jun 17, 2024
68cf51e
Change container className
huong-li-nguyen Jun 17, 2024
769a314
Merge branch 'main' into feat/create_kpi_cards
huong-li-nguyen Jun 18, 2024
ee606f8
Incorporate last PR comments
huong-li-nguyen Jun 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Refine and leave some comments
huong-li-nguyen committed May 21, 2024
commit c2c3710bbef72651ccf45638dbd3e3e2a4bc0163
29 changes: 20 additions & 9 deletions vizro-core/examples/_dev/app.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
"""Dev app to try things out."""

import numpy as np
from typing import Literal, Optional

import dash_bootstrap_components as dbc
import pandas as pd
import plotly.graph_objects as go
import vizro.models as vm
import vizro.plotly.express as px
from dash import html
from vizro import Vizro
from vizro.tables import dash_data_table
from vizro.models.types import capture
import pandas as pd
import plotly.graph_objects as go

from typing import Optional, Literal
from dash import html, dcc
import dash_bootstrap_components as dbc

iris_df = px.data.iris()

# Open questions -------
# Shall we allow for automatic data aggregations? Or shall this be the user's responsibility? (data transformation to live inside / outside component)
# Shall we actually just extend vm.Card and allow a figure attribute there? or shall the KPI Card be its own component?


# Method 1: Using go.Indicator inside vm.Graph
@capture("graph")
def plt_kpi_card(
@@ -66,10 +69,12 @@ def build(self):
className=f"card-border-{self.sign}",
)


vm.Page.add_type("components", CustomKPI)

page = vm.Page(
title="Table Page",
layout=vm.Layout(grid=[[0, 1]] + [[-1, -1]] * 3),
components=[
vm.Graph(
id="kpi-total",
@@ -79,7 +84,13 @@ def build(self):
title="Sepal Width AVG",
),
),
CustomKPI(title="Total Complaints", value="75.513", icon="arrow_circle_up", sign="up", ref_value="5.5% vs. Last Year"),
CustomKPI(
title="Total Complaints",
value="75.513",
icon="arrow_circle_up",
sign="up",
ref_value="5.5% vs. Last Year"
),
],
controls=[vm.Filter(column="species")],
)
4 changes: 2 additions & 2 deletions vizro-core/examples/_dev/assets/css/custom.css
Original file line number Diff line number Diff line change
@@ -8,7 +8,6 @@
padding-left: 12px;
}


.card {
background: var(--bs-card-cap-bg);
display: flex;
@@ -19,10 +18,11 @@

.card .card-title {
height: 100%;
font-size: 1.4rem;
}

.card .card-value {
font-size: 1.2rem;
font-size: 2rem;
font-weight: 600;
height: 100%;
margin: 0;