microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.25k stars 274 forks source link

Displaying Plotly Data Point Hover Data using DASH #15765

Open JosephKarpinski opened 3 weeks ago

JosephKarpinski commented 3 weeks ago

Does this issue occur when all extensions are disabled?: Yes/No

Steps to Reproduce:

  1. Run under Jupyter Notebook works
  2. Run under VScode, plotly hover data doesn't display
  3. See attached code:
  4. from dash import Dash, html, dcc from dash.dependencies import Input, Output, State import numpy as np import plotly.graph_objects as go import json

x = np.random.uniform(-10, 10, size=50) y = np.sin(x) clicked = []

Build App

app = Dash(name) app.layout = html.Div( [ dcc.Graph( id="fig", figure=go.Figure(go.Scatter(x=x, y=y, mode="markers", name="base_points")), ), html.Div(id="debug"), ] )

@app.callback( Output("debug", "children"), Input("fig", "clickData"), ) def point_clicked(clickData): if clickData: point = clickData["points"][0] x, y = point["x"], point["y"] hover_text = f"x: {x}, y: {y}" return hover_text else: return ""

Run app and display result inline in the notebook

if name == "main": app.run_server()

Screenshot 2024-06-06 at 10 44 59 AM Screenshot 2024-06-06 at 10 45 26 AM
rebornix commented 2 weeks ago

@DonJayamanne can you help triage this issue?