Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
kb- committed May 3, 2024
1 parent 641907e commit f263805
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
24 changes: 12 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,39 @@ repos:
hooks:
- id: black-fix
name: black (auto format)
entry: ./env/Scripts/black.exe
entry: ./env311/Scripts/black.exe
language: system
types: [python]

- id: isort-fix
name: isort (auto sort)
entry: ./env/Scripts/isort.exe
entry: ./env311/Scripts/isort.exe
language: system
types: [python]

- id: pytest-selenium
name: pytest (selenium tests)
entry: ./env/Scripts/pytest.exe
args: ['tests/', '-k', 'selenium', '--webdriver', 'Firefox']
language: system
pass_filenames: false
# - id: pytest-selenium
# name: pytest (selenium tests)
# entry: ./env/Scripts/pytest.exe
# args: ['tests/', '-k', 'selenium', '--webdriver', 'Firefox']
# language: system
# pass_filenames: false

- id: pytest-non-selenium
name: pytest (non-selenium tests)
entry: ./env/Scripts/pytest.exe
entry: ./env311/Scripts/pytest.exe
args: ['tests/', '-k', 'not selenium']
language: system
pass_filenames: false

- id: black
name: black
entry: ./env/Scripts/black.exe
entry: ./env311/Scripts/black.exe
language: system
types: [python]

- id: isort
name: isort
entry: ./env/Scripts/isort.exe
entry: ./env311/Scripts/isort.exe
language: system
types: [python]

Expand Down Expand Up @@ -63,6 +63,6 @@ repos:

- id: mypy
name: mypy
entry: ./env/Scripts/mypy.exe
entry: ./env311/Scripts/mypy.exe
language: system
types: [python]
7 changes: 7 additions & 0 deletions dash_tooltip/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

DEFAULT_TEMPLATE = "x: %{x},<br>y: %{y}"

registered_callbacks = set()


def tooltip(
app: dash.Dash,
Expand Down Expand Up @@ -76,6 +78,11 @@ def tooltip(
)

for graph_id in graph_ids:
callback_identifier = (graph_id, "figure")
if callback_identifier in registered_callbacks:
continue # Skip reattaching if already registered

registered_callbacks.add(callback_identifier)
if graph_id not in app.layout:
raise ValueError(f"Invalid graph ID provided: {graph_id}")
add_annotation_store(app.layout, graph_id)
Expand Down
4 changes: 4 additions & 0 deletions dash_tooltip/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ def _display_click_data(

xaxis, yaxis = "x", "y" # Default values

if figure is None:
# Initialize the figure
figure = go.Figure()

# Check if figure is a dictionary
if isinstance(figure, dict):
# Extract data and layout from the figure dictionary
Expand Down

0 comments on commit f263805

Please sign in to comment.