Skip to content

add option to return custom fields#3

Open
cceyda wants to merge 1 commit intonull-jones:masterfrom
cceyda:return_custom_fields
Open

add option to return custom fields#3
cceyda wants to merge 1 commit intonull-jones:masterfrom
cceyda:return_custom_fields

Conversation

@cceyda
Copy link

@cceyda cceyda commented Jun 29, 2022

with this PR you can pass return_fields=True and get custom_data/hover_data return too.

Use Case:
pointIndex wasn't equal to the index of the dataframe in my case, that's why I needed to return some additional data about the selected point. can be useful for other cases too, like when you want to access more custom_data fields.

fig = px.scatter(df, x="x", y="y", color="type", hover_data=["index","index2"])

selected_points = plotly_events(fig,click_event=True,select_event=False,return_fields=True)
st.write(selected_points )
# customdata is an array because it didn't return a dict on the javascript side
0:{
"x":4.478600978851318
"y":-2.733484983444214
"pointNumber":181
"pointIndex":181
"curveNumber":0
"customdata":[
0:"5"
1:"10"
]
}

@sebimarkgraf
Copy link

@null-jones This feature would be quite useful for a lot of users that need the index in any grouped plots.
Would you consider merging this?

@cceyda
Copy link
Author

cceyda commented Jan 31, 2023

@sebimarkgraf Until this is merged you can pip install git+https://github.com/cceyda/streamlit-plotly-events/@release to get version including this PR.

@fuubarbaz
Copy link

It's been quite for some time. Could you please merge it ?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants