Skip to content

[BUG] customdata is missing in clickData for pie charts #1663

Closed
@satyan-g

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
dash                      1.19.0
dash-alternative-viz      0.0.1               /home/satya/Downloads/dash-alternative-viz-master
dash-bootstrap-components 0.12.2
dash-core-components      1.15.0
dash-html-components      1.1.2
dash-renderer             1.9.0
dash-table                4.11.2

pie charts clickData is missing customdata and ids

I am trying to implement cross filtering between scatter plots and pie charts using selectedData and clickData respectively. Click data for pie charts has pointNumbers but not customdata or ids. I need some way to keep track of the index from the unfiltered data set.

As per documentation of go.Pie, customdata is meant for this task, but it is not behaving as expected. Sample code is attached.

import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import plotly.express as px
import plotly.graph_objects as go

# This dataframe has 244 lines, but 4 distinct values for `day`
df = px.data.tips()
df['id'] = df.index
print(df.columns)
app = dash.Dash(__name__)

app.layout = html.Div([
    dcc.Graph(id="pie-chart", figure=go.Figure(data=[go.Pie(labels=df['day'],  ids=df['id'].map(str), customdata=df['id'])])),
    dcc.Textarea(id='textArea')
])

@app.callback(
    Output("textArea", "value"), 
     Input('pie-chart', 'clickData'))
def handleClick(clickData):
    return str(clickData)

app.run_server(debug=True)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions