Skip to content

Commit

Permalink
Add helper functions return type
Browse files Browse the repository at this point in the history
  • Loading branch information
petar-qb committed Oct 26, 2023
1 parent 5fe5989 commit 4eb5174
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
10 changes: 4 additions & 6 deletions vizro-core/examples/default/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ def AgGrid(data_frame=None):
vm.Table(
id="table_id",
figure=dash_data_table(
id="dash_datatable_id",
data_frame="table_data",
style_header={"border": "1px solid green"},
id="dash_datatable_id", data_frame="table_data", style_cell={"border": "5px solid green"},
),
actions=[
vm.Action(id="filter_interaction", function=filter_interaction(targets=["scatter_chart", "table_2_id"]))
Expand All @@ -83,7 +81,7 @@ def AgGrid(data_frame=None):
vm.Table(
id="table_2_id",
figure=dash_data_table(
id="dash_datatable_id_2", data_frame=data, style_header={"border": "1px solid green"}
id="dash_datatable_id_2", data_frame=data, style_cell={"border": "5px solid green"}
),
actions=[vm.Action(id="filter_interaction_2", function=filter_interaction(targets=["scatter_chart"]))],
),
Expand All @@ -98,8 +96,8 @@ def AgGrid(data_frame=None):
controls=[
vm.Filter(column="State", selector=vm.Dropdown()),
vm.Parameter(
targets=["table_id.style_header.border", "table_2_id.style_header.border"],
selector=vm.RadioItems(options=["1px solid green", "1px solid pink"]),
targets=["table_id.style_cell.border", "table_2_id.style_cell.border"],
selector=vm.RadioItems(options=["5px solid green", "5px solid pink"]),
),
],
)
Expand Down
9 changes: 5 additions & 4 deletions vizro-core/src/vizro/actions/_actions_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from vizro.models.types import MultiValueType, SelectorType, SingleValueType

if TYPE_CHECKING:
from vizro.models import Action
from vizro.models import Action, Table

ValidatedNoneValueType = Union[SingleValueType, MultiValueType, None, List[None]]

Expand Down Expand Up @@ -65,7 +65,7 @@ def _apply_filters(

def _apply_chart_filter_interaction(
data_frame: pd.DataFrame, target: str, ctd_filter_interaction: Dict[str, CallbackTriggerDict]
):
) -> pd.DataFrame:
ctd_click_data = ctd_filter_interaction["clickData"]
if not ctd_click_data["value"]:
return data_frame
Expand All @@ -88,17 +88,18 @@ def _apply_chart_filter_interaction(
return data_frame


def _get_parent_vizro_table(_underlying_table_id: str):
def _get_parent_vizro_table(_underlying_table_id: str) -> Table:
from vizro.models import Table

for _, table in model_manager._items_with_type(Table):
if table._underlying_table_id == _underlying_table_id:
return table
raise KeyError(f"No parent Vizro.Table component found for underlying table with id {_underlying_table_id}.")


def _apply_table_filter_interaction(
data_frame: pd.DataFrame, target: str, ctd_filter_interaction: Dict[str, CallbackTriggerDict]
):
) -> pd.DataFrame:
ctd_active_cell = ctd_filter_interaction["active_cell"]
ctd_derived_viewport_data = ctd_filter_interaction["derived_viewport_data"]
if not ctd_active_cell["value"] or not ctd_derived_viewport_data["value"]:
Expand Down

0 comments on commit 4eb5174

Please sign in to comment.