diff --git a/asreviewcontrib/semantic_clustering/interactive.py b/asreviewcontrib/semantic_clustering/interactive.py index 3fee2ce..686d458 100644 --- a/asreviewcontrib/semantic_clustering/interactive.py +++ b/asreviewcontrib/semantic_clustering/interactive.py @@ -87,18 +87,14 @@ def update_abstract(hoverData): # Update graph with hoverData if hoverData is not None: - hover_dict = hoverData['points'][0] - abstract_idx = hover_dict['pointIndex'] + # Get abstract based on x and y values + x = hoverData['points'][0]['x'] + y = hoverData['points'][0]['y'] + return df[(df['x'] == x) & (df['y'] == y) + ]['abstract'].values[0] - # Set variable for abstract window update - abstract = df['abstract'].iloc[abstract_idx] - - # Set hoverData to None again to prevent issues with graph update - hoverData = None else: - abstract = df['abstract'].iloc[0] - - return abstract + return df['abstract'].iloc[0] # Callback to refresh article title @app.callback(dash.dependencies.Output("paper-title", "children"), @@ -110,14 +106,13 @@ def update_title(hoverData): # Update graph with hoverData if hoverData is not None: - hover_dict = hoverData['points'][0] - title_idx = hover_dict['pointIndex'] - - # Set variable for paper title update - title = df['title'].iloc[title_idx] + # Get title based on x and y values + x = hoverData['points'][0]['x'] + y = hoverData['points'][0]['y'] + title = df[(df['x'] == x) & (df['y'] == y) + ]['title'].values[0] + return title - # Set hoverData to None again to prevent issues with graph update - hoverData = None else: title = df['title'].iloc[0] diff --git a/asreviewcontrib/semantic_clustering/semantic_clustering.py b/asreviewcontrib/semantic_clustering/semantic_clustering.py index 176b2bd..27c496b 100644 --- a/asreviewcontrib/semantic_clustering/semantic_clustering.py +++ b/asreviewcontrib/semantic_clustering/semantic_clustering.py @@ -2,7 +2,6 @@ # -*- coding: utf-8 -*- # Path: asreviewcontrib\semantic_clustering\semantic_clustering.py -# Environment imports import os from tqdm import tqdm import numpy as np