plotly / plotly/dash

selections missing from selectedData in Dash 2.6

Open
#2,141 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3
Dominant language
Python
Stars
24.4k
Forks
2.3k
Avg merge
2d 7h
Merged PRs (30d)
13

Description

Describe your context
Please provide us your environment, so we can easily reproduce the issue.

  • replace the result of pip list | grep dash below
Package              Version                   Location
-------------------- ------------------------- --------------------------------------------------------------------
anyio                3.5.0
appdirs              1.4.4
appnope              0.1.3
argon2-cffi          21.3.0
argon2-cffi-bindings 21.2.0
asttokens            2.0.5
attrs                21.4.0
Babel                2.9.1
backcall             0.2.0
backports.tempfile   1.0
backports.weakref    1.0.post1
beautifulsoup4       4.10.0
black                22.3.0
bleach               4.1.0
Brotli               1.0.9
certifi              2021.10.8
cffi                 1.15.0
cfgv                 3.3.1
charset-normalizer   2.0.12
click                8.1.2
click-plugins        1.1.1
cligj                0.7.2
colorcet             3.0.0
coverage             4.3.1
dash                 2.6.0
dash-core-components 2.0.0
dash-html-components 2.0.0
dash-table           5.0.0
debugpy              1.6.0
decorator            5.1.1
defusedxml           0.7.1
distlib              0.3.4
entrypoints          0.4
executing            0.8.3
fastjsonschema       2.15.3
filelock             3.6.0
Fiona                1.8.21
Flask                2.1.3
Flask-Compress       1.12
geopandas            0.10.2
identify             2.4.12
idna                 3.3
importlib-metadata   4.11.3
inflect              5.4.0
ipykernel            6.12.1
ipython              8.2.0
ipython-genutils     0.2.0
ipywidgets           7.7.0
itsdangerous         2.1.2
jedi                 0.18.1
Jinja2               3.1.1
json5                0.9.6
jsonschema           4.4.0
jupyter              1.0.0
jupyter-client       7.2.1
jupyter-console      6.4.3
jupyter-core         4.9.2
jupyter-server       1.16.0
jupyterlab           3.3.2
jupyterlab-pygments  0.1.2
jupyterlab-server    2.12.0
jupyterlab-widgets   1.1.0
jupytext             1.13.7
markdown-it-py       1.1.0
MarkupSafe           2.1.1
matplotlib-inline    0.1.3
mdit-py-plugins      0.3.0
mistune              0.8.4
mock                 2.0.0
more-itertools       8.12.0
munch                2.5.0
mypy-extensions      0.4.3
nbclassic            0.3.7
nbclient             0.5.13
nbconvert            6.4.5
nbformat             5.3.0
nest-asyncio         1.5.5
nodeenv              1.6.0
notebook             6.4.10
notebook-shim        0.1.0
numpy                1.22.3
packaging            21.3
pandas               1.4.2
pandocfilters        1.5.0
param                1.12.1
parso                0.8.3
pathspec             0.9.0
pbr                  5.8.1
pexpect              4.8.0
pickleshare          0.7.5
Pillow               9.1.0
pip                  21.2.4
platformdirs         2.5.1
plotly               (built from latest Plotly.js)
pluggy               0.6.0
pre-commit           2.18.1
prometheus-client    0.13.1
prompt-toolkit       3.0.28
psutil               5.9.0
ptyprocess           0.7.0
pure-eval            0.2.2
py                   1.11.0
pycparser            2.21
pyct                 0.4.8
Pygments             2.11.2
pyparsing            3.0.7
pyproj               3.3.0
pyrsistent           0.18.1
pyshp                2.2.0
pytest               3.5.1
python-dateutil      2.8.2
pytz                 2022.1
PyYAML               6.0
pyzmq                22.3.0
qtconsole            5.3.0
QtPy                 2.0.1
regex                2022.3.15
requests             2.27.1
scipy                1.8.0
Send2Trash           1.8.0
setuptools           58.0.4
Shapely              1.8.1.post1
six                  1.16.0
sniffio              1.2.0
soupsieve            2.3.1
stack-data           0.2.0
tenacity             8.0.1
terminado            0.13.3
testpath             0.6.0
toml                 0.10.2
tomli                2.0.1
tornado              6.1
traitlets            5.1.1
typed-ast            1.5.2
typing_extensions    4.1.1
urllib3              1.26.9
virtualenv           20.14.0
wcwidth              0.2.5
webencodings         0.5.1
websocket-client     1.3.2
Werkzeug             2.1.2
wheel                0.37.1
widgetsnbextension   3.6.0
xarray               2022.3.0
zipp                 3.7.0

Describe the bug

When making a selections in graph, information on these selections are not available in selectedData

Expected behavior

That there would be 'selections' showing the 'selections' from the user.

Screenshots
image

Example code:

import json

from dash import Dash, dcc, html
from dash.dependencies import Input, Output
import plotly.express as px

external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']

app = Dash(__name__, external_stylesheets=external_stylesheets)

styles = {
    'pre': {
        'border': 'thin lightgrey solid',
        'overflowX': 'scroll'
    }
}

df = px.data.iris()
fig = px.scatter(df, x="sepal_width", y="sepal_length", color='petal_length')

app.layout = html.Div([
    dcc.Graph(
        id='basic-interactions-2',
        figure=fig
    ),

        html.Div([
            dcc.Markdown("""
                **Selection Data**

            """),
            html.Pre(id='selected-data-2', style=styles['pre']),
        ]),

])


@app.callback(
    Output('selected-data-2', 'children'),
    Input('basic-interactions-2', 'selectedData'))
def display_selected_data(selectedData):
    return json.dumps(selectedData, indent=2)


if __name__ == '__main__':
    app.run_server(debug=True)

@archmoj

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the dcc.Graph selectedData callback shown in the example and reproduce the issue using the provided iris scatter plot. Trace how a graph selection reaches selectedData; done means the callback output includes the user's selections as expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.