Skip to content

Commit

Permalink
Minor comments and table.build method fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
petar-qb committed Oct 26, 2023
1 parent 438525e commit 1548913
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion vizro-core/docs/pages/user_guides/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ To configure this figure interaction follow the steps below:
```py
actions=[vm.Action(function=filter_interaction(targets=["scatter_relation_2007"]))]
```
2. If the source figure is [`Graph`][vizro.models.Graph], enter the filter columns in the `custom_data` argument of the underlying source chart `function` if the source figure is [`Graph`][vizro.models.Graph].
2. If the source figure is [`Graph`][vizro.models.Graph], enter the filter columns in the `custom_data` argument of the underlying source chart `function`.
```py
Graph(figure=px.scatter(..., custom_data=["continent"]))
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ def _build_action_loop_callbacks() -> None:
actions_chain_trigger_component_id = actions_chain.trigger.component_id
try:
actions_chain_trigger_component = model_manager[ModelID(str(actions_chain_trigger_component_id))]
# Use underlying 'Datatable' object as a trigger component.
# Use underlying table object as a trigger component.
if isinstance(actions_chain_trigger_component, Table):
actions_chain_trigger_component_id = actions_chain_trigger_component._underlying_table_id
# Not all action_chain_trigger_components are included in model_manager. eg on_page_load_action_trigger
# Not all action_chain_trigger_components are included in model_manager e.g. on_page_load_action_trigger
except KeyError:
pass

Expand Down
4 changes: 2 additions & 2 deletions vizro-core/src/vizro/actions/_actions_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _apply_chart_filter_interaction(
if not ctd_click_data["value"]:
return data_frame

source_chart_id = ctd_click_data["id"]
source_chart_id: ModelID = ctd_click_data["id"]
source_chart_actions = _get_component_actions(model_manager[source_chart_id])
try:
custom_data_columns = model_manager[source_chart_id]["custom_data"] # type: ignore[index]
Expand Down Expand Up @@ -108,7 +108,7 @@ def _apply_table_filter_interaction(
try:
source_table_actions = _get_component_actions(model_manager[source_table_id])
except KeyError:
# source_table_id is dash.Datatable id and we need to fetch actions from parent Vizro.Table component
# source_table_id is underlying table id, so actions from parent Vizro.Table component should be considered.
source_table_actions = _get_component_actions(_get_parent_vizro_table(source_table_id))

for action in source_table_actions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def _get_action_callback_inputs(action_id: ModelID) -> Dict[str, Any]:
"filter_interaction": (
_get_inputs_of_chart_interactions(action_id=action_id, action_function=filter_interaction.__wrapped__)
if "filter_interaction" in include_inputs
else {}
else []
),
"theme_selector": (State("theme_selector", "on") if "theme_selector" in include_inputs else []),
}
Expand Down
8 changes: 3 additions & 5 deletions vizro-core/src/vizro/models/_components/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,12 @@ def pre_build(self):
@_log_call
def build(self):
# TODO: We also need to take case what empty object we need to create here once we support AgGrid and others.
dash_datatable_object = (
dash_table.DataTable(id=self._underlying_table_id) if self.actions else dash_table.DataTable()
)

return html.Div(
[
html.H3(self.title, className="table-title") if self.title else None,
html.Div(dash_datatable_object, id=self.id),
html.Div(
dash_table.DataTable(**({"id": self._underlying_table_id} if self.actions else {})), id=self.id
),
],
className="table-container",
)

0 comments on commit 1548913

Please sign in to comment.