selectedData not populated when graph with selection loads

Đang mở
#2,142 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
plotly, python

Hướng nghiên cứu

Bắt đầu bằng cách chạy ví dụ Python được cung cấp với dcc.Graph, một hình chữ nhật Plotly được chọn trước và callback selectedData để tái hiện giá trị ban đầu bị thiếu. Theo dõi đường đi của sự kiện selectedData được sử dụng khi biểu đồ tải, sau đó xác minh rằng callback nhận được lựa chọn đã tồn tại mà không yêu cầu người dùng di chuyển nó.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug P3

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 creating a graph that has a selection pre-selected, this isn't shown in selectedData when the graph loads. The user needs to move or alter the selection for something to populate in selectedData

Expected behavior

selectedData would show

Screenshots
Graph on load:

image

After moving the selection:

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')

fig.add_selection(type="rect",
    x0=3.0, y0=6.5, x1=3.5, y1=5.5,
    line=dict(
        color="Crimson",
        width=2,
        dash="dash",
    ))

fig.update_layout(dragmode='select',
                  newselection=dict(line=dict(color='blue')))

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

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

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

])


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


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




@archmoj

Ngôn ngữ chính
Python
Star
24.4k
Fork
2.3k
Merge trung bình
2 ngày 7 giờ
Pull request đã merge (30 ngày)
13

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của plotly/dash

Tất cả issue của plotly/dash

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.